diff options
author | alexv-smirnov <alex@ydb.tech> | 2023-06-13 11:05:01 +0300 |
---|---|---|
committer | alexv-smirnov <alex@ydb.tech> | 2023-06-13 11:05:01 +0300 |
commit | bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0 (patch) | |
tree | 1d1df72c0541a59a81439842f46d95396d3e7189 /build/scripts/with_kapt_args.py | |
parent | 8bfdfa9a9bd19bddbc58d888e180fbd1218681be (diff) | |
download | ydb-bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0.tar.gz |
add ymake export to ydb
Diffstat (limited to 'build/scripts/with_kapt_args.py')
-rw-r--r-- | build/scripts/with_kapt_args.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/build/scripts/with_kapt_args.py b/build/scripts/with_kapt_args.py new file mode 100644 index 0000000000..eb7438a4c9 --- /dev/null +++ b/build/scripts/with_kapt_args.py @@ -0,0 +1,35 @@ +import sys +import os +import subprocess +import platform +import argparse +import re + + +def parse_args(args): + parser = argparse.ArgumentParser() + parser.add_argument('--ap-classpath', nargs='*', type=str, dest='classpath') + cmd_start = args.index('--') + return parser.parse_args(args[:cmd_start]), args[cmd_start+1:] + + +def get_ap_classpath(directory): + jar_re = re.compile(r'.*(?<!-sources)\.jar') + found_jars = [os.path.join(address, name) for address, dirs, files in os.walk(directory) for name in files if jar_re.match(name)] + if len(found_jars) != 1: + raise Exception("found %d JAR files in directory %s" % (len(found_jars), directory)) + arg = 'plugin:org.jetbrains.kotlin.kapt3:apclasspath=' + found_jars[0] + return '-P', arg + + +def create_extra_args(args): + cp_opts = [arg for d in args.classpath for arg in get_ap_classpath(d)] + return cp_opts + +if __name__ == '__main__': + args, cmd = parse_args(sys.argv[1:]) + res = cmd + create_extra_args(args) + if platform.system() == 'Windows': + sys.exit(subprocess.Popen(res).wait()) + else: + os.execv(res[0], res) |