Merge pull request #957 from rgrinberg/rename-scope-scope-root

Rename SCOPE_ROOT, ${@}, ${^}, etc.
This commit is contained in:
Rudi Grinberg 2018-07-06 19:04:03 +07:00 committed by GitHub
commit 290fffc2f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 243 additions and 141 deletions

View File

@ -21,7 +21,7 @@
(targets dune.inc.gen) (targets dune.inc.gen)
(deps (package dune)) (deps (package dune))
(action (action
(with-stdout-to %{@} (with-stdout-to %{targets}
(run bash %{dep:update-jbuild.sh})))) (run bash %{dep:update-jbuild.sh}))))
(alias (alias

View File

@ -169,7 +169,7 @@ Jbuild Dune
======================== ============ ======================== ============
``${@}`` ``%{targets}`` ``${@}`` ``%{targets}``
``${^}`` ``%{deps}`` ``${^}`` ``%{deps}``
``${<}`` ``%{deps[0]}`` ``${<}`` ``%{first-dep}``
``${path:file}`` ``%{dep:file}`` ``${path:file}`` ``%{dep:file}``
``${SCOPE_ROOT}`` ``%{project_root}`` ``${SCOPE_ROOT}`` ``%{project_root}``
``${findlib:..}`` ``%{lib:..}`` ``${findlib:..}`` ``%{lib:..}``

View File

@ -136,7 +136,7 @@ Add this field to your ``library`` or ``executable`` stanzas:
.. code:: scheme .. code:: scheme
(preprocess (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{<}))) (preprocess (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{first-dep})))
Additionally, if you are include a ``config.h`` file, you need to Additionally, if you are include a ``config.h`` file, you need to
declare the dependency to this file via: declare the dependency to this file via:
@ -155,7 +155,7 @@ Write this in your ``dune`` file:
(rule (rule
(targets foo.ml) (targets foo.ml)
(deps foo.cppo.ml <other files that foo.ml includes>) (deps foo.cppo.ml <other files that foo.ml includes>)
(action (run %{bin:cppo} %{<} -o %{@}))) (action (run %{bin:cppo} %{first-dep} -o %{targets})))
Defining a library with C stubs Defining a library with C stubs
=============================== ===============================
@ -193,7 +193,7 @@ compilation and link flags. Write this ``dune`` file:
(rule (rule
(targets c_flags.sexp c_library_flags.sexp) (targets c_flags.sexp c_library_flags.sexp)
(deps config/discover.exe) (deps config/discover.exe)
(action (run %{<} -ocamlc %{OCAMLC}))) (action (run %{first-dep} -ocamlc %{OCAMLC})))
Then create a ``config`` subdirectory and write this ``dune`` file: Then create a ``config`` subdirectory and write this ``dune`` file:
@ -241,7 +241,7 @@ To generate a file ``foo.ml`` using a program from another directory:
(rule (rule
(targets foo.ml) (targets foo.ml)
(deps ../generator/gen.exe) (deps ../generator/gen.exe)
(action (run %{<} -o %{@}))) (action (run %{first-dep} -o %{targets})))
Defining tests Defining tests
============== ==============
@ -253,7 +253,7 @@ Write this in your ``dune`` file:
(alias (alias
(name runtest) (name runtest)
(deps my-test-program.exe) (deps my-test-program.exe)
(action (run %{<}))) (action (run %{first-dep})))
And run the tests with: And run the tests with:

View File

@ -1,6 +1,6 @@
(rule (rule
((targets (hello_world.output)) ((targets (hello_world.output))
(action (with-stdout-to %{@} (run %{bin:hello_world}))))) (action (with-stdout-to %{targets} (run %{bin:hello_world})))))
(alias (alias
((name runtest) ((name runtest)

View File

@ -2,7 +2,7 @@
((fallback) ((fallback)
(targets (config)) (targets (config))
(deps (config.defaults)) (deps (config.defaults))
(action (copy %{<} %{@})))) (action (copy %{first-dep} %{targets}))))
(rule (rule
((targets (config.full)) ((targets (config.full))

View File

@ -8,5 +8,5 @@
(rule (rule
((targets (config.ml)) ((targets (config.ml))
(deps (../config.full)) (deps (../config.full))
(action (copy %{<} %{@})))) (action (copy %{first-dep} %{targets}))))

View File

@ -1242,8 +1242,8 @@ module Rule = struct
Run (S.virt_text __POS__ "ocamllex", Run (S.virt_text __POS__ "ocamllex",
[ S.virt_text __POS__ "-q" [ S.virt_text __POS__ "-q"
; S.virt_text __POS__ "-o" ; S.virt_text __POS__ "-o"
; S.virt_var __POS__ "@" ; S.virt_var __POS__ "targets"
; S.virt_var __POS__"<" ; S.virt_var __POS__"first-dep"
]))) ])))
; mode ; mode
; locks = [] ; locks = []
@ -1261,7 +1261,7 @@ module Rule = struct
Chdir Chdir
(S.virt_var __POS__ "ROOT", (S.virt_var __POS__ "ROOT",
Run (S.virt_text __POS__ "ocamlyacc", Run (S.virt_text __POS__ "ocamlyacc",
[S.virt_var __POS__ "<"]))) [S.virt_var __POS__ "first-dep"])))
; mode ; mode
; locks = [] ; locks = []
; loc ; loc

View File

@ -397,7 +397,7 @@ let get_ppx_driver sctx ~loc ~scope ~dir_kind pps =
>>= fun libs -> >>= fun libs ->
Ok (ppx_driver_exe sctx libs ~dir_kind, driver) 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 root_var = String_with_vars.virt_var __POS__ "ROOT"
let cookie_library_name lib_name = let cookie_library_name lib_name =

View File

@ -13,3 +13,9 @@ include T
module Set = Set.Make(T) module Set = Set.Make(T)
module Map = Map.Make(T) module Map = Map.Make(T)
let of_string_exn s =
match int_of_string s with
| exception Failure _ ->
failwith (Printf.sprintf "of_string_exn: invalid int %S" s)
| s -> s

View File

@ -3,3 +3,5 @@ val compare : t -> t -> Ordering.t
module Set : Set.S with type elt = t module Set : Set.S with type elt = t
module Map : Map.S with type key = t module Map : Map.S with type key = t
val of_string_exn : string -> t

View File

@ -104,3 +104,9 @@ let rec assoc t x =
| (k, v) :: t -> if x = k then Some v else assoc t x | (k, v) :: t -> if x = k then Some v else assoc t x
let singleton x = [x] let singleton x = [x]
let rec nth t i =
match t, i with
| [], _ -> None
| x :: _, 0 -> Some x
| _ :: xs, i -> nth xs (i - 1)

View File

@ -40,3 +40,5 @@ val compare : 'a t -> 'a t -> compare:('a -> 'a -> Ordering.t) -> Ordering.t
val assoc : ('a * 'b) t -> 'a -> 'b option val assoc : ('a * 'b) t -> 'a -> 'b option
val singleton : 'a -> 'a t val singleton : 'a -> 'a t
val nth : 'a t -> int -> 'a option

View File

@ -126,7 +126,7 @@ let loc t = t.template.loc
let syntax_version t = t.syntax_version let syntax_version t = t.syntax_version
let virt_syntax = (0, 0) let virt_syntax = (1, 0)
let virt ?(quoted=false) pos s = let virt ?(quoted=false) pos s =
let template = Jbuild.parse ~quoted ~loc:(Loc.of_pos pos) s in let template = Jbuild.parse ~quoted ~loc:(Loc.of_pos pos) s in

View File

@ -88,10 +88,18 @@ let expand_var_no_root t var = String.Map.find t.vars var
let (expand_vars, expand_vars_path) = let (expand_vars, expand_vars_path) =
let expand t ~scope ~dir ?(extra_vars=String.Map.empty) s = let expand t ~scope ~dir ?(extra_vars=String.Map.empty) s =
String_with_vars.expand ~mode:Single ~dir s ~f:(fun v _syntax_version -> String_with_vars.expand ~mode:Single ~dir s ~f:(fun v syntax_version ->
match String_with_vars.Var.full_name v with match String_with_vars.Var.full_name v with
| "ROOT" -> Some [Value.Path t.context.build_dir] | "ROOT" -> Some [Value.Path t.context.build_dir]
| "SCOPE_ROOT" -> Some [Value.Path (Scope.root scope)] | "SCOPE_ROOT" ->
if syntax_version >= (1, 0) then
Loc.fail (String_with_vars.Var.loc v)
"Variable %%{SCOPE_ROOT} has been renamed to %%{project_root} \
in dune files"
else
Some [Value.Path (Scope.root scope)]
| "project_root" when syntax_version >= (1, 0) ->
Some [Value.Path (Scope.root scope)]
| var -> | var ->
(match expand_var_no_root t var with (match expand_var_no_root t var with
| Some _ as x -> x | Some _ as x -> x
@ -641,12 +649,12 @@ module Action = struct
| Pair ("dep", s) when syntax_version >= (1, 0) -> | Pair ("dep", s) when syntax_version >= (1, 0) ->
path_with_dep s path_with_dep s
| Pair ("dep", s) -> | Pair ("dep", s) ->
Loc.fail Loc.fail
loc loc
"${dep:%s} is not supported in jbuild files.\n\ "${dep:%s} is not supported in jbuild files.\n\
Hint: Did you mean ${path:%s} instead?" Hint: Did you mean ${path:%s} instead?"
s s
s s
| Pair ("bin", s) -> begin | 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
@ -657,8 +665,8 @@ module Action = struct
| Pair ("findlib", s) when syntax_version >= (1, 0) -> | Pair ("findlib", s) when syntax_version >= (1, 0) ->
Loc.fail Loc.fail
loc loc
"The findlib special variable is not supported anymore, please use lib instead:\n\ "The findlib special variable is not supported in jbuild files, \
%%{lib:%s}" please use lib instead:\n%%{lib:%s} in dune files"
s s
| Pair ("findlib", s) | Pair ("findlib", s)
| Pair ("lib", s) -> begin | Pair ("lib", s) -> begin
@ -739,28 +747,49 @@ module Action = struct
| Some _ as x -> x | Some _ as x -> x
| None -> String.Map.find extra_vars key | None -> String.Map.find extra_vars key
in 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 = let t =
U.partial_expand t ~dir ~map_exe ~f:(fun var syntax_version -> U.partial_expand t ~dir ~map_exe ~f:(fun var syntax_version ->
let var_name = String_with_vars.Var.full_name var in let var_name = String_with_vars.Var.full_name var in
let loc = String_with_vars.Var.loc var in let loc = String_with_vars.Var.loc var in
match var_name with match var_name with
| "ROOT" -> Some (path_exp sctx.context.build_dir) | "ROOT" -> Some (path_exp sctx.context.build_dir)
| "SCOPE_ROOT" -> Some (path_exp (Scope.root scope)) | "SCOPE_ROOT" ->
| "@" -> begin if syntax_version >= (1, 0) then
match targets_written_by_user with Loc.fail loc
| Infer -> Loc.fail loc "You cannot use ${@} with inferred rules." "Variable %%{SCOPE_ROOT} has been renamed to %%{project_root} \
| Alias -> Loc.fail loc "You cannot use ${@} in aliases." in dune files"
| Static l -> Some (Value.L.paths l) else
end Some (path_exp (Scope.root scope))
| "project_root" when syntax_version >= (1, 0) ->
Some (path_exp (Scope.root scope))
| "@" ->
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 match String_with_vars.Var.destruct var with
| Pair ("path-no-dep", s) -> | Pair ("path-no-dep", s) ->
if syntax_version < (1, 0) then if syntax_version < (1, 0) then
Some (path_exp (Path.relative dir s)) Some (path_exp (Path.relative dir s))
else else
Loc.fail Loc.fail
loc loc
"The ${path-no-dep:...} syntax has been removed from dune." "The ${path-no-dep:...} syntax has been removed from dune."
| _ -> | _ ->
let exp = expand var syntax_version in let exp = expand var syntax_version in
Option.iter exp ~f:(fun vs -> Option.iter exp ~f:(fun vs ->
@ -772,23 +801,37 @@ module Action = struct
(t, acc) (t, acc)
let expand_step2 ~dir ~dynamic_expansions ~deps_written_by_user ~map_exe t = let expand_step2 ~dir ~dynamic_expansions ~deps_written_by_user ~map_exe t =
U.Partial.expand t ~dir ~map_exe ~f:(fun var _syntax_version -> U.Partial.expand t ~dir ~map_exe ~f:(fun var syntax_version ->
let key = String_with_vars.Var.full_name var in let key = String_with_vars.Var.full_name var in
let loc = String_with_vars.Var.loc var in let loc = String_with_vars.Var.loc var in
match String.Map.find dynamic_expansions key with match String.Map.find dynamic_expansions key with
| Some _ as opt -> opt | Some _ as opt -> opt
| None -> | None ->
let first_dep () =
Some (
match deps_written_by_user with
| [] ->
Loc.warn loc "Variable '%s' used with no explicit \
dependencies@." key;
[Value.String ""]
| v :: _ -> [Path v]
)
in
match key with match key with
| "<" -> | "<" ->
Some if syntax_version < (1, 0) then
(match deps_written_by_user with first_dep ()
| [] -> else
Loc.warn loc "Variable '<' used with no explicit \ Loc.fail loc "Variable '<' is renamed to 'first-dep' in dune files"
dependencies@."; | "first-dep" when syntax_version >= (1, 0) -> first_dep ()
[Value.String ""] | "^" ->
| dep :: _ -> if syntax_version < (1, 0) then
[Path dep]) Some (Value.L.paths deps_written_by_user)
| "^" -> Some (Value.L.paths deps_written_by_user) else
Loc.fail loc
"Variable %%{^} has been renamed to %%{deps} in dune files"
| "deps" when syntax_version >= (1, 0) ->
Some (Value.L.paths deps_written_by_user)
| _ -> None) | _ -> None)
let run sctx ~loc ?(extra_vars=String.Map.empty) let run sctx ~loc ?(extra_vars=String.Map.empty)
@ -800,8 +843,9 @@ module Action = struct
| [] -> () | [] -> ()
| x :: _ -> | x :: _ ->
let loc = String_with_vars.loc x in let loc = String_with_vars.loc x in
Loc.warn loc "Aliases must not have targets, this target will be ignored.\n\ Loc.warn loc
This will become an error in the future."; "Aliases must not have targets, this target will be ignored.\n\
This will become an error in the future.";
end; end;
let t, forms = let t, forms =
expand_step1 sctx t ~dir ~dep_kind ~scope expand_step1 sctx t ~dir ~dep_kind ~scope

View File

@ -22,7 +22,7 @@
(rule (rule
(targets dune.inc.gen) (targets dune.inc.gen)
(deps (source_tree test-cases)) (deps (source_tree test-cases))
(action (with-stdout-to %{@} (run ./gen_tests.exe)))) (action (with-stdout-to %{targets} (run ./gen_tests.exe))))
(alias (alias
(name runtest) (name runtest)

View File

@ -507,6 +507,14 @@
test-cases/private-public-overlap test-cases/private-public-overlap
(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 project-root)
(deps (package dune) (source_tree test-cases/project-root))
(action
(chdir
test-cases/project-root
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
(alias (alias
(name promote) (name promote)
(deps (package dune) (source_tree test-cases/promote)) (deps (package dune) (source_tree test-cases/promote))
@ -673,6 +681,7 @@
(alias path-variables) (alias path-variables)
(alias ppx-rewriter) (alias ppx-rewriter)
(alias private-public-overlap) (alias private-public-overlap)
(alias project-root)
(alias promote) (alias promote)
(alias quoting) (alias quoting)
(alias redirections) (alias redirections)
@ -740,6 +749,7 @@
(alias output-obj) (alias output-obj)
(alias package-dep) (alias package-dep)
(alias path-variables) (alias path-variables)
(alias project-root)
(alias promote) (alias promote)
(alias quoting) (alias quoting)
(alias redirections) (alias redirections)

View File

@ -3,7 +3,7 @@
(rule (rule
(targets dummy.ml) (targets dummy.ml)
(action (with-stdout-to %{@} (echo "")))) (action (with-stdout-to %{targets} (echo ""))))
(library (library
(name foo) (name foo)

View File

@ -3,8 +3,8 @@ We are dropping support for findlib in dune
$ dune build --root in-dune target.txt $ dune build --root in-dune target.txt
Entering directory 'in-dune' Entering directory 'in-dune'
File "dune", line 2, characters 25-37: File "dune", line 2, characters 25-37:
Error: The findlib special variable is not supported anymore, please use lib instead: Error: The findlib special variable is not supported in jbuild files, please use lib instead:
%{lib:pkg} %{lib:pkg} in dune files
[1] [1]
But it must still be available in jbuild files But it must still be available in jbuild files

View File

@ -4,4 +4,4 @@
(alias (alias
(name runtest) (name runtest)
(deps f.exe) (deps f.exe)
(action (run %{<}))) (action (run %{first-dep})))

View File

@ -6,5 +6,5 @@
(deps (glob_files optional.ml) (deps (glob_files optional.ml)
(glob_files *optional.ml)) (glob_files *optional.ml))
(action (action
(with-stdout-to %{@} (with-stdout-to %{targets}
(run echo "let () = print_endline \"Hello World\"")))) (run echo "let () = print_endline \"Hello World\""))))

View File

@ -8,7 +8,7 @@
(name runtest) (name runtest)
(package lib1) (package lib1)
(deps test1.exe) (deps test1.exe)
(action (run %{<}))) (action (run %{first-dep})))
(executable (executable
(name test1) (name test1)
@ -25,7 +25,7 @@
(name runtest) (name runtest)
(package lib2) (package lib2)
(deps test2.exe) (deps test2.exe)
(action (run %{<}))) (action (run %{first-dep})))
(executable (executable
(name test2) (name test2)

View File

@ -1,6 +1,6 @@
(alias (alias
(name runtest) (name runtest)
(deps main.exe) (deps main.exe)
(action (run %{<}))) (action (run %{first-dep})))
(executable (name main)) (executable (name main))

View File

@ -1,6 +1,6 @@
(alias (alias
(name runtest) (name runtest)
(deps main.exe) (deps main.exe)
(action (run %{<}))) (action (run %{first-dep})))
(executable (name main)) (executable (name main))

View File

@ -1,4 +1,4 @@
(alias (alias
(name print-merlins) (name print-merlins)
(deps lib/.merlin exe/.merlin) (deps lib/.merlin exe/.merlin)
(action (run ./sanitize-dot-merlin/sanitize_dot_merlin.exe %{^}))) (action (run ./sanitize-dot-merlin/sanitize_dot_merlin.exe %{deps})))

View File

@ -1,3 +1,3 @@
(alias (alias
(name runtest) (name runtest)
(deps %{SCOPE_ROOT}/023e1a58-4d08-11e7-a041-aa000008c8a6)) (deps %{project_root}/023e1a58-4d08-11e7-a041-aa000008c8a6))

View File

@ -1,17 +1,17 @@
;; Test for %{^} with globs in rules ;; Test for %{deps} with globs in rules
(rule (rule
(targets result expected) (targets result expected)
(deps dune (glob_files *.txt)) (deps dune (glob_files *.txt))
(action (progn (action (progn
(with-stdout-to result (echo %{^})) (with-stdout-to result (echo %{deps}))
(with-stdout-to expected (echo "dune a.txt b.txt c.txt"))))) (with-stdout-to expected (echo "dune a.txt b.txt c.txt")))))
(rule (rule
(targets result2 expected2) (targets result2 expected2)
(deps (source_tree sub-tree)) (deps (source_tree sub-tree))
(action (progn (action (progn
(with-stdout-to result2 (echo %{^})) (with-stdout-to result2 (echo %{deps}))
(with-stdout-to expected2 (echo "sub-tree/a sub-tree/dir/b"))))) (with-stdout-to expected2 (echo "sub-tree/a sub-tree/dir/b")))))
(alias (alias
@ -31,7 +31,7 @@
(alias (alias
(name runtest) (name runtest)
(deps dune dune-plop) (deps dune dune-plop)
(action (run diff -u %{^}))) (action (run diff -u %{deps})))
;; For some tests in subdirs ;; For some tests in subdirs

View File

@ -21,19 +21,19 @@
(rule (rule
(targets static.exe) (targets static.exe)
(deps test.exe%{ext_obj} static.c) (deps test.exe%{ext_obj} static.c)
(action (run %{CC} -o %{@} -I %{ocaml_where} -I . %{^} (action (run %{CC} -o %{targets} -I %{ocaml_where} -I . %{deps}
%{ocaml-config:native_c_libraries}))) %{ocaml-config:native_c_libraries})))
(rule (rule
(targets static.bc) (targets static.bc)
(deps test.bc%{ext_obj} static.c) (deps test.bc%{ext_obj} static.c)
(action (run %{CC} -o %{@} -I %{ocaml_where} -I . %{^} (action (run %{CC} -o %{targets} -I %{ocaml_where} -I . %{deps}
%{ocaml-config:bytecomp_c_libraries}))) %{ocaml-config:bytecomp_c_libraries})))
(rule (rule
(targets dynamic.exe) (targets dynamic.exe)
(deps dynamic.c) (deps dynamic.c)
(action (run %{CC} -o %{@} %{<} %{ocaml-config:native_c_libraries}))) (action (run %{CC} -o %{targets} %{first-dep} %{ocaml-config:native_c_libraries})))
(alias (alias
(name runtest) (name runtest)
@ -48,9 +48,9 @@
(alias (alias
(name runtest) (name runtest)
(deps test.bc%{ext_dll}) (deps test.bc%{ext_dll})
(action (run ./dynamic.exe ./%{<}))) (action (run ./dynamic.exe ./%{first-dep})))
(alias (alias
(name runtest) (name runtest)
(deps test%{ext_dll}) (deps test%{ext_dll})
(action (run ./dynamic.exe ./%{<}))) (action (run ./dynamic.exe ./%{first-dep})))

View File

@ -0,0 +1,4 @@
(alias
(name runtest)
(action (echo "From root: %{project_root}\n"))
)

View File

@ -0,0 +1,4 @@
(alias
(name runtest)
(action (echo "From dune-file/a/b/: %{project_root}\n"))
)

View File

@ -0,0 +1,4 @@
(alias
(name runtest)
(action (echo "From dune-file/a/: %{project_root}\n"))
)

View File

@ -0,0 +1 @@
(lang dune 1.0)

View File

@ -0,0 +1,5 @@
(alias
((name runtest)
(action (echo "From jbuild/a/b/: ${SCOPE_ROOT}\n"))
)
)

View File

@ -0,0 +1,5 @@
(alias
((name runtest)
(action (echo "From jbuild/a/: ${SCOPE_ROOT}\n"))
)
)

View File

@ -0,0 +1,9 @@
%{SCOPE_ROOT} (or ${SCOPE_ROOT} in jbuild files) refers to the root of the
project.
$ dune runtest
From dune-file/a/b/: ../../..
From dune-file/a/: ../..
From jbuild/a/b/: ../../..
From jbuild/a/: ../..
From root: .

View File

@ -1,3 +1,3 @@
(rule (rule
(targets x y) (targets x y)
(action (with-stdout-to %{@} (echo foo)))) (action (with-stdout-to %{targets} (echo foo))))

View File

@ -1,3 +1,3 @@
(rule (rule
(targets s t) (targets s t)
(action (with-stdout-to "%{@}" (echo foo)))) (action (with-stdout-to "%{targets}" (echo foo))))

View File

@ -3,8 +3,8 @@ that ${@} is not quoted and doesn't contain exactly 1 element
$ dune build --root bad x $ dune build --root bad x
Entering directory 'bad' Entering directory 'bad'
File "dune", line 3, characters 27-29: File "dune", line 3, characters 27-35:
Error: Variable %{@} expands to 2 values, however a single value is expected here. Please quote this atom. Error: Variable %{targets} expands to 2 values, however a single value is expected here. Please quote this atom.
[1] [1]
The targets should only be interpreted as a single path when quoted The targets should only be interpreted as a single path when quoted

View File

@ -8,18 +8,18 @@
(lint (lint
(per_module (per_module
((pps (reasonppx (-lint true))) (hello cppome)) ((pps (reasonppx (-lint true))) (hello cppome))
((action (run ./pp/reasononlypp.exe -lint %{<})) (foo bar pped)))) ((action (run ./pp/reasononlypp.exe -lint %{first-dep})) (foo bar pped))))
(preprocess (preprocess
(per_module (per_module
((pps (reasonppx)) (foo)) ((pps (reasonppx)) (foo))
((pps (reasonppx (-lint false))) (hello)) ((pps (reasonppx (-lint false))) (hello))
((action (run ./pp/reasononlypp.exe %{<})) (cppome)))))) ((action (run ./pp/reasononlypp.exe %{first-dep})) (cppome))))))
(executable (executable
((name rbin) ((name rbin)
(modules rbin) (modules rbin)
(lint (action (run ./pp/reasononlypp.exe -lint %{<}))) (lint (action (run ./pp/reasononlypp.exe -lint %{first-dep})))
(preprocess (action (run ./pp/reasononlypp.exe %{<}))) (preprocess (action (run ./pp/reasononlypp.exe %{first-dep})))
(libraries (rlib)))) (libraries (rlib))))
;; we want to make sure that .rei files are present ;; we want to make sure that .rei files are present
@ -31,4 +31,4 @@
(alias (alias
((name runtest) ((name runtest)
(deps (rbin.exe)) (deps (rbin.exe))
(action (run %{<})))) (action (run %{first-dep}))))

View File

@ -15,15 +15,15 @@
(rule (rule
(targets stdout.expected) (targets stdout.expected)
(action (with-stdout-to %{@} (echo "toto\n")))) (action (with-stdout-to %{targets} (echo "toto\n"))))
(rule (rule
(targets stderr.expected) (targets stderr.expected)
(action (with-stdout-to %{@} (echo "titi\n")))) (action (with-stdout-to %{targets} (echo "titi\n"))))
(rule (rule
(targets both.expected) (targets both.expected)
(action (with-stdout-to %{@} (echo "toto\ntiti\n")))) (action (with-stdout-to %{targets} (echo "toto\ntiti\n"))))
(alias (alias
(name runtest) (name runtest)

View File

@ -11,4 +11,4 @@
(alias (alias
(name runtest) (name runtest)
(deps main.exe) (deps main.exe)
(action (run %{<}))) (action (run %{first-dep})))

View File

@ -51,27 +51,27 @@ Printf.fprintf (open_out Sys.argv.(2)) \"%g\n%!\" (Sys.time ())
(executable (name incr) (libraries unix)) (executable (name incr) (libraries unix))
(rule (targets 01.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 %{@}))) (rule (targets 02.foo) (action (run ./incr.exe x %{targets})))
(rule (targets 03.foo) (action (run ./incr.exe x %{@}))) (rule (targets 03.foo) (action (run ./incr.exe x %{targets})))
(rule (targets 04.foo) (action (run ./incr.exe x %{@}))) (rule (targets 04.foo) (action (run ./incr.exe x %{targets})))
(rule (targets 05.foo) (action (run ./incr.exe x %{@}))) (rule (targets 05.foo) (action (run ./incr.exe x %{targets})))
(rule (targets 06.foo) (action (run ./incr.exe x %{@}))) (rule (targets 06.foo) (action (run ./incr.exe x %{targets})))
(rule (targets 07.foo) (action (run ./incr.exe x %{@}))) (rule (targets 07.foo) (action (run ./incr.exe x %{targets})))
(rule (targets 08.foo) (action (run ./incr.exe x %{@}))) (rule (targets 08.foo) (action (run ./incr.exe x %{targets})))
(rule (targets 09.foo) (action (run ./incr.exe x %{@}))) (rule (targets 09.foo) (action (run ./incr.exe x %{targets})))
(rule (targets 10.foo) (action (run ./incr.exe x %{@}))) (rule (targets 10.foo) (action (run ./incr.exe x %{targets})))
(rule (targets 01.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 %{@})) (locks m)) (rule (targets 02.bar) (action (run ./incr.exe y %{targets})) (locks m))
(rule (targets 03.bar) (action (run ./incr.exe y %{@})) (locks m)) (rule (targets 03.bar) (action (run ./incr.exe y %{targets})) (locks m))
(rule (targets 04.bar) (action (run ./incr.exe y %{@})) (locks m)) (rule (targets 04.bar) (action (run ./incr.exe y %{targets})) (locks m))
(rule (targets 05.bar) (action (run ./incr.exe y %{@})) (locks m)) (rule (targets 05.bar) (action (run ./incr.exe y %{targets})) (locks m))
(rule (targets 06.bar) (action (run ./incr.exe y %{@})) (locks m)) (rule (targets 06.bar) (action (run ./incr.exe y %{targets})) (locks m))
(rule (targets 07.bar) (action (run ./incr.exe y %{@})) (locks m)) (rule (targets 07.bar) (action (run ./incr.exe y %{targets})) (locks m))
(rule (targets 08.bar) (action (run ./incr.exe y %{@})) (locks m)) (rule (targets 08.bar) (action (run ./incr.exe y %{targets})) (locks m))
(rule (targets 09.bar) (action (run ./incr.exe y %{@})) (locks m)) (rule (targets 09.bar) (action (run ./incr.exe y %{targets})) (locks m))
(rule (targets 10.bar) (action (run ./incr.exe y %{@})) (locks m)) (rule (targets 10.bar) (action (run ./incr.exe y %{targets})) (locks m))
(alias (alias
(name runtest-no-deps) (name runtest-no-deps)

View File

@ -5,4 +5,4 @@
(alias (alias
(name runtest) (name runtest)
(deps ./test_configurator.exe) (deps ./test_configurator.exe)
(action (run %{<}))) (action (run %{first-dep})))

View File

@ -19,71 +19,71 @@
(alias (alias
(name runtest) (name runtest)
(deps tests.mlt (deps tests.mlt
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) (glob_files %{project_root}/src/.dune.objs/*.cmi)
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi) (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi)
(source_tree toolchain.d) (source_tree toolchain.d)
(source_tree findlib-db)) (source_tree findlib-db))
(action (chdir %{SCOPE_ROOT} (action (chdir %{project_root}
(progn (progn
(run %{exe:expect_test.exe} %{<}) (run %{exe:expect_test.exe} %{first-dep})
(diff? %{<} %{<}.corrected))))) (diff? %{first-dep} %{first-dep}.corrected)))))
(alias (alias
(name runtest) (name runtest)
(deps filename.mlt (deps filename.mlt
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) (glob_files %{project_root}/src/.dune.objs/*.cmi)
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)) (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
(action (chdir %{SCOPE_ROOT} (action (chdir %{project_root}
(progn (progn
(run %{exe:expect_test.exe} %{<}) (run %{exe:expect_test.exe} %{first-dep})
(diff? %{<} %{<}.corrected))))) (diff? %{first-dep} %{first-dep}.corrected)))))
(alias (alias
(name runtest) (name runtest)
(deps import_dot_map.mlt (deps import_dot_map.mlt
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) (glob_files %{project_root}/src/.dune.objs/*.cmi)
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)) (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
(action (chdir %{SCOPE_ROOT} (action (chdir %{project_root}
(progn (progn
(run %{exe:expect_test.exe} %{<}) (run %{exe:expect_test.exe} %{first-dep})
(diff? %{<} %{<}.corrected))))) (diff? %{first-dep} %{first-dep}.corrected)))))
(alias (alias
(name runtest) (name runtest)
(deps action.mlt (deps action.mlt
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) (glob_files %{project_root}/src/.dune.objs/*.cmi)
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)) (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
(action (chdir %{SCOPE_ROOT} (action (chdir %{project_root}
(progn (progn
(run %{exe:expect_test.exe} %{<}) (run %{exe:expect_test.exe} %{first-dep})
(diff? %{<} %{<}.corrected))))) (diff? %{first-dep} %{first-dep}.corrected)))))
(alias (alias
(name runtest) (name runtest)
(deps path.mlt (deps path.mlt
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) (glob_files %{project_root}/src/.dune.objs/*.cmi)
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)) (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
(action (chdir %{SCOPE_ROOT} (action (chdir %{project_root}
(progn (progn
(run %{exe:expect_test.exe} %{<}) (run %{exe:expect_test.exe} %{first-dep})
(diff? %{<} %{<}.corrected))))) (diff? %{first-dep} %{first-dep}.corrected)))))
(alias (alias
(name runtest) (name runtest)
(deps sexp.mlt (deps sexp.mlt
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) (glob_files %{project_root}/src/.dune.objs/*.cmi)
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)) (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
(action (chdir %{SCOPE_ROOT} (action (chdir %{project_root}
(progn (progn
(run %{exe:expect_test.exe} %{<}) (run %{exe:expect_test.exe} %{first-dep})
(diff? %{<} %{<}.corrected))))) (diff? %{first-dep} %{first-dep}.corrected)))))
(alias (alias
(name runtest) (name runtest)
(deps jbuild.mlt (deps jbuild.mlt
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi) (glob_files %{project_root}/src/.dune.objs/*.cmi)
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)) (glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
(action (chdir %{SCOPE_ROOT} (action (chdir %{project_root}
(progn (progn
(run %{exe:expect_test.exe} %{<}) (run %{exe:expect_test.exe} %{first-dep})
(diff? %{<} %{<}.corrected))))) (diff? %{first-dep} %{first-dep}.corrected)))))

View File

@ -5,4 +5,4 @@
(alias (alias
(name runtest) (name runtest)
(deps ./gh637.exe) (deps ./gh637.exe)
(action (run %{<}))) (action (run %{first-dep})))