(* -*- tuareg -*- *) (* * 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. *) (* NOTE: prepend dune.common to this file! *) let ( ^/ ) = Filename.concat let source_dirs = (if clang then ["al"; "clang"; "unit" ^/ "clang"] else ["clang_stubs"; "unit" ^/ "clang_stubs"]) @ [ (if java then "java" else "java_stubs") ; "backend" ; "concurrency" ; "integration" ; "labs" ; "quandary" ; "test_determinator" ; "topl" ; "unit" ; "unit" ^/ "nullsafe" ] let infer_binaries = ["infer"; "inferunit"] @ if facebook then ["InferCreateTraceViewLinks"] else [] let env_stanza = Format.sprintf {| (env (dev (flags %s)) (opt (flags %s) (ocamlopt_flags (:standard -O3))) (test (flags %s)) ) |} lenient_flags lenient_flags strict_flags let clang_lexer_stanzas = if clang then ["(ocamllex types_lexer ctl_lexer)"; "(menhir (modules types_parser ctl_parser))"] else [] let infer_cflags = [ "-open" ; "Core" ; "-open" ; "Biabduction" ; "-open" ; "Bo" ; "-open" ; "Nullsafe" ; "-open" ; "Pulselib" ; "-open" ; "Checkers" ; "-open" ; "Costlib" ; "-open" ; "Absint" ; "-open" ; "OpenSource" ; "-open" ; "InferStdlib" ; "-open" ; "IStd" ; "-open" ; "InferGenerated" ; "-open" ; "InferIR" ; "-open" ; "InferBase" ; "-open" ; "InferCStubs" ] |> String.concat " " let main_lib_stanza = Format.sprintf {| (library (name InferModules) (public_name infer) (flags (:standard %s)) (libraries %s) (modules :standard \ %s infertop) (preprocess (pps ppx_compare ppx_fields_conv ppx_hash ppx_sexp_conv ppx_variants_conv -no-check)) ) |} infer_cflags (String.concat " " ( common_libraries @ [ "InferIR" ; "InferCStubs" ; "absint" ; "biabduction" ; "nullsafe" ; "bo" ; "pulselib" ; "checkers" ; "costlib" ] )) (String.concat " " infer_binaries) let infer_exe_stanza = Format.sprintf {| (executables (names %s) (modes byte_complete exe) (flags (:standard %s -open InferModules)) (libraries InferModules) (modules %s) (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) infer_cflags (String.concat " " infer_binaries) let infertop_stanza = Format.sprintf {| (executable (name infertop) (modes byte_complete) (flags (:standard %s)) (libraries utop InferModules) (link_flags (-linkall -warn-error -31)) (modules Infertop) (preprocess (pps ppx_compare ppx_fields_conv ppx_hash ppx_sexp_conv ppx_variants_conv -no-check)) (promote (until-clean) (into ../bin)) ) |} infer_cflags let topl_stanzas = ["(ocamllex ToplLexer)"; "(menhir (flags --unused-token INDENT --explain) (modules ToplParser))"] let java_sources_lexer = if java then ["(ocamllex jSourceFileInfo)"] else [] let flatten_sources_stanzas = List.map (fun source_dir -> [ Printf.sprintf "(copy_files# %s/*.ml{,i,l})" source_dir ; (* menhir doesn't support '# 1 ""' directives at the start of the file inserted by copy# actions *) Printf.sprintf "(copy_files %s/*.mly)" source_dir ] ) source_dirs |> List.concat (** The build stanzas to be passed to dune *) let stanzas = (env_stanza :: main_lib_stanza :: infer_exe_stanza :: infertop_stanza :: clang_lexer_stanzas) @ java_sources_lexer @ topl_stanzas @ flatten_sources_stanzas ;; String.concat "\n" stanzas |> Jbuild_plugin.V1.send