@ -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