From f16d77b0a2b4b7002ca4dc10dc4cbb1dd499e8de Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Mon, 17 Nov 2014 11:12:00 -0800 Subject: [PATCH] Bug 1099501 - Export and use ANDROID_TOOLS where appropriate. r=snorp,bnicholson 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. --HG-- extra : rebase_source : 5e0323a94f2b80550f17a624e16f338cdeec406d --- build/annotationProcessors/Makefile.in | 2 +- build/annotationProcessors/SDKProcessor.java | 6 +----- build/autoconf/android.m4 | 3 +++ embedding/android/geckoview_example/Makefile.in | 2 +- mobile/android/geckoview_library/Makefile.in | 14 +++++++------- .../android/geckoview_library/local.properties.in | 2 +- widget/android/bindings/Makefile.in | 12 +++++++++--- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/build/annotationProcessors/Makefile.in b/build/annotationProcessors/Makefile.in index b21a52bbd1f..11a273cd65e 100644 --- a/build/annotationProcessors/Makefile.in +++ b/build/annotationProcessors/Makefile.in @@ -4,7 +4,7 @@ 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 diff --git a/build/annotationProcessors/SDKProcessor.java b/build/annotationProcessors/SDKProcessor.java index 2eab460468a..10393ff58fd 100644 --- a/build/annotationProcessors/SDKProcessor.java +++ b/build/annotationProcessors/SDKProcessor.java @@ -58,10 +58,6 @@ public class SDKProcessor { 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); @@ -252,4 +248,4 @@ public class SDKProcessor { } } } -} \ No newline at end of file +} diff --git a/build/autoconf/android.m4 b/build/autoconf/android.m4 index 82d916336cc..e03e4461ac3 100644 --- a/build/autoconf/android.m4 +++ b/build/autoconf/android.m4 @@ -376,6 +376,9 @@ case "$target" in 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]) diff --git a/embedding/android/geckoview_example/Makefile.in b/embedding/android/geckoview_example/Makefile.in index 1823b7656aa..42bac9b0dff 100644 --- a/embedding/android/geckoview_example/Makefile.in +++ b/embedding/android/geckoview_example/Makefile.in @@ -25,7 +25,7 @@ GARBAGE_DIRS = \ binaries \ $(NULL) -ANDROID=$(ANDROID_SDK)/../../tools/android +ANDROID=$(ANDROID_TOOLS)/android TARGET="android-$(ANDROID_TARGET_SDK)" diff --git a/mobile/android/geckoview_library/Makefile.in b/mobile/android/geckoview_library/Makefile.in index acdb71db766..5a5aaef3f02 100644 --- a/mobile/android/geckoview_library/Makefile.in +++ b/mobile/android/geckoview_library/Makefile.in @@ -10,13 +10,13 @@ GECKOVIEW_LIBRARY_FILES := \ 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 \ diff --git a/mobile/android/geckoview_library/local.properties.in b/mobile/android/geckoview_library/local.properties.in index 383f158aca0..8112f907745 100644 --- a/mobile/android/geckoview_library/local.properties.in +++ b/mobile/android/geckoview_library/local.properties.in @@ -8,4 +8,4 @@ # 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@ diff --git a/widget/android/bindings/Makefile.in b/widget/android/bindings/Makefile.in index 87544958ae6..08396cb323a 100644 --- a/widget/android/bindings/Makefile.in +++ b/widget/android/bindings/Makefile.in @@ -2,15 +2,21 @@ # 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