forked from servo/servo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
256 lines (193 loc) · 7.19 KB
/
Makefile.in
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# Recursive wildcard function
# http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
$(filter $(subst *,%,$2),$d))
include config.mk
# Target-and-rule "utility variables"
ifdef VERBOSE
Q :=
E =
else
Q := @
E = echo $(1)
endif
S := $(CFG_SRC_DIR)
B := $(CFG_BUILD_DIR)
#VPATH := $(S)src
# Delete the built-in rules.
.SUFFIXES:
%:: %,v
%:: RCS/%,v
%:: RCS/%
%:: s.%
%:: SCCS/s.%
MKFILE_DEPS := config.stamp $(call rwildcard,$(S)mk/,*)
CFG_RUSTC_FLAGS := $(RUSTFLAGS) -A default_methods
ifdef CFG_DISABLE_OPTIMIZE
$(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
CFG_RUSTC_FLAGS +=
else
CFG_RUSTC_FLAGS += -O
endif
ifdef CFG_ENABLE_DEBUG
$(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
CFG_RUSTC_FLAGS +=
CFG_GCCISH_CFLAGS += -DRUST_DEBUG
else
CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
endif
export CFG_RUSTC
export CFG_RUSTC_FLAGS
export CFG_LOCAL_RUSTC
export RUSTC=$(CFG_RUSTC)
export RUSTFLAGS=$(CFG_RUSTC_FLAGS)
######################################################################
# Re-configuration
######################################################################
ifndef CFG_DISABLE_MANAGE_SUBMODULES
# This is a pretty expensive operation but I don't see any way to avoid it
NEED_GIT_RECONFIG=$(shell cd "$(S)" && "$(CFG_GIT)" submodule status | grep -c '^\(+\|-\)')
else
NEED_GIT_RECONFIG=0
endif
ifeq ($(NEED_GIT_RECONFIG),0)
else
# If the submodules have changed then always execute config.mk
.PHONY: $(S)config.stamp
endif
$(S)Makefile $(S)config.mk: $(S)config.stamp
$(S)config.stamp : $(S)configure $(S)Makefile.in
@$(call E, cfg: reconfiguring)
$(Q)$(S)configure $(CFG_CONFIGURE_ARGS)
# Build the compiler
ifneq ($(CFG_LOCAL_RUSTC),1)
$(CFG_RUSTC):
$(MAKE) -C "$(CFG_BUILD_DIR)src/rust" CFG_RUSTC_FLAGS="" RUSTFLAGS=""
clean-rust:
$(MAKE) -C "$(CFG_BUILD_DIR)src/rust" CFG_RUSTC_FLAGS="" RUSTFLAGS="" clean
else
$(CFG_RUSTC):
clean-rust:
endif
rust: $(CFG_RUSTC)
define DEF_SUBMODULE_VARS
#defaults
DEPS_$(1) =
CFLAGS_$(1) = -O2
#if global cflags set, inherit that
ifneq ($$(CFLAGS),)
CFLAGS_$(1) = $$(CFLAGS)
endif
# any "done" dummy files must be named libSOMETHING.dummy.
#
# We can't auto-compute this, because some modules have lib* prefix in
# their name already, while others don't.
DONE_$(1) = $$(B)src/$(1)/lib*.dummy
DEPS_SUBMODULES += $(1)
endef
# these will get populated.
DEPS_SUBMODULES =
$(foreach submodule,$(CFG_SUBMODULES),\
$(eval $(call DEF_SUBMODULE_VARS,$(submodule))))
# include submodule dependencies configuration
include $(S)mk/sub.mk
# Define how to make submodule targets
define DEF_SUBMODULE_RULES
# variables that depend on dependency definitions from sub.mk!
ENV_CFLAGS_$(1) = CFLAGS="$$(CFLAGS_$(1))"
ENV_RFLAGS_$(1) = RUSTFLAGS="$$(strip $$(CFG_RUSTC_FLAGS)) $$(addprefix -L $$(B)src/,$$(DEPS_$(1)))"
# use a rough approximation of submodule dependencies to trigger calling submodule make
# whenever a submodule changes
# TODO: this may be a bit brutish, but is there a better way?
ROUGH_DEPS_$(1)=$$(call rwildcard,$$(S)src/$(1),*h *c *cpp *rs *rc)
DONE_DEPS_$(1)=$$(foreach dep,$$(DEPS_$(1)),$$(DONE_$$(dep)))
# the main target for a submodule
# --
# Native builds do not depend on the rust compiler, so we can build them in parallel with rustc
ifneq "$$(filter $(1),$$(NATIVE_BUILDS))" "$(1)"
RUSTC_DEP_$(1)=$$(CFG_RUSTC)
endif
$$(DONE_$(1)) : $$(DONE_DEPS_$(1)) $$(ROUGH_DEPS_$(1)) $$(RUSTC_DEP_$(1))
# @$$(call E, make: $(1))
# @$$(call E, $(1) deps= $$(DEPS_$(1)))
# @$$(call E, $(1) done_deps= $$(DONE_DEPS_$(1)))
# @$$(call E, $(1) cflags= $$(ENV_CFLAGS_$(1)))
# @$$(call E, $(1) rflags= $$(ENV_RFLAGS_$(1)))
$$(Q) \
$$(ENV_CFLAGS_$(1)) \
$$(ENV_RFLAGS_$(1)) \
$$(MAKE) -C $$(B)src/$(1) && touch $$(DONE_$(1))
# main submodule target
$(1) : $$(DONE_$(1))
.PHONY : $(1)
.NOTPARALLEL : $(1)
endef
$(foreach submodule,$(CFG_SUBMODULES),\
$(eval $(call DEF_SUBMODULE_RULES,$(submodule))))
DONE_SUBMODULES = $(foreach dep,$(DEPS_SUBMODULES),$(DONE_$(dep)))
RFLAGS_servo_util = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES))
SRC_servo_util = $(call rwildcard,$(S)src/servo-util/,*.rs)
CRATE_servo_util = $(S)src/servo-util/servo_util.rc
DONE_servo_util = $(B)src/servo-util/libservoutil.dummy
DEPS_servo_util = $(CRATE_servo_util) $(SRC_servo_util) $(DONE_SUBMODULES)
RFLAGS_servo_gfx = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/servo-util
SRC_servo_gfx = $(call rwildcard,$(S)src/servo-gfx/,*.rs)
CRATE_servo_gfx = $(S)src/servo-gfx/servo_gfx.rc
DONE_servo_gfx = $(B)src/servo-gfx/libservogfx.dummy
DEPS_servo_gfx = $(CRATE_servo_gfx) $(SRC_servo_gfx) $(DONE_SUBMODULES) $(DONE_servo_util)
RFLAGS_servo = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/servo-gfx -L $(B)src/servo-util
WEBIDL_servo = $(call rwildcard,$(S)src/servo/,*.webidl)
AUTOGEN_SRC_servo = $(patsubst %.webidl, %Binding.rs, $(WEBIDL_servo))
SRC_servo = $(call rwildcard,$(S)src/servo/,*.rs) $(AUTOGEN_SRC_servo)
CRATE_servo = $(S)src/servo/servo.rc
DEPS_servo = $(CRATE_servo) $(SRC_servo) $(DONE_SUBMODULES) $(DONE_servo_util) $(DONE_servo_gfx)
# rules that depend on having correct meta-target vars (DEPS_CLEAN, DEPS_servo, etc)
include $(S)mk/check.mk
include $(S)mk/clean.mk
.DEFAULT_GOAL := all
.PHONY: all
all: servo package
# Servo helper libraries
$(DONE_servo_util): $(DEPS_servo_util)
$(RUSTC) $(RFLAGS_servo_util) -o $@ $< && touch $@
$(DONE_servo_gfx): $(DEPS_servo_gfx)
$(RUSTC) $(RFLAGS_servo_gfx) -o $@ $< && touch $@
BINDINGS_SRC = $(S)/src/servo/dom/bindings/codegen
CACHE_DIR = $(BINDINGS_SRC)/_cache
bindinggen_dependencies := $(addprefix $(BINDINGS_SRC)/, BindingGen.py Bindings.conf Configuration.py CodegenRust.py parser/WebIDL.py ParserResults.pkl)
$(AUTOGEN_SRC_servo): %Binding.rs: $(bindinggen_dependencies) \
%.webidl
PYTHONDONTWRITEBYTECODE=1 $(CFG_PYTHON2) $(BINDINGS_SRC)/pythonpath.py \
-I$(BINDINGS_SRC)/parser -I$(BINDINGS_SRC)/ply \
-D$(BINDINGS_SRC) \
$(BINDINGS_SRC)/BindingGen.py rs \
$(BINDINGS_SRC)/Bindings.conf $*Binding $*.webidl
globalgen_dependencies := $(addprefix $(BINDINGS_SRC)/, GlobalGen.py Bindings.conf Configuration.py CodegenRust.py parser/WebIDL.py) $(CACHE_DIR)/.done
$(CACHE_DIR)/.done:
mkdir -p $(CACHE_DIR)
@touch $@
$(BINDINGS_SRC)/ParserResults.pkl: $(globalgen_dependencies) \
$(WEBIDL_servo)
PYTHONDONTWRITEBYTECODE=1 $(CFG_PYTHON2) $(BINDINGS_SRC)/pythonpath.py \
-I$(BINDINGS_SRC)/parser -I$(BINDINGS_SRC)/ply \
-D$(BINDINGS_SRC) \
$(BINDINGS_SRC)/GlobalGen.py $(BINDINGS_SRC)/Bindings.conf . \
--cachedir=$(CACHE_DIR) \
$(WEBIDL_servo)
# Servo binaries
servo: $(DEPS_servo)
$(RUSTC) $(RFLAGS_servo) -o $@ $< --bin
# Darwin app packaging
ifeq ($(OSTYPE),apple-darwin)
package: servo
mkdir -p Servo.app/Contents/MacOS/src/rust-cocoa
mkdir -p Servo.app/Contents/MacOS/src/rust-azure
cp $(S)/Info.plist Servo.app/Contents/
cp servo Servo.app/Contents/MacOS/
cp src/rust-cocoa/lib*.dylib Servo.app/Contents/MacOS/src/rust-cocoa/
cp src/rust-azure/lib*.dylib Servo.app/Contents/MacOS/src/rust-azure/
else
bindings: $(AUTOGEN_SRC_servo)
.PHONY: package
package:
endif