Skip to content

Commit 75b3883

Browse files
authored
Merge pull request #1206 from goblint/goblint-dune-libs
Organize some general modules into dune libraries
2 parents d9afd55 + 51b15c2 commit 75b3883

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+299
-106
lines changed

.github/workflows/options.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626
run: npm install -g ajv-cli
2727

2828
- name: Migrate schema # https://github.com/ajv-validator/ajv-cli/issues/199
29-
run: ajv migrate -s src/util/options.schema.json
29+
run: ajv migrate -s src/common/util/options.schema.json
3030

3131
- name: Validate conf
32-
run: ajv validate -s src/util/options.schema.json -d "conf/**/*.json"
32+
run: ajv validate -s src/common/util/options.schema.json -d "conf/**/*.json"
3333

3434
- name: Validate incremental tests
35-
run: ajv validate -s src/util/options.schema.json -d "tests/incremental/*/*.json"
35+
run: ajv validate -s src/common/util/options.schema.json -d "tests/incremental/*/*.json"

.readthedocs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ build:
2020
- pip install json-schema-for-humans
2121
post_build:
2222
- mkdir _readthedocs/html/jsfh/
23-
- generate-schema-doc --config-file jsfh.yml src/util/options.schema.json _readthedocs/html/jsfh/
23+
- generate-schema-doc --config-file jsfh.yml src/common/util/options.schema.json _readthedocs/html/jsfh/

docs/user-guide/configuring.md

+1-1

gobview

mkdocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ nav:
3030
- 👶 Your first analysis: developer-guide/firstanalysis.md
3131
- 🏫 Extending library: developer-guide/extending-library.md
3232
- 📢 Messaging: developer-guide/messaging.md
33-
- 🗃️ API reference: https://goblint.github.io/analyzer/
33+
- 🗃️ API reference: https://goblint.github.io/analyzer/goblint/
3434
- 🚨 Testing: developer-guide/testing.md
3535
- 🪲 Debugging: developer-guide/debugging.md
3636
- 📉 Profiling: developer-guide/profiling.md

src/build-info/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
config*.ml

src/build-info/dune

+19-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,22 @@
88
(library
99
(name goblint_build_info)
1010
(public_name goblint.build-info)
11-
(virtual_modules goblint_build_info))
11+
(libraries batteries.unthreaded)
12+
(virtual_modules dune_build_info))
13+
14+
(rule
15+
(target configVersion.ml)
16+
(mode (promote (until-clean) (only configVersion.ml))) ; replace existing file in source tree, even if releasing (only overrides)
17+
(deps (universe)) ; do not cache, always regenerate
18+
(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\"'")))))
19+
20+
(rule
21+
(target configProfile.ml)
22+
(mode (promote (until-clean) (only configProfile.ml))) ; replace existing file in source tree, even if releasing (only overrides)
23+
(action (write-file %{target} "(* Automatically regenerated, changes do not persist! *)\nlet profile = \"%{profile}\"")))
24+
25+
(rule
26+
(target configOcaml.ml)
27+
(mode (promote (until-clean) (only configOcaml.ml))) ; replace existing file in source tree, even if releasing (only overrides)
28+
(action (write-file %{target} "(* Automatically regenerated, changes do not persist! *)\nlet flambda = \"%{ocaml-config:flambda}\"")))
29+

src/build-info/goblint_build_info.ml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(** Goblint build info. *)
2+
3+
(** OCaml compiler flambda status. *)
4+
let ocaml_flambda = ConfigOcaml.flambda
5+
6+
(** Dune profile. *)
7+
let dune_profile = ConfigProfile.profile
8+
9+
(** Goblint version from git. *)
10+
let git_version = ConfigVersion.version
11+
12+
(** Goblint version from release archive. *)
13+
let release_version = "%%VERSION_NUM%%"
14+
15+
(** Goblint git commit from release archive. *)
16+
let release_commit = "%%VCS_COMMIT_ID%%"
17+
18+
(** Goblint version. *)
19+
let version =
20+
let commit = ConfigVersion.version in
21+
if BatString.starts_with release_version "%" then
22+
commit
23+
else (
24+
let commit =
25+
if commit = "n/a" then (* released archive has no .git *)
26+
release_commit
27+
else
28+
commit
29+
in
30+
Format.sprintf "%s (%s)" release_version commit
31+
)
32+
33+
(** Statically linked libraries with versions. *)
34+
let statically_linked_libraries = Dune_build_info.statically_linked_libraries
File renamed without changes.

src/common/common.mld

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{0 Library goblint.common}
2+
This library is unwrapped and provides the following top-level modules.
3+
For better context, see {!Goblint_lib} which also documents these modules.
4+
5+
6+
{1 Framework}
7+
8+
{2 CFG}
9+
{!modules:
10+
Node
11+
Edge
12+
MyCFG
13+
}
14+
15+
{2 Specification}
16+
{!modules:
17+
AnalysisState
18+
ControlSpecC
19+
}
20+
21+
{2 Configuration}
22+
{!modules:
23+
GobConfig
24+
AfterConfig
25+
JsonSchema
26+
Options
27+
}
28+
29+
30+
{1 Domains}
31+
{!modules:
32+
Printable
33+
Lattice
34+
}
35+
36+
{2 Analysis-specific}
37+
38+
{3 Other}
39+
{!modules:Basetype}
40+
41+
42+
{1 I/O}
43+
{!modules:
44+
Messages
45+
Tracing
46+
}
47+
48+
49+
{1 Utilities}
50+
{!modules:Timing}
51+
52+
{2 General}
53+
{!modules:
54+
LazyEval
55+
ResettableLazy
56+
MessageUtil
57+
XmlUtil
58+
}
59+
60+
{2 CIL}
61+
{!modules:
62+
CilType
63+
Cilfacade
64+
RichVarinfo
65+
}
66+
67+
68+
{1 Library extensions}
69+
70+
{2 Standard library}
71+
{!modules:GobFormat}
72+
73+
{2 Other libraries}
74+
{!modules:MyCheck}

src/domains/lattice.ml renamed to src/common/domains/lattice.ml

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
module Pretty = GoblintCil.Pretty
55

66
(* module type Rel =
7-
sig
8-
type t
9-
type relation = Less | Equal | Greater | Uncomparable
10-
val rel : t -> t -> relation
11-
val in_rel : t -> relation -> t -> bool
12-
end *)
7+
sig
8+
type t
9+
type relation = Less | Equal | Greater | Uncomparable
10+
val rel : t -> t -> relation
11+
val in_rel : t -> relation -> t -> bool
12+
end *)
1313

1414
(* partial order: elements might not be comparable and no bot/top -> join etc. might fail with exception Uncomparable *)
1515
exception Uncomparable
@@ -324,14 +324,14 @@ struct
324324
match (x,y) with
325325
| (`Lifted x, `Lifted y) ->
326326
(try `Lifted (Base.widen x y)
327-
with Uncomparable -> `Top)
327+
with Uncomparable -> `Top)
328328
| _ -> y
329329

330330
let narrow x y =
331331
match (x,y) with
332332
| (`Lifted x, `Lifted y) ->
333333
(try `Lifted (Base.narrow x y)
334-
with Uncomparable -> `Bot)
334+
with Uncomparable -> `Bot)
335335
| _ -> x
336336
end
337337

File renamed without changes.
File renamed without changes.

src/common/dune

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
(include_subdirs unqualified)
2+
3+
(library
4+
(name goblint_common)
5+
(public_name goblint.common)
6+
(wrapped false) ; TODO: wrap
7+
(libraries
8+
batteries.unthreaded
9+
zarith
10+
goblint_std
11+
goblint-cil
12+
fpath
13+
yojson
14+
json-data-encoding
15+
cpu
16+
goblint_timing
17+
goblint_build_info
18+
goblint.sites
19+
qcheck-core.runner)
20+
(flags :standard -open Goblint_std)
21+
(preprocess
22+
(pps
23+
ppx_deriving.std
24+
ppx_deriving_hash
25+
ppx_deriving_yojson
26+
ppx_blob))
27+
(preprocessor_deps (file util/options.schema.json)))
28+
29+
(documentation)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/util/lazyEval.ml renamed to src/common/util/lazyEval.ml

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
Node -> CilType -> Printable -> Goblintutil -> GobConfig -> Tracing -> Node *)
66

77
module Make (M : sig
8-
type t
9-
type result
10-
val eval : t -> result
11-
end) : sig
8+
type t
9+
type result
10+
val eval : t -> result
11+
end) : sig
1212
type t
1313
val make : M.t -> t
1414
val force : t -> M.result
@@ -20,8 +20,8 @@ end = struct
2020
let force l =
2121
match l.value with
2222
| `Closure arg ->
23-
let v = M.eval arg in
24-
l.value <- `Computed v;
25-
v
23+
let v = M.eval arg in
24+
l.value <- `Computed v;
25+
v
2626
| `Computed v -> v
2727
end

src/util/messageCategory.ml renamed to src/common/util/messageCategory.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ let categoryName = function
260260

261261
| Behavior x -> behaviorName x
262262
| Integer x -> (match x with
263-
| Overflow -> "Overflow";
264-
| DivByZero -> "DivByZero")
263+
| Overflow -> "Overflow";
264+
| DivByZero -> "DivByZero")
265265
| Float -> "Float"
266266

267267

File renamed without changes.
File renamed without changes.

src/util/options.ml renamed to src/common/util/options.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(** [src/util/options.schema.json] low-level access. *)
1+
(** [src/common/util/options.schema.json] low-level access. *)
22

33
open Json_schema
44

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/util/tracing.ml renamed to src/common/util/tracing.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ open Pretty
1010
module Strs = Set.Make (String)
1111

1212

13-
let tracing = ConfigProfile.profile = "trace"
13+
let tracing = Goblint_build_info.dune_profile = "trace"
1414

1515
let current_loc = ref locUnknown
1616
let next_loc = ref locUnknown
File renamed without changes.

src/dune

+12-26
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
(name goblint_lib)
88
(public_name goblint.lib)
99
(modules :standard \ goblint mainspec privPrecCompare apronPrecCompare messagesCompare)
10-
(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 fileutils
10+
(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 fileutils goblint_std goblint_common
1111
; Conditionally compile based on whether apron optional dependency is installed or not.
1212
; Alternative dependencies seem like the only way to optionally depend on optional dependencies.
1313
; See: https://dune.readthedocs.io/en/stable/concepts.html#alternative-dependencies.
@@ -56,11 +56,11 @@
5656
(-> violationZ3.no-z3.ml)
5757
)
5858
)
59+
(flags :standard -open Goblint_std)
5960
(foreign_stubs (language c) (names stubs))
6061
(ocamlopt_flags :standard -no-float-const-prop)
6162
(preprocess
6263
(pps ppx_deriving.std ppx_deriving_hash ppx_deriving_yojson ppx_blob))
63-
(preprocessor_deps (file util/options.schema.json))
6464
(instrumentation (backend bisect_ppx))
6565
)
6666

@@ -77,51 +77,35 @@
7777
(public_names goblint -)
7878
(modes byte native) ; https://dune.readthedocs.io/en/stable/dune-files.html#linking-modes
7979
(modules goblint mainspec)
80-
(libraries goblint.lib goblint.sites.dune goblint.build-info.dune)
80+
(libraries goblint.lib goblint.sites.dune goblint.build-info.dune goblint_std)
8181
(preprocess (pps ppx_deriving.std ppx_deriving_hash ppx_deriving_yojson))
82-
(flags :standard -linkall)
82+
(flags :standard -linkall -open Goblint_std)
8383
)
8484

8585
(executable
8686
(name privPrecCompare)
8787
(modules privPrecCompare)
88-
(libraries goblint.lib goblint.sites.dune goblint.build-info.dune)
88+
(libraries goblint.lib goblint.sites.dune goblint.build-info.dune goblint_std)
8989
(preprocess (pps ppx_deriving.std ppx_deriving_hash ppx_deriving_yojson))
90-
(flags :standard -linkall)
90+
(flags :standard -linkall -open Goblint_std)
9191
)
9292

9393
(executable
9494
(name apronPrecCompare)
9595
(modules apronPrecCompare)
96-
(libraries goblint.lib goblint.sites.dune goblint.build-info.dune)
96+
(libraries goblint.lib goblint.sites.dune goblint.build-info.dune goblint_std)
9797
(preprocess (pps ppx_deriving.std ppx_deriving_hash ppx_deriving_yojson))
98-
(flags :standard -linkall)
98+
(flags :standard -linkall -open Goblint_std)
9999
)
100100

101101
(executable
102102
(name messagesCompare)
103103
(modules messagesCompare)
104-
(libraries goblint.lib goblint.sites.dune goblint.build-info.dune)
104+
(libraries goblint.lib goblint.sites.dune goblint.build-info.dune goblint_std)
105105
(preprocess (pps ppx_deriving.std ppx_deriving_hash ppx_deriving_yojson))
106-
(flags :standard -linkall)
106+
(flags :standard -linkall -open Goblint_std)
107107
)
108108

109-
(rule
110-
(target configVersion.ml)
111-
(mode (promote (until-clean) (only configVersion.ml))) ; replace existing file in source tree, even if releasing (only overrides)
112-
(deps (universe)) ; do not cache, always regenerate
113-
(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\"'")))))
114-
115-
(rule
116-
(target configProfile.ml)
117-
(mode (promote (until-clean) (only configProfile.ml))) ; replace existing file in source tree, even if releasing (only overrides)
118-
(action (write-file %{target} "(* Automatically regenerated, changes do not persist! *)\nlet profile = \"%{profile}\"")))
119-
120-
(rule
121-
(target configOcaml.ml)
122-
(mode (promote (until-clean) (only configOcaml.ml))) ; replace existing file in source tree, even if releasing (only overrides)
123-
(action (write-file %{target} "(* Automatically regenerated, changes do not persist! *)\nlet flambda = \"%{ocaml-config:flambda}\"")))
124-
125109
(rule
126110
(alias runtest)
127111
(deps ../goblint ../scripts/update_suite.rb ../Makefile ../make.sh (source_tree ../tests/regression) (source_tree ../includes) (source_tree ../linux-headers))
@@ -141,3 +125,5 @@
141125
(flags (:standard -warn-error -A -w -unused-var-strict -w -unused-functor-parameter -w +9)) ; https://dune.readthedocs.io/en/stable/faq.html#how-to-make-warnings-non-fatal
142126
)
143127
)
128+
129+
(documentation)

src/framework/control.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ struct
529529
GobConfig.write_file config;
530530
let module Meta = struct
531531
type t = { command : string; version: string; timestamp : float; localtime : string } [@@deriving to_yojson]
532-
let json = to_yojson { command = GobSys.command_line; version = Version.goblint; timestamp = Unix.time (); localtime = GobUnix.localtime () }
532+
let json = to_yojson { command = GobSys.command_line; version = Goblint_build_info.version; timestamp = Unix.time (); localtime = GobUnix.localtime () }
533533
end
534534
in
535535
(* Yojson.Safe.to_file meta Meta.json; *)

0 commit comments

Comments
 (0)