@@ -87,7 +87,7 @@ def write_arg_file(arg_file, args):
87
87
raise Exception ('Single quote in argument: ' + arg )
88
88
f .write ("'" + arg .replace ('\\ ' , '/' ) + "'\n " )
89
89
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 ):
91
91
# Use kotlinc to compile .kt files:
92
92
kotlin_arg_file = build_dir + '/kotlin.args'
93
93
kotlin_args = ['-Werror' ,
@@ -96,7 +96,7 @@ def compile_to_dir(build_dir, srcs, language_version, classpath, java_classpath,
96
96
'-d' , output ,
97
97
'-module-name' , 'codeql-kotlin-extractor' ,
98
98
'-Xsuppress-version-warnings' ,
99
- '-language-version' , language_version ,
99
+ '-language-version' , version . toLanguageVersionString () ,
100
100
'-no-reflect' , '-no-stdlib' ,
101
101
'-jvm-target' , '1.8' ,
102
102
'-classpath' , classpath ] + srcs
@@ -116,14 +116,14 @@ def compile_to_dir(build_dir, srcs, language_version, classpath, java_classpath,
116
116
run_process ([javac , '@' + java_arg_file ])
117
117
118
118
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 ):
120
120
class_dir = build_dir + '/classes'
121
121
122
122
if os .path .exists (class_dir ):
123
123
shutil .rmtree (class_dir )
124
124
os .makedirs (class_dir )
125
125
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 )
127
127
128
128
run_process (['jar' , 'cf' , output ,
129
129
'-C' , class_dir , '.' ,
@@ -161,7 +161,7 @@ def transform_to_embeddable(srcs):
161
161
f .write (content )
162
162
163
163
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 ):
165
165
classpath = bases_to_classpath (dependency_folder , jars )
166
166
java_classpath = bases_to_classpath (dependency_folder , java_jars )
167
167
@@ -179,31 +179,24 @@ def compile(jars, java_jars, dependency_folder, transform_to_embeddable, output,
179
179
with open (resource_dir + '/extractor.name' , 'w' ) as f :
180
180
f .write (output )
181
181
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 )
184
183
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 ):
191
186
d = tmp_src_dir + '/main/kotlin/utils/versions/v_' + \
192
- version .replace ('.' , '_' )
187
+ a_version . toString () .replace ('.' , '_' )
193
188
if os .path .exists (d ):
194
189
# copy and overwrite files from the version folder to the include folder
195
190
shutil .copytree (d , include_version_folder , dirs_exist_ok = True )
196
191
197
- language_version = str (parsed_current_version [0 ]) + '.' + str (parsed_current_version [1 ])
198
-
199
192
# remove all version folders:
200
193
shutil .rmtree (tmp_src_dir + '/main/kotlin/utils/versions' )
201
194
202
195
srcs = find_sources (tmp_src_dir )
203
196
204
197
transform_to_embeddable (srcs )
205
198
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 )
207
200
208
201
shutil .rmtree (tmp_src_dir )
209
202
0 commit comments