chiark / gitweb /
Merge branch 'java-home-lookup' into 'master'
[fdroidserver.git] / fdroidserver / common.py
index ce81b3855ba2f901690afc07d5a6284d4e3d189e..593bab2da947abc1686dbea301066fc5a10c3754 100644 (file)
@@ -56,9 +56,10 @@ default_config = {
     'sdk_path': "$ANDROID_HOME",
     'ndk_paths': {
         'r9b': None,
-        'r10e': "$ANDROID_NDK",
+        'r10e': None,
+        'r12b': "$ANDROID_NDK",
     },
-    'build_tools': "24.0.0",
+    'build_tools': "24.0.1",
     'force_build_tools': False,
     'java_paths': None,
     'ant': "ant",
@@ -135,7 +136,7 @@ def fill_config_defaults(thisconfig):
         pathlist += glob.glob('/System/Library/Java/JavaVirtualMachines/1.[6-9].0.jdk')
         pathlist += glob.glob('/Library/Java/JavaVirtualMachines/*jdk*[6-9]*')
         if os.getenv('JAVA_HOME') is not None:
-            pathlist += os.getenv('JAVA_HOME')
+            pathlist.append(os.getenv('JAVA_HOME'))
         if os.getenv('PROGRAMFILES') is not None:
             pathlist += glob.glob(os.path.join(os.getenv('PROGRAMFILES'), 'Java', 'jdk1.[6-9].*'))
         for d in sorted(pathlist):
@@ -158,11 +159,9 @@ def fill_config_defaults(thisconfig):
                 m = re.match(regex, j)
                 if not m:
                     continue
-                osxhome = os.path.join(d, 'Contents', 'Home')
-                if os.path.exists(osxhome):
-                    thisconfig['java_paths'][m.group(1)] = osxhome
-                else:
-                    thisconfig['java_paths'][m.group(1)] = d
+                for p in [d, os.path.join(d, 'Contents', 'Home')]:
+                    if os.path.exists(os.path.join(p, 'bin', 'javac')):
+                        thisconfig['java_paths'][m.group(1)] = p
 
     for java_version in ('7', '8', '9'):
         if java_version not in thisconfig['java_paths']:
@@ -1372,7 +1371,11 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
             props += "sdk.dir=%s\n" % config['sdk_path']
             props += "sdk-location=%s\n" % config['sdk_path']
         ndk_path = build.ndk_path()
-        if ndk_path:
+        # if for any reason the path isn't valid or the directory
+        # doesn't exist, some versions of Gradle will error with a
+        # cryptic message (even if the NDK is not even necessary).
+        # https://gitlab.com/fdroid/fdroidserver/issues/171
+        if ndk_path and os.path.exists(ndk_path):
             # Add ndk location
             props += "ndk.dir=%s\n" % ndk_path
             props += "ndk-location=%s\n" % ndk_path