Add WebRTC logging control in GPUProcess
[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
5 ifneq (,$(SDKROOT))
6         ifneq (,$(OVERRIDE_SDKROOT))
7                 ifneq (default,$(OVERRIDE_SDKROOT))
8                         XCODE_OPTIONS := $(XCODE_OPTIONS) SDKROOT=$(OVERRIDE_SDKROOT)
9                 endif
10                 OVERRIDE_SDKROOT =
11         else
12                 XCODE_OPTIONS := $(XCODE_OPTIONS) SDKROOT=$(SDKROOT)
13         endif
14 endif
15
16 ifneq (,$(ARCHS))
17         ifneq (,$(OVERRIDE_ARCHS))
18                 ifneq (default,$(OVERRIDE_ARCHS))
19                         XCODE_OPTIONS := $(XCODE_OPTIONS) ARCHS="$(OVERRIDE_ARCHS)"
20                         XCODE_OPTIONS += ONLY_ACTIVE_ARCH=NO
21                 endif
22                 OVERRIDE_ARCHS =
23         else
24                 XCODE_OPTIONS := $(XCODE_OPTIONS) ARCHS="$(ARCHS)"
25                 XCODE_OPTIONS += ONLY_ACTIVE_ARCH=NO
26         endif
27 endif
28
29 ifneq (,$(SDK_VARIANT))
30         XCODE_OPTIONS += SDK_VARIANT="$(SDK_VARIANT)"
31 endif
32
33 ifeq (, $(findstring WK_USE_CCACHE, $(ARGS)))
34         ifneq (, $(shell which ccache))
35                 XCODE_OPTIONS += WK_USE_CCACHE=YES
36         endif
37 endif
38
39 ifeq ($(findstring UseNewBuildSystem,$(ARGS)),)
40         CAN_USE_XCBUILD = $(shell perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print canUseXCBuild()')
41         ifeq ($(CAN_USE_XCBUILD),1)
42                 # Temporarily disable default use of XCBuild until issues with it are ironed out.
43                 #XCODE_OPTIONS += -UseNewBuildSystem=YES
44                 XCODE_OPTIONS += -UseNewBuildSystem=NO
45         else
46                 XCODE_OPTIONS += -UseNewBuildSystem=NO
47         endif
48 endif
49
50 DEFAULT_VERBOSITY := $(shell defaults read org.webkit.BuildConfiguration BuildTranscriptVerbosity 2>/dev/null || echo "default")
51 VERBOSITY ?= $(DEFAULT_VERBOSITY)
52
53 ifeq ($(VERBOSITY),default)
54 OUTPUT_FILTER = cat
55 XCODE_OPTIONS += -hideShellScriptEnvironment
56 else
57 ifeq ($(VERBOSITY),noisy)
58 OUTPUT_FILTER = cat
59 else
60 OUTPUT_FILTER = $(SCRIPTS_PATH)/filter-build-webkit
61 endif
62 endif
63
64 ifeq ($(ASAN),YES)
65 ASAN_OPTION=--asan
66 else
67 ifeq ($(ASAN),NO)
68 ASAN_OPTION=--no-asan
69 endif
70 endif
71
72 ifeq ($(TSAN),YES)
73 TSAN_OPTION=--tsan
74 else
75 ifeq ($(TSAN),NO)
76 TSAN_OPTION=--no-tsan
77 endif
78 endif
79
80 ifeq ($(WK_LTO_MODE),full)
81 WK_LTO_OPTION=--lto-mode=full
82 else ifeq ($(WK_LTO_MODE),thin)
83 WK_LTO_OPTION=--lto-mode=thin
84 else ifeq ($(WK_LTO_MODE),none)
85 WK_LTO_OPTION=--lto-mode=none
86 endif
87
88 export DSYMUTIL_NUM_THREADS = $(shell sysctl -n hw.activecpu)
89
90 # Run xcodebuild with the same PATH with which the Xcode IDE runs, to mitigate unnecessary rebuilds due to PATH differences.
91 # See <rdar://problem/16466196>.
92 export PATH = $(shell getconf PATH)
93
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                 echo; \
103                 echo "===== BUILDING $$(basename "$$(pwd)") ====="; \
104                 echo; \
105                 $1 xcodebuild $(OTHER_OPTIONS) $(XCODE_TARGET) $(XCODE_OPTIONS) $2 | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} \
106         )
107 endef
108
109 all:
110 ifneq (,$(strip $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION)))
111         @$(call set_webkit_configuration,)
112 endif
113         @$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
114
115 debug d: force
116         @$(call set_webkit_configuration,--debug)
117         @$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
118
119 release r: force
120         @$(call set_webkit_configuration,--release)
121         @$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
122
123 release+assert ra: force
124         @$(call set_webkit_configuration,--release)
125         @$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) ASSERT_ENABLED=1 $$(inherited)')
126
127 testing t: force
128         @$(call set_webkit_configuration,--debug --force-optimization-level=O3)
129         @$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
130
131 analyze:
132         @$(call set_webkit_configuration,--debug)
133 ifndef PATH_TO_SCAN_BUILD
134         @$(call invoke_xcode,,GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' RUN_CLANG_STATIC_ANALYZER=YES)
135 else
136         @$(call invoke_xcode,$(PATH_TO_SCAN_BUILD),GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)')
137 endif
138
139 clean:
140 ifndef XCODE_TARGET
141         @$(call invoke_xcode,,-alltargets clean)
142 else
143         @$(call invoke_xcode,,clean)
144 endif
145
146 installsrc:
147 ifndef XCODE_TARGET
148         @$(call invoke_xcode,,-alltargets installsrc SRCROOT="$(SRCROOT)$(PATH_FROM_ROOT)")
149 else
150         @$(call invoke_xcode,,installsrc SRCROOT="$(SRCROOT)$(PATH_FROM_ROOT)")
151 endif
152
153 force: ;