Unreviewed, rolling out r245281.
[WebKit-https.git] / Makefile.shared
1 SCRIPTS_PATH ?= ../Tools/Scripts
2
3 SET_COLOR_DIAGNOSTICS_ARG = if [[ -t 1 ]]; then COLOR_DIAGNOSTICS_ARG="COLOR_DIAGNOSTICS=YES"; fi
4 XCODE_OPTIONS = `perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print XcodeOptionString()' -- $(BUILD_WEBKIT_OPTIONS)` $${COLOR_DIAGNOSTICS_ARG} $(ARGS)
5
6 ifneq (,$(SDKROOT))
7         ifneq (,$(OVERRIDE_SDKROOT))
8                 ifneq (default,$(OVERRIDE_SDKROOT))
9                         XCODE_OPTIONS := $(XCODE_OPTIONS) SDKROOT=$(OVERRIDE_SDKROOT)
10                 endif
11                 OVERRIDE_SDKROOT =
12         else
13                 XCODE_OPTIONS := $(XCODE_OPTIONS) SDKROOT=$(SDKROOT)
14         endif
15 endif
16
17 ifneq (,$(ARCHS))
18         ifneq (,$(OVERRIDE_ARCHS))
19                 ifneq (default,$(OVERRIDE_ARCHS))
20                         XCODE_OPTIONS := $(XCODE_OPTIONS) ARCHS="$(OVERRIDE_ARCHS)"
21                         XCODE_OPTIONS += ONLY_ACTIVE_ARCH=NO
22                 endif
23                 OVERRIDE_ARCHS =
24         else
25                 XCODE_OPTIONS := $(XCODE_OPTIONS) ARCHS="$(ARCHS)"
26                 XCODE_OPTIONS += ONLY_ACTIVE_ARCH=NO
27                 # Make Plugin.32 and Plugin.64 build even when they can't be built for the specified architecture.
28                 ifeq ($(ARCHS),i386)
29                         XCODE_OPTIONS += VALID_ARCHS=i386
30                 endif
31                 ifeq ($(ARCHS),x86_64)
32                         XCODE_OPTIONS += VALID_ARCHS=x86_64
33                 endif
34         endif
35 endif
36
37 ifneq (,$(SDK_VARIANT))
38         XCODE_OPTIONS += SDK_VARIANT="$(SDK_VARIANT)"
39 endif
40
41 ifeq (, $(findstring WK_USE_CCACHE, $(ARGS)))
42         ifneq (, $(shell which ccache))
43                 XCODE_OPTIONS += WK_USE_CCACHE=YES
44         endif
45 endif
46
47 ifeq ($(findstring UseNewBuildSystem,$(ARGS)),)
48         CAN_USE_XCBUILD = $(shell perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print canUseXCBuild()')
49         ifeq ($(CAN_USE_XCBUILD),1)
50                 XCODE_OPTIONS += -UseNewBuildSystem=YES
51                 XCODE_OPTIONS += USE_NEW_BUILD_SYSTEM=YES
52         else
53                 XCODE_OPTIONS += -UseNewBuildSystem=NO
54         endif
55 endif
56
57 DEFAULT_VERBOSITY := $(shell defaults read org.webkit.BuildConfiguration BuildTranscriptVerbosity 2>/dev/null || echo "default")
58 VERBOSITY ?= $(DEFAULT_VERBOSITY)
59
60 ifeq ($(VERBOSITY),default)
61 OUTPUT_FILTER = cat
62 XCODE_OPTIONS += -hideShellScriptEnvironment
63 else
64 ifeq ($(VERBOSITY),noisy)
65 OUTPUT_FILTER = cat
66 else
67 OUTPUT_FILTER = $(SCRIPTS_PATH)/filter-build-webkit
68 endif
69 endif
70
71 ifeq ($(ASAN),YES)
72 ASAN_OPTION=--asan
73 else
74 ifeq ($(ASAN),NO)
75 ASAN_OPTION=--no-asan
76 endif
77 endif
78
79 ifeq ($(WK_LTO_MODE),full)
80 WK_LTO_OPTION=--lto-mode=full
81 else ifeq ($(WK_LTO_MODE),thin)
82 WK_LTO_OPTION=--lto-mode=thin
83 else ifeq ($(WK_LTO_MODE),none)
84 WK_LTO_OPTION=--lto-mode=none
85 endif
86
87 export DSYMUTIL_NUM_THREADS = $(shell sysctl -n hw.activecpu)
88
89 # Run xcodebuild with the same PATH with which the Xcode IDE runs, to mitigate unnecessary rebuilds due to PATH differences.
90 # See <rdar://problem/16466196>.
91 export PATH = $(shell getconf PATH)
92
93 all: set_asan_configuration
94         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
95
96 debug d development dev develop: force
97         $(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(WK_LTO_OPTION)
98         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
99
100 release r deployment dep deploy: force
101         $(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION) $(WK_LTO_OPTION)
102         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
103
104 analyze:
105         $(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(WK_LTO_OPTION)
106 ifndef PATH_TO_SCAN_BUILD
107         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) RUN_CLANG_STATIC_ANALYZER=YES | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
108 else
109         ( $(SET_COLOR_DIAGNOSTICS_ARG); $(PATH_TO_SCAN_BUILD) xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
110 endif
111
112 set_asan_configuration:
113 ifneq (,$(ASAN_OPTION))
114         $(SCRIPTS_PATH)/set-webkit-configuration $(ASAN_OPTION)
115 endif
116
117 clean:
118         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) -alltargets clean $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
119
120 force: ;