Bug 1527796 - Part 2. Detect Java on Windows. r=nalexander,glandium
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 05 Mar 2019 11:03:27 +0900
changeset 466816 440350958e77ea77422d48538416a113c1e3d888
parent 466815 c95084270844448e1c44d9e32ed2ea3a0a16848f
child 466817 230ed445be2c2413cf3dff9a6db8e64eafda4ab4
push id35781
push useropoprus@mozilla.com
push dateFri, 29 Mar 2019 21:56:26 +0000
treeherdermozilla-central@4526b65c502e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander, glandium
bugs1527796
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1527796 - Part 2. Detect Java on Windows. r=nalexander,glandium When installing JDK 1.8, it writes path to the following registry. HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8\JavaHome So we use this registry to detect JDK installation path on Windows if available. Differential Revision: https://phabricator.services.mozilla.com/D20449
build/moz.configure/java.configure
--- a/build/moz.configure/java.configure
+++ b/build/moz.configure/java.configure
@@ -6,27 +6,29 @@
 
 
 # Java detection
 # ========================================================
 option('--with-java-bin-path', nargs=1,
        help='Location of Java binaries (java, jarsigner, keytool)')
 
 
-@depends('--with-java-bin-path')
+@depends(host, '--with-java-bin-path')
 @imports(_from='os', _import='environ')
-def java_search_paths(path):
+def java_search_paths(host, path):
     if path:
         # Look for javac and jar in the specified path.
         return path
-    # With no path specified, look for javac and jar in $JAVA_HOME (if set)
-    # and $PATH.
+    # With no path specified, look for javac and jar in $JAVA_HOME (if set),
+    # JDK registery on Windows, and $PATH.
     if 'JAVA_HOME' in environ:
-        return [os.path.join(environ['JAVA_HOME'], 'bin'),
-                environ.get('PATH', '')]
+        return [os.path.join(environ['JAVA_HOME'], 'bin')]
+    if host.os == 'WINNT':
+        for x in get_registry_values(r'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8\JavaHome', get_32_and_64_bit=True):
+            return [os.path.join(x[0], 'bin')]
     return [environ.get('PATH')]
 
 # Finds the given java tool, failing with a custom error message if we can't
 # find it.
 
 
 @template
 def check_java_tool(tool):