Rename path to dep in dune files
See #842 Signed-off-by: Etienne Millon <etienne@cryptosense.com>
This commit is contained in:
parent
9a605b96f5
commit
628914fe28
|
@ -110,6 +110,8 @@ next
|
||||||
|
|
||||||
- Add the `lib_root` and `libexec_root` install sections (#947, @diml)
|
- Add the `lib_root` and `libexec_root` install sections (#947, @diml)
|
||||||
|
|
||||||
|
- Rename `path:file` to `dep:file` (#944, @emillon)
|
||||||
|
|
||||||
1.0+beta20 (10/04/2018)
|
1.0+beta20 (10/04/2018)
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
|
2
doc/dune
2
doc/dune
|
@ -22,7 +22,7 @@
|
||||||
(deps (package dune))
|
(deps (package dune))
|
||||||
(action
|
(action
|
||||||
(with-stdout-to %{@}
|
(with-stdout-to %{@}
|
||||||
(run bash %{path:update-jbuild.sh}))))
|
(run bash %{dep:update-jbuild.sh}))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
|
|
|
@ -830,7 +830,7 @@ In addition, ``(action ...)`` fields support the following special variables:
|
||||||
- ``<`` expands to the first dependency, or the empty string if there are no
|
- ``<`` expands to the first dependency, or the empty string if there are no
|
||||||
dependencies
|
dependencies
|
||||||
- ``^`` expands to the list of dependencies, separated by spaces
|
- ``^`` expands to the list of dependencies, separated by spaces
|
||||||
- ``path:<path>`` expands to ``<path>``
|
- ``dep:<path>`` expands to ``<path>``
|
||||||
- ``path-no-dep:<path>`` is the same as ``path:<path>``, except that
|
- ``path-no-dep:<path>`` is the same as ``path:<path>``, except that
|
||||||
``<path>`` is not considered as a dependency of the action. For instance
|
``<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``
|
``(chdir ${ROOT} (run foo --base ${path-no-dep:bar}))`` in ``src/blah/jbuild``
|
||||||
|
|
|
@ -4,4 +4,4 @@
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
((name runtest)
|
((name runtest)
|
||||||
(action (run diff -uw %{path:hello_world.expected} %{path:hello_world.output}))))
|
(action (run diff -uw %{dep:hello_world.expected} %{dep:hello_world.output}))))
|
||||||
|
|
|
@ -7,4 +7,4 @@
|
||||||
(rule
|
(rule
|
||||||
((targets (config.full))
|
((targets (config.full))
|
||||||
(deps (config_common.ml config))
|
(deps (config_common.ml config))
|
||||||
(action (run %{OCAML} %{path:real_configure.ml}))))
|
(action (run %{OCAML} %{dep:real_configure.ml}))))
|
||||||
|
|
|
@ -631,10 +631,23 @@ module Action = struct
|
||||||
let expand var syntax_version =
|
let expand var syntax_version =
|
||||||
let loc = String_with_vars.Var.loc var in
|
let loc = String_with_vars.Var.loc var in
|
||||||
let key = String_with_vars.Var.full_name var in
|
let key = String_with_vars.Var.full_name var in
|
||||||
|
let path_with_dep s =
|
||||||
|
Some (path_exp (Path.relative dir s) )
|
||||||
|
in
|
||||||
match String_with_vars.Var.destruct var with
|
match String_with_vars.Var.destruct var with
|
||||||
| Pair ("exe" , s) -> Some (path_exp (map_exe (Path.relative dir s)))
|
| Pair ("exe", s) -> Some (path_exp (map_exe (Path.relative dir s)))
|
||||||
| Pair ("path" , s) -> Some (path_exp (Path.relative dir s) )
|
| Pair ("path", s) when syntax_version < (1, 0) ->
|
||||||
| Pair ("bin" , s) -> begin
|
path_with_dep s
|
||||||
|
| Pair ("dep", s) when syntax_version >= (1, 0) ->
|
||||||
|
path_with_dep s
|
||||||
|
| Pair ("dep", s) ->
|
||||||
|
Loc.fail
|
||||||
|
loc
|
||||||
|
"${dep:%s} is not supported in jbuild files.\n\
|
||||||
|
Did you mean: ${path:%s}"
|
||||||
|
s
|
||||||
|
s
|
||||||
|
| Pair ("bin", s) -> begin
|
||||||
let sctx = host sctx in
|
let sctx = host sctx in
|
||||||
match Artifacts.binary (artifacts sctx) s with
|
match Artifacts.binary (artifacts sctx) s with
|
||||||
| Ok path -> Some (path_exp path)
|
| Ok path -> Some (path_exp path)
|
||||||
|
|
|
@ -481,6 +481,14 @@
|
||||||
test-cases/package-dep
|
test-cases/package-dep
|
||||||
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
|
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
|
||||||
|
|
||||||
|
(alias
|
||||||
|
(name path-variables)
|
||||||
|
(deps (package dune) (source_tree test-cases/path-variables))
|
||||||
|
(action
|
||||||
|
(chdir
|
||||||
|
test-cases/path-variables
|
||||||
|
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
(name ppx-rewriter)
|
(name ppx-rewriter)
|
||||||
(deps (package dune) (source_tree test-cases/ppx-rewriter))
|
(deps (package dune) (source_tree test-cases/ppx-rewriter))
|
||||||
|
@ -654,6 +662,7 @@
|
||||||
(alias odoc-unique-mlds)
|
(alias odoc-unique-mlds)
|
||||||
(alias output-obj)
|
(alias output-obj)
|
||||||
(alias package-dep)
|
(alias package-dep)
|
||||||
|
(alias path-variables)
|
||||||
(alias ppx-rewriter)
|
(alias ppx-rewriter)
|
||||||
(alias private-public-overlap)
|
(alias private-public-overlap)
|
||||||
(alias promote)
|
(alias promote)
|
||||||
|
@ -721,6 +730,7 @@
|
||||||
(alias ocamldep-multi-stanzas)
|
(alias ocamldep-multi-stanzas)
|
||||||
(alias output-obj)
|
(alias output-obj)
|
||||||
(alias package-dep)
|
(alias package-dep)
|
||||||
|
(alias path-variables)
|
||||||
(alias promote)
|
(alias promote)
|
||||||
(alias quoting)
|
(alias quoting)
|
||||||
(alias redirections)
|
(alias redirections)
|
||||||
|
|
|
@ -37,25 +37,6 @@
|
||||||
|
|
||||||
(rule (with-stdout-to 023e1a58-4d08-11e7-a041-aa000008c8a6 (echo "plop")))
|
(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 %{^})))
|
|
||||||
|
|
||||||
;; Test for globs
|
;; Test for globs
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
$ dune runtest --display short
|
$ dune runtest --display short
|
||||||
File "dune", line 63, characters 19-42:
|
File "dune", line 44, characters 19-42:
|
||||||
Warning: Directory dir-that-doesnt-exist doesn't exist.
|
Warning: Directory dir-that-doesnt-exist doesn't exist.
|
||||||
diff alias runtest
|
diff alias runtest
|
||||||
diff alias runtest
|
diff alias runtest
|
||||||
diff alias runtest
|
diff alias runtest
|
||||||
diff alias runtest
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
(rule (write-file generated-file dynamic-contents))
|
||||||
|
|
||||||
|
(alias
|
||||||
|
(name test-dep)
|
||||||
|
(action (cat %{dep:generated-file})))
|
||||||
|
|
||||||
|
(alias
|
||||||
|
(name test-path)
|
||||||
|
(action
|
||||||
|
(chdir
|
||||||
|
sub-tree/dir
|
||||||
|
(progn
|
||||||
|
(echo "%{path:file-that-does-not-exist}\n")
|
||||||
|
(echo "%{path:.}\n")))))
|
||||||
|
|
||||||
|
(alias
|
||||||
|
(name test-path-no-dep)
|
||||||
|
(action
|
||||||
|
(chdir
|
||||||
|
sub-tree/dir
|
||||||
|
(progn
|
||||||
|
(echo "%{path-no-dep:file-that-does-not-exist}\n")
|
||||||
|
(echo "%{path-no-dep:.}\n")))))
|
|
@ -0,0 +1 @@
|
||||||
|
(lang dune 1.0)
|
|
@ -0,0 +1,5 @@
|
||||||
|
(rule (write-file generated-file dynamic-contents))
|
||||||
|
|
||||||
|
(alias
|
||||||
|
((name test-dep)
|
||||||
|
(action (cat ${dep:generated-file}))))
|
|
@ -0,0 +1,14 @@
|
||||||
|
(rule (write-file generated-file dynamic-contents))
|
||||||
|
|
||||||
|
(alias
|
||||||
|
((name test-path)
|
||||||
|
(action (cat ${path:generated-file}))))
|
||||||
|
|
||||||
|
(alias
|
||||||
|
((name test-path-no-dep)
|
||||||
|
(action
|
||||||
|
(chdir
|
||||||
|
sub-tree/dir
|
||||||
|
(progn
|
||||||
|
(echo "${path-no-dep:file-that-does-not-exist}\n")
|
||||||
|
(echo "${path-no-dep:.}\n"))))))
|
|
@ -0,0 +1,55 @@
|
||||||
|
dune files
|
||||||
|
==========
|
||||||
|
|
||||||
|
%{dep:string}
|
||||||
|
-------------
|
||||||
|
|
||||||
|
In expands to a file name, and registers this as a dependency.
|
||||||
|
|
||||||
|
$ dune build --root dune @test-dep
|
||||||
|
Entering directory 'dune'
|
||||||
|
dynamic-contents
|
||||||
|
|
||||||
|
%{path-no-dep:string}
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
It expands to a file name, but does not register it as a dependency.
|
||||||
|
|
||||||
|
$ dune build --root dune @test-path-no-dep
|
||||||
|
Entering directory 'dune'
|
||||||
|
../../file-that-does-not-exist
|
||||||
|
../..
|
||||||
|
|
||||||
|
jbuild files
|
||||||
|
============
|
||||||
|
|
||||||
|
${path:string}
|
||||||
|
--------------
|
||||||
|
|
||||||
|
This registers the dependency:
|
||||||
|
|
||||||
|
$ dune build --root jbuild @test-path
|
||||||
|
Entering directory 'jbuild'
|
||||||
|
dynamic-contents
|
||||||
|
|
||||||
|
${path-no-dep:string}
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
This does not:
|
||||||
|
|
||||||
|
$ dune build --root jbuild @test-path-no-dep
|
||||||
|
Entering directory 'jbuild'
|
||||||
|
../../file-that-does-not-exist
|
||||||
|
../..
|
||||||
|
|
||||||
|
${dep:string}
|
||||||
|
--------------
|
||||||
|
|
||||||
|
This form does not exist, but displays an hint:
|
||||||
|
|
||||||
|
$ dune build --root jbuild-invalid @test-dep
|
||||||
|
Entering directory 'jbuild-invalid'
|
||||||
|
File "jbuild", line 5, characters 16-37:
|
||||||
|
Error: ${dep:generated-file} is not supported in jbuild files.
|
||||||
|
Did you mean: ${path:generated-file}
|
||||||
|
[1]
|
Loading…
Reference in New Issue