Skip to content

Commit

Permalink
Merge pull request #14831 from igfoo/igfoo/kot2
Browse files Browse the repository at this point in the history
Kotlin: Add 2.0.0-Beta1
  • Loading branch information
igfoo authored Nov 21, 2023
2 parents d8e7c9c + 95de749 commit 0668b71
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
12 changes: 8 additions & 4 deletions java/kotlin-extractor/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ def write_arg_file(arg_file, args):
def compile_to_dir(build_dir, srcs, version, classpath, java_classpath, output):
# Use kotlinc to compile .kt files:
kotlin_arg_file = build_dir + '/kotlin.args'
kotlin_args = ['-Werror',
'-opt-in=kotlin.RequiresOptIn',
'-opt-in=org.jetbrains.kotlin.ir.symbols.IrSymbolInternals',
'-d', output,
opt_in_args = ['-opt-in=kotlin.RequiresOptIn']
if version.lessThan(kotlin_plugin_versions.Version(2, 0, 0, "")):
opt_in_args.append('-opt-in=org.jetbrains.kotlin.ir.symbols.IrSymbolInternals')
else:
opt_in_args.append('-opt-in=org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI')
kotlin_args = ['-Werror'] \
+ opt_in_args \
+ ['-d', output,
'-module-name', 'codeql-kotlin-extractor',
'-Xsuppress-version-warnings',
'-language-version', version.toLanguageVersionString(),
Expand Down
7 changes: 5 additions & 2 deletions java/kotlin-extractor/kotlin_plugin_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def toTupleWithTag(self):
def toTupleNoTag(self):
return [self.major, self.minor, self.patch]

def lessThan(self, other):
return self.toTupleNoTag() < other.toTupleNoTag()

def lessThanOrEqual(self, other):
return self.toTupleNoTag() <= other.toTupleNoTag()

Expand All @@ -43,7 +46,7 @@ def version_string_to_version(version):
# Version number used by CI.
ci_version = '1.9.0'

many_versions = [ '1.5.0', '1.5.10', '1.5.20', '1.5.30', '1.6.0', '1.6.20', '1.7.0', '1.7.20', '1.8.0', '1.9.0-Beta', '1.9.20-Beta' ]
many_versions = [ '1.5.0', '1.5.10', '1.5.20', '1.5.30', '1.6.0', '1.6.20', '1.7.0', '1.7.20', '1.8.0', '1.9.0-Beta', '1.9.20-Beta', '2.0.0-Beta1' ]

many_versions_versions = [version_string_to_version(v) for v in many_versions]
many_versions_versions_asc = sorted(many_versions_versions, key = lambda v: v.toTupleWithTag())
Expand All @@ -58,7 +61,7 @@ def get_single_version(fakeVersionOutput = None):
if kotlinc is None:
raise KotlincNotFoundException()
versionOutput = subprocess.run([kotlinc, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stderr if fakeVersionOutput is None else fakeVersionOutput
m = re.match(r'.* kotlinc-jvm ([0-9]+\.[0-9]+\.[0-9]+-?[a-zA-Z]*) .*', versionOutput)
m = re.match(r'.* kotlinc-jvm ([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z][a-zA-Z0-9]*)?) .*', versionOutput)
if m is None:
raise Exception('Cannot detect version of kotlinc (got ' + str(versionOutput) + ')')
current_version = version_string_to_version(m.group(1))
Expand Down

0 comments on commit 0668b71

Please sign in to comment.