Rename %{@} to %{targets}
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
c290ad288f
commit
a317fb0606
2
doc/dune
2
doc/dune
|
@ -21,7 +21,7 @@
|
|||
(targets dune.inc.gen)
|
||||
(deps (package dune))
|
||||
(action
|
||||
(with-stdout-to %{@}
|
||||
(with-stdout-to %{targets}
|
||||
(run bash %{dep:update-jbuild.sh}))))
|
||||
|
||||
(alias
|
||||
|
|
|
@ -155,7 +155,7 @@ Write this in your ``dune`` file:
|
|||
(rule
|
||||
(targets foo.ml)
|
||||
(deps foo.cppo.ml <other files that foo.ml includes>)
|
||||
(action (run %{bin:cppo} %{<} -o %{@})))
|
||||
(action (run %{bin:cppo} %{<} -o %{targets})))
|
||||
|
||||
Defining a library with C stubs
|
||||
===============================
|
||||
|
@ -241,7 +241,7 @@ To generate a file ``foo.ml`` using a program from another directory:
|
|||
(rule
|
||||
(targets foo.ml)
|
||||
(deps ../generator/gen.exe)
|
||||
(action (run %{<} -o %{@})))
|
||||
(action (run %{<} -o %{targets})))
|
||||
|
||||
Defining tests
|
||||
==============
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(rule
|
||||
((targets (hello_world.output))
|
||||
(action (with-stdout-to %{@} (run %{bin:hello_world})))))
|
||||
(action (with-stdout-to %{targets} (run %{bin:hello_world})))))
|
||||
|
||||
(alias
|
||||
((name runtest)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
((fallback)
|
||||
(targets (config))
|
||||
(deps (config.defaults))
|
||||
(action (copy %{<} %{@}))))
|
||||
(action (copy %{<} %{targets}))))
|
||||
|
||||
(rule
|
||||
((targets (config.full))
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
(rule
|
||||
((targets (config.ml))
|
||||
(deps (../config.full))
|
||||
(action (copy %{<} %{@}))))
|
||||
(action (copy %{<} %{targets}))))
|
||||
|
||||
|
|
|
@ -1242,7 +1242,7 @@ module Rule = struct
|
|||
Run (S.virt_text __POS__ "ocamllex",
|
||||
[ S.virt_text __POS__ "-q"
|
||||
; S.virt_text __POS__ "-o"
|
||||
; S.virt_var __POS__ "@"
|
||||
; S.virt_var __POS__ "targets"
|
||||
; S.virt_var __POS__"<"
|
||||
])))
|
||||
; mode
|
||||
|
|
|
@ -397,7 +397,7 @@ let get_ppx_driver sctx ~loc ~scope ~dir_kind pps =
|
|||
>>= fun libs ->
|
||||
Ok (ppx_driver_exe sctx libs ~dir_kind, driver)
|
||||
|
||||
let target_var = String_with_vars.virt_var __POS__ "@"
|
||||
let target_var = String_with_vars.virt_var __POS__ "targets"
|
||||
let root_var = String_with_vars.virt_var __POS__ "ROOT"
|
||||
|
||||
let cookie_library_name lib_name =
|
||||
|
|
|
@ -126,7 +126,7 @@ let loc t = t.template.loc
|
|||
|
||||
let syntax_version t = t.syntax_version
|
||||
|
||||
let virt_syntax = (0, 0)
|
||||
let virt_syntax = (1, 0)
|
||||
|
||||
let virt ?(quoted=false) pos s =
|
||||
let template = Jbuild.parse ~quoted ~loc:(Loc.of_pos pos) s in
|
||||
|
|
|
@ -747,6 +747,18 @@ module Action = struct
|
|||
| Some _ as x -> x
|
||||
| None -> String.Map.find extra_vars key
|
||||
in
|
||||
let targets loc name =
|
||||
let var =
|
||||
match name with
|
||||
| "@" -> sprintf "${%s}" name
|
||||
| "targets" -> sprintf "%%{%s}" name
|
||||
| _ -> assert false
|
||||
in
|
||||
match targets_written_by_user with
|
||||
| Infer -> Loc.fail loc "You cannot use %s with inferred rules." var
|
||||
| Alias -> Loc.fail loc "You cannot use %s in aliases." var
|
||||
| Static l -> Some (Value.L.paths l)
|
||||
in
|
||||
let t =
|
||||
U.partial_expand t ~dir ~map_exe ~f:(fun var syntax_version ->
|
||||
let var_name = String_with_vars.Var.full_name var in
|
||||
|
@ -755,19 +767,20 @@ module Action = struct
|
|||
| "ROOT" -> Some (path_exp sctx.context.build_dir)
|
||||
| "SCOPE_ROOT" ->
|
||||
if syntax_version >= (1, 0) then
|
||||
Loc.fail (String_with_vars.Var.loc var)
|
||||
Loc.fail loc
|
||||
"Variable %%{SCOPE_ROOT} has been renamed to %%{project_root} \
|
||||
in dune files"
|
||||
else
|
||||
Some (path_exp (Scope.root scope))
|
||||
| "project_root" when syntax_version >= (1, 0) ->
|
||||
Some (path_exp (Scope.root scope))
|
||||
| "@" -> begin
|
||||
match targets_written_by_user with
|
||||
| Infer -> Loc.fail loc "You cannot use ${@} with inferred rules."
|
||||
| Alias -> Loc.fail loc "You cannot use ${@} in aliases."
|
||||
| Static l -> Some (Value.L.paths l)
|
||||
end
|
||||
| "@" ->
|
||||
if syntax_version >= (1, 0) then
|
||||
targets loc var_name
|
||||
else
|
||||
Loc.fail loc (* variable substitution to avoid ugly escaping *)
|
||||
"Variable %s has been renamed to %%{targets} in dune files" "%{@}"
|
||||
| "targets" when syntax_version >= (1, 0) -> targets loc var_name
|
||||
| _ ->
|
||||
match String_with_vars.Var.destruct var with
|
||||
| Pair ("path-no-dep", s) ->
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
(rule
|
||||
(targets dune.inc.gen)
|
||||
(deps (source_tree test-cases))
|
||||
(action (with-stdout-to %{@} (run ./gen_tests.exe))))
|
||||
(action (with-stdout-to %{targets} (run ./gen_tests.exe))))
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
(rule
|
||||
(targets dummy.ml)
|
||||
(action (with-stdout-to %{@} (echo ""))))
|
||||
(action (with-stdout-to %{targets} (echo ""))))
|
||||
|
||||
(library
|
||||
(name foo)
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
(deps (glob_files optional.ml)
|
||||
(glob_files *optional.ml))
|
||||
(action
|
||||
(with-stdout-to %{@}
|
||||
(with-stdout-to %{targets}
|
||||
(run echo "let () = print_endline \"Hello World\""))))
|
||||
|
|
|
@ -21,19 +21,19 @@
|
|||
(rule
|
||||
(targets static.exe)
|
||||
(deps test.exe%{ext_obj} static.c)
|
||||
(action (run %{CC} -o %{@} -I %{ocaml_where} -I . %{^}
|
||||
(action (run %{CC} -o %{targets} -I %{ocaml_where} -I . %{^}
|
||||
%{ocaml-config:native_c_libraries})))
|
||||
|
||||
(rule
|
||||
(targets static.bc)
|
||||
(deps test.bc%{ext_obj} static.c)
|
||||
(action (run %{CC} -o %{@} -I %{ocaml_where} -I . %{^}
|
||||
(action (run %{CC} -o %{targets} -I %{ocaml_where} -I . %{^}
|
||||
%{ocaml-config:bytecomp_c_libraries})))
|
||||
|
||||
(rule
|
||||
(targets dynamic.exe)
|
||||
(deps dynamic.c)
|
||||
(action (run %{CC} -o %{@} %{<} %{ocaml-config:native_c_libraries})))
|
||||
(action (run %{CC} -o %{targets} %{<} %{ocaml-config:native_c_libraries})))
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
(rule
|
||||
(targets x y)
|
||||
(action (with-stdout-to %{@} (echo foo))))
|
||||
(action (with-stdout-to %{targets} (echo foo))))
|
|
@ -1,3 +1,3 @@
|
|||
(rule
|
||||
(targets s t)
|
||||
(action (with-stdout-to "%{@}" (echo foo))))
|
||||
(action (with-stdout-to "%{targets}" (echo foo))))
|
|
@ -3,8 +3,8 @@ that ${@} is not quoted and doesn't contain exactly 1 element
|
|||
|
||||
$ dune build --root bad x
|
||||
Entering directory 'bad'
|
||||
File "dune", line 3, characters 27-29:
|
||||
Error: Variable %{@} expands to 2 values, however a single value is expected here. Please quote this atom.
|
||||
File "dune", line 3, characters 27-35:
|
||||
Error: Variable %{targets} expands to 2 values, however a single value is expected here. Please quote this atom.
|
||||
[1]
|
||||
|
||||
The targets should only be interpreted as a single path when quoted
|
||||
|
|
|
@ -15,15 +15,15 @@
|
|||
|
||||
(rule
|
||||
(targets stdout.expected)
|
||||
(action (with-stdout-to %{@} (echo "toto\n"))))
|
||||
(action (with-stdout-to %{targets} (echo "toto\n"))))
|
||||
|
||||
(rule
|
||||
(targets stderr.expected)
|
||||
(action (with-stdout-to %{@} (echo "titi\n"))))
|
||||
(action (with-stdout-to %{targets} (echo "titi\n"))))
|
||||
|
||||
(rule
|
||||
(targets both.expected)
|
||||
(action (with-stdout-to %{@} (echo "toto\ntiti\n"))))
|
||||
(action (with-stdout-to %{targets} (echo "toto\ntiti\n"))))
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
|
|
40
test/dune
40
test/dune
|
@ -51,27 +51,27 @@ Printf.fprintf (open_out Sys.argv.(2)) \"%g\n%!\" (Sys.time ())
|
|||
|
||||
(executable (name incr) (libraries unix))
|
||||
|
||||
(rule (targets 01.foo) (action (run ./incr.exe x %{@})))
|
||||
(rule (targets 02.foo) (action (run ./incr.exe x %{@})))
|
||||
(rule (targets 03.foo) (action (run ./incr.exe x %{@})))
|
||||
(rule (targets 04.foo) (action (run ./incr.exe x %{@})))
|
||||
(rule (targets 05.foo) (action (run ./incr.exe x %{@})))
|
||||
(rule (targets 06.foo) (action (run ./incr.exe x %{@})))
|
||||
(rule (targets 07.foo) (action (run ./incr.exe x %{@})))
|
||||
(rule (targets 08.foo) (action (run ./incr.exe x %{@})))
|
||||
(rule (targets 09.foo) (action (run ./incr.exe x %{@})))
|
||||
(rule (targets 10.foo) (action (run ./incr.exe x %{@})))
|
||||
(rule (targets 01.foo) (action (run ./incr.exe x %{targets})))
|
||||
(rule (targets 02.foo) (action (run ./incr.exe x %{targets})))
|
||||
(rule (targets 03.foo) (action (run ./incr.exe x %{targets})))
|
||||
(rule (targets 04.foo) (action (run ./incr.exe x %{targets})))
|
||||
(rule (targets 05.foo) (action (run ./incr.exe x %{targets})))
|
||||
(rule (targets 06.foo) (action (run ./incr.exe x %{targets})))
|
||||
(rule (targets 07.foo) (action (run ./incr.exe x %{targets})))
|
||||
(rule (targets 08.foo) (action (run ./incr.exe x %{targets})))
|
||||
(rule (targets 09.foo) (action (run ./incr.exe x %{targets})))
|
||||
(rule (targets 10.foo) (action (run ./incr.exe x %{targets})))
|
||||
|
||||
(rule (targets 01.bar) (action (run ./incr.exe y %{@})) (locks m))
|
||||
(rule (targets 02.bar) (action (run ./incr.exe y %{@})) (locks m))
|
||||
(rule (targets 03.bar) (action (run ./incr.exe y %{@})) (locks m))
|
||||
(rule (targets 04.bar) (action (run ./incr.exe y %{@})) (locks m))
|
||||
(rule (targets 05.bar) (action (run ./incr.exe y %{@})) (locks m))
|
||||
(rule (targets 06.bar) (action (run ./incr.exe y %{@})) (locks m))
|
||||
(rule (targets 07.bar) (action (run ./incr.exe y %{@})) (locks m))
|
||||
(rule (targets 08.bar) (action (run ./incr.exe y %{@})) (locks m))
|
||||
(rule (targets 09.bar) (action (run ./incr.exe y %{@})) (locks m))
|
||||
(rule (targets 10.bar) (action (run ./incr.exe y %{@})) (locks m))
|
||||
(rule (targets 01.bar) (action (run ./incr.exe y %{targets})) (locks m))
|
||||
(rule (targets 02.bar) (action (run ./incr.exe y %{targets})) (locks m))
|
||||
(rule (targets 03.bar) (action (run ./incr.exe y %{targets})) (locks m))
|
||||
(rule (targets 04.bar) (action (run ./incr.exe y %{targets})) (locks m))
|
||||
(rule (targets 05.bar) (action (run ./incr.exe y %{targets})) (locks m))
|
||||
(rule (targets 06.bar) (action (run ./incr.exe y %{targets})) (locks m))
|
||||
(rule (targets 07.bar) (action (run ./incr.exe y %{targets})) (locks m))
|
||||
(rule (targets 08.bar) (action (run ./incr.exe y %{targets})) (locks m))
|
||||
(rule (targets 09.bar) (action (run ./incr.exe y %{targets})) (locks m))
|
||||
(rule (targets 10.bar) (action (run ./incr.exe y %{targets})) (locks m))
|
||||
|
||||
(alias
|
||||
(name runtest-no-deps)
|
||||
|
|
Loading…
Reference in New Issue