Update desugared_library_jdk_11 deps
This updates to
https://github.com/google/desugar_jdk_libs/commit/4d875ab1e15e336557361f12c26183638597ef97
Also
* add script for updating desugared library
* store the hash of the desugared library with the dependency
Bug: 244156342
Change-Id: Ic9b643d9b78895f837de9ef42c5a02d35244ee89
diff --git a/tools/archive_desugar_jdk_libs.py b/tools/archive_desugar_jdk_libs.py
index 06dbf63..63d02c6 100755
--- a/tools/archive_desugar_jdk_libs.py
+++ b/tools/archive_desugar_jdk_libs.py
@@ -75,6 +75,9 @@
'jdk11_nio': BASE_LIBRARY_NAME + '_jdk11_nio.zip'
}
+DESUGAR_JDK_LIBS_HASH_FILE = os.path.join(
+ defines.THIRD_PARTY, 'openjdk', 'desugar_jdk_libs_11', 'desugar_jdk_libs_hash')
+
def ParseOptions(argv):
result = optparse.OptionParser()
@@ -131,11 +134,11 @@
print('File available at: %s' %
destination.replace('gs://', 'https://storage.googleapis.com/', 1))
-def CloneDesugaredLibrary(github_account, checkout_dir):
+def CloneDesugaredLibrary(github_account, checkout_dir, desugar_jdk_libs_hash):
git_utils.GitClone(
'https://github.com/'
+ github_account + '/' + GITHUB_REPRO, checkout_dir)
- git_utils.GitCheckout('292df0eea1c2c1d6b8fe834c7b347ef0b0fdc11b', checkout_dir)
+ git_utils.GitCheckout(desugar_jdk_libs_hash, checkout_dir)
def GetJavaEnv():
java_env = dict(os.environ, JAVA_HOME = jdk.GetJdk11Home())
@@ -251,10 +254,13 @@
raise Exception(path + ' does not exist or is not a directory')
def BuildAndUpload(options, variant):
+ desugar_jdk_libs_hash = ''
+ with open(DESUGAR_JDK_LIBS_HASH_FILE, 'r') as input_hash:
+ desugar_jdk_libs_hash = input_hash.readline()
if options.build_only:
with utils.TempDir() as checkout_dir:
- CloneDesugaredLibrary(options.github_account, checkout_dir)
- (library_jar, maven_zip) = BuildDesugaredLibrary(checkout_dir, variant)
+ CloneDesugaredLibrary(options.github_account, checkout_dir, desugar_jdk_libs_hash)
+ (library_jar, maven_zip) = BuildDesugaredLibrary(checkout_dir, variant, desugar_jdk_libs_hash)
shutil.copyfile(
library_jar,
os.path.join(options.build_only, os.path.basename(library_jar)))
@@ -267,7 +273,7 @@
is_main = False
with utils.TempDir() as checkout_dir:
- CloneDesugaredLibrary(options.github_account, checkout_dir)
+ CloneDesugaredLibrary(options.github_account, checkout_dir, desugar_jdk_libs_hash)
version = GetVersion(os.path.join(checkout_dir, VERSION_MAP[variant]))
destination = archive.GetVersionDestination(
@@ -318,6 +324,7 @@
utils.DownloadFromGoogleCloudStorage(utils.BAZEL_SHA_FILE)
utils.DownloadFromGoogleCloudStorage(utils.JAVA8_SHA_FILE)
utils.DownloadFromGoogleCloudStorage(utils.JAVA11_SHA_FILE)
+ utils.DownloadFromGoogleCloudStorage(utils.DESUGAR_JDK_LIBS_11_SHA_FILE)
for v in options.variant:
BuildAndUpload(options, v)
diff --git a/tools/desugar_jdk_libs_update.py b/tools/desugar_jdk_libs_update.py
new file mode 100755
index 0000000..2e751e9
--- /dev/null
+++ b/tools/desugar_jdk_libs_update.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python3
+# Copyright (c) 2022, 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.
+
+import argparse
+import os
+from os.path import join
+import shutil
+import subprocess
+import sys
+
+import utils
+
+def GetGitHash(checkout_dir):
+ return subprocess.check_output(
+ ['git', '-C', checkout_dir, 'rev-parse', 'HEAD']).decode('utf-8').strip()
+
+def run(args):
+ with utils.TempDir() as tmp_dir:
+ use_existing_checkout = args.desugar_jdk_libs_checkout != None
+ checkout_dir = (args.desugar_jdk_libs_checkout
+ if use_existing_checkout
+ else join(tmp_dir, 'desugar_jdk_libs'))
+ if (not use_existing_checkout):
+ subprocess.check_call(
+ ['git', 'clone', 'https://github.com/google/desugar_jdk_libs.git', checkout_dir])
+ if (args.desugar_jdk_libs_revision):
+ subprocess.check_call(
+ ['git', '-C', checkout_dir, 'checkout', args.desugar_jdk_libs_revision])
+ print("Building desugared library")
+ bazel = os.path.join(utils.BAZEL_TOOL, 'lib', 'bazel', 'bin', 'bazel')
+ with utils.ChangedWorkingDirectory(checkout_dir):
+ for target in [':desugar_jdk_libs_jdk11', '//jdk11/src:java_base_chm_only']:
+ subprocess.check_call([
+ bazel,
+ '--bazelrc=/dev/null',
+ 'build',
+ '--spawn_strategy=local',
+ '--verbose_failures',
+ target])
+
+ openjdk_dir = join('third_party', 'openjdk')
+ openjdk_subdir = 'desugar_jdk_libs_11'
+ dest_dir = join(openjdk_dir, openjdk_subdir)
+ src_dir = join(checkout_dir, 'bazel-bin', 'jdk11', 'src')
+
+ metadata_files = ('LICENSE', 'README.google')
+ for f in metadata_files:
+ shutil.copyfile(join(dest_dir, f), join(tmp_dir, f))
+ shutil.rmtree(dest_dir)
+ os.remove(join(openjdk_dir, openjdk_subdir + '.tar.gz'))
+ os.remove(join(openjdk_dir, openjdk_subdir + '.tar.gz.sha1'))
+ os.mkdir(dest_dir)
+ for s in [
+ (join(src_dir, 'd8_java_base_selected_with_addon.jar'),
+ join(dest_dir, 'desugar_jdk_libs.jar')),
+ (join(src_dir, 'java_base_chm_only.jar'),
+ join(dest_dir, 'desugar_jdk_libs_chm_only.jar'))]:
+ shutil.copyfile(s[0], s[1])
+ for f in metadata_files:
+ shutil.copyfile(join(tmp_dir, f), join(dest_dir, f))
+ desugar_jdk_libs_hash = os.path.join(dest_dir, 'desugar_jdk_libs_hash')
+ with open(desugar_jdk_libs_hash, 'w') as desugar_jdk_libs_hash_writer:
+ desugar_jdk_libs_hash_writer.write(GetGitHash(checkout_dir))
+
+ print('Now run')
+ print(' (cd %s; upload_to_google_storage.py -a --bucket r8-deps %s)'
+ % (openjdk_dir, openjdk_subdir))
+
+
+
+def main():
+ args = parse_options()
+ run(args)
+
+def parse_options():
+ parser = argparse.ArgumentParser(
+ description='Script for updating third_party/openjdk/desugar_jdk_libs*')
+ parser.add_argument('--desugar-jdk-libs-checkout', '--desugar_jdk_libs_checkout',
+ default=None,
+ metavar=('<path>'),
+ help='Use existing checkout of github.com/google/desugar_jdk_libs.')
+ parser.add_argument('--desugar-jdk-libs-revision', '--desugar_jdk_libs_revision',
+ default=None,
+ metavar=('<revision>'),
+ help='Revision of github.com/google/desugar_jdk_libs to use.')
+ args = parser.parse_args()
+ return args
+
+
+if __name__ == '__main__':
+ sys.exit(main())