From f93f581b1f61383f18790599a2f410616e81faed Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Thu, 26 Sep 2024 10:16:25 +0200 Subject: [PATCH] added support for specifying a JDK selector on the fetch-jdk command line --- src/mx/_impl/mx.py | 2 +- src/mx/_impl/mx_fetchjdk.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mx/_impl/mx.py b/src/mx/_impl/mx.py index 0f99c8c1..da5b7464 100755 --- a/src/mx/_impl/mx.py +++ b/src/mx/_impl/mx.py @@ -18204,7 +18204,7 @@ def alarm_handler(signum, frame): _CACHE_DIR = get_env('MX_CACHE_DIR', join(dot_mx_dir(), 'cache')) # The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue -version = VersionSpec("7.32.0") # GR-56702: fix manifest version +version = VersionSpec("7.32.1") # GR-58516] Added support for specifying a JDK selector on the fetch-jdk command line _mx_start_datetime = datetime.utcnow() diff --git a/src/mx/_impl/mx_fetchjdk.py b/src/mx/_impl/mx_fetchjdk.py index 00aa8f80..6c58410e 100644 --- a/src/mx/_impl/mx_fetchjdk.py +++ b/src/mx/_impl/mx_fetchjdk.py @@ -265,7 +265,7 @@ def _parse_args(args): path_list.add(join(_mx_home, 'jdk-binaries.json')) default_jdk_binaries_location = str(path_list) - parser = ArgumentParser(prog='mx fetch-jdk', usage='%(prog)s [options] []' + r""" + parser = ArgumentParser(prog='mx fetch-jdk', usage='%(prog)s [options] [ []]' + r""" Download and install JDKs. The set of JDKs available for download are specified by the "jdks" field of the JSON @@ -374,6 +374,7 @@ def _parse_args(args): jdk_id_group = parser.add_mutually_exclusive_group() jdk_id_group.add_argument('jdk_id_pos', action='store', metavar='', nargs='?', help='see --jdk-id') jdk_id_group.add_argument('--jdk-id', '--java-distribution', action='store', metavar='', help='Identifier of the JDK that should be downloaded (e.g., "labsjdk-ce-11" or "openjdk8")') + parser.add_argument('selector', action='store', metavar='', nargs='?', help=f'refine base JDK by selector ') parser.add_argument('--configuration', action='store', metavar='', help=f'location of JSON file containing JDK definitions (default: {default_jdk_defs_location})') parser.add_argument('--jdk-binaries', action='store', metavar='', help=f'{os.pathsep} separated JSON files specifying location of JDK binaries (default: {default_jdk_binaries_location})') parser.add_argument('--to', action='store', metavar='', help=f"location where JDK will be installed. Specify to use the system default location. (default: {settings['jdks-dir']})") @@ -417,7 +418,7 @@ def _parse_args(args): # use positional or option argument jdk_id = args.jdk_id_pos or args.jdk_id if jdk_id is not None: - settings["jdk-binary"] = _get_jdk_binary_or_abort(jdk_binaries, jdk_id) + settings["jdk-binary"] = _get_jdk_binary_or_abort(jdk_binaries, jdk_id, args.selector) else: if is_quiet(): parser.print_usage() @@ -439,10 +440,12 @@ def _parse_args(args): return settings -def _get_jdk_binary_or_abort(jdk_binaries, jdk_id): +def _get_jdk_binary_or_abort(jdk_binaries, jdk_id, selector): jdk_binary = jdk_binaries.get(jdk_id) if not jdk_binary: mx.abort(f"Unknown JDK identifier: {jdk_id} [Known JDKs: {', '.join(jdk_binaries.keys())}]") + if selector is not None: + return jdk_binary.with_selector(selector) return jdk_binary