@@ -87,7 +87,7 @@ def write_arg_file(arg_file, args):
8787 raise Exception ('Single quote in argument: ' + arg )
8888 f .write ("'" + arg .replace ('\\ ' , '/' ) + "'\n " )
8989
90- def compile_to_dir (build_dir , srcs , language_version , classpath , java_classpath , output ):
90+ def compile_to_dir (build_dir , srcs , version , classpath , java_classpath , output ):
9191 # Use kotlinc to compile .kt files:
9292 kotlin_arg_file = build_dir + '/kotlin.args'
9393 kotlin_args = ['-Werror' ,
@@ -96,7 +96,7 @@ def compile_to_dir(build_dir, srcs, language_version, classpath, java_classpath,
9696 '-d' , output ,
9797 '-module-name' , 'codeql-kotlin-extractor' ,
9898 '-Xsuppress-version-warnings' ,
99- '-language-version' , language_version ,
99+ '-language-version' , version . toLanguageVersionString () ,
100100 '-no-reflect' , '-no-stdlib' ,
101101 '-jvm-target' , '1.8' ,
102102 '-classpath' , classpath ] + srcs
@@ -116,14 +116,14 @@ def compile_to_dir(build_dir, srcs, language_version, classpath, java_classpath,
116116 run_process ([javac , '@' + java_arg_file ])
117117
118118
119- def compile_to_jar (build_dir , tmp_src_dir , srcs , language_version , classpath , java_classpath , output ):
119+ def compile_to_jar (build_dir , tmp_src_dir , srcs , version , classpath , java_classpath , output ):
120120 class_dir = build_dir + '/classes'
121121
122122 if os .path .exists (class_dir ):
123123 shutil .rmtree (class_dir )
124124 os .makedirs (class_dir )
125125
126- compile_to_dir (build_dir , srcs , language_version , classpath , java_classpath , class_dir )
126+ compile_to_dir (build_dir , srcs , version , classpath , java_classpath , class_dir )
127127
128128 run_process (['jar' , 'cf' , output ,
129129 '-C' , class_dir , '.' ,
@@ -161,7 +161,7 @@ def transform_to_embeddable(srcs):
161161 f .write (content )
162162
163163
164- def compile (jars , java_jars , dependency_folder , transform_to_embeddable , output , build_dir , current_version ):
164+ def compile (jars , java_jars , dependency_folder , transform_to_embeddable , output , build_dir , version_str ):
165165 classpath = bases_to_classpath (dependency_folder , jars )
166166 java_classpath = bases_to_classpath (dependency_folder , java_jars )
167167
@@ -179,31 +179,24 @@ def compile(jars, java_jars, dependency_folder, transform_to_embeddable, output,
179179 with open (resource_dir + '/extractor.name' , 'w' ) as f :
180180 f .write (output )
181181
182- parsed_current_version = kotlin_plugin_versions .version_string_to_tuple (
183- current_version )
182+ version = kotlin_plugin_versions .version_string_to_version (version_str )
184183
185- for version in kotlin_plugin_versions .many_versions :
186- parsed_version = kotlin_plugin_versions .version_string_to_tuple (
187- version )
188- if parsed_version [0 ] < parsed_current_version [0 ] or \
189- (parsed_version [0 ] == parsed_current_version [0 ] and parsed_version [1 ] < parsed_current_version [1 ]) or \
190- (parsed_version [0 ] == parsed_current_version [0 ] and parsed_version [1 ] == parsed_current_version [1 ] and parsed_version [2 ] <= parsed_current_version [2 ]):
184+ for a_version in kotlin_plugin_versions .many_versions_versions_asc :
185+ if a_version .lessThanOrEqual (version ):
191186 d = tmp_src_dir + '/main/kotlin/utils/versions/v_' + \
192- version .replace ('.' , '_' )
187+ a_version . toString () .replace ('.' , '_' )
193188 if os .path .exists (d ):
194189 # copy and overwrite files from the version folder to the include folder
195190 shutil .copytree (d , include_version_folder , dirs_exist_ok = True )
196191
197- language_version = str (parsed_current_version [0 ]) + '.' + str (parsed_current_version [1 ])
198-
199192 # remove all version folders:
200193 shutil .rmtree (tmp_src_dir + '/main/kotlin/utils/versions' )
201194
202195 srcs = find_sources (tmp_src_dir )
203196
204197 transform_to_embeddable (srcs )
205198
206- compile_to_jar (build_dir , tmp_src_dir , srcs , language_version , classpath , java_classpath , output )
199+ compile_to_jar (build_dir , tmp_src_dir , srcs , version , classpath , java_classpath , output )
207200
208201 shutil .rmtree (tmp_src_dir )
209202
0 commit comments