[build] take advantage of latest jbuilder+beta14

Summary:
This allows us to get rid of code that copied source files individually. I
didn't migrate the various flags that could be included as it doesn't look like
that's possible yet (they depend on the context and on some configuration
options).

Reviewed By: jberdine

Differential Revision: D6051825

fbshipit-source-id: c28dd37
master
Jules Villard 7 years ago committed by Facebook Github Bot
parent 171145603e
commit 93de989b4a

@ -3,46 +3,24 @@
let ( ^/ ) = Filename.concat
(* Compute the list of all the source files.
This is needed until jbuilder supports finding sources in subdirectories somehow
(https://github.com/janestreet/jbuilder/issues/34). *)
let sources =
let src_dirs =
( if facebook then
(* do not use the symlinks in src/facebook/: jbuilder will not detect that the files have changed if they are hidden behind a symlink *)
"../../facebook/skel/infer/src/facebook"
else "opensource" )
:: ( ( if clang then ["clang"; ("unit" ^/ "clang")]
else ["clang_stubs"; ("unit" ^/ "clang_stubs")] )
@ [ (if java then "java" else "java_stubs")
; (if python && facebook then "python" else "python_stubs")
; "absint"
; "backend"
; "base"
; "bufferoverrun"
; "checkers"
; "eradicate"
; "harness"
; "integration"
; "IR"
; "labs"
; "quandary"
; "unit" ] )
in
let files = ref [] in
let ml_suffixes = [".ml"; ".mli"; ".mll"; ".mly"] in
let add_file dir file =
if List.exists (Filename.check_suffix file) ml_suffixes then files := (dir ^/ file) :: !files
in
let one_dir dir =
(* absolute path so that running jbuilder from any subdirectory (in particular from src/Makefile)
points at the right original files in ocamlc's error messages *)
let abs_dir = Sys.getcwd () ^/ dir in
Array.iter (add_file abs_dir) (Sys.readdir dir)
in
List.iter one_dir src_dirs ; !files
let source_dirs =
(if facebook then "facebook" else "opensource")
:: ( ( if clang then ["clang"; ("unit" ^/ "clang")]
else ["clang_stubs"; ("unit" ^/ "clang_stubs")] )
@ [ (if java then "java" else "java_stubs")
; (if python && facebook then "python" else "python_stubs")
; "absint"
; "backend"
; "base"
; "bufferoverrun"
; "checkers"
; "eradicate"
; "harness"
; "integration"
; "IR"
; "labs"
; "quandary"
; "unit" ] )
let infer_binaries =
["infer"; "inferunit"] @ if facebook then ["InferCreateTraceViewLinks"] else []
@ -52,16 +30,6 @@ let infer_cflags =
let infer_libraries = "InferStdlib" :: "InferGenerated" :: common_libraries
(** Return the best copy action for a given [source] file. That is, when possibly, use "copy#" so
that jump-to-defition and compiler errors go to the right original source file, otherwise do a
normal copy. *)
let copy_action_of_source source =
if Filename.check_suffix source ".mly" then
(* menhir doesn't support '# 1 "<source file>"' directives at the start of the file inserted by
copy# actions *)
"copy"
else "copy#"
(** The build stanzas to be passed to jbuilder *)
let stanzas =
( if clang then
@ -107,10 +75,13 @@ let stanzas =
|}
(String.concat " " infer_cflags) (String.concat " " common_optflags)
(String.concat " " infer_binaries) ]
@ List.map
(fun source ->
Printf.sprintf "(rule (%s %s %s))" (copy_action_of_source source) source
(Filename.basename source))
sources
@ ( List.map
(fun source_dir ->
[ Printf.sprintf "(copy_files# %s/*.ml{,i,l})" source_dir
; (* menhir doesn't support '# 1 "<source file>"' directives at the start of the file inserted by
copy# actions *)
Printf.sprintf "(copy_files %s/*.mly)" source_dir ])
source_dirs
|> List.concat )
;; String.concat "\n" stanzas |> Jbuild_plugin.V1.send

@ -34,7 +34,7 @@ depends: [
"ctypes" {>="0.9.2"}
"extlib-compat"
"javalib" {>="2.3.3"}
"jbuilder" {build & >="1.0+beta11"}
"jbuilder" {build & >="1.0+beta14"}
"mtime"
"ocamlfind" {build}
"ounit" {="2.0.0"}

@ -24,7 +24,7 @@ fieldslib = v0.9.0
integers = 0.2.2
jane-street-headers = v0.9.0
javalib = 2.3.3
jbuilder = 1.0+beta13
jbuilder = 1.0+beta14
menhir = 20170712
mtime = 1.1.0
num = 0

Loading…
Cancel
Save