blob: c556081d09a508de7ad142c8a674b145dd16584d [file] [log] [blame]
Carl Shapiro7b216702011-06-17 15:09:26 -07001#
2# Copyright (C) 2011 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
17LOCAL_PATH := $(call my-dir)
Carl Shapiro7b216702011-06-17 15:09:26 -070018
Brian Carlstrom4b620ff2011-09-11 01:11:01 -070019# These can be overridden via the environment or by editing to
20# enable/disable certain build configuration.
21ART_BUILD_TARGET_NDEBUG ?= true
22ART_BUILD_TARGET_DEBUG ?= true
Brian Carlstrom56778d82011-09-11 14:08:17 -070023ifeq ($(HOST_OS),linux)
24 ART_BUILD_HOST_NDEBUG ?= true
25 ART_BUILD_HOST_DEBUG ?= true
26else
27 ART_BUILD_HOST_NDEBUG ?= false
28 ART_BUILD_HOST_DEBUG ?= false
29endif
Brian Carlstrom4b620ff2011-09-11 01:11:01 -070030
Carl Shapiro0e6d1972011-07-06 19:17:39 -070031build_path := $(LOCAL_PATH)/build
Brian Carlstromcdc8de42011-07-19 14:23:17 -070032include $(build_path)/Android.common.mk
33
Carl Shapiro0e6d1972011-07-06 19:17:39 -070034include $(build_path)/Android.libart.mk
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070035include $(build_path)/Android.executable.mk
Carl Shapiro7b216702011-06-17 15:09:26 -070036
Brian Carlstrom16192862011-09-12 17:50:06 -070037include $(build_path)/Android.oat.mk
38
Brian Carlstrom07d579f2011-07-27 13:31:51 -070039include $(build_path)/Android.libarttest.mk
Brian Carlstrombbf1e412011-09-18 14:14:51 -070040include $(build_path)/Android.gtest.mk
41include $(build_path)/Android.oattest.mk
Brian Carlstrom934486c2011-07-12 23:42:50 -070042
43# "m build-art" for quick minimal build
44.PHONY: build-art
45build-art: \
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070046 $(ART_TARGET_EXECUTABLES) \
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -070047 $(ART_TARGET_TEST_EXECUTABLES) \
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070048 $(ART_HOST_EXECUTABLES) \
Carl Shapiro47940d62011-08-13 22:21:30 -070049 $(ART_HOST_TEST_EXECUTABLES)
Brian Carlstrom934486c2011-07-12 23:42:50 -070050
Brian Carlstrom4a96b602011-07-26 16:40:23 -070051# "mm test-art" to build and run all tests on host and device
52.PHONY: test-art
53test-art: test-art-host test-art-target
Brian Carlstrom395520e2011-09-25 19:35:00 -070054 @echo test-art PASSED
Brian Carlstrom4a96b602011-07-26 16:40:23 -070055
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070056.PHONY: test-art-gtest
57test-art-gtest: test-art-host test-art-target-gtest
58 @echo test-art-gtest PASSED
59
Elliott Hughes2cae5a22011-08-14 14:27:25 -070060define run-host-tests-with
Elliott Hughesb465ab02011-08-24 11:21:21 -070061 $(foreach file,$(sort $(ART_HOST_TEST_EXECUTABLES)),$(1) $(file) &&) true
Elliott Hughes2cae5a22011-08-14 14:27:25 -070062endef
63
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070064ART_HOST_DEPENDENCIES := $(ART_HOST_EXECUTABLES) $(HOST_OUT_JAVA_LIBRARIES)/core-hostdex.jar
65ART_TARGET_DEPENDENCIES := $(ART_TARGET_EXECUTABLES) $(TARGET_OUT_JAVA_LIBRARIES)/core.jar
Brian Carlstrom0796af02011-10-12 14:31:45 -070066
67ART_HOST_TEST_DEPENDENCIES := $(ART_HOST_DEPENDENCIES) $(ART_TEST_OAT_FILES)
68ART_TARGET_TEST_DEPENDENCIES := $(ART_TARGET_DEPENDENCIES) $(ART_TEST_OAT_FILES)
Brian Carlstrom9f30b382011-08-28 22:41:38 -070069
Brian Carlstrombc2f3e32011-09-22 17:16:54 -070070ART_TARGET_TEST_DEPENDENCIES += $(TARGET_OUT_EXECUTABLES)/oat_process $(TARGET_OUT_EXECUTABLES)/oat_processd
71
72########################################################################
73# host test targets
74
Brian Carlstrom934486c2011-07-12 23:42:50 -070075# "mm test-art-host" to build and run all host tests
76.PHONY: test-art-host
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070077test-art-host: $(ART_HOST_TEST_DEPENDENCIES) $(ART_HOST_TEST_TARGETS)
Brian Carlstrom395520e2011-09-25 19:35:00 -070078 @echo test-art-host PASSED
Brian Carlstrom59848da2011-07-23 20:35:19 -070079
Elliott Hughes5511f212011-08-12 18:07:45 -070080# "mm valgrind-art-host" to build and run all host tests under valgrind.
81.PHONY: valgrind-art-host
Brian Carlstrom9f30b382011-08-28 22:41:38 -070082valgrind-art-host: $(ART_HOST_TEST_DEPENDENCIES)
Elliott Hughes2cae5a22011-08-14 14:27:25 -070083 $(call run-host-tests-with,"valgrind")
Brian Carlstrom395520e2011-09-25 19:35:00 -070084 @echo valgrind-art-host PASSED
Elliott Hughes2cae5a22011-08-14 14:27:25 -070085
86# "mm tsan-art-host" to build and run all host tests under tsan.
87.PHONY: tsan-art-host
Brian Carlstrom9f30b382011-08-28 22:41:38 -070088tsan-art-host: $(ART_HOST_TEST_DEPENDENCIES)
Elliott Hughes2cae5a22011-08-14 14:27:25 -070089 $(call run-host-tests-with,"tsan")
Brian Carlstrom395520e2011-09-25 19:35:00 -070090 @echo tsan-art-host PASSED
Elliott Hughes5511f212011-08-12 18:07:45 -070091
Brian Carlstrombc2f3e32011-09-22 17:16:54 -070092########################################################################
93# target test targets
94
95# "mm test-art-target" to build and run all target tests
Brian Carlstrom4a96b602011-07-26 16:40:23 -070096.PHONY: test-art-target
Brian Carlstrome24fa612011-09-29 00:53:55 -070097test-art-target: test-art-target-gtest test-art-target-oat test-art-target-run-test
Brian Carlstrom395520e2011-09-25 19:35:00 -070098 @echo test-art-target PASSED
Brian Carlstrom86927212011-09-15 11:31:11 -070099
100.PHONY: test-art-target-sync
101test-art-target-sync: $(ART_TARGET_TEST_DEPENDENCIES)
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700102 adb remount
103 adb sync
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700104 adb shell mkdir -p $(ART_TEST_DIR)
Brian Carlstrom86927212011-09-15 11:31:11 -0700105
106.PHONY: test-art-target-gtest
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700107test-art-target-gtest: $(ART_TARGET_TEST_TARGETS)
Brian Carlstrom86927212011-09-15 11:31:11 -0700108
109.PHONY: test-art-target-oat
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700110test-art-target-oat: $(ART_TEST_OAT_TARGETS)
Brian Carlstrom395520e2011-09-25 19:35:00 -0700111 @echo test-art-target-oat PASSED
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700112
Brian Carlstrome24fa612011-09-29 00:53:55 -0700113.PHONY: test-art-target-run-test
114test-art-target-run-test: test-art-target-run-test-002
115 @echo test-art-target-run-test PASSED
116
117.PHONY: test-art-target-run-test-002
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700118test-art-target-run-test-002: test-art-target-sync
Brian Carlstrome24fa612011-09-29 00:53:55 -0700119 art/test/run-test 002
120 @echo test-art-target-run-test-002 PASSED
121
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700122########################################################################
123# oat_process test targets
124
Brian Carlstroma9f19782011-10-13 00:14:47 -0700125# $(1): jar or apk name
126define art-cache-oat
127 $(ART_CACHE_OUT)/$(subst /,@,$(patsubst %.apk,%.oat,$(patsubst %.jar,%.oat,$(1))))
128endef
129
130ART_CACHE_OATS :=
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700131# $(1): name
Brian Carlstroma9f19782011-10-13 00:14:47 -0700132define build-art-cache-oat
133 $(call build-art-oat,$(PRODUCT_OUT)/$(1),$(call art-cache-oat,$(1)),$(TARGET_BOOT_IMG))
134 ART_CACHE_OATS += $(call art-cache-oat,$(1))
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700135endef
136
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700137.PHONY: test-art-target-oat-process
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700138test-art-target-oat-process: test-art-target-oat-process-am # test-art-target-oat-process-Calculator
139
Brian Carlstroma9f19782011-10-13 00:14:47 -0700140$(eval $(call build-art-cache-oat,system/framework/am.jar))
141$(eval $(call build-art-cache-oat,system/app/Calculator.apk))
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700142
143.PHONY: test-art-target-oat-process-am
Brian Carlstroma9f19782011-10-13 00:14:47 -0700144test-art-target-oat-process-am: $(call art-cache-oat,system/framework/am.jar) test-art-target-sync
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700145 adb remount
146 adb sync
Brian Carlstrom5de8fe52011-10-16 14:10:09 -0700147 adb shell sh -c "export CLASSPATH=/system/framework/am.jar && oat_processd /system/bin/app_process /system/bin com.android.commands.am.Am start http://android.com && touch $(ART_TEST_DIR)/test-art-target-process-am"
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700148 $(hide) (adb pull $(ART_TEST_DIR)/test-art-target-process-am /tmp/ && echo test-art-target-process-am PASSED) || echo test-art-target-process-am FAILED
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700149 $(hide) rm /tmp/test-art-target-process-am
150
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700151.PHONY: test-art-target-oat-process-Calculator
152# Note that using this instead of "adb shell am start" make sure that the /data/art-cache is up-to-date
Brian Carlstroma9f19782011-10-13 00:14:47 -0700153test-art-target-oat-process-Calculator: $(call art-cache-oat,system/app/Calculator.oat) $(call art-cache-oat,system/framework/am.jar) test-art-target-sync
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700154 mkdir -p $(ART_CACHE_OUT)
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700155 unzip $(TARGET_OUT_APPS)/Calculator.apk classes.dex -d $(TARGET_OUT_DATA)/art-cache
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700156 mv $(TARGET_OUT_DATA)/art-cache/classes.dex $(ART_CACHE_OUT)/system@app@Calculator.apk@classes.dex.`unzip -lv $(TARGET_OUT_APPS)/Calculator.apk classes.dex | grep classes.dex | sed -E 's/.* ([0-9a-f]+) classes.dex/\1/'` # note this is extracting the crc32 that is needed as the file extension
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700157 adb remount
158 adb sync
Brian Carlstrom395520e2011-09-25 19:35:00 -0700159 if [ "`adb shell getprop wrap.com.android.calculator2 | tr -d '\r'`" = "oat_processd" ]; then \
160 echo wrap.com.android.calculator2 already set; \
Elliott Hughes6ba581a2011-10-25 11:45:35 -0700161 adb shell start; \
Brian Carlstrom395520e2011-09-25 19:35:00 -0700162 else \
163 echo Setting wrap.com.android.calculator2 and restarting runtime; \
164 adb shell setprop wrap.com.android.calculator2 "oat_processd"; \
165 adb shell stop; \
166 adb shell start; \
167 sleep 30; \
168 fi
Brian Carlstromdddab0c2011-09-27 13:35:23 -0700169 adb shell kill `adb shell ps | fgrep com.android.calculator2 | sed -e 's/[^ ]* *\([0-9]*\).*/\1/'`
Brian Carlstrom5de8fe52011-10-16 14:10:09 -0700170 adb shell sh -c "export CLASSPATH=/system/framework/am.jar && oat_processd /system/bin/app_process /system/bin com.android.commands.am.Am start -a android.intent.action.MAIN -n com.android.calculator2/.Calculator && touch $(ART_TEST_DIR)/test-art-target-process-Calculator"
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700171 $(hide) (adb pull $(ART_TEST_DIR)/test-art-target-process-Calculator /tmp/ && echo test-art-target-process-Calculator PASSED) || echo test-art-target-process-Calculator FAILED
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700172 $(hide) rm /tmp/test-art-target-process-Calculator
173
174########################################################################
Brian Carlstrom76aa0c02011-10-11 15:29:43 -0700175# zygote targets
176#
Brian Carlstrom0796af02011-10-12 14:31:45 -0700177# zygote-artd will change to use art to boot the device with a debug build
178# zygote-art will change to use art to boot the device with a production build
179# zygote-dalvik will restore to booting with dalvik
180#
181# zygote-artd-target-sync will just push a new artd in place of dvm
182# zygote-art-target-sync will just push a new art in place of dvm
Brian Carlstrom76aa0c02011-10-11 15:29:43 -0700183
Brian Carlstromfab62932011-10-27 21:47:49 -0700184# $(1): "d" for debug build, "" for ndebug build
185define define-zygote-art-targets
186.PHONY: zygote-art$(1)-target-sync
187zygote-art$(1)-target-sync: $(ART_TARGET_DEPENDENCIES) $(TARGET_BOOT_OAT) $(ART_CACHE_OATS)
188 cp $(TARGET_OUT_SHARED_LIBRARIES)/libart$(1).so $(TARGET_OUT_SHARED_LIBRARIES)/libdvm.so
189 cp $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/libart$(1).so $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/libdvm.so
190 cp $(TARGET_OUT_EXECUTABLES)/oatopt$(1) $(TARGET_OUT_EXECUTABLES)/dexopt
191 cp $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)/oatopt$(1) $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)/dexopt
Brian Carlstrom31edec52011-10-16 17:10:24 -0700192 mkdir -p $(TARGET_OUT_DATA)/property
193 echo -n 1 > $(TARGET_OUT_DATA)/property/persist.sys.strictmode.disabled
Brian Carlstrom0796af02011-10-12 14:31:45 -0700194 adb remount
195 adb sync
196
Brian Carlstromfab62932011-10-27 21:47:49 -0700197.PHONY: zygote-art$(1)
198zygote-art$(1): zygote-art$(1)-target-sync
Brian Carlstromb7bbba42011-10-13 14:58:47 -0700199 sed -e 's/--start-system-server/--start-system-server --no-preload/' -e 's/art-cache 0771/art-cache 0777/' < system/core/rootdir/init.rc > $(ANDROID_PRODUCT_OUT)/root/init.rc
200 adb shell rm -f $(ART_CACHE_DIR)
Brian Carlstrom76aa0c02011-10-11 15:29:43 -0700201 rm -f $(ANDROID_PRODUCT_OUT)/boot.img
202 unset ONE_SHOT_MAKEFILE && $(MAKE) showcommands bootimage
203 adb reboot bootloader
204 fastboot flash boot $(ANDROID_PRODUCT_OUT)/boot.img
205 fastboot reboot
Brian Carlstromfab62932011-10-27 21:47:49 -0700206endef
207
208$(eval $(call define-zygote-art-targets,d))
209$(eval $(call define-zygote-art-targets,))
Brian Carlstrom76aa0c02011-10-11 15:29:43 -0700210
Brian Carlstrom0796af02011-10-12 14:31:45 -0700211.PHONY: zygote-dalvik
212zygote-dalvik:
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700213 cp $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libdvm.so $(TARGET_OUT_SHARED_LIBRARIES)/libdvm.so
214 cp $(call intermediates-dir-for,SHARED_LIBRARIES,libdvm)/LINKED/libdvm.so $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/libdvm.so
Brian Carlstromb7bbba42011-10-13 14:58:47 -0700215 cp $(call intermediates-dir-for,EXECUTABLES,dexopt)/dexopt $(TARGET_OUT_EXECUTABLES)/dexopt
216 cp $(call intermediates-dir-for,EXECUTABLES,dexopt)/LINKED/dexopt $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)/dexopt
Brian Carlstrom24a3c2e2011-10-17 18:07:52 -0700217 rm -f $(TARGET_OUT_DATA)/property/persist.sys.strictmode.disabled
Brian Carlstrom31edec52011-10-16 17:10:24 -0700218 adb shell rm /data/property/persist.sys.strictmode.disabled
Brian Carlstrom0796af02011-10-12 14:31:45 -0700219 adb remount
220 adb sync
Brian Carlstrom648e5e92011-10-11 22:49:18 -0700221 cp system/core/rootdir/init.rc $(ANDROID_PRODUCT_OUT)/root/init.rc
Brian Carlstrom76aa0c02011-10-11 15:29:43 -0700222 rm -f $(ANDROID_PRODUCT_OUT)/boot.img
223 unset ONE_SHOT_MAKEFILE && $(MAKE) showcommands bootimage
224 adb reboot bootloader
225 fastboot flash boot $(ANDROID_PRODUCT_OUT)/boot.img
226 fastboot reboot
227
228########################################################################
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700229# oatdump targets
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700230
Brian Carlstrom395520e2011-09-25 19:35:00 -0700231.PHONY: dump-oat
Brian Carlstrom03a20ba2011-10-13 10:24:13 -0700232dump-oat: dump-oat-core dump-oat-boot dump-oat-Calculator
Brian Carlstrom395520e2011-09-25 19:35:00 -0700233
Brian Carlstrome10b6972011-09-26 13:49:03 -0700234.PHONY: dump-oat-core
235dump-oat-core: $(TARGET_CORE_OAT) $(OATDUMP)
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700236 $(OATDUMP) --image=$(TARGET_CORE_IMG) --host-prefix=$(PRODUCT_OUT) --output=/tmp/core.oatdump.txt
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700237 @echo Output in /tmp/core.oatdump.txt
238
Brian Carlstrome10b6972011-09-26 13:49:03 -0700239.PHONY: dump-oat-boot
240dump-oat-boot: $(TARGET_BOOT_OAT) $(OATDUMP)
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700241 $(OATDUMP) --image=$(TARGET_BOOT_IMG) --host-prefix=$(PRODUCT_OUT) --output=/tmp/boot.oatdump.txt
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700242 @echo Output in /tmp/boot.oatdump.txt
Brian Carlstrom78128a62011-09-15 17:21:19 -0700243
Brian Carlstrome10b6972011-09-26 13:49:03 -0700244.PHONY: dump-oat-Calculator
Brian Carlstrom03a20ba2011-10-13 10:24:13 -0700245dump-oat-Calculator: $(call art-cache-oat,system/app/Calculator.oat) $(TARGET_BOOT_OAT) $(OATDUMP)
246 $(OATDUMP) --oat=$< --boot-image=$(TARGET_BOOT_IMG) --host-prefix=$(PRODUCT_OUT) --output=/tmp/Calculator.oatdump.txt
Brian Carlstrome10b6972011-09-26 13:49:03 -0700247 @echo Output in /tmp/Calculator.oatdump.txt
248
249
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700250########################################################################
Brian Carlstromfab62932011-10-27 21:47:49 -0700251# clean-oat target
252#
253
254.PHONY: clean-oat
255clean-oat:
256 rm -f $(ART_TEST_OUT)/*.oat
257 rm -f $(ART_CACHE_OUT)/*.oat
258 adb shell rm $(ART_TEST_DIR)/*.oat
259 adb shell rm $(ART_CACHE_DIR)/*.oat
260
261########################################################################
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700262# cpplint target
263
Brian Carlstrom59848da2011-07-23 20:35:19 -0700264# "mm cpplint-art" to style check art source files
265.PHONY: cpplint-art
266cpplint-art:
Elliott Hughesa51a3dd2011-10-17 15:19:26 -0700267 ./art/tools/cpplint.py \
268 --filter=-whitespace/comments,-whitespace/line_length,-build/include,-build/header_guard,-readability/streams,-readability/todo,-runtime/references \
Elliott Hughes362f9bc2011-10-17 18:56:41 -0700269 $(ANDROID_BUILD_TOP)/art/src/*.h $(ANDROID_BUILD_TOP)/art/src/*.cc
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700270
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700271########################################################################
272
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700273include $(call all-makefiles-under,$(LOCAL_PATH))