Bug 1099501 - Export and use ANDROID_TOOLS where appropriate. r=snorp, r=bnicholson, a=NPOTB
authorNick Alexander <nalexander@mozilla.com>
Mon, 17 Nov 2014 11:12:00 -0800
changeset 226135 67a53bb6b0bd70219699129d40d1a4c9d7f016f5
parent 226134 5d29e9cd389e8e37312ad4e7be12f0d28751a04e
child 226136 e247a7f7c43842941bdb4207ca1b9d8881798997
push id4175
push userryanvm@gmail.com
push dateMon, 24 Nov 2014 17:08:09 +0000
treeherdermozilla-beta@e247a7f7c438 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, bnicholson, NPOTB
bugs1099501
milestone34.0
Bug 1099501 - Export and use ANDROID_TOOLS where appropriate. r=snorp, r=bnicholson, a=NPOTB In certain configurations, in particular when installing the Android SDK using HomeBrew, one sees a configuration with symlinks like: [brian@brian-macbook git]$ ls -l /usr/local/Cellar/android-sdk/23.0.2/ total 72 ... lrwxr-xr-x 1 brian admin 38 Nov 14 16:39 platforms -> ../../../var/lib/android-sdk/platforms ... drwxr-xr-x 26 brian admin 884 Nov 14 17:43 tools In this case, we have ANDROID_SDK=/usr/local/Cellar/android-sdk/23.0.2/platforms/android-21. It is an anti-pattern to use ANDORID_SDK/.. to find other paths in the tree. This pattern is used in at least two places: 1) When we try to find /usr/local/Cellar/android-sdk/23.0.2/platforms/android-21/../../tools, we end up in the /usr/local/var/lib subtree. This patch works around that by exporting and using ANDROID_TOOLS; ANDROID_TOOLS itself is extracted using path matching, rather than following .. through the filesystem. 2) We also need to use ANDROID_SDK_ROOT rather than ANDROID_SDK/../.. through-out.
build/annotationProcessors/Makefile.in
build/annotationProcessors/SDKProcessor.java
build/autoconf/android.m4
embedding/android/geckoview_example/Makefile.in
mobile/android/geckoview_library/Makefile.in
mobile/android/geckoview_library/local.properties.in
widget/android/bindings/Makefile.in
--- a/build/annotationProcessors/Makefile.in
+++ b/build/annotationProcessors/Makefile.in
@@ -1,12 +1,12 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 include $(topsrcdir)/config/rules.mk
 
-JAVA_CLASSPATH := $(ANDROID_SDK)/android.jar:$(ANDROID_SDK)/../../tools/lib/lint.jar:$(ANDROID_SDK)/../../tools/lib/lint-checks.jar
+JAVA_CLASSPATH := $(ANDROID_SDK)/android.jar:$(ANDROID_TOOLS)/lib/lint.jar:$(ANDROID_TOOLS)/lib/lint-checks.jar
 
 # Include Android specific java flags, instead of what's in rules.mk.
 include $(topsrcdir)/config/android-common.mk
 
 export:: annotationProcessors.jar
--- a/build/annotationProcessors/SDKProcessor.java
+++ b/build/annotationProcessors/SDKProcessor.java
@@ -53,20 +53,16 @@ public class SDKProcessor {
         System.out.println("Processing platform bindings...");
 
         String sdkJar = args[0];
         Vector classes = getClassList(args[1]);
         String outdir = args[2];
         String generatedFilePrefix = args[3];
         sMaxSdkVersion = Integer.parseInt(args[4]);
 
-        Properties props = System.getProperties();
-        props.setProperty("com.android.tools.lint.bindir",
-            new File(new File(sdkJar).getParentFile(), "../../tools").toString());
-
         LintCliClient lintClient = new LintCliClient();
         sApiLookup = ApiLookup.get(lintClient);
 
         // Start the clock!
         long s = System.currentTimeMillis();
 
         // Get an iterator over the classes in the jar files given...
         // Iterator<ClassWithOptions> jarClassIterator = IterableJarLoadingURLClassLoader.getIteratorOverJars(args);
@@ -247,9 +243,9 @@ public class SDKProcessor {
                     headerStream.close();
                 } catch (IOException e) {
                     System.err.println("Unable to close headerStream due to "+e);
                     e.printStackTrace(System.err);
                 }
             }
         }
     }
-}
\ No newline at end of file
+}
--- a/build/autoconf/android.m4
+++ b/build/autoconf/android.m4
@@ -333,16 +333,19 @@ case "$target" in
     fi
     AC_MSG_RESULT([$ANDROID_COMPAT_DIR_BASE])
 
     ANDROID_TOOLS="${android_tools}"
     ANDROID_PLATFORM_TOOLS="${android_platform_tools}"
     ANDROID_BUILD_TOOLS="${android_build_tools}"
     AC_SUBST(ANDROID_SDK_ROOT)
     AC_SUBST(ANDROID_SDK)
+    AC_SUBST(ANDROID_TOOLS)
+    AC_SUBST(ANDROID_PLATFORM_TOOLS)
+    AC_SUBST(ANDROID_BUILD_TOOLS)
 
     ANDROID_COMPAT_LIB=$ANDROID_COMPAT_DIR_BASE/v4/android-support-v4.jar
     AC_MSG_CHECKING([for v4 compat library])
     AC_SUBST(ANDROID_COMPAT_LIB)
     if ! test -e $ANDROID_COMPAT_LIB ; then
         AC_MSG_ERROR([You must download the Android v4 support library when targeting Android.  Run the Android SDK tool and install Android Support Library under Extras.  See https://developer.android.com/tools/extras/support-library.html for more info. (looked for $ANDROID_COMPAT_LIB)])
     fi
     AC_MSG_RESULT([$ANDROID_COMPAT_LIB])
--- a/embedding/android/geckoview_example/Makefile.in
+++ b/embedding/android/geckoview_example/Makefile.in
@@ -20,17 +20,17 @@ GARBAGE_DIRS = \
 	gen \
 	bin \
 	libs \
 	res \
 	src \
 	binaries \
 	$(NULL)
 
-ANDROID=$(ANDROID_SDK)/../../tools/android
+ANDROID=$(ANDROID_TOOLS)/android
 
 TARGET="android-$(ANDROID_TARGET_SDK)"
 
 PACKAGE_DEPS = \
 	assets/libxul.so \
 	build.xml \
 	src/org/mozilla/geckoviewexample/GeckoViewExample.java \
 	$(CURDIR)/res/layout/main.xml \
--- a/mobile/android/geckoview_library/Makefile.in
+++ b/mobile/android/geckoview_library/Makefile.in
@@ -5,23 +5,23 @@
 INSTALL_TARGETS += GECKOVIEW_LIBRARY
 GECKOVIEW_LIBRARY_DEST = $(CURDIR)
 GECKOVIEW_LIBRARY_FILES := \
   .classpath \
   .project \
   build.xml \
   $(NULL)
 
-PP_TARGETS = properties manifest project
-
-properties = local.properties.in
-project = project.properties.in
-manifest = AndroidManifest.xml.in
-
-GARBAGE = $(GECKOVIEW_LIBRARY_FILES) local.properties project.properties AndroidManifest.xml
+PP_TARGETS += gen
+gen := \
+  local.properties.in \
+  project.properties.in \
+  AndroidManifest.xml.in \
+  $(NULL)
+gen_FLAGS += -DANDROID_SDK_ROOT=$(ANDROID_SDK_ROOT)
 
 GARBAGE_DIRS = \
   bin \
   libs \
   src \
   .deps \
   gen  \
   res \
--- a/mobile/android/geckoview_library/local.properties.in
+++ b/mobile/android/geckoview_library/local.properties.in
@@ -3,9 +3,9 @@
 # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
 #
 # This file must *NOT* be checked into Version Control Systems,
 # as it contains information specific to your local configuration.
 
 # location of the SDK. This is only used by Ant
 # For customization when using a Version Control System, please read the
 # header note.
-sdk.dir=@ANDROID_SDK@/../../
+sdk.dir=@ANDROID_SDK_ROOT@
--- a/widget/android/bindings/Makefile.in
+++ b/widget/android/bindings/Makefile.in
@@ -1,21 +1,27 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-annotation_processor_jar_files := $(DEPTH)/build/annotationProcessors/annotationProcessors.jar:$(ANDROID_SDK)/../../tools/lib/lint.jar:$(ANDROID_SDK)/../../tools/lib/lint-checks.jar
+annotation_processor_jar_files := $(DEPTH)/build/annotationProcessors/annotationProcessors.jar:$(ANDROID_TOOLS)/lib/lint.jar:$(ANDROID_TOOLS)/lib/lint-checks.jar
+
+sdk_processor := \
+  $(JAVA) \
+  -Dcom.android.tools.lint.bindir='$(ANDROID_TOOLS)' \
+  -classpath $(annotation_processor_jar_files) \
+  org.mozilla.gecko.annotationProcessors.SDKProcessor
 
 MediaCodec.cpp: $(ANDROID_SDK)/android.jar mediacodec-classes.txt
-	$(JAVA) -classpath $(annotation_processor_jar_files) org.mozilla.gecko.annotationProcessors.SDKProcessor $(ANDROID_SDK)/android.jar $(srcdir)/mediacodec-classes.txt $(CURDIR) MediaCodec 16
+	$(sdk_processor) $(ANDROID_SDK)/android.jar $(srcdir)/mediacodec-classes.txt $(CURDIR) MediaCodec 16
 
 MediaCodec.h: MediaCodec.cpp
 
 SurfaceTexture.cpp: $(ANDROID_SDK)/android.jar surfacetexture-classes.txt
-	$(JAVA) -classpath $(annotation_processor_jar_files) org.mozilla.gecko.annotationProcessors.SDKProcessor $(ANDROID_SDK)/android.jar $(srcdir)/surfacetexture-classes.txt $(CURDIR) SurfaceTexture 16
+	$(sdk_processor) $(ANDROID_SDK)/android.jar $(srcdir)/surfacetexture-classes.txt $(CURDIR) SurfaceTexture 16
 
 SurfaceTexture.h: SurfaceTexture.cpp
 
 # We'd like these to be defined in a future GENERATED_EXPORTS list.
 bindings_exports_FILES := \
   MediaCodec.h \
   SurfaceTexture.h \
   $(NULL)