[dune] jbuilder -> dune

Summary: the_future_is_now

Reviewed By: jberdine

Differential Revision: D8933124

fbshipit-source-id: e5df1a9a3
master
Jules Villard 6 years ago committed by Facebook Github Bot
parent 0bf9666639
commit 83a4a8fa5b

20
.gitignore vendored

@ -152,20 +152,20 @@ infer/src/.project
# generated by Maven
/infer/annotations/target
# jbuilder
# dune
/infer/src/_build
/infer/src/jbuild.common
/infer/src/jbuild
/infer/src/atd/jbuild
/infer/src/base/jbuild
/infer/src/IR/jbuild
/infer/src/istd/jbuild
/infer/src/scripts/jbuild
/infer/src/jbuild-workspace
/infer/src/dune.common
/infer/src/dune
/infer/src/atd/dune
/infer/src/base/dune
/infer/src/IR/dune
/infer/src/istd/dune
/infer/src/scripts/dune
/infer/src/dune-workspace
.merlin
# generated when looking for dead code
/infer/src/deadcode/.depend
/infer/src/deadcode/jbuild
/infer/src/deadcode/dune
/infer/src/deadcode/*.ml
/infer/src/deadcode/*.mli

@ -147,17 +147,17 @@ OCAMLFORMAT_EXE?=ocamlformat
fmt:
parallel $(OCAMLFORMAT_EXE) -i ::: $$(git diff --name-only $$(git merge-base origin/master HEAD) | grep "\.mli\?$$")
JBUILD_ML:=$(shell find * -name 'jbuild*.in' | grep -v workspace | grep -v sledge)
DUNE_ML:=$(shell find * -name 'dune*.in' | grep -v workspace | grep -v sledge)
.PHONY: fmt_jbuild
fmt_jbuild:
parallel $(OCAMLFORMAT_EXE) -i ::: $(JBUILD_ML)
.PHONY: fmt_dune
fmt_dune:
parallel $(OCAMLFORMAT_EXE) -i ::: $(DUNE_ML)
SRC_ML:=$(shell find * \( -name _build -or -name facebook-clang-plugins -or -path facebook/dependencies -or -path sledge/llvm \) -not -prune -or -type f -and -name '*'.ml -or -name '*'.mli 2>/dev/null)
.PHONY: fmt_all
fmt_all:
parallel $(OCAMLFORMAT_EXE) -i ::: $(SRC_ML) $(JBUILD_ML)
parallel $(OCAMLFORMAT_EXE) -i ::: $(SRC_ML) $(DUNE_ML)
# pre-building these avoids race conditions when building, eg src_build and test_build in parallel
.PHONY: src_build_common

@ -0,0 +1,22 @@
(* -*- tuareg -*- *)
(* NOTE: prepend dune.common to this file! *)
;; Format.sprintf
{|
(library
(name InferIR)
(public_name InferIR)
(flags (%s -open Core -open InferStdlib -open IStd -open InferGenerated -open InferBase))
(ocamlopt_flags (%s))
(libraries %s)
(preprocess (pps ppx_compare))
)
(documentation
(package InferIR)
(mld_files index)
)
|}
(String.concat " " common_cflags)
(String.concat " " common_optflags)
(String.concat " " ("InferBase" :: common_libraries))
|> Jbuild_plugin.V1.send

@ -1,22 +0,0 @@
(* -*- tuareg -*- *)
(* NOTE: prepend jbuild.common to this file! *)
;; Format.sprintf
{|
(library
((name InferIR)
(public_name InferIR)
(flags (%s -open Core -open InferStdlib -open IStd -open InferGenerated -open InferBase))
(ocamlopt_flags (%s))
(libraries (%s))
(preprocess (pps (ppx_compare)))
))
(documentation
((package InferIR)
(mld_files (index))
))
|}
(String.concat " " common_cflags)
(String.concat " " common_optflags)
(String.concat " " ("InferBase" :: common_libraries))
|> Jbuild_plugin.V1.send

@ -9,7 +9,7 @@ include $(ROOT_DIR)/Makefile.config
#### Global declarations ####
ETC_DIR = $(INFER_DIR)/etc
# paths to BUILD_DIR are relative because that's how jbuilder likes it
# paths to BUILD_DIR are relative because that's how dune likes it
# can be overriden to specify another build mode (eg opt)
INFER_BUILD_DIR = _build/default
@ -91,11 +91,11 @@ OCAML_SOURCES = \
.PHONY: all
all: infer
GENERATED_FROM_AUTOCONF = jbuild.common jbuild-workspace base/Version.ml
GENERATED_FROM_AUTOCONF = dune.common dune-workspace base/Version.ml
GENERATED_JBUILDS += jbuild atd/jbuild base/jbuild IR/jbuild istd/jbuild scripts/jbuild
GENERATED_DUNES += dune atd/dune base/dune IR/dune istd/dune scripts/dune
SRC_BUILD_COMMON = $(GENERATED_FROM_AUTOCONF) $(GENERATED_JBUILDS) $(OCAML_SOURCES)
SRC_BUILD_COMMON = $(GENERATED_FROM_AUTOCONF) $(GENERATED_DUNES) $(OCAML_SOURCES)
ifeq ($(BUILD_C_ANALYZERS),yes)
SRC_BUILD_COMMON += $(CLANG_BINIOU_DICT)
endif
@ -106,19 +106,19 @@ 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
$(INFER_BUILD_DIR)/$(INFER_MAIN).exe: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
$(QUIET)jbuilder build $(INFER_CONFIG_TARGETS)
$(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
test: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
$(QUIET)jbuilder build \
$(QUIET)dune build \
$(patsubst $(INFER_BUILD_DIR)/%.exe,_build/test/%.bc,$(INFER_CONFIG_TARGETS)) \
_build/test/scripts/checkCopyright.bc _build/test/$(INFERUNIT_MAIN).bc _build/test/infertop.bc
.PHONY: doc
doc: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
$(QUIET)jbuilder build @$(INFER_BUILD_DIR)/doc
$(QUIET)dune build @$(INFER_BUILD_DIR)/doc
INFER_BIN_ALIASES = $(foreach alias,$(INFER_COMMANDS),$(BIN_DIR)/$(alias))
@ -141,7 +141,7 @@ endif
infer: $(INFER_BIN).exe
$(INFER_BUILD_DIR)/$(INFER_MAIN).bc: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
jbuilder build $(INFER_CONFIG_TARGETS:.exe=.bc)
dune build $(INFER_CONFIG_TARGETS:.exe=.bc)
$(QUIET)touch $@
$(INFER_BIN).bc: $(INFER_BUILD_DIR)/$(INFER_MAIN).bc $(INFER_BIN_ALIASES)
@ -181,7 +181,7 @@ dsort:
$(QUIET)ocamldep.opt -sort $(inc_flags) $(ml_src_files)
$(INFER_BUILD_DIR)/infertop.bc: $(SRC_DIR)/infertop.ml $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
jbuilder build $@
dune build $@
$(QUIET)touch $@
.PHONY: toplevel
@ -191,7 +191,7 @@ toplevel: $(INFER_BUILD_DIR)/infertop.bc
checkCopyright: $(CHECKCOPYRIGHT_BIN)
$(CHECKCOPYRIGHT_BIN): $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
jbuilder build $(INFER_BUILD_DIR)/scripts/$(CHECKCOPYRIGHT_MAIN).exe
dune build $(INFER_BUILD_DIR)/scripts/$(CHECKCOPYRIGHT_MAIN).exe
$(INSTALL_PROGRAM) $(INFER_BUILD_DIR)/scripts/$(CHECKCOPYRIGHT_MAIN).exe $(CHECKCOPYRIGHT_BIN)
define gen_atdgen_rules
@ -258,20 +258,20 @@ $(GENERATED_FROM_AUTOCONF): $(MAKEFILE_LIST)
$@.in > "$$TMPFILE"; \
cat "$$TMPFILE" > $@; \
$(REMOVE) "$$TMPFILE"
jbuild.common: jbuild.common.in
jbuild-workspace: jbuild-workspace.in
dune.common: dune.common.in
dune-workspace: dune-workspace.in
base/Version.ml: base/Version.ml.in
$(GENERATED_JBUILDS): jbuild.common
$(GENERATED_DUNES): dune.common
$(QUIET)cat $+ > $@
jbuild: jbuild.in
atd/jbuild: atd/jbuild.in
base/jbuild: base/jbuild.in
deadcode/jbuild: deadcode/jbuild.in
IR/jbuild: IR/jbuild.in
istd/jbuild: istd/jbuild.in
scripts/jbuild: scripts/jbuild.in
dune: dune.in
atd/dune: atd/dune.in
base/dune: base/dune.in
deadcode/dune: deadcode/dune.in
IR/dune: IR/dune.in
istd/dune: istd/dune.in
scripts/dune: scripts/dune.in
.PHONY: clean
clean:
@ -281,8 +281,8 @@ clean:
$(REMOVE_DIR) $(BUILD_DIR)
$(REMOVE) $(ETC_DIR)/clang_ast.dict
$(REMOVE) $(GENERATED_FROM_AUTOCONF)
$(REMOVE) $(GENERATED_JBUILDS)
$(REMOVE) base/Version.ml.tmp.* jbuild.tmp.* jbuild-workspace.tmp.*
$(REMOVE) $(GENERATED_DUNES)
$(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
# only existed in previous versions get removed as well
$(REMOVE) $(BIN_DIR)/Infer* $(BIN_DIR)/infer-* $(INFER_BIN){,.bc,.exe} $(INFER_BIN_ALIASES) \

@ -1,2 +1,2 @@
The OCaml source files for infer live here. The Makefile is
responsible for building them, together with jbuild.in.
responsible for building them, together with dune.in.

@ -0,0 +1,24 @@
(* -*- tuareg -*- *)
(* NOTE: prepend dune.common to this file! *)
let cflags = common_cflags @ ["-w"; "-27-32-34-35-39"]
;; Format.sprintf
{|
(library
(name InferGenerated)
(public_name InferGenerated)
(flags (%s))
(ocamlopt_flags (%s))
(libraries atdgen core)
(preprocess (pps ppx_compare))
)
(documentation
(package InferGenerated)
(mld_files index)
)
|}
(String.concat " " cflags)
(String.concat " " common_optflags)
|> Jbuild_plugin.V1.send

@ -1,24 +0,0 @@
(* -*- tuareg -*- *)
(* NOTE: prepend jbuild.common to this file! *)
let cflags = common_cflags @ ["-w"; "-27-32-34-35-39"]
;; Format.sprintf
{|
(library
((name InferGenerated)
(public_name InferGenerated)
(flags (%s))
(ocamlopt_flags (%s))
(libraries (atdgen core))
(preprocess (pps (ppx_compare)))
))
(documentation
((package InferGenerated)
(mld_files (index))
))
|}
(String.concat " " cflags)
(String.concat " " common_optflags)
|> Jbuild_plugin.V1.send

@ -0,0 +1,22 @@
(* -*- tuareg -*- *)
(* NOTE: prepend dune.common to this file! *)
;; Format.sprintf
{|
(library
(name InferBase)
(public_name InferBase)
(flags (%s -open Core -open InferStdlib -open IStd -open InferGenerated))
(ocamlopt_flags (%s))
(libraries %s)
(preprocess (pps ppx_compare))
)
(documentation
(package InferBase)
(mld_files index)
)
|}
(String.concat " " common_cflags)
(String.concat " " common_optflags)
(String.concat " " ("InferStdlib" :: "InferGenerated" :: common_libraries))
|> Jbuild_plugin.V1.send

@ -1,22 +0,0 @@
(* -*- tuareg -*- *)
(* NOTE: prepend jbuild.common to this file! *)
;; Format.sprintf
{|
(library
((name InferBase)
(public_name InferBase)
(flags (%s -open Core -open InferStdlib -open IStd -open InferGenerated))
(ocamlopt_flags (%s))
(libraries (%s))
(preprocess (pps (ppx_compare)))
))
(documentation
((package InferBase)
(mld_files (index))
))
|}
(String.concat " " common_cflags)
(String.concat " " common_optflags)
(String.concat " " ("InferStdlib" :: "InferGenerated" :: common_libraries))
|> Jbuild_plugin.V1.send

@ -18,7 +18,7 @@
# 4. Kill detected dead code; repeat until dry.
#
# Infer is first compiled so that atdgen, ocamllex, and menhir generate the appropriate files. The
# ocamllex and menhir files are generated inside ../_build by jbuilder, and copied here by this
# ocamllex and menhir files are generated inside ../_build by dune, and copied here by this
# Makefile.
#
# ocamldepend is used to `cat` the source files in the right order into all_infer_in_one_file.ml.
@ -127,11 +127,11 @@ flatten_infer: infer.cmx unit/inferunit.cmx facebook/InferCreateTraceViewLinks.c
.PHONY: detect_dead_code
detect_dead_code:
$(MAKE) clean
# create a dummy implementation file to keep jbuilder happy, as we are about to generate the
# jbuilder file for this directory
# create a dummy implementation file to keep dune happy, as we are about to generate the
# dune file for this directory
touch $(ALL_INFER_IN_ONE_FILE_ML) $(ALL_INFER_IN_ONE_FILE_ML:.ml=.mli)
# needed to get jbuild generated, and the generated code for the lexers and parsers in ../_build
$(MAKE) GENERATED_JBUILDS=deadcode/jbuild -C .. test
# needed to get dune generated, and the generated code for the lexers and parsers in ../_build
$(MAKE) GENERATED_DUNES=deadcode/dune -C .. test
# copy generated source files from ../_build
for file in $(ml_src_files_from_mlly); do \
set +e; \
@ -153,14 +153,14 @@ detect_dead_code:
$(MAKE) -j 1 ALL_INFER_IN_ONE_FILE_ML="$$tmp_file" flatten_infer; \
mv "$$tmp_file" $(ALL_INFER_IN_ONE_FILE_ML)
# build and get dead code warnings; clean in case of errors so as not to leave rubbish around
if ! jbuilder build $(INFER_BUILD_DIR)/deadcode/all_infer_in_one_file.bc; then \
if ! dune build $(INFER_BUILD_DIR)/deadcode/all_infer_in_one_file.bc; then \
$(MAKE) clean; \
exit 1; \
fi
# be paranoid about cleaning because we do not want to include infer_in_one_file into infer by
# accident and I don't know enough jbuilder to be positive that it won't happen
# accident and I don't know enough dune to be positive that it won't happen
$(MAKE) clean
.PHONY: clean
clean:
$(REMOVE) .depend *.ml *.mli jbuild
$(REMOVE) .depend *.ml *.mli dune

@ -0,0 +1,18 @@
(* -*- tuareg -*- *)
(* NOTE: prepend dune.common to this file! *)
;; Format.sprintf
{|
(executable
(name all_infer_in_one_file)
(flags (%s -w +60))
(ocamlopt_flags (%s))
(libraries %s)
(modules All_infer_in_one_file)
(preprocess (pps ppx_compare ppx_sexp_conv -no-check))
)
|}
(String.concat " " common_cflags)
(String.concat " " common_optflags)
(String.concat " " common_libraries)
|> Jbuild_plugin.V1.send

@ -1,18 +0,0 @@
(* -*- tuareg -*- *)
(* NOTE: prepend jbuild.common to this file! *)
;; Format.sprintf
{|
(executable
((name all_infer_in_one_file)
(flags (%s -w +60))
(ocamlopt_flags (%s))
(libraries (%s))
(modules (All_infer_in_one_file))
(preprocess (pps (ppx_compare ppx_sexp_conv -no-check)))
))
|}
(String.concat " " common_cflags)
(String.concat " " common_optflags)
(String.concat " " common_libraries)
|> Jbuild_plugin.V1.send

@ -0,0 +1,2 @@
(lang dune 1.0)
(using menhir 1.0)

@ -0,0 +1,5 @@
(lang dune 1.0)
(context (opam (switch @OPAMSWITCH@) (name default) (merlin)))
(context (opam (switch @OPAMSWITCH@) (name opt)))
(context (opam (switch @OPAMSWITCH@) (name test)))

@ -1,5 +1,5 @@
(* -*- tuareg -*- *)
(* NOTE: prepend jbuild.common to this file! *)
(* NOTE: prepend dune.common to this file! *)
let ( ^/ ) = Filename.concat
@ -41,29 +41,28 @@ let infer_cflags =
; "InferBase" ]
(** The build stanzas to be passed to jbuilder *)
(** The build stanzas to be passed to dune *)
let stanzas =
( if clang then
["(ocamllex (types_lexer ctl_lexer))"; "(menhir ((modules (types_parser ctl_parser))))"]
( if clang then ["(ocamllex types_lexer ctl_lexer)"; "(menhir (modules types_parser ctl_parser))"]
else [] )
@ ( if python && facebook then ["(ocamllex (pythonLexer))"; "(menhir ((modules (pythonParser))))"]
@ ( if python && facebook then ["(ocamllex pythonLexer)"; "(menhir (modules pythonParser))"]
else [] )
@ [ Format.sprintf
{|
(library
((name InferModules)
(name InferModules)
(public_name infer)
(flags (%s))
(ocamlopt_flags (%s))
(libraries (%s))
(modules (:standard \ %s infertop))
(preprocess (pps (ppx_compare ppx_sexp_conv -no-check)))
))
(libraries %s)
(modules :standard \ %s infertop)
(preprocess (pps ppx_compare ppx_sexp_conv -no-check))
)
(documentation
((package infer)
(mld_files (index))
))
(package infer)
(mld_files index)
)
|}
(String.concat " " infer_cflags)
(String.concat " " common_optflags)
@ -72,13 +71,13 @@ let stanzas =
; Format.sprintf
{|
(executables
((names (%s))
(names %s)
(flags (%s -open InferModules))
(ocamlopt_flags (%s))
(libraries (InferModules))
(modules (%s))
(preprocess (pps (ppx_compare ppx_sexp_conv -no-check)))
))
(libraries InferModules)
(modules %s)
(preprocess (pps ppx_compare ppx_sexp_conv -no-check))
)
|}
(String.concat " " infer_binaries)
(String.concat " " infer_cflags)
@ -87,12 +86,13 @@ let stanzas =
; Format.sprintf
{|
(executable
((name infertop)
(name infertop)
(flags (%s))
(libraries (utop InferModules))
(modules (Infertop))
(preprocess (pps (ppx_compare ppx_sexp_conv -no-check)))
(link_flags (-linkall -warn-error -31))))
(libraries utop InferModules)
(modules Infertop)
(preprocess (pps ppx_compare ppx_sexp_conv -no-check))
(link_flags (-linkall -warn-error -31))
)
|}
(String.concat " " infer_cflags) ]
@ ( List.map

@ -0,0 +1,22 @@
(* -*- tuareg -*- *)
(* NOTE: prepend dune.common to this file! *)
;; Format.sprintf
{|
(library
(name InferStdlib)
(public_name InferStdlib)
(flags (%s -open Core))
(ocamlopt_flags (%s))
(libraries %s)
(preprocess (pps ppx_compare))
)
(documentation
(package InferStdlib)
(mld_files index)
)
|}
(String.concat " " common_cflags)
(String.concat " " common_optflags)
(String.concat " " common_libraries)
|> Jbuild_plugin.V1.send

@ -1,22 +0,0 @@
(* -*- tuareg -*- *)
(* NOTE: prepend jbuild.common to this file! *)
;; Format.sprintf
{|
(library
((name InferStdlib)
(public_name InferStdlib)
(flags (%s -open Core))
(ocamlopt_flags (%s))
(libraries (%s))
(preprocess (pps (ppx_compare)))
))
(documentation
((package InferStdlib)
(mld_files (index))
))
|}
(String.concat " " common_cflags)
(String.concat " " common_optflags)
(String.concat " " common_libraries)
|> Jbuild_plugin.V1.send

@ -1,3 +0,0 @@
(context ((switch @OPAMSWITCH@) (name default) (merlin)))
(context ((switch @OPAMSWITCH@) (name opt)))
(context ((switch @OPAMSWITCH@) (name test)))

@ -0,0 +1,12 @@
(* NOTE: prepend dune.common to this file! *)
;; Format.sprintf
{|
(executable
(name checkCopyright)
(flags (%s))
(libraries core str)
(preprocess (pps ppx_compare))
)
|}
(String.concat " " common_cflags)
|> Jbuild_plugin.V1.send

@ -1,12 +0,0 @@
(* NOTE: prepend jbuild.common to this file! *)
;; Format.sprintf
{|
(executable
((name checkCopyright)
(flags (%s))
(libraries (core str))
(preprocess (pps (ppx_compare)))
))
|}
(String.concat " " common_cflags)
|> Jbuild_plugin.V1.send

@ -35,9 +35,9 @@ depends: [
"conf-sqlite3" {build}
"conf-zlib" {build}
"ctypes" {>="0.9.2"}
"dune" {build & >="1.0"}
"extlib-compat"
"javalib" {>="2.3.4"}
"jbuilder" {build & >="1.0+beta14"}
"mtime"
"ocamlfind" {build}
"ounit" {="2.0.5"}

@ -21,18 +21,19 @@ core_kernel = v0.11.0
cppo = 1.6.4
cppo_ocamlbuild = 1.6.0
ctypes = 0.14.0
dune = 1.0.0
easy-format = 1.3.1
extlib-compat = 1.7.2
fieldslib = v0.11.0
integers = 0.2.2
jane-street-headers = v0.11.0
javalib = 2.3.4
jbuilder = 1.0+beta20
jbuilder = transition
menhir = 20171222
mtime = 1.1.0
num = 1.1
ocaml-compiler-libs = v0.11.0
ocaml-migrate-parsetree = 1.0.9
ocaml-migrate-parsetree = 1.0.11
ocamlbuild = 0.12.0
ocamlfind = 1.8.0
octavius = 1.2.0
@ -66,7 +67,7 @@ ppx_sexp_value = v0.11.0
ppx_tools = 5.1+4.06.0
ppx_typerep_conv = v0.11.0
ppx_variants_conv = v0.11.0
ppxlib = 0.2.0
ppxlib = 0.2.1
re = 1.7.3
result = 1.3
sawja = 1.5.3

@ -17,7 +17,7 @@ INCLUDE_FLAGS=$(find "$TOPLEVEL_DIR" -type d -name '*.objs' -exec printf -- '-I
# file. In interactive mode $SCRIPT_DIR isn't needed
set -x
# infertop expects to be run from where jbuild is located
# infertop expects to be run from where dune is located
cd "$SCRIPT_DIR"/../infer
"$TOPLEVEL_DIR"/infertop.bc \
-init "$SCRIPT_DIR"/toplevel_init \

@ -30,7 +30,7 @@ let flags deps =
{|(flags (%s %s))
(ocamlc_flags (%s))
(ocamlopt_flags (%s))
(preprocess (pps (ppx_compare ppx_sexp_conv ppx_trace %s ppx_driver.runner)))|}
(preprocess (pps ppx_compare ppx_sexp_conv ppx_trace %s ppx_driver.runner))|}
common_flags
(String.concat " "
(List.map (fun d -> "-open " ^ String.capitalize_ascii d) ("core_kernel" :: deps)))

Loading…
Cancel
Save