Title: [267424] trunk
Revision
267424
Author
krol...@apple.com
Date
2020-09-22 11:37:51 -0700 (Tue, 22 Sep 2020)

Log Message

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:

Modified Paths

Diff

Modified: trunk/ChangeLog (267423 => 267424)


--- trunk/ChangeLog	2020-09-22 18:30:53 UTC (rev 267423)
+++ trunk/ChangeLog	2020-09-22 18:37:51 UTC (rev 267424)
@@ -1,3 +1,20 @@
+2020-09-22  Keith Rollin  <krol...@apple.com>
+
+        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:
+
 2020-09-22  Jonathan Bedard  <jbed...@apple.com>
 
         Correct instructions for building iOS in ReadMe

Modified: trunk/Makefile (267423 => 267424)


--- trunk/Makefile	2020-09-22 18:30:53 UTC (rev 267423)
+++ trunk/Makefile	2020-09-22 18:37:51 UTC (rev 267424)
@@ -1,29 +1,30 @@
 MODULES = WebKitLibraries Source Tools
 
+define build_target_for_each_module
+	for dir in $(MODULES); do \
+		${MAKE} $@ -C $$dir PATH_FROM_ROOT=$(PATH_FROM_ROOT)/$${dir}; \
+		exit_status=$$?; \
+		[ $$exit_status -ne 0 ] && exit $$exit_status; \
+	done; true
+endef
+
 all:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 debug d:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 release r:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 release+assert ra:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 testing t:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 analyze:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 clean:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)

Modified: trunk/Makefile.shared (267423 => 267424)


--- trunk/Makefile.shared	2020-09-22 18:30:53 UTC (rev 267423)
+++ trunk/Makefile.shared	2020-09-22 18:37:51 UTC (rev 267424)
@@ -1,6 +1,5 @@
 SCRIPTS_PATH ?= ../Tools/Scripts
 
-SET_COLOR_DIAGNOSTICS_ARG = if [[ -t 1 ]]; then COLOR_DIAGNOSTICS_ARG="COLOR_DIAGNOSTICS=YES"; fi
 XCODE_OPTIONS = `perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print XcodeOptionString()' -- $(BUILD_WEBKIT_OPTIONS)` $${COLOR_DIAGNOSTICS_ARG} $(ARGS)
 
 ifneq (,$(SDKROOT))
@@ -92,42 +91,47 @@
 # See <rdar://problem/16466196>.
 export PATH = $(shell getconf PATH)
 
-all: set_sanitizer_configuration
-	( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
 
+define set_webkit_configuration
+	$(SCRIPTS_PATH)/set-webkit-configuration $1 $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION)
+endef
+
+define invoke_xcode
+	( \
+		[[ -t 1 ]] && COLOR_DIAGNOSTICS_ARG="COLOR_DIAGNOSTICS=YES"; \
+		$1 xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) $2 | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} \
+	)
+endef
+
+all:
+	@$(call set_webkit_configuration,)
+	@$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
+
 debug d development dev develop: force
-	$(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION)
-	( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
+	@$(call set_webkit_configuration,--debug)
+	@$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
 
 release r deployment dep deploy: force
-	$(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION)
-	( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
+	@$(call set_webkit_configuration,--release)
+	@$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
 
 release+assert ra: force
-	$(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION)
-	( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) ASSERT_ENABLED=1 $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
+	@$(call set_webkit_configuration,--release)
+	@$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) ASSERT_ENABLED=1 $$(inherited)')
 
 testing t: force
-	$(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION) --force-optimization-level=O3
-	( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
+	@$(call set_webkit_configuration,--debug --force-optimization-level=O3)
+	@$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
 
 analyze:
-	$(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION)
+	@$(call set_webkit_configuration,--debug)
 ifndef PATH_TO_SCAN_BUILD
-	( $(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]} )
+	@$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' RUN_CLANG_STATIC_ANALYZER=YES)
 else
-	( $(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]} )
+	@$(call invoke_xcode,$(PATH_TO_SCAN_BUILD),GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
 endif
 
-set_sanitizer_configuration:
-ifneq (,$(ASAN_OPTION))
-	$(SCRIPTS_PATH)/set-webkit-configuration $(ASAN_OPTION)
-endif
-ifneq (,$(TSAN_OPTION))
-	$(SCRIPTS_PATH)/set-webkit-configuration $(TSAN_OPTION)
-endif
-
 clean:
-	( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) -alltargets clean $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
+	@$(call invoke_xcode,,-alltargets clean)
 
 force: ;

Modified: trunk/Source/Makefile (267423 => 267424)


--- trunk/Source/Makefile	2020-09-22 18:30:53 UTC (rev 267423)
+++ trunk/Source/Makefile	2020-09-22 18:37:51 UTC (rev 267424)
@@ -10,30 +10,31 @@
 
 MODULES = bmalloc WTF _javascript_Core ThirdParty WebCore $(WEBINSPECTORUI_MODULE) WebKitLegacy WebKit
 
+define build_target_for_each_module
+	for dir in $(MODULES); do \
+		${MAKE} $@ -C $$dir PATH_FROM_ROOT=$(PATH_FROM_ROOT)/$${dir}; \
+		exit_status=$$?; \
+		[ $$exit_status -ne 0 ] && exit $$exit_status; \
+	done; true
+endef
+
 all:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 debug d:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 release r:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 release+assert ra:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 testing t:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 analyze:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 clean:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)

Modified: trunk/Source/ThirdParty/ChangeLog (267423 => 267424)


--- trunk/Source/ThirdParty/ChangeLog	2020-09-22 18:30:53 UTC (rev 267423)
+++ trunk/Source/ThirdParty/ChangeLog	2020-09-22 18:37:51 UTC (rev 267424)
@@ -1,3 +1,18 @@
+2020-09-22  Keith Rollin  <krol...@apple.com>
+
+        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:
+
 2020-08-05  Tim Horton  <timothy_hor...@apple.com>
 
         Remove all references to non-existent 10.16

Modified: trunk/Source/ThirdParty/Makefile (267423 => 267424)


--- trunk/Source/ThirdParty/Makefile	2020-09-22 18:30:53 UTC (rev 267423)
+++ trunk/Source/ThirdParty/Makefile	2020-09-22 18:37:51 UTC (rev 267424)
@@ -24,30 +24,31 @@
 
 MODULES = ANGLE $(LIBWEBRTC_MODULE)
 
+define build_target_for_each_module
+	for dir in $(MODULES); do \
+		${MAKE} $@ -C $$dir PATH_FROM_ROOT=$(PATH_FROM_ROOT)/$${dir}; \
+		exit_status=$$?; \
+		[ $$exit_status -ne 0 ] && exit $$exit_status; \
+	done; true
+endef
+
 all:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 debug d development dev develop:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 release r deployment dep deploy:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 release+assert ra:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 testing t:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 analyze:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 clean:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)

Modified: trunk/Tools/ChangeLog (267423 => 267424)


--- trunk/Tools/ChangeLog	2020-09-22 18:30:53 UTC (rev 267423)
+++ trunk/Tools/ChangeLog	2020-09-22 18:37:51 UTC (rev 267424)
@@ -1,3 +1,18 @@
+2020-09-22  Keith Rollin  <krol...@apple.com>
+
+        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:
+
 2020-09-22  Youenn Fablet  <you...@apple.com>
 
         Implement a default prompt for getUserMedia

Modified: trunk/Tools/Makefile (267423 => 267424)


--- trunk/Tools/Makefile	2020-09-22 18:30:53 UTC (rev 267423)
+++ trunk/Tools/Makefile	2020-09-22 18:37:51 UTC (rev 267424)
@@ -20,30 +20,31 @@
 	MODULES = DumpRenderTree WebKitTestRunner ../Source/ThirdParty/gtest/xcode TestWebKitAPI
 endif
 
+define build_target_for_each_module
+	for dir in $(MODULES); do \
+		${MAKE} $@ -C $$dir PATH_FROM_ROOT=$(PATH_FROM_ROOT)/$${dir}; \
+		exit_status=$$?; \
+		[ $$exit_status -ne 0 ] && exit $$exit_status; \
+	done; true
+endef
+
 all:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 debug d development dev develop:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 release r deployment dep deploy:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 release+assert ra:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 testing t:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 analyze:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
 
 clean:
-	@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
-	if [ $$exit_status -ne 0 ]; then exit $$exit_status; fi; done
+	@$(build_target_for_each_module)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to