Skip to content

Commit

Permalink
feature: sandbox menhir actions
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

ps-id: ba679cfd-9795-4bfb-902d-24ab89eaaf39
  • Loading branch information
rgrinberg committed Aug 17, 2022
1 parent fcb7897 commit d4bcecb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
- Introduce a `dirs` field in the `install` stanza to install entire
directories (#5097, fixes #5059, @rgrinberg)

- Menhir rules are now sandboxed by default (#6076, @rgrinberg)

- Allow rules producing directory targets to create symlinks (#6077, fixes
#5945, @rgrinberg)

Expand Down
8 changes: 7 additions & 1 deletion src/dune_rules/menhir_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ module Run (P : PARAMS) = struct

let expander = Compilation_context.expander cctx

let sandbox =
let scope = Compilation_context.scope cctx in
let project = Scope.project scope in
if Dune_project.dune_version project < (3, 5) then Sandbox_config.default
else Sandbox_config.needs_sandboxing

(* ------------------------------------------------------------------------ *)

(* Naming conventions. *)
Expand Down Expand Up @@ -109,7 +115,7 @@ module Run (P : PARAMS) = struct
let menhir (args : 'a args) :
Action.Full.t Action_builder.With_targets.t Memo.t =
Memo.map menhir_binary ~f:(fun prog ->
Command.run ~dir:(Path.build build_dir) prog args)
Command.run ~sandbox ~dir:(Path.build build_dir) prog args)

let rule ?(mode = stanza.mode) :
Action.Full.t Action_builder.With_targets.t -> unit Memo.t =
Expand Down

0 comments on commit d4bcecb

Please sign in to comment.