-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
179 lines (150 loc) · 4.56 KB
/
Makefile
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
#
# Copyright (c) [2020-2021] Huawei Technologies Co.,Ltd.All rights reserved.
#
# OpenArkCompiler is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#
# http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
# FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
#
# Makefile for OpenArkCompiler
OPT := O2
DEBUG := $(MAPLE_DEBUG)
INSTALL_DIR := $(MAPLE_BUILD_OUTPUT)
LIB_CORE_PATH := $(MAPLE_BUILD_OUTPUT)/libjava-core/host-x86_64-$(OPT)
MAPLE_BIN_DIR := $(MAPLE_ROOT)/src/mapleall/bin
MRT_ROOT := $(MAPLE_ROOT)/src/mrt
ANDROID_ROOT := $(MAPLE_ROOT)/android
ifeq ($(DEBUG),0)
BUILD_TYPE := RELEASE
else
BUILD_TYPE := DEBUG
endif
HOST_ARCH := 64
MIR_JAVA := 1
GN := $(MAPLE_ROOT)/tools/gn/gn
NINJA := $(shell ls $(MAPLE_ROOT)/tools/ninja*/ninja | tail -1)
ifneq ($(findstring GC,$(OPT)),)
GCONLY := 1
else
GCONLY := 0
endif
GN_OPTIONS := \
GN_INSTALL_PREFIX="$(MAPLE_ROOT)" \
GN_BUILD_TYPE="$(BUILD_TYPE)" \
HOST_ARCH=$(HOST_ARCH) \
MIR_JAVA=$(MIR_JAVA) \
OPT="$(OPT)" \
GCONLY=$(GCONLY) \
TARGET="$(TARGET_PROCESSOR)" \
.PHONY: default
default: install
.PHONY: directory
directory:
$(shell mkdir -p $(INSTALL_DIR)/bin;)
.PHONY: install_patch
install_patch:
@bash build/third_party/patch.sh patch
.PHONY: uninstall_patch
uninstall_patch:
@bash build/third_party/patch.sh unpatch
.PHONY: maplegen
maplegen:install_patch
$(call build_gn, $(GN_OPTIONS), maplegen)
.PHONY: maplegendef
maplegendef: maplegen
$(call build_gn, $(GN_OPTIONS), maplegendef)
.PHONY: maple
maple: maplegendef
$(call build_gn, $(GN_OPTIONS), maple)
.PHONY: irbuild
irbuild: install_patch
$(call build_gn, $(GN_OPTIONS), irbuild)
.PHONY: mpldbg
mpldbg:
$(call build_gn, $(GN_OPTIONS), mpldbg)
.PHONY: ast2mpl
ast2mpl:
$(call build_gn, $(GN_OPTIONS), ast2mpl)
.PHONY: mplfe
mplfe: install_patch
$(call build_gn, $(GN_OPTIONS), mplfe)
.PHONY: clang2mpl
clang2mpl: maple
(cd tools/clang2mpl; make setup; make; make install)
.PHONY: mplfeUT
mplfeUT:
$(call build_gn, $(GN_OPTIONS) COV_CHECK=1, mplfeUT)
.PHONY: libcore
libcore: maple-rt
cd $(LIB_CORE_PATH); \
$(MAKE) install OPT=$(OPT) DEBUG=$(DEBUG)
.PHONY: maple-rt
maple-rt: java-core-def
$(call build_gn, $(GN_OPTIONS), maple-rt)
.PHONY: java-core-def
java-core-def: install
mkdir -p $(LIB_CORE_PATH); \
cp -rp $(MAPLE_ROOT)/libjava-core/* $(LIB_CORE_PATH)/; \
cd $(LIB_CORE_PATH); \
ln -f -s $(MAPLE_ROOT)/build/core/libcore.mk ./makefile; \
$(MAKE) gen-def OPT=$(OPT) DEBUG=$(DEBUG) OPS_ANDROID=$(OPS_ANDROID)
.PHONY: install
install: maple dex2mpl_install irbuild mplfe
$(shell mkdir -p $(INSTALL_DIR)/ops/linker/; \
rsync -a -L $(MRT_ROOT)/maplert/linker/maplelld.so.lds $(INSTALL_DIR)/ops/linker/; \
rsync -a -L $(MAPLE_ROOT)/build/java2d8 $(INSTALL_DIR)/bin; \
rsync -a -L $(MAPLE_BIN_DIR)/java2jar $(INSTALL_DIR)/bin/; \
cp -rf $(MAPLE_ROOT)/testsuite/tools $(INSTALL_DIR)/../; \
rsync -a -L $(MAPLE_ROOT)/src/mplfe/ast_input/lib/sys/ $(INSTALL_DIR)/lib/include/;)
.PHONY: all
all: install libcore
.PHONY: dex2mpl_install
dex2mpl_install: directory
$(shell rsync -a -L $(MAPLE_BIN_DIR)/dex2mpl $(INSTALL_DIR)/bin/;)
.PHONY: setup
setup:
(cd tools; ./setup_tools.sh)
.PHONY: demo
demo:
test/maple_aarch64_with_mplfe.sh test/c_demo printHuawei 1 1
test/maple_aarch64_with_clang2mpl.sh test/c_demo printHuawei 1 1
.PHONY: ctorture-ci
ctorture-ci:
(cd third_party/ctorture; git checkout .; git pull; ./ci.sh)
.PHONY: ctorture
ctorture:
(cd third_party/ctorture; git checkout .; git pull; ./run.sh work.list)
THREADS := 50
ifneq ($(findstring test,$(MAKECMDGOALS)),)
TESTTARGET := $(MAKECMDGOALS)
ifdef TARGET
REALTARGET := $(TARGET)
else
REALTARGET := $(TESTTARGET)
endif
.PHONY: $(TESTTARGET)
${TESTTARGET}:
@python3 $(MAPLE_ROOT)/testsuite/driver/src/driver.py --target=$(REALTARGET) --run-path=$(MAPLE_ROOT)/output/$(MAPLE_BUILD_TYPE)/testsuite $(if $(MOD), --mod=$(MOD),) --j=$(THREADS) --retry --report=$(MAPLE_ROOT)/report.txt
endif
.PHONY: cleanrsd
cleanrsd:uninstall_patch
@rm -rf libjava-core/libcore-all.* libjava-core/m* libjava-core/comb.*
.PHONY: clean
clean: cleanrsd
@rm -rf $(MAPLE_BUILD_OUTPUT)/
@rm -rf $(MAPLE_ROOT)/report.txt
.PHONY: clobber
clobber: cleanrsd
@rm -rf output
define build_gn
mkdir -p $(INSTALL_DIR); \
$(GN) gen $(INSTALL_DIR) --args='$(1)' --export-compile-commands; \
cd $(INSTALL_DIR); \
$(NINJA) -v $(2);
endef