diff --git a/build/moz.configure/java.configure b/build/moz.configure/java.configure index 0bb0a22c712f..c5fd7de3392d 100644 --- a/build/moz.configure/java.configure +++ b/build/moz.configure/java.configure @@ -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,7 +37,25 @@ def java_search_paths(path, host, toolchains_base_dir): ) return [path] except JavaLocationFailedException as e: - die(str(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)) # Finds the given java tool, failing with a custom error message if we can't diff --git a/python/mozbuild/mozbuild/test/configure/test_checks_configure.py b/python/mozbuild/mozbuild/test/configure/test_checks_configure.py index e2506fb18773..f5550627f2e3 100644 --- a/python/mozbuild/mozbuild/test/configure/test_checks_configure.py +++ b/python/mozbuild/mozbuild/test/configure/test_checks_configure.py @@ -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}