Unreviewed, rolling out r237280.
[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 ifeq (iosmac,$(SDK_VARIANT))
38         XCODE_OPTIONS += SDK_VARIANT=iosmac
39         XCODE_OPTIONS += WK_ALTERNATE_FRAMEWORKS_DIR=/System/iOSSupport
40 endif
41
42 DEFAULT_VERBOSITY := $(shell defaults read org.webkit.BuildConfiguration BuildTranscriptVerbosity 2>/dev/null || echo "default")
43 VERBOSITY ?= $(DEFAULT_VERBOSITY)
44
45 ifeq ($(VERBOSITY),default)
46 OUTPUT_FILTER = cat
47 XCODE_OPTIONS += -hideShellScriptEnvironment
48 else
49 ifeq ($(VERBOSITY),noisy)
50 OUTPUT_FILTER = cat
51 else
52 OUTPUT_FILTER = $(SCRIPTS_PATH)/filter-build-webkit
53 endif
54 endif
55
56 ifeq ($(ASAN),YES)
57 ASAN_OPTION=--asan
58 else
59 ifeq ($(ASAN),NO)
60 ASAN_OPTION=--no-asan
61 endif
62 endif
63
64 ifeq ($(WK_LTO_MODE),full)
65 WK_LTO_OPTION=--lto-mode=full
66 else ifeq ($(WK_LTO_MODE),thin)
67 WK_LTO_OPTION=--lto-mode=thin
68 else ifeq ($(WK_LTO_MODE),none)
69 WK_LTO_OPTION=--lto-mode=none
70 endif
71
72 export DSYMUTIL_NUM_THREADS = $(shell sysctl -n hw.activecpu)
73
74 # Run xcodebuild with the same PATH with which the Xcode IDE runs, to mitigate unnecessary rebuilds due to PATH differences.
75 # See <rdar://problem/16466196>.
76 export PATH = $(shell getconf PATH)
77
78 all: set_asan_configuration
79         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
80
81 debug d development dev develop: force
82         $(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(WK_LTO_OPTION)
83         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
84
85 release r deployment dep deploy: force
86         $(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION) $(WK_LTO_OPTION)
87         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
88
89 analyze:
90         $(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(WK_LTO_OPTION)
91 ifndef PATH_TO_SCAN_BUILD
92         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) RUN_CLANG_STATIC_ANALYZER=YES | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
93 else
94         ( $(SET_COLOR_DIAGNOSTICS_ARG); $(PATH_TO_SCAN_BUILD) xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
95 endif
96
97 set_asan_configuration:
98 ifneq (,$(ASAN_OPTION))
99         $(SCRIPTS_PATH)/set-webkit-configuration $(ASAN_OPTION)
100 endif
101
102 clean:
103         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) -alltargets clean $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
104
105 force: ;