Skip to content

Commit 56bb399

Browse files
committed
prepare for 0.4.5
1 parent ae2fcdb commit 56bb399

File tree

3 files changed

+40
-48
lines changed

3 files changed

+40
-48
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.5 (2023-09-10)
2+
3+
* lintcstubs-dune-rules helper added
4+
15
## 0.4.4 (2023-09-09)
26

37
* helpers tools and examples added

example/dune2/dune.analysis.inc

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@
77
(action
88
(with-stdout-to dune.analysis.inc.gen
99
(run %{bin:lintcstubs-dune-rules} %{mlfiles} %{cfiles}))))
10-
(rule (alias runtest) (package lintcstubs)
11-
(enabled_if %{bin-available:lintcstubs})
10+
(rule (alias runtest) (enabled_if %{bin-available:lintcstubs})
1211
(action (diff dune.analysis.inc dune.analysis.inc.gen)))
13-
(rule (target compile_commands.json)
14-
(action (pipe-stdout (run dune rules) (run %{bin:dune-compiledb}))))
12+
(rule (targets ./lintcstubs.log ./lintcstubs.sarif)
13+
(enabled_if %{bin-available:lintcstubs})
14+
(deps (:primitives ./primitives.h) (:model foo2.model.c) %{bin:lintcstubs}
15+
(package lintcstubs))
16+
(action
17+
(with-stdout-to ./lintcstubs.log
18+
(run %{bin:lintcstubs} --conf lintcstubs.json -o ./lintcstubs.sarif -I
19+
%{ocaml_where} --set dbg.solver-stats-interval 0 compile_commands.json
20+
%{model}))))
21+
(rule (action (with-stdout-to compile_commands.json (echo [])))
22+
(mode fallback))
23+
(rule (alias analyze) (deps ./lintcstubs.log)
24+
(action (diff lintcstubs.out.reference %{deps})))
1525
(rule (enabled_if %{bin-available:lintcstubs_genmain})
1626
(targets foo2.model.c ./primitives.h)
1727
(deps (:cmt ./.foo2.objs/byte/foo2.cmt) %{bin:lintcstubs_arity_cmt}
@@ -22,14 +32,3 @@
2232
(with-stdout-to foo2.model.c
2333
(progn (run %{bin:lintcstubs_genwrap} %{cmt})
2434
(run %{bin:lintcstubs_genmain} %{cmt}))))))
25-
(rule (enabled_if %{bin-available:lintcstubs})
26-
(targets ./lintcstubs.log ./lintcstubs.sarif)
27-
(deps compile_commands.json (:primitives ./primitives.h)
28-
(:model foo2.model.c) %{bin:lintcstubs} (package lintcstubs))
29-
(action
30-
(with-stdout-to ./lintcstubs.log
31-
(run %{bin:lintcstubs} --conf lintcstubs.json -o ./lintcstubs.sarif -I
32-
%{ocaml_where} --set dbg.solver-stats-interval 0 compile_commands.json
33-
%{model}))))
34-
(rule (alias analyze) (deps (:log ./lintcstubs.log))
35-
(action (diff lintcstubs.out.reference %{deps})))

rules/main.ml

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,31 @@ let cmt_rule =
4242
4343
depend on (package) to get all files installed, e.g. json conf files
4444
*)
45-
let analyze_rule =
46-
Sexplib.Sexp.of_string
45+
let analyze_rules =
46+
Sexplib.Sexp.of_string_many
4747
{|
4848
(rule
49-
(enabled_if %{bin-available:lintcstubs})
5049
(targets %{log} %{sarif})
51-
(deps compile_commands.json (:primitives) (:model) %{bin:lintcstubs} (package lintcstubs))
50+
(enabled_if %{bin-available:lintcstubs})
51+
(deps (:primitives) (:model) %{bin:lintcstubs} (package lintcstubs))
5252
(action
5353
(with-stdout-to %{log}
5454
(run %{bin:lintcstubs} --conf lintcstubs.json -o %{sarif} -I %{ocaml_where} --set dbg.solver-stats-interval 0 compile_commands.json %{model})
5555
)
5656
)
5757
)
58-
|}
5958

60-
let analyze_alias_rule =
61-
Sexplib.Sexp.of_string
62-
{|
59+
(rule
60+
(action (with-stdout-to compile_commands.json (echo [])))
61+
(mode fallback)
62+
)
63+
6364
(rule
6465
(alias analyze)
65-
(deps (:log))
66+
(deps %{log})
6667
(action (diff lintcstubs.out.reference %{deps}))
6768
)
68-
|}
69+
|}
6970

7071
let incgen_rule =
7172
Sexplib.Sexp.of_string_many
@@ -84,20 +85,9 @@ let incgen_rule =
8485

8586
(rule
8687
(alias runtest)
87-
(package lintcstubs)
8888
(enabled_if %{bin-available:lintcstubs})
8989
(action
9090
(diff dune.analysis.inc dune.analysis.inc.gen)))
91-
92-
(rule
93-
(target compile_commands.json)
94-
(action
95-
(pipe-stdout
96-
(run dune rules)
97-
(run %{bin:dune-compiledb})
98-
)
99-
)
100-
)
10191
|}
10292

10393
let group_by_dirs paths =
@@ -163,18 +153,17 @@ let () =
163153
in
164154
let log_file = Fpath.(dir / "lintcstubs.log") in
165155
let sarif_file = Fpath.set_ext ".sarif" log_file in
166-
let analyze_rule =
167-
analyze_rule
168-
|> apply_template' "%{log}" log_file
169-
|> apply_template' "%{sarif}" sarif_file
170-
|> apply_template ":primitives" [primitives_file]
171-
|> apply_template ":model" (Fpath.Set.to_seq model_files |> List.of_seq)
172-
in
173-
let analyze_alias_rule =
174-
analyze_alias_rule |> apply_template ":log" [log_file]
156+
let analyze_rules =
157+
analyze_rules
158+
|> List.map @@ fun analyze_rule ->
159+
analyze_rule
160+
|> apply_template' "%{log}" log_file
161+
|> apply_template' "%{sarif}" sarif_file
162+
|> apply_template ":primitives" [primitives_file]
163+
|> apply_template ":model"
164+
(Fpath.Set.to_seq model_files |> List.of_seq)
175165
in
166+
List.iter (Format.printf "%a@." Sexplib.Sexp.pp_hum) analyze_rules ;
176167
cmt_rules
177168
|> List.iter @@ fun cmt_rule ->
178-
Format.printf "%a@." Sexplib.Sexp.pp_hum cmt_rule ;
179-
Format.printf "%a@." Sexplib.Sexp.pp_hum analyze_rule ;
180-
Format.printf "%a@." Sexplib.Sexp.pp_hum analyze_alias_rule
169+
Format.printf "%a@." Sexplib.Sexp.pp_hum cmt_rule

0 commit comments

Comments
 (0)