|
|
|
# Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
[make] s/ocamlbuild/jbuilder/g
Summary:
Use jbuilder to build infer instead of ocamlbuild. This is mainly to get faster builds:
```
times in 10ms, ±differences measured in speedups, 4 cores
| | ocb total | jb | ±total | ocb user | jb | ±user | ocb cpu | jb | ±cpu | ocb sys | jb | ±sys |
|-----------------------------------+-----------+------+--------+----------+------+-------+---------+-----+------+---------+------+------|
| byte from scratch | 6428 | 2456 | 2.62 | 7743 | 6662 | 1.16 | 138 | 331 | 2.40 | 1184 | 1477 | 0.80 |
| native from scratch | 9841 | 4289 | 2.29 | 9530 | 8834 | 1.08 | 110 | 245 | 2.23 | 1373 | 1712 | 0.80 |
| byte after native | 29578 | 1602 | 18.46 | 4514 | 4640 | 0.97 | 170 | 325 | 1.91 | 543 | 576 | 0.94 |
| change infer.ml byte | 344 | 282 | 1.22 | 292 | 215 | 1.36 | 96 | 99 | 1.03 | 040 | 066 | 0.61 |
| change infer.ml native | 837 | 223 | 3.75 | 789 | 174 | 4.53 | 98 | 99 | 1.01 | 036 | 47 | 0.77 |
| change Config.ml byte | 451 | 339 | 1.33 | 382 | 336 | 1.14 | 97 | 122 | 1.26 | 056 | 80 | 0.70 |
| change Config.ml native | 4024 | 1760 | 2.29 | 4585 | 4225 | 1.09 | 127 | 276 | 2.17 | 559 | 644 | 0.87 |
| change cFrontend_config.ml byte | 348 | 643 | 0.54 | 297 | 330 | 0.90 | 96 | 67 | 0.70 | 038 | 102 | 0.37 |
| change cFrontend_config.ml native | 1480 | 584 | 2.53 | 1435 | 906 | 1.58 | 106 | 185 | 1.75 | 136 | 178 | 0.76 |
#+TBLFM: $4=$2/$3;f2::$7=$5/$6;f2::$10=$9/$8;f2::$13=$11/$12;f2
50 cores
| | ocb total | jb | ±total | ocb user | jb | ±user | ocb cpu | jb | ±cpu | ocb sys | jb | ±sys |
|---------------------+-----------+------+--------+----------+------+-------+---------+----+------+---------+------+------|
| byte from scratch | 9114 | 2061 | 4.42 | 9334 | 5133 | 1.82 | | | 0/0 | 2566 | 1726 | 1.49 |
| native from scratch | 13481 | 3967 | 3.40 | 12291 | 7608 | 1.62 | | | 0/0 | 3003 | 2100 | 1.43 |
| byte after native | 3467 | 1476 | 2.35 | 5067 | 3912 | 1.30 | | | 0/0 | 971 | 801 | 1.21 |
#+TBLFM: $4=$2/$3;f2::$7=$5/$6;f2::$10=$9/$8;f2::$13=$11/$12;f2
```
Menu:
1. Write a jbuild file, autogenerated from jbuild.in because we need to fill in
some information at build-time (really, at configure time, but TODO), such as
whether or not clang is enabled.
2. Nuke lots of stuff from infer/src/Makefile that is now in the jbuild file
3. The jbuild file lives in infer/src/ so it can see all the sources. If we put it somewhere else, eg, infer/, then `jbuilder` scans too many files (all irrelevant) and takes 2.5s to start instead of .8s. Adding irrelevant directories to jbuild-ignore does not help.
4. jbuilder does not support subdirectories, so resort to listing all the
source files in the generated jbuild (only source directories need to be
manually listed in jbuild.in though). Still, the generated .merlin is wrong
and makes merlin find source files in _build, so manually tune it to get
good merlin support. We also lose some of merlin for unit tests as it
cannot see their build artefacts anymore.
5. checkCopyright gets its own jbuild because it's standalone. Also, remove
some deprecation warnings in checkCopyright due to the new version of Core from
a while ago.
6. Drop less-used Makefile features (they had regressed anyway) such as
building individual modules. Also, building mod_dep.pdf now takes all the
source files available so they better build (before, it would only take the
source files from the config, eg with or without clang) (that's pretty minor).
7. The toplevel is now built as a custom toplevel because that was easier. It
should soon be even easier: https://github.com/janestreet/jbuilder/issues/210
8. Move BUILTINS.mli to BUILTINS.ml because jbuilder is not happy about
interface files without implementations.
In particular, I did not try to migrate too much of the Makefile logic to jbuilder,
more can be done in the future.
Reviewed By: jberdine
Differential Revision: D5573661
fbshipit-source-id: 4ca6d8f
7 years ago
|
|
|
BUILD_DIR = $(SRC_DIR)/_build
|
|
|
|
|
|
|
|
JAVA_LIB_DIR = $(LIB_DIR)/java
|
|
|
|
SPECS_LIB_DIR = $(LIB_DIR)/specs
|
|
|
|
|
|
|
|
PYTHON_DIR = $(LIB_DIR)/python
|
|
|
|
PYTHON_LIB_DIR = $(PYTHON_DIR)/inferlib
|
|
|
|
CAPTURE_LIB_DIR = $(PYTHON_LIB_DIR)/capture
|
|
|
|
|
|
|
|
INFER_BIN = $(BIN_DIR)/infer
|
[CLI] switch to infer-<command> (symlinks) executables
Summary:
Introduce `infer-<command>` for each command, except for internal commands
(only `infer-clang` for now) which are not exported. Install these executables
(which are just symlinks to `infer`) on `make install`. The main executable
looks at the name it was invoked with to figure out if it should behave as a
particular command.
Get rid of `InferClang`, `InferAnalyze`, and `InferPrint`. As a bonus, we now
only need to build one executable: `infer`, which should be a few seconds
faster (less link time).
`InferAnalyze` is now `infer-analyze` and `InferPrint` is `infer-print`. To run
`InferClang`, use a symlink named `clang`, `clang++`, etc. to `infer`. There
are such symlinks available in "infer/lib/wrappers/" already.
I also noticed that the scripts in xcodebuild_wrappers/ don't seem useful
anymore, so use wrappers/ instead, as for `make`.
Reviewed By: mbouaziz
Differential Revision: D5036495
fbshipit-source-id: 4a90030
8 years ago
|
|
|
INFER_COMMANDS = \
|
|
|
|
infer-analyze \
|
|
|
|
infer-capture \
|
|
|
|
infer-compile \
|
|
|
|
infer-explore \
|
[CLI] switch to infer-<command> (symlinks) executables
Summary:
Introduce `infer-<command>` for each command, except for internal commands
(only `infer-clang` for now) which are not exported. Install these executables
(which are just symlinks to `infer`) on `make install`. The main executable
looks at the name it was invoked with to figure out if it should behave as a
particular command.
Get rid of `InferClang`, `InferAnalyze`, and `InferPrint`. As a bonus, we now
only need to build one executable: `infer`, which should be a few seconds
faster (less link time).
`InferAnalyze` is now `infer-analyze` and `InferPrint` is `infer-print`. To run
`InferClang`, use a symlink named `clang`, `clang++`, etc. to `infer`. There
are such symlinks available in "infer/lib/wrappers/" already.
I also noticed that the scripts in xcodebuild_wrappers/ don't seem useful
anymore, so use wrappers/ instead, as for `make`.
Reviewed By: mbouaziz
Differential Revision: D5036495
fbshipit-source-id: 4a90030
8 years ago
|
|
|
infer-report \
|
|
|
|
infer-reportdiff \
|
|
|
|
infer-run \
|
|
|
|
|
|
|
|
INFERTOP_BIN = $(BIN_DIR)/infertop.bc
|
|
|
|
INFERUNIT_BIN = $(BIN_DIR)/InferUnit
|
|
|
|
|
|
|
|
INFER_CREATE_TRACEVIEW_LINKS = InferCreateTraceViewLinks
|
|
|
|
INFER_CREATE_TRACEVIEW_LINKS_BIN = $(BIN_DIR)/$(INFER_CREATE_TRACEVIEW_LINKS)
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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 = \
|
|
|
|
$(addprefix $(PYTHON_LIB_DIR)/, \
|
|
|
|
analyze.py bucklib.py config.py issues.py jwlib.py source.py utils.py) \
|
|
|
|
$(addprefix $(CAPTURE_LIB_DIR)/, util.py) \
|
|
|
|
$(ANDROID_JAR) $(GUAVA_JAR) $(JACKSON_JAR) $(JSR_305_JAR) $(INFER_ANNOTATIONS_JAR) \
|
[CLI] switch to infer-<command> (symlinks) executables
Summary:
Introduce `infer-<command>` for each command, except for internal commands
(only `infer-clang` for now) which are not exported. Install these executables
(which are just symlinks to `infer`) on `make install`. The main executable
looks at the name it was invoked with to figure out if it should behave as a
particular command.
Get rid of `InferClang`, `InferAnalyze`, and `InferPrint`. As a bonus, we now
only need to build one executable: `infer`, which should be a few seconds
faster (less link time).
`InferAnalyze` is now `infer-analyze` and `InferPrint` is `infer-print`. To run
`InferClang`, use a symlink named `clang`, `clang++`, etc. to `infer`. There
are such symlinks available in "infer/lib/wrappers/" already.
I also noticed that the scripts in xcodebuild_wrappers/ don't seem useful
anymore, so use wrappers/ instead, as for `make`.
Reviewed By: mbouaziz
Differential Revision: D5036495
fbshipit-source-id: 4a90030
8 years ago
|
|
|
$(INFER_BIN)
|
|
|
|
|
|
|
|
JAVA_DEPS = $(JAVA_DEPS_NO_MODELS) $(JAVA_MODELS_JAR)
|
|
|
|
|
|
|
|
# marker to keep track of when clang models have been rebuilt
|
|
|
|
MODELS_RESULTS_FILE = $(SPECS_LIB_DIR)/clang_models
|
|
|
|
|
|
|
|
CLANG_DEPS_NO_MODELS = \
|
|
|
|
$(addprefix $(PYTHON_LIB_DIR)/, \
|
|
|
|
analyze.py config.py issues.py source.py utils.py) \
|
|
|
|
$(addprefix $(CAPTURE_LIB_DIR)/, util.py) \
|
[CLI] switch to infer-<command> (symlinks) executables
Summary:
Introduce `infer-<command>` for each command, except for internal commands
(only `infer-clang` for now) which are not exported. Install these executables
(which are just symlinks to `infer`) on `make install`. The main executable
looks at the name it was invoked with to figure out if it should behave as a
particular command.
Get rid of `InferClang`, `InferAnalyze`, and `InferPrint`. As a bonus, we now
only need to build one executable: `infer`, which should be a few seconds
faster (less link time).
`InferAnalyze` is now `infer-analyze` and `InferPrint` is `infer-print`. To run
`InferClang`, use a symlink named `clang`, `clang++`, etc. to `infer`. There
are such symlinks available in "infer/lib/wrappers/" already.
I also noticed that the scripts in xcodebuild_wrappers/ don't seem useful
anymore, so use wrappers/ instead, as for `make`.
Reviewed By: mbouaziz
Differential Revision: D5036495
fbshipit-source-id: 4a90030
8 years ago
|
|
|
$(INFER_BIN)
|
|
|
|
|
|
|
|
CLANG_DEPS = $(CLANG_DEPS_NO_MODELS) $(MODELS_RESULTS_FILE) \
|
|
|
|
$(shell find $(MODELS_DIR)/cpp/include -type f)
|
|
|
|
|
|
|
|
define copy_or_same_file
|
|
|
|
$(COPY) "$(1)" "$(2)" || diff -q "$(1)" "$(2)"
|
|
|
|
endef
|
|
|
|
|
|
|
|
INTERACTIVE = $(shell [ -t 0 ] && 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)
|
|
|
|
|
|
|
|
# 99999 PIDs ought to be enough for anybody, but check if pid_max can be found just in case
|
|
|
|
MAX_PID_SIZE = \
|
|
|
|
$(shell PID_MAX=$$(cat /proc/sys/kernel/pid_max 2>/dev/null); echo $${\#PID_MAX} || 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
|