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)
|
||||
|
||||
- Rename `path:file` to `dep:file` (#944, @emillon)
|
||||
|
||||
1.0+beta20 (10/04/2018)
|
||||
-----------------------
|
||||
|
||||
|
|
2
doc/dune
2
doc/dune
|
@ -22,7 +22,7 @@
|
|||
(deps (package dune))
|
||||
(action
|
||||
(with-stdout-to %{@}
|
||||
(run bash %{path:update-jbuild.sh}))))
|
||||
(run bash %{dep:update-jbuild.sh}))))
|
||||
|
||||
(alias
|
||||
(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
|
||||
dependencies
|
||||
- ``^`` 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>`` is not considered as a dependency of the action. For instance
|
||||
``(chdir ${ROOT} (run foo --base ${path-no-dep:bar}))`` in ``src/blah/jbuild``
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
|
||||
(alias
|
||||
((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
|
||||
((targets (config.full))
|
||||
(deps (config_common.ml config))
|
||||
(action (run %{OCAML} %{path:real_configure.ml}))))
|
||||
(action (run %{OCAML} %{dep:real_configure.ml}))))
|
||||
|
|
|
@ -631,9 +631,22 @@ module Action = struct
|
|||
let expand var syntax_version =
|
||||
let loc = String_with_vars.Var.loc 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
|
||||
| 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) ->
|
||||
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
|
||||
match Artifacts.binary (artifacts sctx) s with
|
||||
|
|
|
@ -481,6 +481,14 @@
|
|||
test-cases/package-dep
|
||||
(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
|
||||
(name ppx-rewriter)
|
||||
(deps (package dune) (source_tree test-cases/ppx-rewriter))
|
||||
|
@ -654,6 +662,7 @@
|
|||
(alias odoc-unique-mlds)
|
||||
(alias output-obj)
|
||||
(alias package-dep)
|
||||
(alias path-variables)
|
||||
(alias ppx-rewriter)
|
||||
(alias private-public-overlap)
|
||||
(alias promote)
|
||||
|
@ -721,6 +730,7 @@
|
|||
(alias ocamldep-multi-stanzas)
|
||||
(alias output-obj)
|
||||
(alias package-dep)
|
||||
(alias path-variables)
|
||||
(alias promote)
|
||||
(alias quoting)
|
||||
(alias redirections)
|
||||
|
|
|
@ -37,25 +37,6 @@
|
|||
|
||||
(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
|
||||
|
||||
(alias
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
$ 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.
|
||||
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