-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move [System] to be a custom action (#10833)
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
- Loading branch information
Showing
16 changed files
with
65 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
open Import | ||
open Fiber.O | ||
|
||
module Spec = struct | ||
type (_, _) t = string | ||
|
||
let name = "system" | ||
let version = 1 | ||
let bimap t _ _ = t | ||
let is_useful_to ~memoize = memoize | ||
let encode cmd _ _ : Sexp.t = List [ Atom name; Atom cmd ] | ||
|
||
let action cmd ~(ectx : Action.context) ~(eenv : Action.env) = | ||
let prog, arg = | ||
Dune_util.Prog.system_shell_exn ~needed_to:"interpret (system ...) actions" | ||
in | ||
let display = !Clflags.display in | ||
Process.run | ||
(Accept eenv.exit_codes) | ||
prog | ||
[ arg; cmd ] | ||
~display | ||
~metadata:ectx.metadata | ||
~stdout_to:eenv.stdout_to | ||
~stderr_to:eenv.stderr_to | ||
~stdin_from:eenv.stdin_from | ||
~dir:eenv.working_dir | ||
~env:eenv.env | ||
>>| function | ||
| Error _ -> () | ||
| Ok s -> s | ||
;; | ||
end | ||
|
||
let action cmd = | ||
Action.Extension | ||
(module struct | ||
type path = Path.t | ||
type target = Path.Build.t | ||
|
||
module Spec = Spec | ||
|
||
let v = cmd | ||
end) | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(** The system action runs [/bin/sh] *) | ||
|
||
open Import | ||
|
||
val action : string -> Action.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters