1 # 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 17 LOCAL_PATH := $(call my-dir) 18 19 art_path := $(LOCAL_PATH) 20 art_build_path := $(art_path)/build 21 22 ######################################################################## 23 # clean-oat targets 24 # 25 26 # following the example of build's dont_bother for clean targets 27 ifneq (,$(filter clean-oat,$(MAKECMDGOALS))) 28 art_dont_bother := true 29 endif 30 ifneq (,$(filter clean-oat-host,$(MAKECMDGOALS))) 31 art_dont_bother := true 32 endif 33 ifneq (,$(filter clean-oat-target,$(MAKECMDGOALS))) 34 art_dont_bother := true 35 endif 36 37 .PHONY: clean-oat 38 clean-oat: clean-oat-host clean-oat-target 39 40 .PHONY: clean-oat-host 41 clean-oat-host: 42 rm -f $(ART_NATIVETEST_OUT)/*.odex 43 rm -f $(ART_NATIVETEST_OUT)/*.oat 44 rm -f $(ART_NATIVETEST_OUT)/*.art 45 rm -f $(ART_TEST_OUT)/*.odex 46 rm -f $(ART_TEST_OUT)/*.oat 47 rm -f $(ART_TEST_OUT)/*.art 48 rm -f $(DALVIK_CACHE_OUT)/*@classes.dex 49 rm -f $(DALVIK_CACHE_OUT)/*.oat 50 rm -f $(DALVIK_CACHE_OUT)/*.art 51 rm -f $(HOST_OUT_JAVA_LIBRARIES)/*.odex 52 rm -f $(HOST_OUT_JAVA_LIBRARIES)/*.oat 53 rm -f $(HOST_OUT_JAVA_LIBRARIES)/*.art 54 rm -f $(TARGET_OUT_JAVA_LIBRARIES)/*.odex 55 rm -f $(TARGET_OUT_JAVA_LIBRARIES)/*.oat 56 rm -f $(TARGET_OUT_JAVA_LIBRARIES)/*.art 57 rm -f $(TARGET_OUT_UNSTRIPPED)/system/framework/*.odex 58 rm -f $(TARGET_OUT_UNSTRIPPED)/system/framework/*.oat 59 rm -f $(TARGET_OUT_APPS)/*.odex 60 rm -f $(TARGET_OUT_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/javalib.odex 61 rm -f $(TARGET_OUT_INTERMEDIATES)/APPS/*_intermediates/*.odex 62 rm -rf /tmp/test-*/dalvik-cache/*@classes.dex 63 64 .PHONY: clean-oat-target 65 clean-oat-target: 66 adb remount 67 adb shell rm $(ART_NATIVETEST_DIR)/*.odex 68 adb shell rm $(ART_NATIVETEST_DIR)/*.oat 69 adb shell rm $(ART_NATIVETEST_DIR)/*.art 70 adb shell rm $(ART_TEST_DIR)/*.odex 71 adb shell rm $(ART_TEST_DIR)/*.oat 72 adb shell rm $(ART_TEST_DIR)/*.art 73 adb shell rm $(DALVIK_CACHE_DIR)/*.dex 74 adb shell rm $(DALVIK_CACHE_DIR)/*.oat 75 adb shell rm $(DALVIK_CACHE_DIR)/*.art 76 adb shell rm $(DEXPREOPT_BOOT_JAR_DIR)/*.oat 77 adb shell rm $(DEXPREOPT_BOOT_JAR_DIR)/*.art 78 adb shell rm system/app/*.odex 79 adb shell rm data/run-test/test-*/dalvik-cache/*@classes.dex 80 81 ifneq ($(art_dont_bother),true) 82 83 ######################################################################## 84 # product targets 85 include $(art_path)/runtime/Android.mk 86 include $(art_path)/compiler/Android.mk 87 include $(art_path)/dex2oat/Android.mk 88 include $(art_path)/oatdump/Android.mk 89 include $(art_path)/dalvikvm/Android.mk 90 include $(art_path)/jdwpspy/Android.mk 91 include $(art_build_path)/Android.oat.mk 92 93 # ART_HOST_DEPENDENCIES depends on Android.executable.mk above for ART_HOST_EXECUTABLES 94 ART_HOST_DEPENDENCIES := $(ART_HOST_EXECUTABLES) $(HOST_OUT_JAVA_LIBRARIES)/core-hostdex.jar 95 ART_HOST_DEPENDENCIES += $(HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION) 96 ART_TARGET_DEPENDENCIES := $(ART_TARGET_EXECUTABLES) $(TARGET_OUT_JAVA_LIBRARIES)/core.jar $(TARGET_OUT_SHARED_LIBRARIES)/libjavacore.so 97 98 ######################################################################## 99 # test targets 100 101 include $(art_path)/test/Android.mk 102 include $(art_build_path)/Android.gtest.mk 103 104 # The ART_*_TEST_DEPENDENCIES definitions: 105 # - depend on Android.oattest.mk above for ART_TEST_*_DEX_FILES 106 # - depend on Android.gtest.mk above for ART_*_TEST_EXECUTABLES 107 ART_HOST_TEST_DEPENDENCIES := $(ART_HOST_DEPENDENCIES) $(ART_HOST_TEST_EXECUTABLES) $(ART_TEST_HOST_DEX_FILES) $(HOST_CORE_IMG_OUT) 108 ART_TARGET_TEST_DEPENDENCIES := $(ART_TARGET_DEPENDENCIES) $(ART_TARGET_TEST_EXECUTABLES) $(ART_TEST_TARGET_DEX_FILES) $(TARGET_CORE_IMG_OUT) 109 110 include $(art_build_path)/Android.libarttest.mk 111 112 # "mm test-art" to build and run all tests on host and device 113 .PHONY: test-art 114 test-art: test-art-host test-art-target 115 @echo test-art PASSED 116 117 .PHONY: test-art-gtest 118 test-art-gtest: test-art-host-gtest test-art-target-gtest 119 @echo test-art-gtest PASSED 120 121 .PHONY: test-art-oat 122 test-art-oat: test-art-host-oat test-art-target-oat 123 @echo test-art-oat PASSED 124 125 .PHONY: test-art-run-test 126 test-art-run-test: test-art-host-run-test test-art-target-run-test 127 @echo test-art-run-test PASSED 128 129 ######################################################################## 130 # host test targets 131 132 # "mm test-art-host" to build and run all host tests 133 .PHONY: test-art-host 134 test-art-host: test-art-host-gtest test-art-host-oat test-art-host-run-test 135 @echo test-art-host PASSED 136 137 .PHONY: test-art-host-interpreter 138 test-art-host-interpreter: test-art-host-oat-interpreter test-art-host-run-test-interpreter 139 @echo test-art-host-interpreter PASSED 140 141 .PHONY: test-art-host-dependencies 142 test-art-host-dependencies: $(ART_HOST_TEST_DEPENDENCIES) $(HOST_OUT_SHARED_LIBRARIES)/libarttest$(ART_HOST_SHLIB_EXTENSION) $(HOST_CORE_DEX_LOCATIONS) 143 144 .PHONY: test-art-host-gtest 145 test-art-host-gtest: $(ART_HOST_TEST_TARGETS) 146 @echo test-art-host-gtest PASSED 147 148 define run-host-gtests-with 149 $(foreach file,$(sort $(ART_HOST_TEST_EXECUTABLES)),$(1) $(file) &&) true 150 endef 151 152 # "mm valgrind-test-art-host-gtest" to build and run the host gtests under valgrind. 153 .PHONY: valgrind-test-art-host-gtest 154 valgrind-test-art-host-gtest: test-art-host-dependencies 155 $(call run-host-gtests-with,valgrind --leak-check=full) 156 @echo valgrind-test-art-host-gtest PASSED 157 158 .PHONY: test-art-host-oat-default 159 test-art-host-oat-default: $(ART_TEST_HOST_OAT_DEFAULT_TARGETS) 160 @echo test-art-host-oat-default PASSED 161 162 .PHONY: test-art-host-oat-interpreter 163 test-art-host-oat-interpreter: $(ART_TEST_HOST_OAT_INTERPRETER_TARGETS) 164 @echo test-art-host-oat-interpreter PASSED 165 166 .PHONY: test-art-host-oat 167 test-art-host-oat: test-art-host-oat-default test-art-host-oat-interpreter 168 @echo test-art-host-oat PASSED 169 170 define declare-test-art-host-run-test 171 .PHONY: test-art-host-run-test-default-$(1) 172 test-art-host-run-test-default-$(1): test-art-host-dependencies 173 art/test/run-test --host $(1) 174 @echo test-art-host-run-test-default-$(1) PASSED 175 176 TEST_ART_HOST_RUN_TEST_DEFAULT_TARGETS += test-art-host-run-test-default-$(1) 177 178 .PHONY: test-art-host-run-test-interpreter-$(1) 179 test-art-host-run-test-interpreter-$(1): test-art-host-dependencies 180 art/test/run-test --host --interpreter $(1) 181 @echo test-art-host-run-test-interpreter-$(1) PASSED 182 183 TEST_ART_HOST_RUN_TEST_INTERPRETER_TARGETS += test-art-host-run-test-interpreter-$(1) 184 185 .PHONY: test-art-host-run-test-$(1) 186 test-art-host-run-test-$(1): test-art-host-run-test-default-$(1) test-art-host-run-test-interpreter-$(1) 187 188 endef 189 190 $(foreach test, $(wildcard art/test/[0-9]*), $(eval $(call declare-test-art-host-run-test,$(notdir $(test))))) 191 192 .PHONY: test-art-host-run-test-default 193 test-art-host-run-test-default: $(TEST_ART_HOST_RUN_TEST_DEFAULT_TARGETS) 194 @echo test-art-host-run-test-default PASSED 195 196 .PHONY: test-art-host-run-test-interpreter 197 test-art-host-run-test-interpreter: $(TEST_ART_HOST_RUN_TEST_INTERPRETER_TARGETS) 198 @echo test-art-host-run-test-interpreter PASSED 199 200 .PHONY: test-art-host-run-test 201 test-art-host-run-test: test-art-host-run-test-default test-art-host-run-test-interpreter 202 @echo test-art-host-run-test PASSED 203 204 ######################################################################## 205 # target test targets 206 207 # "mm test-art-target" to build and run all target tests 208 .PHONY: test-art-target 209 test-art-target: test-art-target-gtest test-art-target-oat test-art-target-run-test 210 @echo test-art-target PASSED 211 212 .PHONY: test-art-target-dependencies 213 test-art-target-dependencies: $(ART_TARGET_TEST_DEPENDENCIES) $(ART_TEST_OUT)/libarttest.so 214 215 .PHONY: test-art-target-sync 216 test-art-target-sync: test-art-target-dependencies 217 adb remount 218 adb sync 219 adb shell mkdir -p $(ART_TEST_DIR) 220 221 .PHONY: test-art-target-gtest 222 test-art-target-gtest: $(ART_TARGET_TEST_TARGETS) 223 224 .PHONY: test-art-target-oat 225 test-art-target-oat: $(ART_TEST_TARGET_OAT_TARGETS) 226 @echo test-art-target-oat PASSED 227 228 define declare-test-art-target-run-test 229 .PHONY: test-art-target-run-test-$(1) 230 test-art-target-run-test-$(1): test-art-target-sync 231 art/test/run-test $(1) 232 @echo test-art-target-run-test-$(1) PASSED 233 234 TEST_ART_TARGET_RUN_TEST_TARGETS += test-art-target-run-test-$(1) 235 236 test-art-run-test-$(1): test-art-host-run-test-$(1) test-art-target-run-test-$(1) 237 238 endef 239 240 $(foreach test, $(wildcard art/test/[0-9]*), $(eval $(call declare-test-art-target-run-test,$(notdir $(test))))) 241 242 .PHONY: test-art-target-run-test 243 test-art-target-run-test: $(TEST_ART_TARGET_RUN_TEST_TARGETS) 244 @echo test-art-target-run-test PASSED 245 246 ######################################################################## 247 # oat-target and oat-target-sync targets 248 249 OAT_TARGET_TARGETS := 250 251 # $(1): input jar or apk target location 252 define declare-oat-target-target 253 ifneq (,$(filter $(1),$(addprefix system/app/,$(addsuffix .apk,$(PRODUCT_DEX_PREOPT_PACKAGES_IN_DATA))))) 254 OUT_OAT_FILE := $(call dalvik-cache-out,$(1)/classes.dex) 255 else 256 OUT_OAT_FILE := $(PRODUCT_OUT)/$(basename $(1)).odex 257 endif 258 259 ifeq ($(ONE_SHOT_MAKEFILE),) 260 # ONE_SHOT_MAKEFILE is empty for a top level build and we don't want 261 # to define the oat-target-* rules there because they will conflict 262 # with the build/core/dex_preopt.mk defined rules. 263 .PHONY: oat-target-$(1) 264 oat-target-$(1): 265 266 else 267 .PHONY: oat-target-$(1) 268 oat-target-$(1): $$(OUT_OAT_FILE) 269 270 $$(OUT_OAT_FILE): $(PRODUCT_OUT)/$(1) $(TARGET_BOOT_IMG_OUT) $(DEX2OAT_DEPENDENCY) 271 @mkdir -p $$(dir $$@) 272 $(DEX2OAT) $(PARALLEL_ART_COMPILE_JOBS) --runtime-arg -Xms64m --runtime-arg -Xmx64m --boot-image=$(TARGET_BOOT_IMG_OUT) --dex-file=$(PRODUCT_OUT)/$(1) --dex-location=/$(1) --oat-file=$$@ --host-prefix=$(PRODUCT_OUT) --instruction-set=$(TARGET_ARCH) --android-root=$(PRODUCT_OUT)/system 273 274 endif 275 276 OAT_TARGET_TARGETS += oat-target-$(1) 277 endef 278 279 $(foreach file,\ 280 $(filter-out\ 281 $(addprefix $(TARGET_OUT_JAVA_LIBRARIES)/,$(addsuffix .jar,$(TARGET_BOOT_JARS))),\ 282 $(wildcard $(TARGET_OUT_APPS)/*.apk) $(wildcard $(TARGET_OUT_JAVA_LIBRARIES)/*.jar)),\ 283 $(eval $(call declare-oat-target-target,$(subst $(PRODUCT_OUT)/,,$(file))))) 284 285 .PHONY: oat-target 286 oat-target: $(ART_TARGET_DEPENDENCIES) $(TARGET_BOOT_OAT_OUT) $(OAT_TARGET_TARGETS) 287 288 .PHONY: oat-target-sync 289 oat-target-sync: oat-target 290 adb remount 291 adb sync 292 293 ######################################################################## 294 # "m build-art" for quick minimal build 295 .PHONY: build-art 296 build-art: build-art-host build-art-target 297 298 .PHONY: build-art-host 299 build-art-host: $(ART_HOST_EXECUTABLES) $(ART_HOST_TEST_EXECUTABLES) $(HOST_CORE_IMG_OUT) $(HOST_OUT)/lib/libjavacore.so 300 301 .PHONY: build-art-target 302 build-art-target: $(ART_TARGET_EXECUTABLES) $(ART_TARGET_TEST_EXECUTABLES) $(TARGET_CORE_IMG_OUT) $(TARGET_OUT)/lib/libjavacore.so 303 304 ######################################################################## 305 # oatdump targets 306 307 .PHONY: dump-oat 308 dump-oat: dump-oat-core dump-oat-boot 309 310 .PHONY: dump-oat-core 311 dump-oat-core: dump-oat-core-host dump-oat-core-target 312 313 .PHONY: dump-oat-core-host 314 ifeq ($(ART_BUILD_HOST),true) 315 dump-oat-core-host: $(HOST_CORE_IMG_OUT) $(OATDUMP) 316 $(OATDUMP) --image=$(HOST_CORE_IMG_OUT) --output=/tmp/core.host.oatdump.txt --host-prefix="" 317 @echo Output in /tmp/core.host.oatdump.txt 318 endif 319 320 .PHONY: dump-oat-core-target 321 ifeq ($(ART_BUILD_TARGET),true) 322 dump-oat-core-target: $(TARGET_CORE_IMG_OUT) $(OATDUMP) 323 $(OATDUMP) --image=$(TARGET_CORE_IMG_OUT) --output=/tmp/core.target.oatdump.txt 324 @echo Output in /tmp/core.target.oatdump.txt 325 endif 326 327 .PHONY: dump-oat-boot 328 ifeq ($(ART_BUILD_TARGET_NDEBUG),true) 329 dump-oat-boot: $(TARGET_BOOT_IMG_OUT) $(OATDUMP) 330 $(OATDUMP) --image=$(TARGET_BOOT_IMG_OUT) --output=/tmp/boot.oatdump.txt 331 @echo Output in /tmp/boot.oatdump.txt 332 endif 333 334 .PHONY: dump-oat-Calculator 335 ifeq ($(ART_BUILD_TARGET_NDEBUG),true) 336 dump-oat-Calculator: $(TARGET_OUT_APPS)/Calculator.odex $(TARGET_BOOT_IMG_OUT) $(OATDUMP) 337 $(OATDUMP) --oat-file=$< --output=/tmp/Calculator.oatdump.txt 338 @echo Output in /tmp/Calculator.oatdump.txt 339 endif 340 341 ######################################################################## 342 # cpplint targets to style check art source files 343 344 include $(art_build_path)/Android.cpplint.mk 345 346 ######################################################################## 347 # targets to switch back and forth from libdvm to libart 348 349 .PHONY: use-art 350 use-art: 351 adb root && sleep 3 352 adb shell setprop persist.sys.dalvik.vm.lib libart.so 353 adb reboot 354 355 .PHONY: use-artd 356 use-artd: 357 adb root && sleep 3 358 adb shell setprop persist.sys.dalvik.vm.lib libartd.so 359 adb reboot 360 361 .PHONY: use-dalvik 362 use-dalvik: 363 adb root && sleep 3 364 adb shell setprop persist.sys.dalvik.vm.lib libdvm.so 365 adb reboot 366 367 ######################################################################## 368 369 endif # !art_dont_bother 370