From 85aee73e98118e68c13c17dbef26b3b73dcaec40 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Fri, 8 Sep 2017 21:26:31 -0700 Subject: [PATCH 1/2] aapt: Always use our libz Instead of using the system libz (-lz), include our copy as a static library. This is safer in case the system version isn't compatible. Also removes references to -ldl -lrt -lpthread, which are now implied. Test: m -j Test: out/host/linux-x86/nativetest64/libaapt_tests/libaapt_tests Test: out/host/linux-x86/nativetest64/aapt2_tests/aapt2_tests Test: out/host/linux-x86/nativetest64/libsplit-select_tests/libsplit-select_tests Change-Id: Icd26dc1e0d011e5b5f158e562640533c5ac34e33 --- tools/aapt/Android.mk | 19 ++----------------- tools/aapt2/Android.bp | 6 +----- tools/split-select/Android.mk | 18 ++---------------- 3 files changed, 5 insertions(+), 38 deletions(-) diff --git a/tools/aapt/Android.mk b/tools/aapt/Android.mk index 04f46d9b27fc7..0a515db087a10 100644 --- a/tools/aapt/Android.mk +++ b/tools/aapt/Android.mk @@ -62,20 +62,12 @@ aaptHostStaticLibs := \ libcutils \ libexpat \ libziparchive \ - libbase + libbase \ + libz aaptCFlags := -DAAPT_VERSION=\"$(BUILD_NUMBER_FROM_FILE)\" aaptCFlags += -Wall -Werror -aaptHostLdLibs_linux := -lrt -ldl -lpthread - -# Statically link libz for MinGW (Win SDK under Linux), -# and dynamically link for all others. -aaptHostStaticLibs_windows := libz -aaptHostLdLibs_linux += -lz -aaptHostLdLibs_darwin := -lz - - # ========================================================== # Build the host static library: libaapt # ========================================================== @@ -88,7 +80,6 @@ LOCAL_CPPFLAGS := $(aaptCppFlags) LOCAL_CFLAGS_darwin := -D_DARWIN_UNLIMITED_STREAMS LOCAL_SRC_FILES := $(aaptSources) LOCAL_STATIC_LIBRARIES := $(aaptHostStaticLibs) -LOCAL_STATIC_LIBRARIES_windows := $(aaptHostStaticLibs_windows) include $(BUILD_HOST_STATIC_LIBRARY) @@ -101,11 +92,8 @@ LOCAL_MODULE := aapt LOCAL_MODULE_HOST_OS := darwin linux windows LOCAL_CFLAGS := $(aaptCFlags) LOCAL_CPPFLAGS := $(aaptCppFlags) -LOCAL_LDLIBS_darwin := $(aaptHostLdLibs_darwin) -LOCAL_LDLIBS_linux := $(aaptHostLdLibs_linux) LOCAL_SRC_FILES := $(aaptMain) LOCAL_STATIC_LIBRARIES := libaapt $(aaptHostStaticLibs) -LOCAL_STATIC_LIBRARIES_windows := $(aaptHostStaticLibs_windows) include $(BUILD_HOST_EXECUTABLE) @@ -118,12 +106,9 @@ include $(CLEAR_VARS) LOCAL_MODULE := libaapt_tests LOCAL_CFLAGS := $(aaptCFlags) LOCAL_CPPFLAGS := $(aaptCppFlags) -LOCAL_LDLIBS_darwin := $(aaptHostLdLibs_darwin) -LOCAL_LDLIBS_linux := $(aaptHostLdLibs_linux) LOCAL_SRC_FILES := $(aaptTests) LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_STATIC_LIBRARIES := libaapt $(aaptHostStaticLibs) -LOCAL_STATIC_LIBRARIES_windows := $(aaptHostStaticLibs_windows) include $(BUILD_HOST_NATIVE_TEST) diff --git a/tools/aapt2/Android.bp b/tools/aapt2/Android.bp index eff82837dd8ae..14333b14c1e07 100644 --- a/tools/aapt2/Android.bp +++ b/tools/aapt2/Android.bp @@ -39,14 +39,9 @@ cc_defaults { windows: { enabled: true, cflags: ["-Wno-maybe-uninitialized"], - static_libs: ["libz"], }, darwin: { cflags: ["-D_DARWIN_UNLIMITED_STREAMS"], - host_ldlibs: ["-lz"], - }, - linux: { - host_ldlibs: ["-lz"], }, }, static_libs: [ @@ -59,6 +54,7 @@ cc_defaults { "libpng", "libbase", "libprotobuf-cpp-lite", + "libz", ], group_static_libs: true, } diff --git a/tools/split-select/Android.mk b/tools/split-select/Android.mk index 4a1511eae43a4..a21383ed4b6ce 100644 --- a/tools/split-select/Android.mk +++ b/tools/split-select/Android.mk @@ -40,7 +40,6 @@ testSources := \ TestRules.cpp cIncludes := \ - external/zlib \ frameworks/base/tools hostStaticLibs := \ @@ -52,18 +51,11 @@ hostStaticLibs := \ libcutils \ libexpat \ libziparchive \ - libbase + libbase \ + libz cFlags := -Wall -Werror -hostLdLibs_linux := -lrt -ldl -lpthread - -# Statically link libz for MinGW (Win SDK under Linux), -# and dynamically link for all others. -hostStaticLibs_windows := libz -hostLdLibs_darwin := -lz -hostLdLibs_linux += -lz - # ========================================================== # Build the host static library: libsplit-select @@ -91,9 +83,6 @@ LOCAL_SRC_FILES := $(testSources) LOCAL_C_INCLUDES := $(cIncludes) LOCAL_STATIC_LIBRARIES := libsplit-select $(hostStaticLibs) -LOCAL_STATIC_LIBRARIES_windows := $(hostStaticLibs_windows) -LOCAL_LDLIBS_darwin := $(hostLdLibs_darwin) -LOCAL_LDLIBS_linux := $(hostLdLibs_linux) LOCAL_CFLAGS := $(cFlags) include $(BUILD_HOST_NATIVE_TEST) @@ -109,9 +98,6 @@ LOCAL_SRC_FILES := $(main) LOCAL_C_INCLUDES := $(cIncludes) LOCAL_STATIC_LIBRARIES := libsplit-select $(hostStaticLibs) -LOCAL_STATIC_LIBRARIES_windows := $(hostStaticLibs_windows) -LOCAL_LDLIBS_darwin := $(hostLdLibs_darwin) -LOCAL_LDLIBS_linux := $(hostLdLibs_linux) LOCAL_CFLAGS := $(cFlags) include $(BUILD_HOST_EXECUTABLE) From 896f01879b424e4f37e65bcf546dc9d5cd712e25 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Fri, 8 Sep 2017 22:02:41 -0700 Subject: [PATCH 2/2] Don't compile libaapt with the build number Only do that for the aapt binary itself. This will allow libaapt to be converted to Soong. Also remove a few lines that weren't doing anything: aaptCppflags was never set, LOCAL_C_INCLUDES := $(LOCAL_PATH) is implied. Test: m aapt Test: aapt version Change-Id: Ia3bcece14921417e1bfd3406630961c013bd497c --- tools/aapt/Android.mk | 9 ++------- tools/aapt/Command.cpp | 18 ------------------ tools/aapt/Main.cpp | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/tools/aapt/Android.mk b/tools/aapt/Android.mk index 0a515db087a10..e74a3dfbb839f 100644 --- a/tools/aapt/Android.mk +++ b/tools/aapt/Android.mk @@ -65,8 +65,7 @@ aaptHostStaticLibs := \ libbase \ libz -aaptCFlags := -DAAPT_VERSION=\"$(BUILD_NUMBER_FROM_FILE)\" -aaptCFlags += -Wall -Werror +aaptCFlags := -Wall -Werror # ========================================================== # Build the host static library: libaapt @@ -76,7 +75,6 @@ include $(CLEAR_VARS) LOCAL_MODULE := libaapt LOCAL_MODULE_HOST_OS := darwin linux windows LOCAL_CFLAGS := -Wno-format-y2k -DSTATIC_ANDROIDFW_FOR_TOOLS $(aaptCFlags) -LOCAL_CPPFLAGS := $(aaptCppFlags) LOCAL_CFLAGS_darwin := -D_DARWIN_UNLIMITED_STREAMS LOCAL_SRC_FILES := $(aaptSources) LOCAL_STATIC_LIBRARIES := $(aaptHostStaticLibs) @@ -90,8 +88,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := aapt LOCAL_MODULE_HOST_OS := darwin linux windows -LOCAL_CFLAGS := $(aaptCFlags) -LOCAL_CPPFLAGS := $(aaptCppFlags) +LOCAL_CFLAGS := -DAAPT_VERSION=\"$(BUILD_NUMBER_FROM_FILE)\" $(aaptCFlags) LOCAL_SRC_FILES := $(aaptMain) LOCAL_STATIC_LIBRARIES := libaapt $(aaptHostStaticLibs) @@ -105,9 +102,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libaapt_tests LOCAL_CFLAGS := $(aaptCFlags) -LOCAL_CPPFLAGS := $(aaptCppFlags) LOCAL_SRC_FILES := $(aaptTests) -LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_STATIC_LIBRARIES := libaapt $(aaptHostStaticLibs) include $(BUILD_HOST_NATIVE_TEST) diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp index ba731801e5070..5e85802551970 100644 --- a/tools/aapt/Command.cpp +++ b/tools/aapt/Command.cpp @@ -29,24 +29,6 @@ using namespace android; -#ifndef AAPT_VERSION - #define AAPT_VERSION "" -#endif - -/* - * Show version info. All the cool kids do it. - */ -int doVersion(Bundle* bundle) -{ - if (bundle->getFileSpecCount() != 0) { - printf("(ignoring extra arguments)\n"); - } - printf("Android Asset Packaging Tool, v0.2-" AAPT_VERSION "\n"); - - return 0; -} - - /* * Open the file read only. The call fails if the file doesn't exist. * diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp index 417b7ae087e14..d714687ee914f 100644 --- a/tools/aapt/Main.cpp +++ b/tools/aapt/Main.cpp @@ -20,6 +20,23 @@ using namespace android; static const char* gProgName = "aapt"; +#ifndef AAPT_VERSION + #define AAPT_VERSION "" +#endif + +/* + * Show version info. All the cool kids do it. + */ +int doVersion(Bundle* bundle) +{ + if (bundle->getFileSpecCount() != 0) { + printf("(ignoring extra arguments)\n"); + } + printf("Android Asset Packaging Tool, v0.2-" AAPT_VERSION "\n"); + + return 0; +} + /* * When running under Cygwin on Windows, this will convert slash-based * paths into back-slash-based ones. Otherwise the ApptAssets file comparisons