1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
# Copyright (C) 2012 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
LOCAL_PATH:= $(call my-dir)
#
# Build jack script
#
include $(CLEAR_VARS)
LOCAL_MODULE := jack
LOCAL_SRC_FILES := etc/jack
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := $(HOST_EXECUTABLE_SUFFIX)
LOCAL_BUILT_MODULE_STEM := jack$(HOST_EXECUTABLE_SUFFIX)
LOCAL_IS_HOST_MODULE := true
include $(BUILD_PREBUILT)
jack_script := $(LOCAL_INSTALLED_MODULE)
#
# Build jack-admin script
#
include $(CLEAR_VARS)
LOCAL_MODULE := jack-admin
LOCAL_SRC_FILES := etc/jack-admin
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := $(HOST_EXECUTABLE_SUFFIX)
LOCAL_BUILT_MODULE_STEM := jack-admin$(HOST_EXECUTABLE_SUFFIX)
LOCAL_IS_HOST_MODULE := true
include $(BUILD_PREBUILT)
jack_admin_script := $(LOCAL_INSTALLED_MODULE)
#
# Build Jack
#
# $(1): library name
# $(2): Non-empty if IS_HOST_MODULE
define java-lib-libs
$(foreach lib,$(1),$(call _java-lib-dir,$(lib),$(2))/$(if $(2),javalib,classes)$(COMMON_JAVA_PACKAGE_SUFFIX))
endef
include $(CLEAR_VARS)
LOCAL_MODULE := jack-no-server
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
proguard_intermediates := \
$(call local-intermediates-dir,COMMON)/grammar/com/android/jack/shrob/proguard
preprocessor_intermediates := \
$(call local-intermediates-dir,COMMON)/grammar/com/android/jack/preprocessor
GEN_PG := $(addprefix $(proguard_intermediates)/, \
ProguardLexer.java \
ProguardParser.java \
)
GEN_PP := $(addprefix $(preprocessor_intermediates)/, \
PreProcessorLexer.java \
PreProcessorParser.java \
PreProcessor_Java.java \
)
ANTLR_JACK_JAR = $(call java-lib-libs,antlr-jack,true)
$(info ANTLR_JACK_JAR = $(ANTLR_JACK_JAR))
$(GEN_PG): $(ANTLR_JACK_JAR)
$(GEN_PG): PRIVATE_PATH := $(LOCAL_PATH)
$(GEN_PG): PRIVATE_CUSTOM_TOOL = java -jar $(ANTLR_JACK_JAR) -fo $(dir $@) $<
$(GEN_PG): $(LOCAL_PATH)/src/com/android/jack/shrob/proguard/Proguard.g
$(transform-generated-source)
$(GEN_PP): $(ANTLR_JACK_JAR)
$(GEN_PP): PRIVATE_PATH := $(LOCAL_PATH)
$(GEN_PP): PRIVATE_CUSTOM_TOOL = java -jar $(ANTLR_JACK_JAR) -fo $(dir $@) $<
$(GEN_PP): $(LOCAL_PATH)/src/com/android/jack/preprocessor/PreProcessor.g
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN_PG) $(GEN_PP)
LOCAL_SRC_FILES := $(filter-out %/ProguardLexer.java %/ProguardParser.java %/PreProcessorLexer.java %/PreProcessorParser.java %/PreProcessor_Java.java, \
$(call all-java-files-under, src))
LOCAL_JAVA_RESOURCE_DIRS := rsc
LOCAL_JAR_MANIFEST := etc/manifest.txt
LOCAL_JAVACFLAGS := -processor com.android.sched.build.SchedAnnotationProcessor
JACK_STATIC_JAVA_LIBRARIES := \
ecj-jack \
guava-jack \
jsr305lib-jack \
dx-jack \
schedlib \
freemarker-jack \
watchmaker-jack \
maths-jack \
args4j-jack \
antlr-runtime-jack \
jack-api
LOCAL_JAVA_LIBRARIES := \
sched-build \
allocation-jack \
$(JACK_STATIC_JAVA_LIBRARIES)
JACK_VERSION_FILE := $(call local-intermediates-dir,COMMON)/generated.version/jack-version.properties
LOCAL_JAVA_RESOURCE_FILES += $(JACK_VERSION_FILE)
LOCAL_ADDITIONAL_DEPENDENCIES += $(JACK_VERSION_FILE)
include $(BUILD_HOST_JAVA_LIBRARY)
$(JACK_VERSION_FILE): $(TOP_DIR)$(LOCAL_PATH)/../version.properties | $(ACP)
$(copy-file-to-target)
$(LOCAL_INSTALLED_MODULE) : $(jack_script) $(jack_admin_script)
INSTALLED_JACK_NOSERVER := $(LOCAL_INSTALLED_MODULE)
JACK_JAR_INTERMEDIATE:=$(LOCAL_BUILT_MODULE).intermediate.jar
$(JACK_JAR_INTERMEDIATE): $(LOCAL_BUILT_MODULE)
java -jar $(call java-lib-libs,sched-build,true) $< $(call java-lib-libs,$(JACK_STATIC_JAVA_LIBRARIES),true) $@
JACK_CORE_STUBS_MINI := $(LOCAL_BUILT_MODULE).core-stub-mini.jack
JACK_CORE_STUBS_MINI_SRC := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/,$(call all-java-files-under, ../core-stubs-mini/src))
JACK_DEFAULT_LIB := $(LOCAL_BUILT_MODULE).defaultlib.jack
JACK_DEFAULT_LIB_SRC :=$(addprefix $(TOP_DIR)$(LOCAL_PATH)/,$(call all-java-files-under, src/com/android/jack/annotations))
$(JACK_CORE_STUBS_MINI) $(JACK_DEFAULT_LIB): PRIVATE_JACK_VM_ARGS := $(DEFAULT_JACK_VM_ARGS)
ifneq ($(ANDROID_JACK_VM_ARGS),)
$(JACK_CORE_STUBS_MINI) $(JACK_DEFAULT_LIB): PRIVATE_JACK_VM_ARGS := $(ANDROID_JACK_VM_ARGS)
endif
$(JACK_CORE_STUBS_MINI) $(JACK_DEFAULT_LIB): PRIVATE_JACK_EXTRA_ARGS := $(DEFAULT_JACK_EXTRA_ARGS)
ifneq ($(ANDROID_JACK_EXTRA_ARGS),)
$(JACK_CORE_STUBS_MINI) $(JACK_DEFAULT_LIB): PRIVATE_JACK_EXTRA_ARGS := $(ANDROID_JACK_EXTRA_ARGS)
endif
$(JACK_CORE_STUBS_MINI) $(JACK_DEFAULT_LIB): PRIVATE_JACK_VM := $(DEFAULT_JACK_VM)
ifneq ($(strip $(ANDROID_JACK_VM)),)
$(JACK_CORE_STUBS_MINI) $(JACK_DEFAULT_LIB): PRIVATE_JACK_VM := $(ANDROID_JACK_VM)
endif
$(JACK_CORE_STUBS_MINI): $(JACK_CORE_STUBS_MINI_SRC) $(JACK_JAR_INTERMEDIATE)
$(PRIVATE_JACK_VM) $(PRIVATE_JACK_VM_ARGS) -cp $(JACK_JAR_INTERMEDIATE) com.android.jack.Main $(PRIVATE_JACK_EXTRA_ARGS) \
-D jack.classpath.default-libraries=false --output-jack $(JACK_CORE_STUBS_MINI) $(JACK_CORE_STUBS_MINI_SRC)
$(JACK_DEFAULT_LIB): $(JACK_DEFAULT_LIB_SRC) $(JACK_CORE_STUBS_MINI) $(JACK_JAR_INTERMEDIATE)
$(PRIVATE_JACK_VM) $(PRIVATE_JACK_VM_ARGS) -cp $(JACK_JAR_INTERMEDIATE) com.android.jack.Main $(PRIVATE_JACK_EXTRA_ARGS) \
--classpath $(JACK_CORE_STUBS_MINI) -D jack.classpath.default-libraries=false --output-jack $(JACK_DEFAULT_LIB) $(JACK_DEFAULT_LIB_SRC)
# overwrite install rule, using LOCAL_POST_INSTALL_CMD may cause the installed jar to be used before the post install command is completed
$(LOCAL_INSTALLED_MODULE): PRIVATE_JAR_MANIFEST := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
$(LOCAL_INSTALLED_MODULE): $(JACK_JAR_INTERMEDIATE) $(JACK_DEFAULT_LIB)
$(hide) rm -rf $<.tmp
$(hide) mkdir -p $<.tmp/jack-default-lib
$(hide) unzip -qd $<.tmp $<
$(hide) unzip -qd $<.tmp/jack-default-lib $(JACK_DEFAULT_LIB)
$(hide) jar -cfm $@ $(PRIVATE_JAR_MANIFEST) -C $<.tmp .
# Merge with sched lib support
$(LOCAL_BUILT_MODULE): $(call java-lib-libs,sched-build,true)
include $(CLEAR_VARS)
LOCAL_MODULE := jack
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_JAVA_LIBRARIES := \
jack-server
LOCAL_ADDITIONAL_DEPENDENCIES := $(jack_admin_script)
include $(BUILD_HOST_JAVA_LIBRARY)
$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
$(hide) $(jack_admin_script) kill-server || echo
$(hide) rm -rf $<.tmp
$(hide) mkdir -p $<.tmp
$(hide) unzip -qd $<.tmp $<
$(hide) unzip -oqd $<.tmp $(INSTALLED_JACK_NOSERVER)
$(hide) jar -cf $@ -C $<.tmp .
# Include this library in the build server's output directory
$(call dist-for-goals, dist_files, $(LOCAL_BUILT_MODULE):jack.jar)
#
# Build jack-annotations.jar
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, src/com/android/jack/annotations)
LOCAL_MODULE := jack-annotations
LOCAL_MODULE_TAGS := optional
include $(BUILD_HOST_JAVA_LIBRARY)
#
# Build Jack tests
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, tests)
LOCAL_MODULE := libjackunittests
LOCAL_MODULE_TAGS := optional
LOCAL_JAVACFLAGS := -processor com.android.sched.build.SchedAnnotationProcessor
TEST_STATIC_JAVA_LIBRARIES := \
jack \
junit4-jack \
dexlib-jack \
dx \
dexcomparator
LOCAL_JAVA_LIBRARIES := \
sched-build \
$(TEST_STATIC_JAVA_LIBRARIES)
LOCAL_REQUIRED_MODULES:= \
core-stubs-mini \
core-libart \
bouncycastle \
ext \
core-junit \
framework \
telephony-common \
android.policy \
hamcrest-core-jack
include $(BUILD_HOST_JAVA_LIBRARY)
# overwrite install rule, using LOCAL_POST_INSTALL_CMD may cause the installed jar to be used before the post install command is completed
$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) $(call java-lib-libs,sched-build,true)
java -jar $(call java-lib-libs,sched-build,true) $< $(JACK_JAR) $(call java-lib-libs,$(TEST_STATIC_JAVA_LIBRARIES),true) $@
#
# Test targets
#
LIB_JACK_UNIT_TESTS := $(LOCAL_INSTALLED_MODULE)
local_unit_libs := $(call java-lib-files,core-libart-hostdex junit4-hostdex-jack,true)
.PHONY: test-jack-unit
test-jack-unit: PRIVATE_RUN_TESTS := ./run-jack-unit-tests
test-jack-unit: PRIVATE_PATH := $(LOCAL_PATH)
test-jack-unit: $(LIB_JACK_UNIT_TESTS) $(LOCAL_PATH)/run-jack-unit-tests $(local_unit_libs) $(JACK_JAR)
$(hide) cd $(PRIVATE_PATH) && $(PRIVATE_RUN_TESTS) com.android.jack.PreSubmitUnitTests
local_long_libs := $(call java-lib-files,core-libart bouncycastle core-junit ext framework guava services \
libarity prebuilt-google-play-services-first-party telephony-common,)
.PHONY: test-jack-long
test-jack-long: PRIVATE_RUN_TESTS := ./run-jack-unit-tests
test-jack-long: PRIVATE_PATH := $(LOCAL_PATH)
test-jack-long: $(LIB_JACK_UNIT_TESTS) $(LOCAL_PATH)/run-jack-unit-tests $(local_long_libs) $(JACK_JAR)
$(hide) cd $(PRIVATE_PATH) && $(PRIVATE_RUN_TESTS) com.android.jack.LongLastingUnitTests && echo "$@: PASSED"
.PHONY: test-jack-unit-all
test-jack-unit-all: PRIVATE_RUN_TESTS := ./run-jack-unit-tests
test-jack-unit-all: PRIVATE_PATH := $(LOCAL_PATH)
test-jack-unit-all: $(LIB_JACK_UNIT_TESTS) $(LOCAL_PATH)/run-jack-unit-tests $(local_unit_libs) $(local_long_libs) $(JACK_JAR)
$(hide) cd $(PRIVATE_PATH) && $(PRIVATE_RUN_TESTS) com.android.jack.AllUnitTests
.PHONY: clean-jack-files
clean-jack-files: clean-dex-files
$(hide) find $(OUT_DIR) -name "*.jack" | xargs rm -f
$(hide) find $(OUT_DIR) -type d -name "jack" | xargs rm -rf
@echo "All jack files have been removed."
.PHONY: clean-dex-files
clean-dex-files:
$(hide) find $(OUT_DIR) -name "*.dex" | xargs rm -f
$(hide) for i in `find $(OUT_DIR) -name "*.jar" -o -name "*.apk"` ; do ((unzip -l $$i 2> /dev/null | \
grep -q "\.dex$$" && rm -f $$i) || continue ) ; done
@echo "All dex files and archives containing dex files have been removed."
|