OSDN Git Service

aapt: Always use our libz
authorDan Willemsen <dwillemsen@google.com>
Sat, 9 Sep 2017 04:26:31 +0000 (21:26 -0700)
committerDan Willemsen <dwillemsen@google.com>
Sat, 9 Sep 2017 05:44:19 +0000 (22:44 -0700)
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
tools/aapt2/Android.bp
tools/split-select/Android.mk

index 04f46d9..0a515db 100644 (file)
@@ -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)
 
index eff8283..14333b1 100644 (file)
@@ -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,
 }
index 4a1511e..a21383e 100644 (file)
@@ -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)