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
17LOCAL_PATH := $(call my-dir)
18
19include art/build/Android.executable.mk
20
21OATDUMP_SRC_FILES := \
22	oatdump.cc
23
24ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
25  $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),libcutils libart-disassembler,art/disassembler,target,ndebug))
26endif
27ifeq ($(ART_BUILD_TARGET_DEBUG),true)
28  $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),libcutils libartd-disassembler,art/disassembler,target,debug))
29endif
30
31ifeq ($(ART_BUILD_HOST_NDEBUG),true)
32  $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),libart-disassembler,art/disassembler,host,ndebug))
33endif
34ifeq ($(ART_BUILD_HOST_DEBUG),true)
35  $(eval $(call build-art-executable,oatdump,$(OATDUMP_SRC_FILES),libartd-disassembler,art/disassembler,host,debug))
36endif
37
38########################################################################
39# oatdump targets
40
41ART_DUMP_OAT_PATH ?= $(OUT_DIR)
42
43OATDUMP := $(HOST_OUT_EXECUTABLES)/oatdump$(HOST_EXECUTABLE_SUFFIX)
44OATDUMPD := $(HOST_OUT_EXECUTABLES)/oatdumpd$(HOST_EXECUTABLE_SUFFIX)
45# TODO: for now, override with debug version for better error reporting
46OATDUMP := $(OATDUMPD)
47
48.PHONY: dump-oat
49dump-oat: dump-oat-core dump-oat-boot
50
51.PHONY: dump-oat-core
52dump-oat-core: dump-oat-core-host dump-oat-core-target
53
54.PHONY: dump-oat-core-host
55ifeq ($(ART_BUILD_HOST),true)
56dump-oat-core-host: $(HOST_CORE_IMG_OUT) $(OATDUMP)
57	$(OATDUMP) --image=$(HOST_CORE_IMG_LOCATION) --output=$(ART_DUMP_OAT_PATH)/core.host.oatdump.txt
58	@echo Output in $(ART_DUMP_OAT_PATH)/core.host.oatdump.txt
59endif
60
61.PHONY: dump-oat-core-target
62ifeq ($(ART_BUILD_TARGET),true)
63dump-oat-core-target: $(TARGET_CORE_IMG_OUT) $(OATDUMP)
64	$(OATDUMP) --image=$(TARGET_CORE_IMG_LOCATION) \
65	  --output=$(ART_DUMP_OAT_PATH)/core.target.oatdump.txt --instruction-set=$(TARGET_ARCH)
66	@echo Output in $(ART_DUMP_OAT_PATH)/core.target.oatdump.txt
67endif
68
69.PHONY: dump-oat-boot-$(TARGET_ARCH)
70ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
71dump-oat-boot-$(TARGET_ARCH): $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) $(OATDUMP)
72	$(OATDUMP) --image=$(DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION) \
73	  --output=$(ART_DUMP_OAT_PATH)/boot.$(TARGET_ARCH).oatdump.txt --instruction-set=$(TARGET_ARCH)
74	@echo Output in $(ART_DUMP_OAT_PATH)/boot.$(TARGET_ARCH).oatdump.txt
75endif
76
77ifdef TARGET_2ND_ARCH
78dump-oat-boot-$(TARGET_2ND_ARCH): $(2ND_DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) $(OATDUMP)
79	$(OATDUMP) --image=$(2ND_DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION) \
80	  --output=$(ART_DUMP_OAT_PATH)/boot.$(TARGET_2ND_ARCH).oatdump.txt --instruction-set=$(TARGET_2ND_ARCH)
81	@echo Output in $(ART_DUMP_OAT_PATH)/boot.$(TARGET_2ND_ARCH).oatdump.txt
82endif
83
84.PHONY: dump-oat-boot
85dump-oat-boot: dump-oat-boot-$(TARGET_ARCH)
86ifdef TARGET_2ND_ARCH
87dump-oat-boot: dump-oat-boot-$(TARGET_2ND_ARCH)
88endif
89
90.PHONY: dump-oat-Calculator
91ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
92dump-oat-Calculator: $(TARGET_OUT_APPS)/Calculator.odex $(DEFAULT_DEX_PREOPT_BUILT_IMAGE) $(OATDUMP)
93	$(OATDUMP) --oat-file=$< --output=$(ART_DUMP_OAT_PATH)/Calculator.oatdump.txt
94	@echo Output in $(ART_DUMP_OAT_PATH)/Calculator.oatdump.txt
95endif
96