-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make all processes use the special temp dir
Signed-off-by: Rudi Grinberg <[email protected]>
- Loading branch information
Showing
5 changed files
with
41 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
open Stdune | ||
|
||
let temp_dir = lazy (Temp.create Dir ~prefix:"build" ~suffix:".dune") | ||
|
||
let file ~prefix ~suffix = | ||
Temp.temp_in_dir File ~dir:(Lazy.force temp_dir) ~suffix ~prefix | ||
|
||
let add_to_env env = | ||
let value = Path.to_absolute_filename (Lazy.force temp_dir) in | ||
match env with | ||
| None -> Env.add Env.initial ~var:Env.Var.temp_dir ~value | ||
| Some env -> | ||
Env.update env ~var:Env.Var.temp_dir ~f:(function | ||
| None -> Some value | ||
| Some _ as s -> s) | ||
|
||
let destroy = Temp.destroy | ||
|
||
let clear () = if Lazy.is_val temp_dir then Temp.clear (Lazy.force temp_dir) | ||
|
||
let () = Hooks.End_of_build.always clear |
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,13 @@ | ||
(** Temp directory used by dune processes *) | ||
open Stdune | ||
|
||
(** This returns a build path, but we don't rely on that *) | ||
val file : prefix:string -> suffix:string -> Path.t | ||
|
||
(** Add the temp env var to the enviornment passed or return the initial | ||
environment with the temp var added. If temp is already set in the | ||
environment, do nothing *) | ||
val add_to_env : Env.t option -> Env.t | ||
|
||
(** Destroy the temporary file or directory *) | ||
val destroy : Temp.what -> Path.t -> unit |
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