1# 2# Copyright (C) 2014 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# This tool is prebuilt if we're doing an app-only build. 18ifeq ($(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK)),) 19 20# ========================================================== 21# Setup some common variables for the different build 22# targets here. 23# ========================================================== 24LOCAL_PATH:= $(call my-dir) 25 26aaptMain := Main.cpp 27aaptSources := \ 28 AaptAssets.cpp \ 29 AaptConfig.cpp \ 30 AaptUtil.cpp \ 31 AaptXml.cpp \ 32 ApkBuilder.cpp \ 33 Command.cpp \ 34 CrunchCache.cpp \ 35 FileFinder.cpp \ 36 Images.cpp \ 37 Package.cpp \ 38 pseudolocalize.cpp \ 39 qsort_r_compat.c \ 40 Resource.cpp \ 41 ResourceFilter.cpp \ 42 ResourceIdCache.cpp \ 43 ResourceTable.cpp \ 44 SourcePos.cpp \ 45 StringPool.cpp \ 46 WorkQueue.cpp \ 47 XMLNode.cpp \ 48 ZipEntry.cpp \ 49 ZipFile.cpp 50 51aaptTests := \ 52 tests/AaptConfig_test.cpp \ 53 tests/AaptGroupEntry_test.cpp \ 54 tests/ResourceFilter_test.cpp 55 56aaptCIncludes := \ 57 external/libpng \ 58 external/zlib 59 60aaptHostLdLibs := 61aaptHostStaticLibs := \ 62 libandroidfw \ 63 libpng \ 64 liblog \ 65 libutils \ 66 libcutils \ 67 libexpat \ 68 libziparchive-host 69 70aaptCFlags := -DAAPT_VERSION=\"$(BUILD_NUMBER)\" 71 72ifeq ($(HOST_OS),linux) 73 aaptHostLdLibs += -lrt -ldl -lpthread 74endif 75 76# Statically link libz for MinGW (Win SDK under Linux), 77# and dynamically link for all others. 78ifneq ($(strip $(USE_MINGW)),) 79 aaptHostStaticLibs += libz 80else 81 aaptHostLdLibs += -lz 82endif 83 84 85# ========================================================== 86# Build the host static library: libaapt 87# ========================================================== 88include $(CLEAR_VARS) 89 90LOCAL_MODULE := libaapt 91LOCAL_CFLAGS += -Wno-format-y2k -DSTATIC_ANDROIDFW_FOR_TOOLS $(aaptCFlags) 92LOCAL_CPPFLAGS += $(aaptCppFlags) 93ifeq (darwin,$(HOST_OS)) 94LOCAL_CFLAGS += -D_DARWIN_UNLIMITED_STREAMS 95endif 96LOCAL_C_INCLUDES += $(aaptCIncludes) 97LOCAL_SRC_FILES := $(aaptSources) 98 99include $(BUILD_HOST_STATIC_LIBRARY) 100 101 102# ========================================================== 103# Build the host executable: aapt 104# ========================================================== 105include $(CLEAR_VARS) 106 107LOCAL_MODULE := aapt 108LOCAL_CFLAGS += $(aaptCFlags) 109LOCAL_CPPFLAGS += $(aaptCppFlags) 110LOCAL_LDLIBS += $(aaptHostLdLibs) 111LOCAL_SRC_FILES := $(aaptMain) 112LOCAL_STATIC_LIBRARIES += libaapt $(aaptHostStaticLibs) 113 114include $(BUILD_HOST_EXECUTABLE) 115 116 117# ========================================================== 118# Build the host tests: libaapt_tests 119# ========================================================== 120include $(CLEAR_VARS) 121 122LOCAL_MODULE := libaapt_tests 123LOCAL_CFLAGS += $(aaptCFlags) 124LOCAL_CPPFLAGS += $(aaptCppFlags) 125LOCAL_LDLIBS += $(aaptHostLdLibs) 126LOCAL_SRC_FILES += $(aaptTests) 127LOCAL_C_INCLUDES += $(LOCAL_PATH) 128LOCAL_STATIC_LIBRARIES += libaapt $(aaptHostStaticLibs) 129 130include $(BUILD_HOST_NATIVE_TEST) 131 132 133# ========================================================== 134# Build the device executable: aapt 135# ========================================================== 136ifneq ($(SDK_ONLY),true) 137include $(CLEAR_VARS) 138 139LOCAL_MODULE := aapt 140LOCAL_CFLAGS += $(aaptCFlags) 141LOCAL_SRC_FILES := $(aaptSources) $(aaptMain) 142LOCAL_C_INCLUDES += \ 143 $(aaptCIncludes) \ 144 bionic \ 145 external/stlport/stlport 146LOCAL_SHARED_LIBRARIES := \ 147 libandroidfw \ 148 libutils \ 149 libcutils \ 150 libpng \ 151 liblog \ 152 libz 153LOCAL_STATIC_LIBRARIES := \ 154 libstlport_static \ 155 libexpat_static 156 157include $(BUILD_EXECUTABLE) 158 159endif # Not SDK_ONLY 160 161endif # No TARGET_BUILD_APPS or TARGET_BUILD_PDK 162