[build] Replace custom make cmds w/ dune promotion and byte_complete

Summary:
Main changes are:

1. Dune can promote targets into the source tree as a part of build. This
allows us to **remove custom promotion/installation logic in src/Makefile**.

2. Dune promotion only works for path within workspace. This required
**moving dune-workspace one folder up**: from infer/infer/src to infer/infer.
But this is not bad, since it makes it possible to migrate tests under dune at some point.

3. `checkCopyright` now also promoted into `infer/infer/bin` instead of
`infer/scripts` partly for consistency and partly because of the
dune-workspace location.

4. `byte` mode was replaced with `byte_complete`. The latter takes
similar amount of time to build compared to `byte`, but produces
standalone binaries that don't require InferCStubs to be
installed. This allowed to remove `dune_exec_shim` and custom logic
around `dune build InferCStubs.install` when dealing with byte
targets.

All in all, `infer/src/Makefile` is not about 2/3 its previous size
with less custom logic in Makefiles/scripts and more encoded in dune
build files.

Reviewed By: jvillard

Differential Revision: D20303902

fbshipit-source-id: 9e4c65bd0
master
Artem Pianykh 5 years ago committed by Facebook GitHub Bot
parent 9fc048b503
commit 786a72574f

19
.gitignore vendored

@ -112,20 +112,6 @@ buck-out/
.buckd/ .buckd/
#other #other
/infer/bin/infer
/infer/bin/infer.bc
/infer/bin/infer.exe
/infer/bin/infer-analyze
/infer/bin/infer-capture
/infer/bin/infer-compile
/infer/bin/infer-explore
/infer/bin/infer-report
/infer/bin/infer-reportdiff
/infer/bin/infer-run
/infer/bin/InferCreateTraceViewLinks
/infer/bin/InferUnit
/infer/bin/infertop.bc
/infer/bin/llvm_sil
/infer/man/man1/*.1 /infer/man/man1/*.1
/infer/man/man1/*.1.gz /infer/man/man1/*.1.gz
@ -142,7 +128,6 @@ buck-out/
/infer/lib/specs/cpp_models /infer/lib/specs/cpp_models
/infer/lib/specs/objc_models /infer/lib/specs/objc_models
/infer/lib/specs/clean_models /infer/lib/specs/clean_models
/scripts/checkCopyright
/infer/etc/clang_ast.dict /infer/etc/clang_ast.dict
/infer/src/toplevel.mlpack /infer/src/toplevel.mlpack
@ -174,10 +159,10 @@ infer/src/.project
/infer/annotations/target /infer/annotations/target
# dune # dune
/infer/src/_build /infer/_build
/infer/dune-workspace
/infer/src/dune.common /infer/src/dune.common
/infer/src/dune /infer/src/dune
/infer/src/dune-workspace
.merlin .merlin
# generated when looking for dead code # generated when looking for dead code

@ -55,7 +55,7 @@ make devsetup
if you're unsure of a module name. if you're unsure of a module name.
```console ```console
$ ledit ocamldebug infer/bin/infer.bc $ ledit ocamldebug infer/bin/infer.bc.exe
(ocd) break @ InferModules__InferAnalyze 100 (ocd) break @ InferModules__InferAnalyze 100
Breakpoint 1 at 9409684: file backend/InferAnalyze.ml, line 99, characters 18-78 Breakpoint 1 at 9409684: file backend/InferAnalyze.ml, line 99, characters 18-78
``` ```

@ -439,8 +439,7 @@ clang_plugin_test_replace: clang_setup
ocaml_unit_test: test_build ocaml_unit_test: test_build
$(QUIET)$(REMOVE_DIR) infer-out-unit-tests $(QUIET)$(REMOVE_DIR) infer-out-unit-tests
$(QUIET)$(call silent_on_success,Running OCaml unit tests,\ $(QUIET)$(call silent_on_success,Running OCaml unit tests,\
INFER_ARGS=--results-dir^infer-out-unit-tests \ INFER_ARGS=--results-dir^infer-out-unit-tests $(INFERUNIT_BIN))
$(SCRIPT_DIR)/dune_exec_shim.sh $(BUILD_DIR)/default/inferunit.bc)
define silence_make define silence_make
$(1) 2> >(grep -v 'warning: \(ignoring old\|overriding\) \(commands\|recipe\) for target') $(1) 2> >(grep -v 'warning: \(ignoring old\|overriding\) \(commands\|recipe\) for target')
@ -593,9 +592,6 @@ ifeq (,$(findstring s,$(MAKEFLAGS)))
$(QUIET)echo "$(TERM_INFO)ALL TESTS PASSED$(TERM_RESET)" $(QUIET)echo "$(TERM_INFO)ALL TESTS PASSED$(TERM_RESET)"
endif endif
.PHONY: quick-test
quick-test: test_build ocaml_unit_test
.PHONY: test-replace .PHONY: test-replace
test-replace: $(BUILD_SYSTEMS_TESTS:%=build_%_replace) $(DIRECT_TESTS:%=direct_%_replace) \ test-replace: $(BUILD_SYSTEMS_TESTS:%=build_%_replace) $(DIRECT_TESTS:%=direct_%_replace) \
clang_plugin_test_replace clang_plugin_test_replace

@ -43,7 +43,7 @@ JAVA_BUILTINS_DIR = $(MODELS_DIR)/java/builtins
JAVA_MODELS_DIR = $(MODELS_DIR)/java/src JAVA_MODELS_DIR = $(MODELS_DIR)/java/src
SRC_DIR = $(INFER_DIR)/src SRC_DIR = $(INFER_DIR)/src
BUILD_DIR = $(SRC_DIR)/_build BUILD_DIR = $(INFER_DIR)/_build
JAVA_LIB_DIR = $(LIB_DIR)/java JAVA_LIB_DIR = $(LIB_DIR)/java
SPECS_LIB_DIR = $(LIB_DIR)/specs SPECS_LIB_DIR = $(LIB_DIR)/specs
@ -62,8 +62,9 @@ INFER_COMMANDS = \
infer-reportdiff \ infer-reportdiff \
infer-run \ infer-run \
INFERTOP_BIN = $(BIN_DIR)/infertop.bc INFERTOP_BIN = $(BIN_DIR)/infertop.bc.exe
INFERUNIT_BIN = $(BIN_DIR)/InferUnit INFERUNIT_BIN = $(BIN_DIR)/inferunit.bc.exe
CHECKCOPYRIGHT_BIN = $(BIN_DIR)/checkCopyright
INFER_CREATE_TRACEVIEW_LINKS = InferCreateTraceViewLinks INFER_CREATE_TRACEVIEW_LINKS = InferCreateTraceViewLinks
INFER_CREATE_TRACEVIEW_LINKS_BIN = $(BIN_DIR)/$(INFER_CREATE_TRACEVIEW_LINKS) INFER_CREATE_TRACEVIEW_LINKS_BIN = $(BIN_DIR)/$(INFER_CREATE_TRACEVIEW_LINKS)

@ -0,0 +1,6 @@
# .gitignore to keep the directory for dune to promote binaries into
###################################
# Filter everything except the .gitignore
*
!.gitignore

@ -1,11 +0,0 @@
#!/bin/bash
# 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.
## Wrapper around the bytecode version of infer produced by `make byte`
# This is needed to find the dynamic libraries of our C stubs
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
exec "$SCRIPT_DIR"/../../scripts/dune_exec_shim.sh "${0%.byte}.bc" "$@"

@ -8,21 +8,19 @@ include $(ROOT_DIR)/Makefile.config
#### Global declarations #### #### Global declarations ####
# override this for faster builds (but slower infer) # Override this for faster builds (but slower infer)
BUILD_MODE ?= opt BUILD_MODE ?= opt
BUILD_ROOT = _build
# paths to BUILD_DIR are relative because that's how dune likes it
INFER_BUILD_DIR = $(BUILD_ROOT)/default
DUNE_BUILD = dune build --profile=$(BUILD_MODE) --build-dir=$(BUILD_ROOT) DUNE_BUILD = dune build --profile=$(BUILD_MODE)
ETC_DIR = $(INFER_DIR)/etc ETC_DIR = $(INFER_DIR)/etc
#### Backend declarations ####
INFER_MAIN = infer INFER_MAIN = infer
INFERTOP_MAIN = infertop
#### Checkers declarations #### INFERUNIT_MAIN = inferunit
INFER_CREATE_TRACEVIEW_LINKS_MODULE = InferCreateTraceViewLinks
INFER_CREATE_TRACEVIEW_LINKS_MAIN = $(INFER_CREATE_TRACEVIEW_LINKS_MODULE)
CHECKCOPYRIGHT_MAIN = checkCopyright
INFER_ATDGEN_STUB_BASES = atd/jsonbug atd/runstate atd/java_method_decl atd/perf_profiler atd/java_profiler_samples atd/clang_profiler_samples INFER_ATDGEN_STUB_BASES = atd/jsonbug atd/runstate atd/java_method_decl atd/perf_profiler atd/java_profiler_samples atd/clang_profiler_samples
INFER_ATDGEN_TYPES = j t INFER_ATDGEN_TYPES = j t
@ -31,15 +29,8 @@ INFER_ATDGEN_SUFFIXES = $(foreach atd_t,$(INFER_ATDGEN_TYPES),_$(atd_t).ml _$(at
INFER_ATDGEN_STUBS = $(foreach base,$(INFER_ATDGEN_STUB_BASES),\ INFER_ATDGEN_STUBS = $(foreach base,$(INFER_ATDGEN_STUB_BASES),\
$(addprefix $(base),$(INFER_ATDGEN_SUFFIXES))) $(addprefix $(base),$(INFER_ATDGEN_SUFFIXES)))
#### InferCreateTraceViewLinks declarations ####
FACEBOOK_DIR = facebook FACEBOOK_DIR = facebook
INFER_CREATE_TRACEVIEW_LINKS_MODULE = InferCreateTraceViewLinks
INFER_CREATE_TRACEVIEW_LINKS_MAIN = $(INFER_CREATE_TRACEVIEW_LINKS_MODULE)
### InferUnit declarations ###
INFERUNIT_MAIN = inferunit
#### Clang declarations #### #### Clang declarations ####
@ -65,21 +56,14 @@ CLANG_PLUGIN_MIRRORED_FILES = $(addprefix $(CLANG_PLUGIN_MIRROR)/, $(notdir $(FC
CLANG_BINIOU_DICT = $(ETC_DIR)/clang_ast.dict CLANG_BINIOU_DICT = $(ETC_DIR)/clang_ast.dict
#### scripts declarations ####
CHECKCOPYRIGHT_BIN = $(SCRIPT_DIR)/checkCopyright
CHECKCOPYRIGHT_MAIN = checkCopyright
#### End of declarations ####
ifeq ($(ENABLE_OCAMLOPT_CUSTOM_CC),yes) ifeq ($(ENABLE_OCAMLOPT_CUSTOM_CC),yes)
EXTRA_CFLAGS += -cc,$(CC) EXTRA_CFLAGS += -cc,$(CC)
endif endif
# list of ocamlbuild targets common to all build targets -- native version # list of ocamlbuild targets common to all build targets -- native version
INFER_CONFIG_TARGETS = $(INFER_BUILD_DIR)/$(INFER_MAIN).exe INFER_CONFIG_TARGETS = $(INFER_MAIN).exe
ifeq ($(IS_FACEBOOK_TREE),yes) ifeq ($(IS_FACEBOOK_TREE),yes)
INFER_CONFIG_TARGETS += $(INFER_BUILD_DIR)/$(INFER_CREATE_TRACEVIEW_LINKS_MAIN).exe INFER_CONFIG_TARGETS += $(INFER_CREATE_TRACEVIEW_LINKS_MAIN).exe
endif endif
OCAML_GENERATED_SOURCES = \ OCAML_GENERATED_SOURCES = \
@ -96,7 +80,10 @@ OCAML_SOURCES = \
.PHONY: all .PHONY: all
all: infer all: infer
GENERATED_FROM_AUTOCONF = dune.common dune-workspace base/Version.ml GENERATED_FROM_AUTOCONF = dune.common ../dune-workspace base/Version.ml
.PHONY: dune-workspace
dune-workspace: ../dune-workspace
GENERATED_DUNES += dune GENERATED_DUNES += dune
@ -108,25 +95,12 @@ endif
.PHONY: src_build_common .PHONY: src_build_common
src_build_common: $(SRC_BUILD_COMMON) src_build_common: $(SRC_BUILD_COMMON)
# Single out infer.exe as the source of truth for make, knowing that in fact several
# targets are produced by the build.
# The target is marked as .PHONY because if you build with one profile `make
# BUILD_MODE=dev` and then try with another profile `make BUILD_MODE=opt`, make won't
# trigger a rebuild since it has only partial view on the dependencies.
.PHONY: $(INFER_BUILD_DIR)/$(INFER_MAIN).exe
$(INFER_BUILD_DIR)/$(INFER_MAIN).exe: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
$(QUIET)$(DUNE_BUILD) $(INFER_CONFIG_TARGETS)
# let make know that the target is up-to-date even if ocamlbuild cached it
$(QUIET)touch $@
.PHONY: test .PHONY: test
test: BUILD_MODE = test test: BUILD_MODE = test
test: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST) test: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
# needed for dune to "install" the relevant dynamic libraries for the C stubs
$(QUIET)cd c_stubs; $(DUNE_BUILD) InferCStubs.install
$(QUIET)$(DUNE_BUILD) \ $(QUIET)$(DUNE_BUILD) \
$(patsubst $(INFER_BUILD_DIR)/%.exe,%.bc, $(INFER_CONFIG_TARGETS)) \ $(patsubst %.exe, %.bc.exe, $(INFER_CONFIG_TARGETS)) \
scripts/checkCopyright.bc $(INFERUNIT_MAIN).bc infertop.bc scripts/$(CHECKCOPYRIGHT_MAIN).bc.exe $(INFERUNIT_MAIN).bc.exe $(INFERTOP_MAIN).bc.exe
.PHONY: doc .PHONY: doc
doc: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST) doc: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
@ -136,57 +110,54 @@ doc: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
check: src_build_common check: src_build_common
$(DUNE_BUILD) @check $(DUNE_BUILD) @check
#### Aliases for building binaries ####
INFER_BIN_ALIASES = $(foreach alias,$(INFER_COMMANDS),$(BIN_DIR)/$(alias)) # Single out infer[.bc].exe as the source of truth for make, knowing that in fact several
# targets are produced by the build.
# The targets below are marked as .PHONY because if you build with one profile `make
# BUILD_MODE=dev` and then try with another profile `make BUILD_MODE=opt`, make won't
# trigger a rebuild since it has only partial view on the dependencies.
$(INFER_BIN_ALIASES): Makefile $(BIN_DIR)/$(INFER_MAIN) .PHONY: $(INFER_BIN).exe
$(REMOVE) $@ $(INFER_BIN).exe: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
$(QUIET)cd $(@D) && $(LN_S) -f infer $(@F) $(QUIET)$(DUNE_BUILD) $(INFER_CONFIG_TARGETS)
$(QUIET)touch $@
$(INFER_BIN).exe: $(INFER_BUILD_DIR)/$(INFER_MAIN).exe .PHONY: $(INFER_BIN).bc.exe
$(QUIET)$(MKDIR_P) $(BIN_DIR) $(INFER_BIN).bc.exe: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
ifeq ($(WINDOWS_BUILD),yes) $(QUIET)$(DUNE_BUILD) $(patsubst %.exe, %.bc.exe, $(INFER_CONFIG_TARGETS))
# http://cygwin.1069669.n5.nabble.com/cp-utility-bug-when-dest-name-exe-file-exist-tp57955p58001.html
$(REMOVE) $(INFER_BIN) $(INFER_BIN).exe .PHONY: $(INFERTOP_BIN) toplevel
endif $(INFERTOP_BIN): $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
$(INSTALL_PROGRAM) -C $(INFER_BUILD_DIR)/$(INFER_MAIN).exe $(INFER_BIN).exe $(DUNE_BUILD) $(INFERTOP_MAIN).bc.exe
ifeq ($(IS_FACEBOOK_TREE),yes) toplevel: $(INFERTOP_BIN)
$(INSTALL_PROGRAM) -C $(INFER_BUILD_DIR)/$(INFER_CREATE_TRACEVIEW_LINKS_MAIN).exe \
$(INFER_CREATE_TRACEVIEW_LINKS_BIN)
endif
.PHONY: $(CHECKCOPYRIGHT_BIN) checkCopyright
$(CHECKCOPYRIGHT_BIN): $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
$(DUNE_BUILD) scripts/$(CHECKCOPYRIGHT_MAIN)
checkCopyright: $(CHECKCOPYRIGHT_BIN)
.PHONY: infer .PHONY: infer
infer: $(INFER_BIN).exe infer: $(INFER_BIN).exe
$(INSTALL_PROGRAM) -C $(INFER_BIN).exe $(INFER_BIN) $(INSTALL_PROGRAM) -C $(INFER_BIN).exe $(INFER_BIN)
$(MAKE) $(INFER_BIN_ALIASES)
.PHONY: $(INFER_BUILD_DIR)/$(INFER_MAIN).bc
$(INFER_BUILD_DIR)/$(INFER_MAIN).bc: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
$(DUNE_BUILD) $(INFER_CONFIG_TARGETS:.exe=.bc)
$(QUIET)touch $@
.PHONY: $(INFER_BIN).bc
$(INFER_BIN).bc: $(INFER_BUILD_DIR)/$(INFER_MAIN).bc
$(QUIET)$(MKDIR_P) $(BIN_DIR)
ifeq ($(WINDOWS_BUILD),yes)
# http://cygwin.1069669.n5.nabble.com/cp-utility-bug-when-dest-name-exe-file-exist-tp57955p58001.html
$(REMOVE) $(INFER_BIN) $(INFER_BIN).exe
endif
$(INSTALL_PROGRAM) -C $(INFER_BUILD_DIR)/$(INFER_MAIN).bc $(INFER_BIN).bc
ifeq ($(IS_FACEBOOK_TREE),yes) ifeq ($(IS_FACEBOOK_TREE),yes)
$(INSTALL_PROGRAM) -C $(INFER_BUILD_DIR)/$(INFER_CREATE_TRACEVIEW_LINKS_MAIN).bc \ $(INSTALL_PROGRAM) -C $(INFER_CREATE_TRACEVIEW_LINKS_BIN).exe $(INFER_CREATE_TRACEVIEW_LINKS_BIN)
$(INFER_CREATE_TRACEVIEW_LINKS_BIN)
endif endif
# needed for dune to "install" the relevant dynamic libraries for the C stubs $(MAKE) $(INFER_BIN_ALIASES)
cd c_stubs; $(DUNE_BUILD) InferCStubs.install
.PHONY: byte .PHONY: byte
byte: $(INFER_BIN).bc byte: $(INFER_BIN).bc.exe
$(INSTALL_PROGRAM) -C $(INFER_BIN).byte $(INFER_BIN) $(INSTALL_PROGRAM) -C $(INFER_BIN).bc.exe $(INFER_BIN)
ifeq ($(IS_FACEBOOK_TREE),yes)
$(INSTALL_PROGRAM) -C $(INFER_CREATE_TRACEVIEW_LINKS_BIN).bc.exe $(INFER_CREATE_TRACEVIEW_LINKS_BIN)
endif
$(MAKE) $(INFER_BIN_ALIASES) $(MAKE) $(INFER_BIN_ALIASES)
INFER_BIN_ALIASES = $(foreach alias,$(INFER_COMMANDS),$(BIN_DIR)/$(alias))
$(INFER_BIN_ALIASES): Makefile $(BIN_DIR)/$(INFER_MAIN)
$(REMOVE) $@
$(QUIET)cd $(@D) && $(LN_S) -f infer $(@F)
$(QUIET)touch $@
roots:=Infer roots:=Infer
ifeq ($(IS_FACEBOOK_TREE),yes) ifeq ($(IS_FACEBOOK_TREE),yes)
roots += $(INFER_CREATE_TRACEVIEW_LINKS_MODULE) roots += $(INFER_CREATE_TRACEVIEW_LINKS_MODULE)
@ -212,28 +183,6 @@ mod_dep.pdf: mod_dep.dot
dsort: dsort:
$(QUIET)ocamldep.opt -sort $(inc_flags) $(ml_src_files) $(QUIET)ocamldep.opt -sort $(inc_flags) $(ml_src_files)
.PHONY: $(INFER_BUILD_DIR)/infertop.bc
$(INFER_BUILD_DIR)/infertop.bc: $(SRC_DIR)/infertop.ml $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
$(DUNE_BUILD) $@
# needed for dune to "install" the relevant dynamic libraries for the C stubs
cd c_stubs; $(DUNE_BUILD) InferCStubs.install
$(QUIET)touch $@
$(INFERTOP_BIN): $(INFER_BUILD_DIR)/infertop.bc
$(QUIET)$(INSTALL_PROGRAM) -C $< $@
$(QUIET)touch $@
.PHONY: toplevel
toplevel: $(INFERTOP_BIN)
.PHONY: checkCopyright
checkCopyright: $(CHECKCOPYRIGHT_BIN)
.PHONY: $(CHECKCOPYRIGHT_BIN)
$(CHECKCOPYRIGHT_BIN): $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
$(DUNE_BUILD) $(INFER_BUILD_DIR)/scripts/$(CHECKCOPYRIGHT_MAIN).exe
$(INSTALL_PROGRAM) -C $(INFER_BUILD_DIR)/scripts/$(CHECKCOPYRIGHT_MAIN).exe $(CHECKCOPYRIGHT_BIN)
define gen_atdgen_rules define gen_atdgen_rules
# generate files using atdgen # generate files using atdgen
# parameters: # parameters:
@ -300,7 +249,7 @@ $(GENERATED_FROM_AUTOCONF): $(MAKEFILE_LIST)
cat "$$TMPFILE" > $@; \ cat "$$TMPFILE" > $@; \
$(REMOVE) "$$TMPFILE" $(REMOVE) "$$TMPFILE"
dune.common: dune.common.in dune.common: dune.common.in
dune-workspace: dune-workspace.in ../dune-workspace: ../dune-workspace.in
base/Version.ml: base/Version.ml.in base/Version.ml: base/Version.ml.in
$(GENERATED_DUNES): dune.common $(GENERATED_DUNES): dune.common
@ -314,20 +263,18 @@ clean:
$(MAKE) -C deadcode clean $(MAKE) -C deadcode clean
$(REMOVE) $(INFER_TARGET) $(REMOVE) $(INFER_TARGET)
$(REMOVE) toplevel.mlpack $(REMOVE) toplevel.mlpack
$(REMOVE_DIR) $(BUILD_DIR)
$(REMOVE) $(ETC_DIR)/clang_ast.dict $(REMOVE) $(ETC_DIR)/clang_ast.dict
$(REMOVE) $(GENERATED_FROM_AUTOCONF) $(REMOVE) $(GENERATED_FROM_AUTOCONF)
$(REMOVE) $(GENERATED_DUNES) $(REMOVE) $(GENERATED_DUNES)
$(REMOVE) base/Version.ml.tmp.* dune.tmp.* dune-workspace.tmp.* $(REMOVE) base/Version.ml.tmp.* dune.tmp.* dune-workspace.tmp.*
# be a bit more aggressive than needed with what we remove here so that stale binaries that # be a bit more aggressive than needed with what we remove here so that stale binaries that
# only existed in previous versions get removed as well # only existed in previous versions get removed as well
$(REMOVE) $(BIN_DIR)/Infer* $(BIN_DIR)/infer-* $(INFER_BIN){,.bc,.exe} $(INFER_BIN_ALIASES) \ $(REMOVE) $(INFER_BIN) $(INFER_BIN_ALIASES) $(INFER_CREATE_TRACEVIEW_LINKS_BIN)
$(INFERUNIT_BIN) $(CHECKCOPYRIGHT_BIN)
$(REMOVE) $(BIN_DIR)/llvm_sil $(REMOVE) $(BIN_DIR)/llvm_sil
$(REMOVE) $(INFER_CREATE_TRACEVIEW_LINKS_BIN)
$(REMOVE) atd/*_{j,t,v}.ml{,i} atd/clang_ast_* $(REMOVE) atd/*_{j,t,v}.ml{,i} atd/clang_ast_*
$(REMOVE) mod_dep.dot $(REMOVE) mod_dep.dot
$(REMOVE) mod_dep.pdf $(REMOVE) mod_dep.pdf
cd .. && dune clean
.PHONY: fmt .PHONY: fmt
fmt: fmt:

@ -1,18 +1,11 @@
(* -*- tuareg -*- *) ; Copyright (c) Facebook, Inc. and its affiliates.
(* ;
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
;;
Format.sprintf
{|
(library (library
(name InferCStubs) (name InferCStubs)
(public_name InferCStubs) (public_name InferCStubs)
(foreign_stubs (language c) (names fnv64_hash)) (foreign_stubs
) (language c)
|} (names fnv64_hash)))
|> Jbuild_plugin.V1.send

@ -28,7 +28,7 @@
ROOT_DIR = ../../.. ROOT_DIR = ../../..
include $(ROOT_DIR)/Makefile.config include $(ROOT_DIR)/Makefile.config
INFER_BUILD_DIR = ../_build/default INFER_BUILD_DIR = $(INFER_DIR)/_build/default/src
ALL_INFER_IN_ONE_FILE_ML = all_infer_in_one_file.ml ALL_INFER_IN_ONE_FILE_ML = all_infer_in_one_file.ml
ALL_ML_FILES = all_ml_files ALL_ML_FILES = all_ml_files
@ -38,13 +38,13 @@ ALL_MLI_FILES_COPIED = all_mli_files_copied
default: detect_dead_code default: detect_dead_code
ml_src_files_from_mlly:=$(shell find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../_build/*" -regex '\.\./[a-zA-Z].*\.ml[ly]') ml_src_files_from_mlly:=$(shell find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../../_build/*" -regex '\.\./[a-zA-Z].*\.ml[ly]')
ml_src_files:=$(shell for i in $$(find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../_build/*" -regex '\.\./[a-zA-Z].*\.ml'); do echo $${i\#"../"}; done) ml_src_files:=$(shell for i in $$(find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../../_build/*" -regex '\.\./[a-zA-Z].*\.ml'); do echo $${i\#"../"}; done)
mli_src_files:=$(shell for i in $$(find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../_build/*" -regex '\.\./[a-zA-Z].*\.mli'); do echo $${i\#"../"}; done) mli_src_files:=$(shell for i in $$(find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../../_build/*" -regex '\.\./[a-zA-Z].*\.mli'); do echo $${i\#"../"}; done)
ml_src_files_without_mli:=$(shell for i in $$(find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../_build/*" -regex '\.\./[a-zA-Z].*\.ml'); do [ -f $${i}i ] || echo $${i\#"../"}; done) ml_src_files_without_mli:=$(shell for i in $$(find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../../_build/*" -regex '\.\./[a-zA-Z].*\.ml'); do [ -f $${i}i ] || echo $${i\#"../"}; done)
.PHONY: depend .PHONY: depend
depend: depend:
@ -168,7 +168,7 @@ detect_dead_code:
rm "$$tmp_file_copied" rm "$$tmp_file_copied"
$(MAKE) -j 1 detect_dead_src_file $(MAKE) -j 1 detect_dead_src_file
# build and get dead code warnings; clean in case of errors so as not to leave rubbish around # build and get dead code warnings; clean in case of errors so as not to leave rubbish around
if ! dune build --profile test $(INFER_BUILD_DIR)/deadcode/all_infer_in_one_file.bc; then \ if ! dune build --profile test all_infer_in_one_file.bc; then \
$(MAKE) clean; \ $(MAKE) clean; \
exit 1; \ exit 1; \
fi fi

@ -5,3 +5,4 @@
; LICENSE file in the root directory of this source tree. ; LICENSE file in the root directory of this source tree.
(using menhir 1.0) (using menhir 1.0)
(formatting (enabled_for dune))

@ -45,7 +45,8 @@ let env_stanza =
(flags %s) (flags %s)
(ocamlopt_flags (:standard -O3))) (ocamlopt_flags (:standard -O3)))
(test (test
(flags %s))) (flags %s))
)
|} |}
lenient_flags lenient_flags strict_flags lenient_flags lenient_flags strict_flags
@ -102,11 +103,12 @@ let infer_exe_stanza =
{| {|
(executables (executables
(names %s) (names %s)
(modes byte exe) (modes byte_complete exe)
(flags (:standard %s -open InferModules)) (flags (:standard %s -open InferModules))
(libraries InferModules) (libraries InferModules)
(modules %s) (modules %s)
(preprocess (pps ppx_compare ppx_fields_conv ppx_hash ppx_sexp_conv ppx_variants_conv -no-check)) (preprocess (pps ppx_compare ppx_fields_conv ppx_hash ppx_sexp_conv ppx_variants_conv -no-check))
(promote (until-clean) (into ../bin))
) )
|} |}
(String.concat " " infer_binaries) (String.concat " " infer_binaries)
@ -119,12 +121,13 @@ let infertop_stanza =
{| {|
(executable (executable
(name infertop) (name infertop)
(modes byte) (modes byte_complete)
(flags (:standard %s)) (flags (:standard %s))
(libraries utop InferModules) (libraries utop InferModules)
(link_flags (-linkall -warn-error -31))
(modules Infertop) (modules Infertop)
(preprocess (pps ppx_compare ppx_fields_conv ppx_hash ppx_sexp_conv ppx_variants_conv -no-check)) (preprocess (pps ppx_compare ppx_fields_conv ppx_hash ppx_sexp_conv ppx_variants_conv -no-check))
(link_flags (-linkall -warn-error -31)) (promote (until-clean) (into ../bin))
) )
|} |}
infer_cflags infer_cflags

@ -6,7 +6,7 @@
ROOT_DIR = ../../.. ROOT_DIR = ../../..
include $(ROOT_DIR)/Makefile.config include $(ROOT_DIR)/Makefile.config
INFER_BUILD_DIR = ../_build/default INFER_BUILD_DIR = ../../_build/default
default: llvm_sil default: llvm_sil

@ -5,8 +5,16 @@
(executable (executable
(name checkCopyright) (name checkCopyright)
(modes byte exe) (modes byte_complete exe)
(flags (:standard)) (flags (:standard))
(libraries core str) (libraries core str)
(preprocess (preprocess
(pps ppx_compare))) (pps ppx_compare)))
(rule
(action
(copy checkCopyright.exe checkCopyright))
(mode
(promote
(until-clean)
(into ../../bin))))

@ -8,13 +8,12 @@ ROOT_DIR = $(TESTS_DIR)/../..
include $(TESTS_DIR)/base.make include $(TESTS_DIR)/base.make
toplevel.exp.test: $(BUILD_DIR)/default/infertop.bc $(SCRIPT_DIR)/infer_repl \ toplevel.exp.test: $(INFERTOP_BIN) $(SCRIPT_DIR)/infer_repl \
$(SCRIPT_DIR)/toplevel_init $(INFER_DIR)/tests/repl/infer_batch_script.mltop $(SCRIPT_DIR)/toplevel_init $(INFER_DIR)/tests/repl/infer_batch_script.mltop
$(QUIET)$(call silent_on_success,Testing infer OCaml REPL,\ $(QUIET)$(call silent_on_success,Testing infer OCaml REPL,\
BUILD_DIR=$(BUILD_DIR)/default \
$(SCRIPT_DIR)/infer_repl $(INFER_DIR)/tests/repl/infer_batch_script.mltop | \ $(SCRIPT_DIR)/infer_repl $(INFER_DIR)/tests/repl/infer_batch_script.mltop | \
sed -e 's#^The files .*/extLib.cma$$#The files [...]/extLib.cma#' \ sed -e 's#^The files .*/extLib.cma$$#The files [...]/extLib.cma#' \
-e 's#^and .*/infertop.bc$$#and [...]/infertop.bc#' \ -e 's#^and .*/infertop.bc.exe$$#and [...]/infertop.bc.exe#' \
> $@) > $@)
.PHONY: print .PHONY: print

@ -8,7 +8,7 @@ Findlib has been successfully loaded. Additional directives:
#thread;; to enable threads #thread;; to enable threads
The files [...]/extLib.cma The files [...]/extLib.cma
and [...]/infertop.bc and [...]/infertop.bc.exe
disagree over interface Base64 disagree over interface Base64
n$5 n$5
false false

@ -1,25 +0,0 @@
#!/bin/bash
# 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.
## Wrapper around the bytecode versions of infer
# This is needed to find the dynamic libraries of our C stubs
if [ "$#" -lt 1 ]; then
echo "usage: $0 BYTECODE_PROGRAM" >&2
exit 1
fi
prog=$1
shift
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SRC_DIR="$SCRIPT_DIR"/../infer/src
BUILD_MODE=${BUILD_MODE:-dev}
DUNE_INSTALL_DIR=${INSTALL_DIR:-"$SRC_DIR/_build/install/default"}
export CAML_LD_LIBRARY_PATH="$DUNE_INSTALL_DIR"/lib/stublibs:"$CAML_LD_LIBRARY_PATH"
exec "$prog" "$@"

@ -5,7 +5,8 @@
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# where to find toplevel.bc, can be overridden # where to find toplevel.bc, can be overridden
BUILD_DIR=${BUILD_DIR:-"$SCRIPT_DIR"/../infer/src/_build/default} BUILD_DIR=${BUILD_DIR:-"$SCRIPT_DIR"/../infer/_build/default/src}
BIN_DIR="$SCRIPT_DIR/../infer/bin"
INCLUDE_FLAGS=$(find "$BUILD_DIR" -type d -name '*.objs' -exec printf -- '-I {}/byte\n' \;) INCLUDE_FLAGS=$(find "$BUILD_DIR" -type d -name '*.objs' -exec printf -- '-I {}/byte\n' \;)
# The -init option is effective only in interactive mode. # The -init option is effective only in interactive mode.
@ -17,7 +18,7 @@ INCLUDE_FLAGS=$(find "$BUILD_DIR" -type d -name '*.objs' -exec printf -- '-I {}/
# file. In interactive mode $SCRIPT_DIR isn't needed # file. In interactive mode $SCRIPT_DIR isn't needed
set -x set -x
"$SCRIPT_DIR"/dune_exec_shim.sh infertop.bc \ $BIN_DIR/infertop.bc.exe \
-init "$SCRIPT_DIR"/toplevel_init \ -init "$SCRIPT_DIR"/toplevel_init \
$INCLUDE_FLAGS \ $INCLUDE_FLAGS \
-I "$SCRIPT_DIR" \ -I "$SCRIPT_DIR" \

Loading…
Cancel
Save