Simplify building with ASan
[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         XCODE_OPTIONS += SDKROOT=$(SDKROOT)
8 endif
9
10 ifneq (,$(ARCHS))
11         XCODE_OPTIONS += ARCHS="$(ARCHS)"
12         XCODE_OPTIONS += ONLY_ACTIVE_ARCH=NO
13 endif
14
15 DEFAULT_VERBOSITY := $(shell defaults read org.webkit.BuildConfiguration BuildTranscriptVerbosity 2>/dev/null || echo "default")
16 VERBOSITY ?= $(DEFAULT_VERBOSITY)
17
18 ifeq ($(VERBOSITY),default)
19 OUTPUT_FILTER = grep -v setenv
20 else
21 ifeq ($(VERBOSITY),noisy)
22 OUTPUT_FILTER = cat
23 else
24 OUTPUT_FILTER = $(SCRIPTS_PATH)/filter-build-webkit
25 endif
26 endif
27
28 ifeq ($(ASAN),YES)
29 ASAN_OPTION=--asan
30 else
31 ifeq ($(ASAN),NO)
32 ASAN_OPTION=--no-asan
33 endif
34 endif
35
36 export DSYMUTIL_NUM_THREADS = $(shell sysctl -n hw.activecpu)
37
38 all: set_asan_configuration
39         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
40
41 debug d development dev develop: force
42         $(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION)
43         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
44
45 release r deployment dep deploy: force
46         $(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION)
47         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
48
49 analyze:
50         $(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION)
51 ifndef PATH_TO_SCAN_BUILD
52         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) RUN_CLANG_STATIC_ANALYZER=YES | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
53 else
54         ( $(SET_COLOR_DIAGNOSTICS_ARG); $(PATH_TO_SCAN_BUILD) xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
55 endif
56
57 set_asan_configuration:
58 ifneq (,$(ASAN_OPTION))
59         $(SCRIPTS_PATH)/set-webkit-configuration $(ASAN_OPTION)
60 endif
61
62 clean:
63         ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) -alltargets clean $(XCODE_OPTIONS) | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} )
64
65 force: ;