Add ${path-no-dep:...}

To be able to resolve path names that are not dependencies.
This commit is contained in:
Jeremie Dimino 2017-09-29 11:55:23 +01:00
parent 726e738bb6
commit 50cbbe2ac5
4 changed files with 28 additions and 2 deletions

View File

@ -593,8 +593,13 @@ In addition, ``(action ...)`` fields support the following special variables:
- ``@`` expands to the list of target
- ``<`` expands to the first dependency, or the empty string if there are no
dependencies
- ``^`` expands to the list of dependencies, separated by spaces
- ``path:<path>`` expands to ``<path>``
- ``^`` expands to the list of dependencies, separated by spaces
- ``path:<path>`` expands to ``<path>``
- ``path-no-dep:<path>`` is the same as ``path:<path>``, except that
``<path>`` is not considered as a dependency of the action. For instance
``(chdir ${ROOT} (run foo --base ${path-no-dep:bar}))`` in ``src/blah/jbuild``
will expand to ``(chdir ../.. (run foo --base src/blah/bar))`` where
``src/blah/bar`` doesn't have to be an existing or buildable file
- ``exe:<path>`` is the same as ``<path>``, except when cross-compiling, in
which case it will expand to ``<path>`` from the host build context
- ``bin:<program>`` expands to a path to ``program``. If ``program``

View File

@ -514,6 +514,7 @@ module Action = struct
let open Action.Var_expansion in
let cos, var = parse_bang key in
match String.lsplit2 var ~on:':' with
| Some ("path-no-dep", s) -> Some (path_exp (Path.relative dir s))
| Some ("exe" , s) -> static_dep_exp acc (Path.relative dir s)
| Some ("path" , s) -> static_dep_exp acc (Path.relative dir s)
| Some ("bin" , s) -> begin

View File

@ -38,3 +38,22 @@
;; For some tests in subdirs
(rule (with-stdout-to 023e1a58-4d08-11e7-a041-aa000008c8a6 (echo "plop")))
;; Test for ${path-no-dep}
(rule
(progn
(with-stdout-to pnd-result
(chdir sub-tree/dir
(progn
(echo "${path-no-dep:file-that-doesn't-exist}\n")
(echo "${path-no-dep:.}\n"))))
(with-stdout-to pnd-expected
(progn
(echo "../../file-that-doesn't-exist\n")
(echo "../..\n")))))
(alias
((name runtest)
(deps (pnd-result pnd-expected))
(action (run diff -u ${!^}))))

View File

@ -2,3 +2,4 @@
diff alias runtest
diff alias runtest
diff alias runtest
diff alias runtest