[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 let ( ^/ ) = Filename.concat
(* Compute the list of all the source files. let source_dirs =
(if facebook then "facebook" else "opensource")
This is needed until jbuilder supports finding sources in subdirectories somehow :: ( ( if clang then ["clang"; ("unit" ^/ "clang")]
(https://github.com/janestreet/jbuilder/issues/34). *) else ["clang_stubs"; ("unit" ^/ "clang_stubs")] )
@ [ (if java then "java" else "java_stubs")
let sources = ; (if python && facebook then "python" else "python_stubs")
let src_dirs = ; "absint"
( if facebook then ; "backend"
(* do not use the symlinks in src/facebook/: jbuilder will not detect that the files have changed if they are hidden behind a symlink *) ; "base"
"../../facebook/skel/infer/src/facebook" ; "bufferoverrun"
else "opensource" ) ; "checkers"
:: ( ( if clang then ["clang"; ("unit" ^/ "clang")] ; "eradicate"
else ["clang_stubs"; ("unit" ^/ "clang_stubs")] ) ; "harness"
@ [ (if java then "java" else "java_stubs") ; "integration"
; (if python && facebook then "python" else "python_stubs") ; "IR"
; "absint" ; "labs"
; "backend" ; "quandary"
; "base" ; "unit" ] )
; "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 infer_binaries = let infer_binaries =
["infer"; "inferunit"] @ if facebook then ["InferCreateTraceViewLinks"] else [] ["infer"; "inferunit"] @ if facebook then ["InferCreateTraceViewLinks"] else []
@ -52,16 +30,6 @@ let infer_cflags =
let infer_libraries = "InferStdlib" :: "InferGenerated" :: common_libraries 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 *) (** The build stanzas to be passed to jbuilder *)
let stanzas = let stanzas =
( if clang then ( if clang then
@ -107,10 +75,13 @@ let stanzas =
|} |}
(String.concat " " infer_cflags) (String.concat " " common_optflags) (String.concat " " infer_cflags) (String.concat " " common_optflags)
(String.concat " " infer_binaries) ] (String.concat " " infer_binaries) ]
@ List.map @ ( List.map
(fun source -> (fun source_dir ->
Printf.sprintf "(rule (%s %s %s))" (copy_action_of_source source) source [ Printf.sprintf "(copy_files# %s/*.ml{,i,l})" source_dir
(Filename.basename source)) ; (* menhir doesn't support '# 1 "<source file>"' directives at the start of the file inserted by
sources copy# actions *)
Printf.sprintf "(copy_files %s/*.mly)" source_dir ])
source_dirs
|> List.concat )
;; String.concat "\n" stanzas |> Jbuild_plugin.V1.send ;; String.concat "\n" stanzas |> Jbuild_plugin.V1.send

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

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

Loading…
Cancel
Save