Skip to content

Commit 31f856b

Browse files
committed
Refactor build rules in Makefiles and Makefile.shared
https://bugs.webkit.org/show_bug.cgi?id=216806 <rdar://problem/69332316> Reviewed by David Kilzer. Factor out the common aspects of the build rules in Makefile.shared and the various Makefiles. This allows us to more easily see what's different between the various build targets, and to apply uniform changes across all of the targets. * Makefile: .: * Makefile.shared: * Source/Makefile: Canonical link: https://commits.webkit.org/229628@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267424 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 1db9d26 commit 31f856b

8 files changed

Lines changed: 134 additions & 79 deletions

File tree

ChangeLog

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2020-09-22 Keith Rollin <krollin@apple.com>
2+
3+
Refactor build rules in Makefiles and Makefile.shared
4+
https://bugs.webkit.org/show_bug.cgi?id=216806
5+
<rdar://problem/69332316>
6+
7+
Reviewed by David Kilzer.
8+
9+
Factor out the common aspects of the build rules in Makefile.shared
10+
and the various Makefiles. This allows us to more easily see what's
11+
different between the various build targets, and to apply uniform
12+
changes across all of the targets.
13+
14+
* Makefile:
15+
* Makefile.shared:
16+
* Source/Makefile:
17+
118
2020-09-22 Jonathan Bedard <jbedard@apple.com>
219

320
Correct instructions for building iOS in ReadMe

Makefile

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
MODULES = WebKitLibraries Source Tools
22

3+
define build_target_for_each_module
4+
for dir in $(MODULES); do \
5+
${MAKE} $@ -C $$dir PATH_FROM_ROOT=$(PATH_FROM_ROOT)/$${dir}; \
6+
exit_status=$$?; \
7+
[ $$exit_status -ne 0 ] && exit $$exit_status; \
8+
done; true
9+
endef
10+
311
all:
4-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
5-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
12+
@$(build_target_for_each_module)
613

714
debug d:
8-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
9-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
15+
@$(build_target_for_each_module)
1016

1117
release r:
12-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
13-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
18+
@$(build_target_for_each_module)
1419

1520
release+assert ra:
16-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
17-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
21+
@$(build_target_for_each_module)
1822

1923
testing t:
20-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
21-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
24+
@$(build_target_for_each_module)
2225

2326
analyze:
24-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
25-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
27+
@$(build_target_for_each_module)
2628

2729
clean:
28-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
29-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
30+
@$(build_target_for_each_module)

Makefile.shared

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
SCRIPTS_PATH ?= ../Tools/Scripts
22

3-
SET_COLOR_DIAGNOSTICS_ARG = if [[ -t 1 ]]; then COLOR_DIAGNOSTICS_ARG="COLOR_DIAGNOSTICS=YES"; fi
43
XCODE_OPTIONS = `perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print XcodeOptionString()' -- $(BUILD_WEBKIT_OPTIONS)` $${COLOR_DIAGNOSTICS_ARG} $(ARGS)
54

65
ifneq (,$(SDKROOT))
@@ -92,42 +91,47 @@ export DSYMUTIL_NUM_THREADS = $(shell sysctl -n hw.activecpu)
9291
# See <rdar://problem/16466196>.
9392
export PATH = $(shell getconf PATH)
9493

95-
all: set_sanitizer_configuration
96-
( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
94+
95+
define set_webkit_configuration
96+
$(SCRIPTS_PATH)/set-webkit-configuration $1 $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION)
97+
endef
98+
99+
define invoke_xcode
100+
( \
101+
[[ -t 1 ]] && COLOR_DIAGNOSTICS_ARG="COLOR_DIAGNOSTICS=YES"; \
102+
$1 xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) $2 | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} \
103+
)
104+
endef
105+
106+
all:
107+
@$(call set_webkit_configuration,)
108+
@$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
97109

98110
debug d development dev develop: force
99-
$(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION)
100-
( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
111+
@$(call set_webkit_configuration,--debug)
112+
@$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
101113

102114
release r deployment dep deploy: force
103-
$(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION)
104-
( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
115+
@$(call set_webkit_configuration,--release)
116+
@$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
105117

106118
release+assert ra: force
107-
$(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION)
108-
( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) ASSERT_ENABLED=1 $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
119+
@$(call set_webkit_configuration,--release)
120+
@$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) ASSERT_ENABLED=1 $$(inherited)')
109121

110122
testing t: force
111-
$(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION) --force-optimization-level=O3
112-
( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
123+
@$(call set_webkit_configuration,--debug --force-optimization-level=O3)
124+
@$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
113125

114126
analyze:
115-
$(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION)
127+
@$(call set_webkit_configuration,--debug)
116128
ifndef PATH_TO_SCAN_BUILD
117-
( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' RUN_CLANG_STATIC_ANALYZER=YES | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
129+
@$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' RUN_CLANG_STATIC_ANALYZER=YES)
118130
else
119-
( $(SET_COLOR_DIAGNOSTICS_ARG); $(PATH_TO_SCAN_BUILD) xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
120-
endif
121-
122-
set_sanitizer_configuration:
123-
ifneq (,$(ASAN_OPTION))
124-
$(SCRIPTS_PATH)/set-webkit-configuration $(ASAN_OPTION)
125-
endif
126-
ifneq (,$(TSAN_OPTION))
127-
$(SCRIPTS_PATH)/set-webkit-configuration $(TSAN_OPTION)
131+
@$(call invoke_xcode,$(PATH_TO_SCAN_BUILD),GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
128132
endif
129133

130134
clean:
131-
( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) -alltargets clean $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
135+
@$(call invoke_xcode,,-alltargets clean)
132136

133137
force: ;

Source/Makefile

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,31 @@ endif
1010

1111
MODULES = bmalloc WTF JavaScriptCore ThirdParty WebCore $(WEBINSPECTORUI_MODULE) WebKitLegacy WebKit
1212

13+
define build_target_for_each_module
14+
for dir in $(MODULES); do \
15+
${MAKE} $@ -C $$dir PATH_FROM_ROOT=$(PATH_FROM_ROOT)/$${dir}; \
16+
exit_status=$$?; \
17+
[ $$exit_status -ne 0 ] && exit $$exit_status; \
18+
done; true
19+
endef
20+
1321
all:
14-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
15-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
22+
@$(build_target_for_each_module)
1623

1724
debug d:
18-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
19-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
25+
@$(build_target_for_each_module)
2026

2127
release r:
22-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
23-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
28+
@$(build_target_for_each_module)
2429

2530
release+assert ra:
26-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
27-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
31+
@$(build_target_for_each_module)
2832

2933
testing t:
30-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
31-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
34+
@$(build_target_for_each_module)
3235

3336
analyze:
34-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
35-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
37+
@$(build_target_for_each_module)
3638

3739
clean:
38-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
39-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
40+
@$(build_target_for_each_module)

Source/ThirdParty/ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2020-09-22 Keith Rollin <krollin@apple.com>
2+
3+
Refactor build rules in Makefiles and Makefile.shared
4+
https://bugs.webkit.org/show_bug.cgi?id=216806
5+
<rdar://problem/69332316>
6+
7+
Reviewed by David Kilzer.
8+
9+
Factor out the common aspects of the build rules in Makefile.shared
10+
and the various Makefiles. This allows us to more easily see what's
11+
different between the various build targets, and to apply uniform
12+
changes across all of the targets.
13+
14+
* Makefile:
15+
116
2020-08-05 Tim Horton <timothy_horton@apple.com>
217

318
Remove all references to non-existent 10.16

Source/ThirdParty/Makefile

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,31 @@ endif
2424

2525
MODULES = ANGLE $(LIBWEBRTC_MODULE)
2626

27+
define build_target_for_each_module
28+
for dir in $(MODULES); do \
29+
${MAKE} $@ -C $$dir PATH_FROM_ROOT=$(PATH_FROM_ROOT)/$${dir}; \
30+
exit_status=$$?; \
31+
[ $$exit_status -ne 0 ] && exit $$exit_status; \
32+
done; true
33+
endef
34+
2735
all:
28-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
29-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
36+
@$(build_target_for_each_module)
3037

3138
debug d development dev develop:
32-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
33-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
39+
@$(build_target_for_each_module)
3440

3541
release r deployment dep deploy:
36-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
37-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
42+
@$(build_target_for_each_module)
3843

3944
release+assert ra:
40-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
41-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
45+
@$(build_target_for_each_module)
4246

4347
testing t:
44-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
45-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
48+
@$(build_target_for_each_module)
4649

4750
analyze:
48-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
49-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
51+
@$(build_target_for_each_module)
5052

5153
clean:
52-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
53-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
54+
@$(build_target_for_each_module)

Tools/ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2020-09-22 Keith Rollin <krollin@apple.com>
2+
3+
Refactor build rules in Makefiles and Makefile.shared
4+
https://bugs.webkit.org/show_bug.cgi?id=216806
5+
<rdar://problem/69332316>
6+
7+
Reviewed by David Kilzer.
8+
9+
Factor out the common aspects of the build rules in Makefile.shared
10+
and the various Makefiles. This allows us to more easily see what's
11+
different between the various build targets, and to apply uniform
12+
changes across all of the targets.
13+
14+
* Makefile:
15+
116
2020-09-22 Youenn Fablet <youenn@apple.com>
217

318
Implement a default prompt for getUserMedia

Tools/Makefile

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,31 @@ ifeq (iosmac,$(SDK_VARIANT))
2020
MODULES = DumpRenderTree WebKitTestRunner ../Source/ThirdParty/gtest/xcode TestWebKitAPI
2121
endif
2222

23+
define build_target_for_each_module
24+
for dir in $(MODULES); do \
25+
${MAKE} $@ -C $$dir PATH_FROM_ROOT=$(PATH_FROM_ROOT)/$${dir}; \
26+
exit_status=$$?; \
27+
[ $$exit_status -ne 0 ] && exit $$exit_status; \
28+
done; true
29+
endef
30+
2331
all:
24-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
25-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
32+
@$(build_target_for_each_module)
2633

2734
debug d development dev develop:
28-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
29-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
35+
@$(build_target_for_each_module)
3036

3137
release r deployment dep deploy:
32-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
33-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
38+
@$(build_target_for_each_module)
3439

3540
release+assert ra:
36-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
37-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
41+
@$(build_target_for_each_module)
3842

3943
testing t:
40-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
41-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
44+
@$(build_target_for_each_module)
4245

4346
analyze:
44-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
45-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
47+
@$(build_target_for_each_module)
4648

4749
clean:
48-
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
49-
if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
50+
@$(build_target_for_each_module)

0 commit comments

Comments
 (0)