-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
These variables can occur outside actions so such expansions shouldn't live under Var_expansion. Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
- Loading branch information
Showing
7 changed files
with
104 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
open Stdune | ||
|
||
module T = struct | ||
type t = | ||
| Paths of Path.t list | ||
| Strings of string list | ||
|
||
let length = function | ||
| Paths x -> List.length x | ||
| Strings x -> List.length x | ||
|
||
let is_multivalued = function | ||
| Paths [_] -> false | ||
| Strings [_] -> false | ||
| _ -> true | ||
|
||
type context = Path.t (* For String_with_vars.Expand_to *) | ||
|
||
let concat = function | ||
| [s] -> s | ||
| l -> String.concat ~sep:" " l | ||
|
||
let string_of_path ~dir p = Path.reach ~from:dir p | ||
|
||
let to_string (dir: context) = function | ||
| Strings l -> concat l | ||
| Paths l -> concat (List.map l ~f:(string_of_path ~dir)) | ||
end | ||
|
||
include T | ||
|
||
module Expand = String_with_vars.Expand_to(T) | ||
|
||
let path_of_string dir s = Path.relative dir s | ||
|
||
let to_strings dir = function | ||
| Strings l -> l | ||
| Paths l -> List.map l ~f:(string_of_path ~dir) | ||
|
||
let to_path dir = function | ||
| Strings l -> path_of_string dir (concat l) | ||
| Paths [p] -> p | ||
| Paths l -> | ||
path_of_string dir (concat (List.map l ~f:(string_of_path ~dir))) |
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,19 @@ | ||
open Stdune | ||
|
||
type t = | ||
| Paths of Path.t list | ||
| Strings of string list | ||
|
||
val to_string : Path.t -> t -> string | ||
(** [to_string dir v] convert the variable expansion to a string. | ||
If it is a path, the corresponding string will be relative to | ||
[dir]. *) | ||
|
||
val path_of_string : Path.t -> string -> Path.t | ||
|
||
val to_strings : Path.t -> t -> string list | ||
|
||
val to_path : Path.t -> t -> Path.t | ||
|
||
module Expand : String_with_vars.Expand_intf | ||
with type expansion = t and type context = Path.t |