Add support for downloading kotlin dev compilers Contents of README.google: Name: Kotlin URL: https://github.com/JetBrains/kotlin/ Version: 1.5.0 Revision: NA License: Apache License Version 2.0 Bug: 200582899 Change-Id: I9285f3026c171ce4954166a19fb7de83cf6e2341
diff --git a/.gitignore b/.gitignore index 080826a..7a9429b 100644 --- a/.gitignore +++ b/.gitignore
@@ -114,6 +114,8 @@ third_party/kotlin/kotlin-compiler-1.4.20 third_party/kotlin/kotlin-compiler-1.5.0.tar.gz third_party/kotlin/kotlin-compiler-1.5.0 +third_party/kotlin/kotlin-compiler-dev.tar.gz +third_party/kotlin/kotlin-compiler-dev third_party/kotlinx-coroutines-1.3.6.tar.gz third_party/kotlinx-coroutines-1.3.6 third_party/nest/*
diff --git a/third_party/kotlin/kotlin-compiler-dev.tar.gz.sha1 b/third_party/kotlin/kotlin-compiler-dev.tar.gz.sha1 new file mode 100644 index 0000000..9ff5928 --- /dev/null +++ b/third_party/kotlin/kotlin-compiler-dev.tar.gz.sha1
@@ -0,0 +1 @@ +853bdb3640fd85a859d9baf3a972f71b037c5f8c \ No newline at end of file
diff --git a/tools/download_kotlin_dev.py b/tools/download_kotlin_dev.py new file mode 100755 index 0000000..c6c127e --- /dev/null +++ b/tools/download_kotlin_dev.py
@@ -0,0 +1,78 @@ +#!/usr/bin/env python +# Copyright (c) 2021, the R8 project authors. Please see the AUTHORS file +# for details. All rights reserved. Use of this source code is governed by a +# BSD-style license that can be found in the LICENSE file. + +from HTMLParser import HTMLParser +import os +import sys +import urllib +import utils + +JETBRAINS_KOTLIN_MAVEN_URL = "https://maven.pkg.jetbrains.space/kotlin/p/" \ + "kotlin/bootstrap/org/jetbrains/kotlin/" +KOTLIN_RELEASE_URL = JETBRAINS_KOTLIN_MAVEN_URL + "kotlin-compiler/" + +def download_newest(): + response = urllib.urlopen(KOTLIN_RELEASE_URL) + if response.getcode() != 200: + raise Exception('Url: %s \n returned %s' + % (KOTLIN_RELEASE_URL, response.getcode())) + content = response.read() + release_candidates = [] + + class HTMLContentParser(HTMLParser): + def handle_data(self, data): + if ('-dev-' in data): + release_candidates.append(data) + + parser = HTMLContentParser() + parser.feed(content) + + top_most_version = (0, 0, 0, 0) + top_most_version_and_build = None + + for version in release_candidates: + # The compiler version is on the form <major>.<minor>.<revision>-dev-<build>/ + version = version.replace('/', '') + version_build_args = version.split('-') + version_components = version_build_args[0].split('.') + version_components.append(version_build_args[2]) + current_version = tuple(map(int, version_components)) + if (current_version > top_most_version): + top_most_version = current_version + top_most_version_and_build = version + + if (top_most_version_and_build is None): + raise Exception('Url: %s \n returned %s' + % (KOTLIN_RELEASE_URL, response.getcode())) + + # We can now download all files related to the kotlin compiler version. + print("Downloading version: " + top_most_version_and_build) + + kotlinc_lib = os.path.join( + utils.THIRD_PARTY, "kotlin", "kotlin-compiler-dev", "kotlinc", "lib") + + utils.DownloadFromGoogleCloudStorage( + os.path.join( + utils.THIRD_PARTY, "kotlin", "kotlin-compiler-dev.tar.gz.sha1")) + + download_and_save( + JETBRAINS_KOTLIN_MAVEN_URL + "kotlin-compiler/{0}/kotlin-compiler-{0}.jar" + .format(top_most_version_and_build), kotlinc_lib, "kotlin-compiler.jar") + download_and_save( + JETBRAINS_KOTLIN_MAVEN_URL + "kotlin-stdlib/{0}/kotlin-stdlib-{0}.jar" + .format(top_most_version_and_build), kotlinc_lib, "kotlin-stdlib.jar") + download_and_save( + JETBRAINS_KOTLIN_MAVEN_URL + "kotlin-reflect/{0}/kotlin-reflect-{0}.jar" + .format(top_most_version_and_build), kotlinc_lib, "kotlin-reflect.jar") + + +def download_and_save(url, path, name): + print('Downloading: ' + url) + urllib.urlretrieve(url, os.path.join(path, name)) + + +if __name__ == '__main__': + sys.exit(download_newest()) +
diff --git a/tools/test.py b/tools/test.py index 6553358..c278251 100755 --- a/tools/test.py +++ b/tools/test.py
@@ -8,6 +8,7 @@ # force the tests to run, even if no input changed. import archive_desugar_jdk_libs +import download_kotlin_dev import notify import optparse import os @@ -187,6 +188,10 @@ '--stacktrace', help='Pass --stacktrace to the gradle run', default=False, action='store_true') + result.add_option('--kotlin-dev-compiler', + help='Specify to download a kotlin dev compiler and run ' + 'tests with that', + default=False, action='store_true') return result.parse_args() def archive_failures(): @@ -275,6 +280,8 @@ gradle_args.append('-Pprint_full_stacktraces') if options.print_obfuscated_stacktraces: gradle_args.append('-Pprint_obfuscated_stacktraces') + if options.kotlin_dev_compiler: + download_kotlin_dev.download_newest() if os.name == 'nt': # temporary hack gradle_args.append('-Pno_internal')