-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect path resolution ambiguity (#45)
* Detect path resolution ambiguity * Fix test
- Loading branch information
Showing
19 changed files
with
667 additions
and
305 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,41 @@ | ||
# Path resolution | ||
|
||
Werk supports translating [abstract paths](../paths.md) into native OS paths in | ||
string interpolations, using the special `"<...>"` interpolation syntax. | ||
|
||
Normal string interpolations `"{...}"` are always "verbatim" - the interpolation | ||
is performed literally. | ||
|
||
However, string interpolation with `<...>` performs extra logic to obtain a | ||
native OS path whenever it occurs, and this logic is sensitive to the | ||
surroundings of the interpolation, as well as the presence of build recipe | ||
rules. | ||
|
||
Consider the following Werkfile: | ||
|
||
```werk | ||
# c:\workspace | ||
# target\ | ||
# dir\ | ||
# foo.txt | ||
config out-dir = "target" | ||
let input = "foo.txt" | ||
let output = "bar.txt" | ||
let dir = "dir" | ||
``` | ||
|
||
- `"<input>"` resolves to `c:\workspace\foo.txt`, because `foo.txt` exists in | ||
the workspace. | ||
- `"<output>"` resolves to `c:\workspace\target\bar.txt`, because `bar.txt` | ||
does not exist in the workspace. | ||
- `"<input:out-dir>"` resolves to `c:\workspace\target\foo.txt`, because it is | ||
explicitly requested. | ||
- `"<output:workspace>"` resolves to `c:\workspace\bar.txt`, because it is | ||
explicitly requested, even though the file does not exist in the workspace. | ||
- `"<dir>"` resolves to `c:\workspace\dir`, even though it is a directory. | ||
- When an `<...>` interpolation would match a file in the workspace, but also | ||
matches a build recipe, `werk` fails with an error describing the ambiguity. | ||
The path can be disambiguated by using `:out-dir` or `:workspace` to | ||
disambiguate path resolution. |
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,15 @@ | ||
config out-dir = "../../target/examples/issue-41" | ||
config default = "build" | ||
|
||
build "foo" { | ||
info "<out>" | ||
} | ||
|
||
build "bar" { | ||
info "<out>" | ||
} | ||
|
||
task build { | ||
build "foo" | ||
build "bar" | ||
} |
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
Oops, something went wrong.