AX: AXIsolatedTree::updateChildren sometimes fails to update isolated subtrees when...
[WebKit-https.git] / Makefile.shared
1 SCRIPTS_PATH ?= ../Tools/Scripts
2
3 XCODE_OPTIONS = `perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print XcodeOptionString()' -- $(BUILD_WEBKIT_OPTIONS)` $${COLOR_DIAGNOSTICS_ARG} $(ARGS)
4 ifeq (ON,$(ENABLE_LLVM_PROFILE_GENERATION))
5         XCODE_OPTIONS += ENABLE_LLVM_PROFILE_GENERATION=ENABLE_LLVM_PROFILE_GENERATION
6 endif
7
8 ifeq ($(USE_WORKSPACE),YES)
9 SCHEME ?= $(notdir $(CURDIR))
10 WORKSPACE_PATH ?= $(dir $(lastword $(MAKEFILE_LIST)))WebKit.xcworkspace
11 XCODE_TARGET = -workspace $(WORKSPACE_PATH) -scheme "$(SCHEME)"
12 XCODE_OPTIONS += WK_VALIDATE_DEPENDENCIES=YES_ERROR
13 else
14 USE_WORKSPACE =
15 endif
16
17 ifneq (,$(SDKROOT))
18         ifneq (,$(OVERRIDE_SDKROOT))
19                 ifneq (default,$(OVERRIDE_SDKROOT))
20                         XCODE_OPTIONS := $(XCODE_OPTIONS) SDKROOT=$(OVERRIDE_SDKROOT)
21                 endif
22                 OVERRIDE_SDKROOT =
23         else
24                 XCODE_OPTIONS := $(XCODE_OPTIONS) SDKROOT=$(SDKROOT)
25         endif
26 endif
27
28 ifneq (,$(ARCHS))
29         ifneq (,$(OVERRIDE_ARCHS))
30                 ifneq (default,$(OVERRIDE_ARCHS))
31                         XCODE_OPTIONS := $(XCODE_OPTIONS) ARCHS="$(OVERRIDE_ARCHS)"
32                         XCODE_OPTIONS += ONLY_ACTIVE_ARCH=NO
33                 endif
34                 OVERRIDE_ARCHS =
35         else
36                 XCODE_OPTIONS := $(XCODE_OPTIONS) ARCHS="$(ARCHS)"
37                 XCODE_OPTIONS += ONLY_ACTIVE_ARCH=NO
38         endif
39 endif
40
41 ifneq (,$(SDK_VARIANT))
42         XCODE_OPTIONS += SDK_VARIANT="$(SDK_VARIANT)"
43 endif
44
45 ifeq (, $(findstring WK_USE_CCACHE, $(ARGS)))
46         ifneq (, $(shell which ccache))
47                 XCODE_OPTIONS += WK_USE_CCACHE=YES
48         endif
49 endif
50
51 ifneq (,$(EXPORT_COMPILE_COMMANDS))
52                 XCODE_OPTIONS += OTHER_CFLAGS='$$(inherited) -gen-cdb-fragment-path $$(BUILT_PRODUCTS_DIR)/compile_commands'
53                 XCODE_OPTIONS += GCC_PRECOMPILE_PREFIX_HEADER=NO
54                 XCODE_OPTIONS += CLANG_ENABLE_MODULE_DEBUGGING=NO
55                 XCODE_OPTIONS += COMPILER_INDEX_STORE_ENABLE=NO
56 endif
57
58 DEFAULT_VERBOSITY := $(shell defaults read org.webkit.BuildConfiguration BuildTranscriptVerbosity 2>/dev/null || echo "default")
59 VERBOSITY ?= $(DEFAULT_VERBOSITY)
60
61 ifeq ($(VERBOSITY),default)
62 OUTPUT_FILTER = cat
63 XCODE_OPTIONS += -hideShellScriptEnvironment
64 else
65 ifeq ($(VERBOSITY),noisy)
66 OUTPUT_FILTER = cat
67 else
68 OUTPUT_FILTER = $(SCRIPTS_PATH)/filter-build-webkit
69 endif
70 endif
71
72 ifeq ($(ASAN),YES)
73 CONFIG_OPTIONS += --asan
74 else
75 ifeq ($(ASAN),NO)
76 CONFIG_OPTIONS += --no-asan
77 endif
78 endif
79
80 ifeq ($(TSAN),YES)
81 CONFIG_OPTIONS += --tsan
82 else
83 ifeq ($(TSAN),NO)
84 CONFIG_OPTIONS += --no-tsan
85 endif
86 endif
87
88 ifeq ($(UBSAN),YES)
89 CONFIG_OPTIONS += --ubsan
90 else
91 ifeq ($(UBSAN),NO)
92 CONFIG_OPTIONS += --no-ubsan
93 endif
94 endif
95
96 ifeq ($(WK_LTO_MODE),full)
97 CONFIG_OPTIONS += --lto-mode=full
98 else ifeq ($(WK_LTO_MODE),thin)
99 CONFIG_OPTIONS += --lto-mode=thin
100 else ifeq ($(WK_LTO_MODE),none)
101 CONFIG_OPTIONS += --lto-mode=none
102 endif
103
104 export DSYMUTIL_NUM_THREADS = $(shell sysctl -n hw.activecpu)
105
106 # Run xcodebuild with the same PATH with which the Xcode IDE runs, to mitigate unnecessary rebuilds due to PATH differences.
107 # See <rdar://problem/16466196>.
108 export PATH = $(shell getconf PATH)
109
110
111 define set_webkit_configuration
112         $(SCRIPTS_PATH)/set-webkit-configuration $1 $(CONFIG_OPTIONS)
113 endef
114
115 define invoke_xcode
116         ( \
117                 [[ -t 1 ]] && COLOR_DIAGNOSTICS_ARG="COLOR_DIAGNOSTICS=YES"; \
118                 echo; \
119                 echo "===== BUILDING $(if $(USE_WORKSPACE),$(SCHEME),$(notdir $(CURDIR))) ====="; \
120                 echo; \
121                 $1 xcodebuild $2 $(OTHER_OPTIONS) $(XCODE_TARGET) $(XCODE_OPTIONS) $3 | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} \
122         )
123 endef
124
125 all:
126         @$(call set_webkit_configuration,)
127         @$(call invoke_xcode,,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
128
129 debug d: force
130         @$(call set_webkit_configuration,--debug)
131         @$(call invoke_xcode,,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
132
133 release r: force
134         @$(call set_webkit_configuration,--release)
135         @$(call invoke_xcode,,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
136
137 release+assert ra: force
138         @$(call set_webkit_configuration,--release)
139         @$(call invoke_xcode,,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) ASSERT_ENABLED=1 $$(inherited)')
140
141 testing t: force
142         @$(call set_webkit_configuration,--debug --force-optimization-level=O3)
143         @$(call invoke_xcode,,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
144
145 analyze:
146         @$(call set_webkit_configuration,--debug)
147         @$(call invoke_xcode,$(PATH_TO_SCAN_BUILD),build analyze,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
148
149 clean:
150 ifndef XCODE_TARGET
151         @$(call invoke_xcode,,,-alltargets clean)
152 else
153         @$(call invoke_xcode,,,clean)
154 endif
155
156 installsrc:
157 ifndef XCODE_TARGET
158         @$(call invoke_xcode,,,-alltargets installsrc SRCROOT="$(SRCROOT)$(PATH_FROM_ROOT)")
159 else
160         @$(call invoke_xcode,,,installsrc SRCROOT="$(SRCROOT)$(PATH_FROM_ROOT)")
161 endif
162
163 force: ;