Skip to content

Commit

Permalink
Extract virtual library for build-info for JS compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
sim642 committed Jan 16, 2023
1 parent c941a11 commit 7b3b392
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gobview
Submodule gobview updated 1 files
+1 −0 src/dune
6 changes: 6 additions & 0 deletions src/build-info/build_info_dune/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; goblint.build-info implementation which properly uses dune-build-info
(library
(name goblint_build_info_dune)
(public_name goblint.build-info.dune)
(implements goblint.build-info)
(libraries dune-build-info))
6 changes: 6 additions & 0 deletions src/build-info/build_info_dune/goblint_build_info.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let statically_linked_libraries =
List.map (fun lib ->
let name = Build_info.V1.Statically_linked_library.name lib in
let version = Option.map Build_info.V1.Version.to_string (Build_info.V1.Statically_linked_library.version lib) in
(name, version)
) (Build_info.V1.Statically_linked_libraries.to_list ())
5 changes: 5 additions & 0 deletions src/build-info/build_info_js/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
; goblint.build-info implementation which works with js_of_ocaml and doesn't use dune-build-info
(library
(name goblint_build_info_js)
(public_name goblint.build-info.js)
(implements goblint.build-info))
1 change: 1 addition & 0 deletions src/build-info/build_info_js/goblint_build_info.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let statically_linked_libraries = []
11 changes: 11 additions & 0 deletions src/build-info/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(include_subdirs no)

; virtual library to allow js build (for gobview) without dune-build-info
; dune-build-info seems to be incompatible with js_of_ocaml
; File "gobview/src/.App.eobjs/build_info_data.ml-gen", line 1:
; Error: Could not find the .cmi file for interface
; gobview/src/.App.eobjs/build_info_data.ml-gen.
(library
(name goblint_build_info)
(public_name goblint.build-info)
(virtual_modules goblint_build_info))
1 change: 1 addition & 0 deletions src/build-info/goblint_build_info.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
val statically_linked_libraries: (string * string option) list
10 changes: 5 additions & 5 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
(name goblint_lib)
(public_name goblint.lib)
(modules :standard \ goblint mainspec privPrecCompare apronPrecCompare messagesCompare)
(libraries goblint.sites goblint-cil.all-features batteries.unthreaded qcheck-core.runner sha json-data-encoding jsonrpc cpu arg-complete fpath yaml yaml.unix uuidm goblint_timing catapult goblint_backtrace dune-build-info
(libraries goblint.sites goblint.build-info goblint-cil.all-features batteries.unthreaded qcheck-core.runner sha json-data-encoding jsonrpc cpu arg-complete fpath yaml yaml.unix uuidm goblint_timing catapult goblint_backtrace
; Conditionally compile based on whether apron optional dependency is installed or not.
; Alternative dependencies seem like the only way to optionally depend on optional dependencies.
; See: https://dune.readthedocs.io/en/stable/concepts.html#alternative-dependencies.
Expand Down Expand Up @@ -76,31 +76,31 @@
(public_names goblint -)
(modes byte native) ; https://dune.readthedocs.io/en/stable/dune-files.html#linking-modes
(modules goblint mainspec)
(libraries goblint.lib goblint.sites.dune)
(libraries goblint.lib goblint.sites.dune goblint.build-info.dune)
(preprocess (pps ppx_deriving.std ppx_deriving_hash ppx_deriving_yojson))
(flags :standard -linkall)
)

(executable
(name privPrecCompare)
(modules privPrecCompare)
(libraries goblint.lib goblint.sites.dune)
(libraries goblint.lib goblint.sites.dune goblint.build-info.dune)
(preprocess (pps ppx_deriving.std ppx_deriving_hash ppx_deriving_yojson))
(flags :standard -linkall)
)

(executable
(name apronPrecCompare)
(modules apronPrecCompare)
(libraries goblint.lib goblint.sites.dune)
(libraries goblint.lib goblint.sites.dune goblint.build-info.dune)
(preprocess (pps ppx_deriving.std ppx_deriving_hash ppx_deriving_yojson))
(flags :standard -linkall)
)

(executable
(name messagesCompare)
(modules messagesCompare)
(libraries goblint.lib goblint.sites.dune)
(libraries goblint.lib goblint.sites.dune goblint.build-info.dune)
(preprocess (pps ppx_deriving.std ppx_deriving_hash ppx_deriving_yojson))
(flags :standard -linkall)
)
Expand Down
10 changes: 3 additions & 7 deletions src/maingoblint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@ let print_version ch =
printf "OCaml flambda: %s\n" ConfigOcaml.flambda;
if get_bool "dbg.verbose" then (
printf "Library versions:\n";
List.iter (fun lib ->
let name = Build_info.V1.Statically_linked_library.name lib in
let version = match Build_info.V1.Statically_linked_library.version lib with
| Some v -> Build_info.V1.Version.to_string v
| None -> "[unknown]"
in
List.iter (fun (name, version) ->
let version = Option.default "[unknown]" version in
printf " %s: %s\n" name version
) (Build_info.V1.Statically_linked_libraries.to_list ())
) Goblint_build_info.statically_linked_libraries
);
exit 0

Expand Down
2 changes: 1 addition & 1 deletion unittest/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

(test
(name mainTest)
(libraries ounit2 qcheck-ounit goblint.lib goblint.sites.dune)
(libraries ounit2 qcheck-ounit goblint.lib goblint.sites.dune goblint.build-info.dune)
(preprocess (pps ppx_deriving.std ppx_deriving_hash ppx_deriving_yojson))
(flags :standard -linkall))

Expand Down

0 comments on commit 7b3b392

Please sign in to comment.