| SCRIPTS_PATH ?= ../Tools/Scripts | |
| ifneq ($(USE_WORKSPACE),NO) | |
| SCHEME ?= $(notdir $(CURDIR)) | |
| XCODE_TARGET = -scheme "$(SCHEME)" | |
| ifneq (,$(WORKSPACE_PATH)) | |
| CONFIG_OPTIONS += --workspace=$(WORKSPACE_PATH) | |
| endif | |
| # FIXME: Move this setting to xcconfigs once all local Xcode builds of WebKit | |
| # happen in the workspace. When this is only passed on the command line, it | |
| # invalidates build results made in the IDE (rdar://88135402). | |
| #XCODE_OPTIONS += WK_VALIDATE_DEPENDENCIES=YES_ERROR | |
| BUILD_GOAL = $(SCHEME) | |
| else | |
| USE_WORKSPACE = | |
| BUILD_WEBKIT_BASE += --no-use-workspace | |
| BUILD_GOAL = $(notdir $(CURDIR)) | |
| endif | |
| XCODE_OPTIONS = $(ARGS) | |
| XCODE_OPTIONS += $(if $(GCC_PREPROCESSOR_ADDITIONS),GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)') | |
| ifeq (ON,$(ENABLE_LLVM_PROFILE_GENERATION)) | |
| XCODE_OPTIONS += ENABLE_LLVM_PROFILE_GENERATION=YES | |
| endif | |
| ifneq (,$(SDKROOT)) | |
| ifneq (,$(OVERRIDE_SDKROOT)) | |
| ifneq (default,$(OVERRIDE_SDKROOT)) | |
| CONFIG_OPTIONS += --sdk=$(OVERRIDE_SDKROOT) | |
| BUILD_WEBKIT_BASE := $(BUILD_WEBKIT_BASE) --sdk=$(OVERRIDE_SDKROOT) | |
| endif | |
| OVERRIDE_SDKROOT = | |
| else | |
| CONFIG_OPTIONS += --sdk=$(SDKROOT) | |
| BUILD_WEBKIT_BASE := $(BUILD_WEBKIT_BASE) --sdk=$(SDKROOT) | |
| endif | |
| endif | |
| ifneq (,$(ARCHS)) | |
| ifneq (,$(OVERRIDE_ARCHS)) | |
| ifneq (default,$(OVERRIDE_ARCHS)) | |
| BUILD_WEBKIT_BASE := $(BUILD_WEBKIT_BASE) --architecture="$(OVERRIDE_ARCHS)" | |
| endif | |
| OVERRIDE_ARCHS = | |
| else | |
| BUILD_WEBKIT_BASE := $(BUILD_WEBKIT_BASE) --architecture="$(ARCHS)" | |
| endif | |
| endif | |
| ifeq (iosmac,$(SDK_VARIANT)) | |
| BUILD_WEBKIT_BASE += --maccatalyst | |
| endif | |
| ifneq (,$(EXPORT_COMPILE_COMMANDS)) | |
| EXTRA_CFLAGS += -gen-cdb-fragment-path $$(BUILT_PRODUCTS_DIR)/compile_commands | |
| XCODE_OPTIONS += GCC_PRECOMPILE_PREFIX_HEADER=NO | |
| XCODE_OPTIONS += CLANG_ENABLE_MODULE_DEBUGGING=NO | |
| XCODE_OPTIONS += COMPILER_INDEX_STORE_ENABLE=NO | |
| endif | |
| DEFAULT_VERBOSITY := $(shell defaults read org.webkit.BuildConfiguration BuildTranscriptVerbosity 2>/dev/null || echo "default") | |
| VERBOSITY ?= $(DEFAULT_VERBOSITY) | |
| ifeq ($(VERBOSITY),default) | |
| OUTPUT_FILTER = cat | |
| XCODE_OPTIONS += -hideShellScriptEnvironment | |
| else ifeq ($(VERBOSITY),noisy) | |
| OUTPUT_FILTER = cat | |
| else ifeq ($(VERBOSITY),oneline) | |
| OUTPUT_FILTER = $(SCRIPTS_PATH)/filter-build-webkit -f oneline | |
| else | |
| OUTPUT_FILTER = $(SCRIPTS_PATH)/filter-build-webkit | |
| endif | |
| ifeq ($(ASAN),YES) | |
| CONFIG_OPTIONS += --asan | |
| else | |
| ifeq ($(ASAN),NO) | |
| CONFIG_OPTIONS += --no-asan | |
| endif | |
| endif | |
| ifneq ($(CC),) | |
| ifneq ($(CC),cc) # Default value without -R flag | |
| XCODE_OPTIONS += CC=$(CC) | |
| endif | |
| endif | |
| ifeq ($(CODE_COVERAGE),YES) | |
| CONFIG_OPTIONS += --coverage | |
| else | |
| ifeq ($(CODE_COVERAGE),NO) | |
| CONFIG_OPTIONS += --no-coverage | |
| endif | |
| endif | |
| ifneq ($(CPLUSPLUS),) | |
| XCODE_OPTIONS += CPLUSPLUS=$(CPLUSPLUS) | |
| endif | |
| ifeq ($(LIBFUZZER),YES) | |
| CONFIG_OPTIONS += --libfuzzer | |
| else | |
| ifeq ($(LIBFUZZER),NO) | |
| CONFIG_OPTIONS += --no-libfuzzer | |
| endif | |
| endif | |
| ifneq (,$(OTHER_CFLAGS)$(EXTRA_CFLAGS)) | |
| XCODE_OPTIONS += OTHER_CFLAGS='$$(inherited) $(EXTRA_CFLAGS) $(OTHER_CFLAGS)' | |
| endif | |
| ifneq (,$(OTHER_LDFLAGS)) | |
| XCODE_OPTIONS += OTHER_LDFLAGS='$$(inherited) $(OTHER_LDFLAGS)' | |
| endif | |
| ifneq (,$(OTHER_SWIFT_FLAGS)) | |
| XCODE_OPTIONS += OTHER_SWIFT_FLAGS='$$(inherited) $(OTHER_SWIFT_FLAGS)' | |
| endif | |
| ifneq ($(WK_SANITIZER_COVERAGE),) | |
| XCODE_OPTIONS += WK_SANITIZER_COVERAGE=$(WK_SANITIZER_COVERAGE) | |
| endif | |
| ifeq ($(TSAN),YES) | |
| CONFIG_OPTIONS += --tsan | |
| else | |
| ifeq ($(TSAN),NO) | |
| CONFIG_OPTIONS += --no-tsan | |
| endif | |
| endif | |
| ifeq ($(UBSAN),YES) | |
| CONFIG_OPTIONS += --ubsan | |
| else | |
| ifeq ($(UBSAN),NO) | |
| CONFIG_OPTIONS += --no-ubsan | |
| endif | |
| endif | |
| ifeq ($(WK_LTO_MODE),full) | |
| CONFIG_OPTIONS += --lto-mode=full | |
| else ifeq ($(WK_LTO_MODE),thin) | |
| CONFIG_OPTIONS += --lto-mode=thin | |
| else ifeq ($(WK_LTO_MODE),none) | |
| CONFIG_OPTIONS += --lto-mode=none | |
| endif | |
| ANALYZER_XCODE_SETTINGS = RUN_CLANG_STATIC_ANALYZER=YES CLANG_STATIC_ANALYZER_MODE=deep CLANG_ANALYZER_OUTPUT=html | |
| ifneq (,$(ANALYZER_EXEC)) | |
| ANALYZER_XCODE_SETTINGS += CLANG_ANALYZER_EXEC="$(ANALYZER_EXEC)" | |
| endif | |
| ifneq (,$(ANALYZER_FLAGS)) | |
| ANALYZER_XCODE_SETTINGS += CLANG_ANALYZER_OTHER_FLAGS="$(ANALYZER_FLAGS)" | |
| endif | |
| ifneq (,$(ANALYZER_OUTPUT)) | |
| ANALYZER_XCODE_SETTINGS += CLANG_ANALYZER_OUTPUT_DIR="$(ANALYZER_OUTPUT)" | |
| endif | |
| ifeq (,$(PATH_TO_SCAN_BUILD)) | |
| PATH_TO_SCAN_BUILD = scan-build | |
| endif | |
| export DSYMUTIL_NUM_THREADS = $(shell sysctl -n hw.activecpu) | |
| define set_webkit_configuration | |
| $(SCRIPTS_PATH)/set-webkit-configuration $1 $(CONFIG_OPTIONS) | |
| endef | |
| define invoke_xcode | |
| ( \ | |
| echo; \ | |
| echo "===== BUILDING $(BUILD_GOAL) ====="; \ | |
| echo; \ | |
| eval build_webkit_options=(`perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print XcodeOptionString()' -- $(BUILD_WEBKIT_BASE) $(BUILD_WEBKIT_OPTIONS)`); \ | |
| xcodebuild $1 $(OTHER_OPTIONS) $(XCODE_TARGET) "$${build_webkit_options[@]}" $(XCODE_OPTIONS) $2 | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} \ | |
| ) | |
| endef | |
| all: | |
| @$(call set_webkit_configuration,) | |
| @$(call invoke_xcode,,) | |
| debug d: force | |
| @$(call set_webkit_configuration,--debug) | |
| @$(call invoke_xcode,,) | |
| release r: force | |
| @$(call set_webkit_configuration,--release) | |
| @$(call invoke_xcode,,) | |
| release+assert ra: force | |
| @$(call set_webkit_configuration,--release) | |
| @$(call invoke_xcode,,) | |
| release+assert ra: override GCC_PREPROCESSOR_ADDITIONS += ASSERT_ENABLED=1 | |
| testing t: force | |
| @$(call set_webkit_configuration,--debug --force-optimization-level=O3) | |
| @$(call invoke_xcode,,) | |
| analyze: | |
| @$(call set_webkit_configuration,) | |
| @$(call invoke_xcode,analyze,$(ANALYZER_XCODE_SETTINGS)) | |
| @for dir in $$(ls -d $(ANALYZER_OUTPUT)/StaticAnalyzer/*); do \ | |
| mkdir -p $$dir/StaticAnalyzerReports; \ | |
| find $$dir -name 'report-*.html' -exec sh -c 'mv "$$@" "$$0"' $$dir/StaticAnalyzerReports/ {} +; \ | |
| $(PATH_TO_SCAN_BUILD) --generate-index-only $$dir; \ | |
| done | |
| clean: | |
| ifndef XCODE_TARGET | |
| @$(call invoke_xcode,,-alltargets clean) | |
| else | |
| @$(call invoke_xcode,,clean) | |
| endif | |
| force: ; |