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    Resource.cpp \
40    ResourceFilter.cpp \
41    ResourceIdCache.cpp \
42    ResourceTable.cpp \
43    SourcePos.cpp \
44    StringPool.cpp \
45    WorkQueue.cpp \
46    XMLNode.cpp \
47    ZipEntry.cpp \
48    ZipFile.cpp
49
50aaptTests := \
51    tests/AaptConfig_test.cpp \
52    tests/AaptGroupEntry_test.cpp \
53    tests/Pseudolocales_test.cpp \
54    tests/ResourceFilter_test.cpp \
55    tests/ResourceTable_test.cpp
56
57aaptHostStaticLibs := \
58    libandroidfw \
59    libpng \
60    liblog \
61    libutils \
62    libcutils \
63    libexpat \
64    libziparchive-host \
65    libbase
66
67aaptCFlags := -DAAPT_VERSION=\"$(BUILD_NUMBER_FROM_FILE)\"
68aaptCFlags += -Wall -Werror
69
70aaptHostLdLibs_linux := -lrt -ldl -lpthread
71
72# Statically link libz for MinGW (Win SDK under Linux),
73# and dynamically link for all others.
74aaptHostStaticLibs_windows := libz
75aaptHostLdLibs_linux += -lz
76aaptHostLdLibs_darwin := -lz
77
78
79# ==========================================================
80# Build the host static library: libaapt
81# ==========================================================
82include $(CLEAR_VARS)
83
84LOCAL_MODULE := libaapt
85LOCAL_MODULE_HOST_OS := darwin linux windows
86LOCAL_CFLAGS := -Wno-format-y2k -DSTATIC_ANDROIDFW_FOR_TOOLS $(aaptCFlags)
87LOCAL_CPPFLAGS := $(aaptCppFlags)
88LOCAL_CFLAGS_darwin := -D_DARWIN_UNLIMITED_STREAMS
89LOCAL_SRC_FILES := $(aaptSources)
90LOCAL_STATIC_LIBRARIES := $(aaptHostStaticLibs)
91LOCAL_STATIC_LIBRARIES_windows := $(aaptHostStaticLibs_windows)
92
93include $(BUILD_HOST_STATIC_LIBRARY)
94
95# ==========================================================
96# Build the host executable: aapt
97# ==========================================================
98include $(CLEAR_VARS)
99
100LOCAL_MODULE := aapt
101LOCAL_MODULE_HOST_OS := darwin linux windows
102LOCAL_CFLAGS := $(aaptCFlags)
103LOCAL_CPPFLAGS := $(aaptCppFlags)
104LOCAL_LDLIBS_darwin := $(aaptHostLdLibs_darwin)
105LOCAL_LDLIBS_linux := $(aaptHostLdLibs_linux)
106LOCAL_SRC_FILES := $(aaptMain)
107LOCAL_STATIC_LIBRARIES := libaapt $(aaptHostStaticLibs)
108LOCAL_STATIC_LIBRARIES_windows := $(aaptHostStaticLibs_windows)
109
110include $(BUILD_HOST_EXECUTABLE)
111
112
113# ==========================================================
114# Build the host tests: libaapt_tests
115# ==========================================================
116include $(CLEAR_VARS)
117
118LOCAL_MODULE := libaapt_tests
119LOCAL_CFLAGS := $(aaptCFlags)
120LOCAL_CPPFLAGS := $(aaptCppFlags)
121LOCAL_LDLIBS_darwin := $(aaptHostLdLibs_darwin)
122LOCAL_LDLIBS_linux := $(aaptHostLdLibs_linux)
123LOCAL_SRC_FILES := $(aaptTests)
124LOCAL_C_INCLUDES := $(LOCAL_PATH)
125LOCAL_STATIC_LIBRARIES := libaapt $(aaptHostStaticLibs)
126LOCAL_STATIC_LIBRARIES_windows := $(aaptHostStaticLibs_windows)
127
128include $(BUILD_HOST_NATIVE_TEST)
129
130
131endif # No TARGET_BUILD_APPS or TARGET_BUILD_PDK
132