Skip to content

Commit

Permalink
Move config modules to build_info dune library
Browse files Browse the repository at this point in the history
  • Loading branch information
sim642 committed Oct 5, 2023
1 parent a840e41 commit 7b76751
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 56 deletions.
1 change: 1 addition & 0 deletions src/build-info/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config*.ml
20 changes: 19 additions & 1 deletion src/build-info/dune
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,22 @@
(library
(name goblint_build_info)
(public_name goblint.build-info)
(virtual_modules goblint_build_info))
(libraries batteries.unthreaded)
(virtual_modules dune_build_info))

(rule
(target configVersion.ml)
(mode (promote (until-clean) (only configVersion.ml))) ; replace existing file in source tree, even if releasing (only overrides)
(deps (universe)) ; do not cache, always regenerate
(action (pipe-stdout (bash "git describe --all --long --dirty || echo \"n/a\"") (with-stdout-to %{target} (bash "xargs printf '(* Automatically regenerated, changes do not persist! *)\nlet version = \"%s\"'")))))

(rule
(target configProfile.ml)
(mode (promote (until-clean) (only configProfile.ml))) ; replace existing file in source tree, even if releasing (only overrides)
(action (write-file %{target} "(* Automatically regenerated, changes do not persist! *)\nlet profile = \"%{profile}\"")))

(rule
(target configOcaml.ml)
(mode (promote (until-clean) (only configOcaml.ml))) ; replace existing file in source tree, even if releasing (only overrides)
(action (write-file %{target} "(* Automatically regenerated, changes do not persist! *)\nlet flambda = \"%{ocaml-config:flambda}\"")))

File renamed without changes.
34 changes: 34 additions & 0 deletions src/build-info/goblint_build_info.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(** Goblint build info. *)

(** OCaml compiler flambda status. *)
let ocaml_flambda = ConfigOcaml.flambda

(** Dune profile. *)
let dune_profile = ConfigProfile.profile

(** Goblint version from git. *)
let git_version = ConfigVersion.version

(** Goblint version from release archive. *)
let release_version = "%%VERSION_NUM%%"

(** Goblint git commit from release archive. *)
let release_commit = "%%VCS_COMMIT_ID%%"

(** Goblint version. *)
let version =
let commit = ConfigVersion.version in
if BatString.starts_with release_version "%" then
commit
else (
let commit =
if commit = "n/a" then (* released archive has no .git *)
release_commit
else
commit
in
Format.sprintf "%s (%s)" release_version commit
)

(** Statically linked libraries with versions. *)
let statically_linked_libraries = Dune_build_info.statically_linked_libraries
16 changes: 0 additions & 16 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,6 @@
(flags :standard -linkall -open Goblint_std)
)

(rule
(target configVersion.ml)
(mode (promote (until-clean) (only configVersion.ml))) ; replace existing file in source tree, even if releasing (only overrides)
(deps (universe)) ; do not cache, always regenerate
(action (pipe-stdout (bash "git describe --all --long --dirty || echo \"n/a\"") (with-stdout-to %{target} (bash "xargs printf '(* Automatically regenerated, changes do not persist! *)\nlet version = \"%s\"'")))))

(rule
(target configProfile.ml)
(mode (promote (until-clean) (only configProfile.ml))) ; replace existing file in source tree, even if releasing (only overrides)
(action (write-file %{target} "(* Automatically regenerated, changes do not persist! *)\nlet profile = \"%{profile}\"")))

(rule
(target configOcaml.ml)
(mode (promote (until-clean) (only configOcaml.ml))) ; replace existing file in source tree, even if releasing (only overrides)
(action (write-file %{target} "(* Automatically regenerated, changes do not persist! *)\nlet flambda = \"%{ocaml-config:flambda}\"")))

(rule
(alias runtest)
(deps ../goblint ../scripts/update_suite.rb ../Makefile ../make.sh (source_tree ../tests/regression) (source_tree ../includes) (source_tree ../linux-headers))
Expand Down
2 changes: 1 addition & 1 deletion src/framework/control.ml
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ struct
GobConfig.write_file config;
let module Meta = struct
type t = { command : string; version: string; timestamp : float; localtime : string } [@@deriving to_yojson]
let json = to_yojson { command = GobSys.command_line; version = Version.goblint; timestamp = Unix.time (); localtime = GobUnix.localtime () }
let json = to_yojson { command = GobSys.command_line; version = Goblint_build_info.version; timestamp = Unix.time (); localtime = GobUnix.localtime () }
end
in
(* Yojson.Safe.to_file meta Meta.json; *)
Expand Down
15 changes: 0 additions & 15 deletions src/goblint_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -452,21 +452,6 @@ module PrivPrecCompareUtil = PrivPrecCompareUtil
module RelationPrecCompareUtil = RelationPrecCompareUtil
module ApronPrecCompareUtil = ApronPrecCompareUtil

(** {2 Build info} *)

(** OCaml compiler info. *)
module ConfigOcaml = ConfigOcaml

(** Dune profile info. *)
module ConfigProfile = ConfigProfile

(** Goblint version info. *)
module Version = Version

(** Goblint git version info. *)
module ConfigVersion = ConfigVersion


(** {1 Library extensions}
OCaml library extensions which are completely independent of Goblint.
Expand Down
6 changes: 3 additions & 3 deletions src/maingoblint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ let writeconffile = ref None

(** Print version and bail. *)
let print_version ch =
printf "Goblint version: %s\n" Version.goblint;
printf "Goblint version: %s\n" Goblint_build_info.version;
printf "Cil version: %s\n" Cil.cilVersion;
printf "Dune profile: %s\n" ConfigProfile.profile;
printf "Dune profile: %s\n" Goblint_build_info.dune_profile;
printf "OCaml version: %s\n" Sys.ocaml_version;
printf "OCaml flambda: %s\n" ConfigOcaml.flambda;
printf "OCaml flambda: %s\n" Goblint_build_info.ocaml_flambda;
if get_bool "dbg.verbose" then (
printf "Library versions:\n";
List.iter (fun (name, version) ->
Expand Down
2 changes: 1 addition & 1 deletion src/util/sarif.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let goblintTool: Tool.t = {
fullName = "Goblint static analyser";
informationUri = "https://goblint.in.tum.de/home";
organization = "TUM - i2 and UTartu - SWS";
version = Version.goblint;
version = Goblint_build_info.version;
rules = List.map transformToReportingDescriptor (List.map (fun rule -> rule.name) rules)
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/tracing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open Pretty
module Strs = Set.Make (String)


let tracing = ConfigProfile.profile = "trace"
let tracing = Goblint_build_info.dune_profile = "trace"

let current_loc = ref locUnknown
let next_loc = ref locUnknown
Expand Down
16 changes: 0 additions & 16 deletions src/version.ml

This file was deleted.

2 changes: 1 addition & 1 deletion src/witness/witness.ml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ let write_file filename (module Task:Task) (module TaskResult:WitnessTaskResult)
| Result.Unknown -> "unknown_witness"
);
GML.write_metadata g "sourcecodelang" "C";
GML.write_metadata g "producer" (Printf.sprintf "Goblint (%s)" Version.goblint);
GML.write_metadata g "producer" (Printf.sprintf "Goblint (%s)" Goblint_build_info.version);
GML.write_metadata g "specification" (Svcomp.Specification.to_string Task.specification);
let programfile = (Node.location (N.cfgnode main_entry)).file in
GML.write_metadata g "programfile" programfile;
Expand Down
2 changes: 1 addition & 1 deletion src/witness/yamlWitness.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct
(* let yaml_conf: Yaml.value = Json_repr.convert (module Json_repr.Yojson) (module Json_repr.Ezjsonm) (!GobConfig.json_conf) in *)
let producer: Producer.t = {
name = "Goblint";
version = Version.goblint;
version = Goblint_build_info.version;
command_line = Some GobSys.command_line;
}

Expand Down

0 comments on commit 7b76751

Please sign in to comment.