diff --git a/doc/jbuild.rst b/doc/jbuild.rst index ef2fad68..9b103b6b 100644 --- a/doc/jbuild.rst +++ b/doc/jbuild.rst @@ -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:`` expands to ```` +- ``^`` expands to the list of dependencies, separated by spaces +- ``path:`` expands to ```` +- ``path-no-dep:`` is the same as ``path:``, except that + ```` 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:`` is the same as ````, except when cross-compiling, in which case it will expand to ```` from the host build context - ``bin:`` expands to a path to ``program``. If ``program`` diff --git a/src/super_context.ml b/src/super_context.ml index 3fd8d0be..af523e72 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -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 diff --git a/test/blackbox-tests/test-cases/misc/jbuild b/test/blackbox-tests/test-cases/misc/jbuild index c28067ea..362e3b13 100644 --- a/test/blackbox-tests/test-cases/misc/jbuild +++ b/test/blackbox-tests/test-cases/misc/jbuild @@ -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 ${!^})))) diff --git a/test/blackbox-tests/test-cases/misc/run.t b/test/blackbox-tests/test-cases/misc/run.t index 68b6d51e..a2ac0a8e 100644 --- a/test/blackbox-tests/test-cases/misc/run.t +++ b/test/blackbox-tests/test-cases/misc/run.t @@ -2,3 +2,4 @@ diff alias runtest diff alias runtest diff alias runtest + diff alias runtest