blob: a27d526dc611cd4ef60edf7ddbb041e7b1863e51 [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
Elliott Hughes2cae5a22011-08-14 14:27:25 -070056define run-host-tests-with
Elliott Hughesb465ab02011-08-24 11:21:21 -070057 $(foreach file,$(sort $(ART_HOST_TEST_EXECUTABLES)),$(1) $(file) &&) true
Elliott Hughes2cae5a22011-08-14 14:27:25 -070058endef
59
Brian Carlstrom16192862011-09-12 17:50:06 -070060ART_HOST_TEST_DEPENDENCIES := $(ART_HOST_TEST_EXECUTABLES) $(ANDROID_HOST_OUT)/framework/core-hostdex.jar $(ART_TEST_OAT_FILES)
61ART_TARGET_TEST_DEPENDENCIES := $(ART_TARGET_TEST_EXECUTABLES) $(ANDROID_PRODUCT_OUT)/system/framework/core.jar $(ART_TEST_OAT_FILES)
Brian Carlstrom9f30b382011-08-28 22:41:38 -070062
Brian Carlstrombc2f3e32011-09-22 17:16:54 -070063ART_TARGET_TEST_DEPENDENCIES += $(TARGET_OUT_EXECUTABLES)/oat_process $(TARGET_OUT_EXECUTABLES)/oat_processd
64
65########################################################################
66# host test targets
67
Brian Carlstrom934486c2011-07-12 23:42:50 -070068# "mm test-art-host" to build and run all host tests
69.PHONY: test-art-host
Brian Carlstrom9f30b382011-08-28 22:41:38 -070070test-art-host: $(ART_HOST_TEST_DEPENDENCIES)
Elliott Hughes2cae5a22011-08-14 14:27:25 -070071 $(call run-host-tests-with,)
Brian Carlstrom395520e2011-09-25 19:35:00 -070072 @echo test-art-host PASSED
Brian Carlstrom59848da2011-07-23 20:35:19 -070073
Elliott Hughes5511f212011-08-12 18:07:45 -070074# "mm valgrind-art-host" to build and run all host tests under valgrind.
75.PHONY: valgrind-art-host
Brian Carlstrom9f30b382011-08-28 22:41:38 -070076valgrind-art-host: $(ART_HOST_TEST_DEPENDENCIES)
Elliott Hughes2cae5a22011-08-14 14:27:25 -070077 $(call run-host-tests-with,"valgrind")
Brian Carlstrom395520e2011-09-25 19:35:00 -070078 @echo valgrind-art-host PASSED
Elliott Hughes2cae5a22011-08-14 14:27:25 -070079
80# "mm tsan-art-host" to build and run all host tests under tsan.
81.PHONY: tsan-art-host
Brian Carlstrom9f30b382011-08-28 22:41:38 -070082tsan-art-host: $(ART_HOST_TEST_DEPENDENCIES)
Elliott Hughes2cae5a22011-08-14 14:27:25 -070083 $(call run-host-tests-with,"tsan")
Brian Carlstrom395520e2011-09-25 19:35:00 -070084 @echo tsan-art-host PASSED
Elliott Hughes5511f212011-08-12 18:07:45 -070085
Brian Carlstrombc2f3e32011-09-22 17:16:54 -070086########################################################################
87# target test targets
88
89# "mm test-art-target" to build and run all target tests
Brian Carlstrom4a96b602011-07-26 16:40:23 -070090.PHONY: test-art-target
Brian Carlstrom86927212011-09-15 11:31:11 -070091test-art-target: test-art-target-gtest test-art-target-oat
Brian Carlstrom395520e2011-09-25 19:35:00 -070092 @echo test-art-target PASSED
Brian Carlstrom86927212011-09-15 11:31:11 -070093
94.PHONY: test-art-target-sync
95test-art-target-sync: $(ART_TARGET_TEST_DEPENDENCIES)
Brian Carlstrom4a96b602011-07-26 16:40:23 -070096 adb remount
97 adb sync
Brian Carlstrom86927212011-09-15 11:31:11 -070098
99.PHONY: test-art-target-gtest
100test-art-target-gtest: test-art-target-sync
101 adb shell touch /sdcard/test-art-target-gtest
102 adb shell rm /sdcard/test-art-target-gtest
103 adb shell sh -c "$(foreach file,$(sort $(ART_TARGET_TEST_EXECUTABLES)), /system/bin/$(notdir $(file)) &&) touch /sdcard/test-art-target-gtest"
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700104 $(hide) (adb pull /sdcard/test-art-target-gtest /tmp/ && echo test-art-target-gtest PASSED) || echo test-art-target-gtest FAILED
Brian Carlstrom86927212011-09-15 11:31:11 -0700105 $(hide) rm /tmp/test-art-target-gtest
106
107.PHONY: test-art-target-oat
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700108test-art-target-oat: $(ART_TEST_OAT_TARGETS)
Brian Carlstrom395520e2011-09-25 19:35:00 -0700109 @echo test-art-target-oat PASSED
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700110
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700111########################################################################
112# oat_process test targets
113
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700114# $(1): name
115define build-art-framework-oat
116 $(call build-art-oat,$(1),$(TARGET_BOOT_OAT),$(TARGET_BOOT_DEX))
117endef
118
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700119.PHONY: test-art-target-oat-process
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700120test-art-target-oat-process: test-art-target-oat-process-am # test-art-target-oat-process-Calculator
121
122$(eval $(call build-art-framework-oat,$(TARGET_OUT_JAVA_LIBRARIES)/am.jar))
123
124.PHONY: test-art-target-oat-process-am
125test-art-target-oat-process-am: $(TARGET_OUT_JAVA_LIBRARIES)/am.oat test-art-target-sync
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700126 adb remount
127 adb sync
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700128 adb shell sh -c "export CLASSPATH=/system/framework/am.jar && oat_processd /system/bin/app_process -Xbootimage:/system/framework/boot.oat -Ximage:/system/framework/am.oat /system/bin com.android.commands.am.Am start http://android.com && touch /sdcard/test-art-target-process-am"
129 $(hide) (adb pull /sdcard/test-art-target-process-am /tmp/ && echo test-art-target-process-am PASSED) || echo test-art-target-process-am FAILED
130 $(hide) rm /tmp/test-art-target-process-am
131
132$(eval $(call build-art-framework-oat,$(TARGET_OUT_APPS)/Calculator.apk))
133
134.PHONY: test-art-target-oat-process-Calculator
135# Note that using this instead of "adb shell am start" make sure that the /data/art-cache is up-to-date
Brian Carlstrom65ca0772011-09-24 16:03:08 -0700136test-art-target-oat-process-Calculator: $(TARGET_OUT_APPS)/Calculator.oat $(TARGET_OUT_JAVA_LIBRARIES)/am.oat test-art-target-sync
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700137 mkdir -p $(TARGET_OUT_DATA)/art-cache
138 unzip $(TARGET_OUT_APPS)/Calculator.apk classes.dex -d $(TARGET_OUT_DATA)/art-cache
Brian Carlstrom395520e2011-09-25 19:35:00 -0700139 mv $(TARGET_OUT_DATA)/art-cache/classes.dex $(TARGET_OUT_DATA)/art-cache/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 -0700140 adb remount
141 adb sync
Brian Carlstrom395520e2011-09-25 19:35:00 -0700142 if [ "`adb shell getprop wrap.com.android.calculator2 | tr -d '\r'`" = "oat_processd" ]; then \
143 echo wrap.com.android.calculator2 already set; \
144 else \
145 echo Setting wrap.com.android.calculator2 and restarting runtime; \
146 adb shell setprop wrap.com.android.calculator2 "oat_processd"; \
147 adb shell stop; \
148 adb shell start; \
149 sleep 30; \
150 fi
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700151 adb shell sh -c "export CLASSPATH=/system/framework/am.jar && oat_processd /system/bin/app_process -Xbootimage:/system/framework/boot.oat -Ximage:/system/framework/am.oat /system/bin com.android.commands.am.Am start -a android.intent.action.MAIN -n com.android.calculator2/.Calculator && touch /sdcard/test-art-target-process-Calculator"
152 $(hide) (adb pull /sdcard/test-art-target-process-Calculator /tmp/ && echo test-art-target-process-Calculator PASSED) || echo test-art-target-process-Calculator FAILED
153 $(hide) rm /tmp/test-art-target-process-Calculator
154
155########################################################################
156# oatdump targets
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700157
Brian Carlstrom395520e2011-09-25 19:35:00 -0700158.PHONY: dump-oat
Brian Carlstrome10b6972011-09-26 13:49:03 -0700159dump-oat: dump-oat-core dump-oat-boot
Brian Carlstrom395520e2011-09-25 19:35:00 -0700160
Brian Carlstrome10b6972011-09-26 13:49:03 -0700161.PHONY: dump-oat-core
162dump-oat-core: $(TARGET_CORE_OAT) $(OATDUMP)
163 $(OATDUMP) $(addprefix --dex-file=,$(TARGET_CORE_DEX)) --image=$< --strip-prefix=$(PRODUCT_OUT) --output=/tmp/core.oatdump.txt
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700164 @echo Output in /tmp/core.oatdump.txt
165
Brian Carlstrome10b6972011-09-26 13:49:03 -0700166.PHONY: dump-oat-boot
167dump-oat-boot: $(TARGET_BOOT_OAT) $(OATDUMP)
168 $(OATDUMP) $(addprefix --dex-file=,$(TARGET_BOOT_DEX)) --image=$< --strip-prefix=$(PRODUCT_OUT) --output=/tmp/boot.oatdump.txt
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700169 @echo Output in /tmp/boot.oatdump.txt
Brian Carlstrom78128a62011-09-15 17:21:19 -0700170
Brian Carlstrome10b6972011-09-26 13:49:03 -0700171.PHONY: dump-oat-Calculator
172dump-oat-Calculator: $(TARGET_OUT_APPS)/Calculator.oat $(TARGET_BOOT_OAT) $(OATDUMP)
173 $(OATDUMP) --dex-file=$(TARGET_OUT_APPS)/Calculator.apk --image=$< $(addprefix --boot-dex-file=,$(TARGET_BOOT_DEX)) --boot=$(TARGET_BOOT_OAT) --strip-prefix=$(PRODUCT_OUT) --output=/tmp/Calculator.oatdump.txt
174 @echo Output in /tmp/Calculator.oatdump.txt
175
176
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700177########################################################################
178# cpplint target
179
Brian Carlstrom59848da2011-07-23 20:35:19 -0700180# "mm cpplint-art" to style check art source files
181.PHONY: cpplint-art
182cpplint-art:
183 $(LOCAL_PATH)/tools/cpplint.py $(LOCAL_PATH)/src/*.h $(LOCAL_PATH)/src/*.cc
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700184
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700185########################################################################
186
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700187include $(call all-makefiles-under,$(LOCAL_PATH))