Bug 1947388 - Download jdk under --enable-bootstrap if it's missing r=nalexander,glandium,gerard-majax

Differential Revision: https://phabricator.services.mozilla.com/D237711
This commit is contained in:
serge-sans-paille
2025-02-19 07:39:55 +00:00
parent ad5ec08465
commit 64850361b9
2 changed files with 24 additions and 3 deletions

View File

@@ -14,12 +14,14 @@ option(
)
@depends("--with-java-bin-path", host, toolchains_base_dir)
@depends("--with-java-bin-path", host, toolchains_base_dir, want_bootstrap)
@imports(_from="mozboot.android", _import="ensure_java")
@imports(_from="mozboot.android", _import="JavaLocationFailedException")
@imports(_from="mozboot.android", _import="locate_java_bin_path")
@imports(_from="os", _import="environ")
@imports(_from="os.path", _import="dirname")
def java_search_paths(path, host, toolchains_base_dir):
@imports(_from="__builtin__", _import="Exception")
def java_search_paths(path, host, toolchains_base_dir, want_bootstrap):
if path:
# Look for javac and jar in the specified path.
return path
@@ -35,6 +37,24 @@ def java_search_paths(path, host, toolchains_base_dir):
)
return [path]
except JavaLocationFailedException as e:
if not want_bootstrap("jdk"):
die(str(e))
os_name = {"Linux": "linux", "Darwin": "macosx", "WINNT": "windows"}.get(
host.kernel
)
if os_name is None:
die(
"We don't support bootstrapping the Java SDK on {0} yet!".format(
host.kernel
)
)
os_arch = host.cpu
try:
# FIXME: should use the bootstrap.configure mechanism instead
return [str(ensure_java(os_name, os_arch))]
except Exception as e:
die(str(e))

View File

@@ -554,6 +554,7 @@ class TestChecksConfigure(unittest.TestCase):
def host(_):
return namespace(os='unknown', kernel='unknown')
toolchains_base_dir = depends(when=True)(lambda: '/mozbuild')
want_bootstrap = dependable(lambda: lambda _: False)
include('%(topsrcdir)s/build/moz.configure/java.configure')
"""
% {"topsrcdir": topsrcdir}