forked from facebook/infer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.config
214 lines (178 loc) · 6.96 KB
/
Makefile.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
ORIG_SHELL := $(shell echo "$$SHELL")
SHELL := bash -e -o pipefail -u
ORIG_SHELL_PATH := $(shell printf "%s" "$$PATH")
# Make infer crash a bit more often to detect issues in the way we call infer within this repo, eg,
# using deprecated options.
export INFER_STRICT_MODE := 1
include $(ROOT_DIR)/Makefile.autoconf
# possible values:
# - dev: flambda optimizations disabled, build warnings are errors
# - dev-noerror: flambda optimizations disabled, build warnings do not fail the build
# - opt: flambda optimizations enabled, build warnings do not fail the build
BUILD_MODE = dev
DUNE_BUILD = dune build --profile=$(BUILD_MODE)
PLATFORM := $(shell uname)
COPY := cp -f
COPY_DIR := cp -Rf
REMOVE := rm -f
REMOVE_DIR := rm -rf
ABSOLUTE_ROOT_DIR := $(shell cd $(ROOT_DIR) && pwd)
DEPENDENCIES_DIR := $(ABSOLUTE_ROOT_DIR)/dependencies
DOCKER_DIR := $(ABSOLUTE_ROOT_DIR)/docker
EXAMPLES_DIR := $(ABSOLUTE_ROOT_DIR)/examples
INFER_DIR := $(ABSOLUTE_ROOT_DIR)/infer
FCP_DIR := $(ABSOLUTE_ROOT_DIR)/facebook-clang-plugins
M4_DIR := $(ABSOLUTE_ROOT_DIR)/m4
SCRIPT_DIR := $(ABSOLUTE_ROOT_DIR)/scripts
WEBSITE_DIR := $(ABSOLUTE_ROOT_DIR)/website
FCP_CLANG_OCAML_DIR := $(FCP_DIR)/clang-ocaml
ANNOTATIONS_DIR := $(INFER_DIR)/annotations
BIN_DIR := $(INFER_DIR)/bin
ETC_DIR := $(INFER_DIR)/etc
LIB_DIR := $(INFER_DIR)/lib
MAN_DIR := $(INFER_DIR)/man
MODELS_DIR := $(INFER_DIR)/models
JAVA_BUILTINS_DIR := $(MODELS_DIR)/java/builtins
JAVA_MODELS_DIR := $(MODELS_DIR)/java/src
SRC_DIR := $(INFER_DIR)/src
BUILD_DIR := $(INFER_DIR)/_build
JAVA_LIB_DIR := $(LIB_DIR)/java
INFER_BIN := $(BIN_DIR)/infer
INFER_COMMANDS := \
infer-analyze \
infer-capture \
infer-compile \
infer-debug \
infer-explore \
infer-help \
infer-report \
infer-reportdiff \
infer-run \
INFERTOP_BIN := $(BIN_DIR)/infertop.bc.exe
INFERUNIT_BIN := $(BIN_DIR)/inferunit.bc.exe
CHECKCOPYRIGHT_BIN := $(BIN_DIR)/checkCopyright
INFER_COMMAND_MANUALS := $(INFER_COMMANDS:%=$(MAN_DIR)/man1/%.1)
INFER_COMMAND_TEXT_MANUALS := $(INFER_COMMANDS:%=$(MAN_DIR)/man1/%.txt)
INFER_MANUAL := $(MAN_DIR)/man1/infer.1
INFER_GROFF_MANUALS := $(INFER_COMMAND_MANUALS) $(INFER_MANUAL)
INFER_GROFF_MANUALS_GZIPPED := $(INFER_GROFF_MANUALS:=.gz)
INFER_TEXT_MANUAL := $(MAN_DIR)/man1/infer.txt
INFER_FULL_TEXT_MANUAL := $(MAN_DIR)/man1/infer-full.txt
INFER_TEXT_MANUALS := $(INFER_COMMAND_TEXT_MANUALS) $(INFER_TEXT_MANUAL) $(INFER_FULL_TEXT_MANUAL)
INFER_MANUALS := $(INFER_GROFF_MANUALS) $(INFER_TEXT_MANUALS)
ifeq ($(BUILD_JAVA_ANALYZERS),yes)
JAVA_HOME := $(USER_JAVA_HOME)
endif
# marker to keep track of when models have been rebuilt
MODELS_RESULTS_FILE := $(LIB_DIR)/models.sql
ANDROID_JAR := $(LIB_DIR)/java/android/android-23.jar
GUAVA_JAR := $(DEPENDENCIES_DIR)/java/guava/guava-23.0.jar
INFER_ANNOTATIONS_JAR := $(ANNOTATIONS_DIR)/annotations.jar
JACKSON_JAR := $(DEPENDENCIES_DIR)/java/jackson/jackson-2.2.3.jar
JSR_305_JAR := $(DEPENDENCIES_DIR)/java/jsr-305/jsr305.jar
JAVA_MODELS_JAR := $(LIB_DIR)/java/models.jar
JAVA_DEPS_NO_MODELS := \
$(ANDROID_JAR) $(GUAVA_JAR) $(JACKSON_JAR) $(JSR_305_JAR) $(INFER_ANNOTATIONS_JAR) \
$(INFER_BIN)
JAVA_DEPS := $(JAVA_DEPS_NO_MODELS) $(JAVA_MODELS_JAR) $(MODELS_RESULTS_FILE)
CLANG_DEPS_NO_MODELS := $(INFER_BIN)
CLANG_DEPS := $(CLANG_DEPS_NO_MODELS) $(MODELS_RESULTS_FILE)
XCODE_ISYSROOT_SUFFIX := Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
ifeq ($(wildcard $(XCODE_BASE)/$(XCODE_ISYSROOT_SUFFIX)),)
XCODE_ISYSROOT_SUFFIX := SDKs/MacOSX.sdk
endif
ifeq ($(HAS_OBJC),yes)
XCODE_ISYSROOT := $(XCODE_BASE)/$(XCODE_ISYSROOT_SUFFIX)
endif
define copy_or_same_file
$(COPY) "$(1)" "$(2)" || diff -q "$(1)" "$(2)"
endef
INTERACTIVE := $(shell [ -t 0 ] && ! [ x"$$TERM" = xdumb ] && echo 1)
SILENT := $(findstring s,$(filter-out -%,$(firstword $(MAKEFLAGS))))
ifeq (1,$(INTERACTIVE))
TERM_ERROR := $(shell printf '\e[31;1m')
TERM_INFO := $(shell printf '\e[;1m')
TERM_SUCCESS := $(shell printf '\e[;2m')
TERM_RESET := $(shell printf '\e[0m')
endif
ifneq ($(VERBOSE),1)
# quiet
QUIET := @
endif
MAKE := $(MAKE) INTERACTIVE=$(INTERACTIVE)
# check if pid_max can be found else default to whatever
KERNEL_PID_MAX_FILE := /proc/sys/kernel/pid_max
MAX_PID_SIZE := $(shell \
[ -r $(KERNEL_PID_MAX_FILE) ] \
&& echo $$(( $$(wc -m < $(KERNEL_PID_MAX_FILE)) - 1 )) \
|| echo 5)
# Arguments:
# $(1) is a string describing the command
# $(2) is the command to run
#
ifeq ($(VERBOSE),1)
define silent_on_success
$(2)
endef
else
# Run and time the command and redirect its stdout and stderr to files. Display info about the
# command only in case of error. Try to be as helpful as possible in the error case.
#
# The PID of the process is used in the names of the output files, and as a prefix for each error
# message so that it's possible to piece error messages together even when they are interleaved with
# other messages from concurrent `make` processes.
#
# Detect if we are already wrapped inside a silent_on_success call and try not to clutter the output
# too much in that case.
define silent_on_success
if [ -n "$${INSIDE_SILENT_ON_SUCCESS-}" ]; then \
echo '*** inner $(1)'; \
echo '*** inner command: $(2)'; \
echo '*** inner CWD: $(CURDIR)'; \
($(2)); \
exit $$?; \
fi; \
export INSIDE_SILENT_ON_SUCCESS=1; \
HASH="$$$$"; \
UNIX_START_DATE=$$(date +"%s"); \
HUMAN_START_DATE=$$(date +"%H:%M:%S"); \
if [ -z $(SILENT) ]; then \
printf '[%s][%$(MAX_PID_SIZE)s] $(TERM_INFO)%s...$(TERM_RESET)\n' \
"$$HUMAN_START_DATE" "$$HASH" "$(1)"; \
fi; \
$(MKDIR_P) $(ABSOLUTE_ROOT_DIR)/_build_logs; \
ERRCODE=0; \
($(2)) 1>$(ABSOLUTE_ROOT_DIR)/_build_logs/cmd-$$HASH.out \
2>$(ABSOLUTE_ROOT_DIR)/_build_logs/cmd-$$HASH.err \
|| ERRCODE=$$?; \
if [ $$ERRCODE != 0 ]; then \
echo "$(TERM_ERROR)[*ERROR**][$$HASH] *** ERROR '$(1)'$(TERM_RESET)" >&2; \
echo "$(TERM_ERROR)[*ERROR**][$$HASH] *** command: '"'$(2)'"'$(TERM_RESET)" >&2; \
echo "$(TERM_ERROR)[*ERROR**][$$HASH] *** CWD: '$(CURDIR)'$(TERM_RESET)" >&2; \
echo "$(TERM_ERROR)[*ERROR**][$$HASH] *** stdout:$(TERM_RESET)" >&2; \
sed -e "s/^\(.*\)$$/$(TERM_ERROR)[*ERROR**][$$HASH]$(TERM_RESET) \1/" \
$(ABSOLUTE_ROOT_DIR)/_build_logs/cmd-$$HASH.out; >&2; \
echo "$(TERM_ERROR)[*ERROR**][$$HASH] *** stderr:$(TERM_RESET)" >&2; \
sed -e "s/^\(.*\)$$/$(TERM_ERROR)[*ERROR**][$$HASH]$(TERM_RESET) \1/" \
$(ABSOLUTE_ROOT_DIR)/_build_logs/cmd-$$HASH.err; >&2; \
exit $$ERRCODE; \
elif [ -z $(SILENT) ]; then \
UNIX_END_DATE=$$(date +"%s"); \
printf '[%7ss][%$(MAX_PID_SIZE)s] $(TERM_SUCCESS)SUCCESS %s$(TERM_RESET)\n' \
"$$(($$UNIX_END_DATE - $$UNIX_START_DATE))" "$$HASH" "$(1)"; \
fi
endef
endif
# print any variable for Makefile debugging
print-%:
$(QUIET)echo '$*=$($*)'
TESTLOCK := $(INFER_DIR)/tests/testlock.py
ifeq ($(IS_FACEBOOK_TREE),yes)
MAIN_GIT_BRANCH := master
else
MAIN_GIT_BRANCH := main
endif