Skip to content

Commit 752cef1

Browse files
committed
feature(cinaps): sandbox running cinaps actions
Signed-off-by: Rudi Grinberg <me@rgrinberg.com> ps-id: 1ab4ad8e-b4aa-4f3e-829b-d87c213c82f8
1 parent 20f6611 commit 752cef1

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
3.5.0 (unreleased)
22
------------------
33

4+
- Sandbox running cinaps actions starting from cinaps 1.1 (#6176, @rgrinberg)
5+
46
- Add a `runtime_deps` field in the `cinaps` stanza to specify runtime
57
dependencies for running the cinaps preprocessing action (#6175, @rgrinberg)
68

src/dune_rules/cinaps.ml

+16-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type t =
77
; preprocess : Preprocess.Without_instrumentation.t Preprocess.Per_module.t
88
; preprocessor_deps : Dep_conf.t list
99
; runtime_deps : Dep_conf.t list
10+
; cinaps_version : Syntax.Version.t
1011
}
1112

1213
let name = "cinaps"
@@ -31,9 +32,17 @@ let decode =
3132
and+ runtime_deps =
3233
field ~default:[] "runtime_deps"
3334
(Dune_lang.Syntax.since syntax (1, 1) >>> repeat Dep_conf.decode)
35+
and+ cinaps_version = Dune_lang.Syntax.get_exn syntax
3436
(* TODO use this field? *)
3537
and+ _flags = Ocaml_flags.Spec.decode in
36-
{ loc; files; libraries; preprocess; preprocessor_deps; runtime_deps })
38+
{ loc
39+
; files
40+
; libraries
41+
; preprocess
42+
; preprocessor_deps
43+
; runtime_deps
44+
; cinaps_version
45+
})
3746

3847
let () =
3948
let open Dune_lang.Decoder in
@@ -85,9 +94,7 @@ let gen_rules sctx t ~dir ~scope =
8594
let* () =
8695
(* Ask cinaps to produce a .ml file to build *)
8796
let sandbox =
88-
let project = Scope.project scope in
89-
if Dune_project.dune_version project >= (3, 5) then
90-
Sandbox_config.needs_sandboxing
97+
if t.cinaps_version >= (1, 1) then Sandbox_config.needs_sandboxing
9198
else Sandbox_config.default
9299
in
93100
Super_context.add_rule sctx ~loc:t.loc ~dir
@@ -135,7 +142,11 @@ let gen_rules sctx t ~dir ~scope =
135142
let module A = Action in
136143
let cinaps_exe = Path.build cinaps_exe in
137144
let runtime_deps, sandbox =
138-
Dep_conf_eval.unnamed ~expander t.runtime_deps
145+
let sandbox =
146+
if t.cinaps_version >= (1, 1) then Sandbox_config.needs_sandboxing
147+
else Sandbox_config.no_special_requirements
148+
in
149+
Dep_conf_eval.unnamed ~sandbox ~expander t.runtime_deps
139150
in
140151
let* () = runtime_deps in
141152
let+ () = Action_builder.path cinaps_exe in

0 commit comments

Comments
 (0)