Merge pull request #957 from rgrinberg/rename-scope-scope-root
Rename SCOPE_ROOT, ${@}, ${^}, etc.
This commit is contained in:
commit
290fffc2f3
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
|
||||
|
|
|
@ -169,7 +169,7 @@ Jbuild Dune
|
|||
======================== ============
|
||||
``${@}`` ``%{targets}``
|
||||
``${^}`` ``%{deps}``
|
||||
``${<}`` ``%{deps[0]}``
|
||||
``${<}`` ``%{first-dep}``
|
||||
``${path:file}`` ``%{dep:file}``
|
||||
``${SCOPE_ROOT}`` ``%{project_root}``
|
||||
``${findlib:..}`` ``%{lib:..}``
|
||||
|
|
|
@ -136,7 +136,7 @@ Add this field to your ``library`` or ``executable`` stanzas:
|
|||
|
||||
.. 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
|
||||
declare the dependency to this file via:
|
||||
|
@ -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} %{first-dep} -o %{targets})))
|
||||
|
||||
Defining a library with C stubs
|
||||
===============================
|
||||
|
@ -193,7 +193,7 @@ compilation and link flags. Write this ``dune`` file:
|
|||
(rule
|
||||
(targets c_flags.sexp c_library_flags.sexp)
|
||||
(deps config/discover.exe)
|
||||
(action (run %{<} -ocamlc %{OCAMLC})))
|
||||
(action (run %{first-dep} -ocamlc %{OCAMLC})))
|
||||
|
||||
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
|
||||
(targets foo.ml)
|
||||
(deps ../generator/gen.exe)
|
||||
(action (run %{<} -o %{@})))
|
||||
(action (run %{first-dep} -o %{targets})))
|
||||
|
||||
Defining tests
|
||||
==============
|
||||
|
@ -253,7 +253,7 @@ Write this in your ``dune`` file:
|
|||
(alias
|
||||
(name runtest)
|
||||
(deps my-test-program.exe)
|
||||
(action (run %{<})))
|
||||
(action (run %{first-dep})))
|
||||
|
||||
And run the tests with:
|
||||
|
||||
|
|
|
@ -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 %{first-dep} %{targets}))))
|
||||
|
||||
(rule
|
||||
((targets (config.full))
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
(rule
|
||||
((targets (config.ml))
|
||||
(deps (../config.full))
|
||||
(action (copy %{<} %{@}))))
|
||||
(action (copy %{first-dep} %{targets}))))
|
||||
|
||||
|
|
|
@ -1242,8 +1242,8 @@ 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__"<"
|
||||
; S.virt_var __POS__ "targets"
|
||||
; S.virt_var __POS__"first-dep"
|
||||
])))
|
||||
; mode
|
||||
; locks = []
|
||||
|
@ -1261,7 +1261,7 @@ module Rule = struct
|
|||
Chdir
|
||||
(S.virt_var __POS__ "ROOT",
|
||||
Run (S.virt_text __POS__ "ocamlyacc",
|
||||
[S.virt_var __POS__ "<"])))
|
||||
[S.virt_var __POS__ "first-dep"])))
|
||||
; mode
|
||||
; locks = []
|
||||
; loc
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -13,3 +13,9 @@ include T
|
|||
|
||||
module Set = Set.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
|
||||
|
|
|
@ -3,3 +3,5 @@ val compare : t -> t -> Ordering.t
|
|||
|
||||
module Set : Set.S with type elt = t
|
||||
module Map : Map.S with type key = t
|
||||
|
||||
val of_string_exn : string -> t
|
||||
|
|
|
@ -104,3 +104,9 @@ let rec assoc t x =
|
|||
| (k, v) :: t -> if x = k then Some v else assoc t 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)
|
||||
|
|
|
@ -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 singleton : 'a -> 'a t
|
||||
|
||||
val nth : 'a t -> int -> 'a option
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 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
|
||||
| "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 ->
|
||||
(match expand_var_no_root t var with
|
||||
| Some _ as x -> x
|
||||
|
@ -641,12 +649,12 @@ module Action = struct
|
|||
| 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\
|
||||
Hint: Did you mean ${path:%s} instead?"
|
||||
s
|
||||
s
|
||||
Loc.fail
|
||||
loc
|
||||
"${dep:%s} is not supported in jbuild files.\n\
|
||||
Hint: Did you mean ${path:%s} instead?"
|
||||
s
|
||||
s
|
||||
| Pair ("bin", s) -> begin
|
||||
let sctx = host sctx in
|
||||
match Artifacts.binary (artifacts sctx) s with
|
||||
|
@ -657,8 +665,8 @@ module Action = struct
|
|||
| Pair ("findlib", s) when syntax_version >= (1, 0) ->
|
||||
Loc.fail
|
||||
loc
|
||||
"The findlib special variable is not supported anymore, please use lib instead:\n\
|
||||
%%{lib:%s}"
|
||||
"The findlib special variable is not supported in jbuild files, \
|
||||
please use lib instead:\n%%{lib:%s} in dune files"
|
||||
s
|
||||
| Pair ("findlib", s)
|
||||
| Pair ("lib", s) -> begin
|
||||
|
@ -739,28 +747,49 @@ 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
|
||||
let loc = String_with_vars.Var.loc var in
|
||||
match var_name with
|
||||
| "ROOT" -> Some (path_exp sctx.context.build_dir)
|
||||
| "SCOPE_ROOT" -> 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
|
||||
| "SCOPE_ROOT" ->
|
||||
if syntax_version >= (1, 0) then
|
||||
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))
|
||||
| "@" ->
|
||||
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) ->
|
||||
if syntax_version < (1, 0) then
|
||||
Some (path_exp (Path.relative dir s))
|
||||
else
|
||||
Loc.fail
|
||||
loc
|
||||
"The ${path-no-dep:...} syntax has been removed from dune."
|
||||
if syntax_version < (1, 0) then
|
||||
Some (path_exp (Path.relative dir s))
|
||||
else
|
||||
Loc.fail
|
||||
loc
|
||||
"The ${path-no-dep:...} syntax has been removed from dune."
|
||||
| _ ->
|
||||
let exp = expand var syntax_version in
|
||||
Option.iter exp ~f:(fun vs ->
|
||||
|
@ -772,23 +801,37 @@ module Action = struct
|
|||
(t, acc)
|
||||
|
||||
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 loc = String_with_vars.Var.loc var in
|
||||
match String.Map.find dynamic_expansions key with
|
||||
| Some _ as opt -> opt
|
||||
| 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
|
||||
| "<" ->
|
||||
Some
|
||||
(match deps_written_by_user with
|
||||
| [] ->
|
||||
Loc.warn loc "Variable '<' used with no explicit \
|
||||
dependencies@.";
|
||||
[Value.String ""]
|
||||
| dep :: _ ->
|
||||
[Path dep])
|
||||
| "^" -> Some (Value.L.paths deps_written_by_user)
|
||||
if syntax_version < (1, 0) then
|
||||
first_dep ()
|
||||
else
|
||||
Loc.fail loc "Variable '<' is renamed to 'first-dep' in dune files"
|
||||
| "first-dep" when syntax_version >= (1, 0) -> first_dep ()
|
||||
| "^" ->
|
||||
if syntax_version < (1, 0) then
|
||||
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)
|
||||
|
||||
let run sctx ~loc ?(extra_vars=String.Map.empty)
|
||||
|
@ -800,8 +843,9 @@ module Action = struct
|
|||
| [] -> ()
|
||||
| x :: _ ->
|
||||
let loc = String_with_vars.loc x in
|
||||
Loc.warn loc "Aliases must not have targets, this target will be ignored.\n\
|
||||
This will become an error in the future.";
|
||||
Loc.warn loc
|
||||
"Aliases must not have targets, this target will be ignored.\n\
|
||||
This will become an error in the future.";
|
||||
end;
|
||||
let t, forms =
|
||||
expand_step1 sctx t ~dir ~dep_kind ~scope
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -507,6 +507,14 @@
|
|||
test-cases/private-public-overlap
|
||||
(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
|
||||
(name promote)
|
||||
(deps (package dune) (source_tree test-cases/promote))
|
||||
|
@ -673,6 +681,7 @@
|
|||
(alias path-variables)
|
||||
(alias ppx-rewriter)
|
||||
(alias private-public-overlap)
|
||||
(alias project-root)
|
||||
(alias promote)
|
||||
(alias quoting)
|
||||
(alias redirections)
|
||||
|
@ -740,6 +749,7 @@
|
|||
(alias output-obj)
|
||||
(alias package-dep)
|
||||
(alias path-variables)
|
||||
(alias project-root)
|
||||
(alias promote)
|
||||
(alias quoting)
|
||||
(alias redirections)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
(rule
|
||||
(targets dummy.ml)
|
||||
(action (with-stdout-to %{@} (echo ""))))
|
||||
(action (with-stdout-to %{targets} (echo ""))))
|
||||
|
||||
(library
|
||||
(name foo)
|
||||
|
|
|
@ -3,8 +3,8 @@ We are dropping support for findlib in dune
|
|||
$ dune build --root in-dune target.txt
|
||||
Entering directory 'in-dune'
|
||||
File "dune", line 2, characters 25-37:
|
||||
Error: The findlib special variable is not supported anymore, please use lib instead:
|
||||
%{lib:pkg}
|
||||
Error: The findlib special variable is not supported in jbuild files, please use lib instead:
|
||||
%{lib:pkg} in dune files
|
||||
[1]
|
||||
|
||||
But it must still be available in jbuild files
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(deps f.exe)
|
||||
(action (run %{<})))
|
||||
(action (run %{first-dep})))
|
||||
|
|
|
@ -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\""))))
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
(name runtest)
|
||||
(package lib1)
|
||||
(deps test1.exe)
|
||||
(action (run %{<})))
|
||||
(action (run %{first-dep})))
|
||||
|
||||
(executable
|
||||
(name test1)
|
||||
|
@ -25,7 +25,7 @@
|
|||
(name runtest)
|
||||
(package lib2)
|
||||
(deps test2.exe)
|
||||
(action (run %{<})))
|
||||
(action (run %{first-dep})))
|
||||
|
||||
(executable
|
||||
(name test2)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(deps main.exe)
|
||||
(action (run %{<})))
|
||||
(action (run %{first-dep})))
|
||||
|
||||
(executable (name main))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(deps main.exe)
|
||||
(action (run %{<})))
|
||||
(action (run %{first-dep})))
|
||||
|
||||
(executable (name main))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(alias
|
||||
(name print-merlins)
|
||||
(deps lib/.merlin exe/.merlin)
|
||||
(action (run ./sanitize-dot-merlin/sanitize_dot_merlin.exe %{^})))
|
||||
(action (run ./sanitize-dot-merlin/sanitize_dot_merlin.exe %{deps})))
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(deps %{SCOPE_ROOT}/023e1a58-4d08-11e7-a041-aa000008c8a6))
|
||||
(deps %{project_root}/023e1a58-4d08-11e7-a041-aa000008c8a6))
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
;; Test for %{^} with globs in rules
|
||||
;; Test for %{deps} with globs in rules
|
||||
|
||||
(rule
|
||||
(targets result expected)
|
||||
(deps dune (glob_files *.txt))
|
||||
(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")))))
|
||||
|
||||
(rule
|
||||
(targets result2 expected2)
|
||||
(deps (source_tree sub-tree))
|
||||
(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")))))
|
||||
|
||||
(alias
|
||||
|
@ -31,7 +31,7 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(deps dune dune-plop)
|
||||
(action (run diff -u %{^})))
|
||||
(action (run diff -u %{deps})))
|
||||
|
||||
;; For some tests in subdirs
|
||||
|
||||
|
|
|
@ -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 . %{deps}
|
||||
%{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 . %{deps}
|
||||
%{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} %{first-dep} %{ocaml-config:native_c_libraries})))
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
|
@ -48,9 +48,9 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(deps test.bc%{ext_dll})
|
||||
(action (run ./dynamic.exe ./%{<})))
|
||||
(action (run ./dynamic.exe ./%{first-dep})))
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
(deps test%{ext_dll})
|
||||
(action (run ./dynamic.exe ./%{<})))
|
||||
(action (run ./dynamic.exe ./%{first-dep})))
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(action (echo "From root: %{project_root}\n"))
|
||||
)
|
|
@ -0,0 +1,4 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(action (echo "From dune-file/a/b/: %{project_root}\n"))
|
||||
)
|
|
@ -0,0 +1,4 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(action (echo "From dune-file/a/: %{project_root}\n"))
|
||||
)
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.0)
|
|
@ -0,0 +1,5 @@
|
|||
(alias
|
||||
((name runtest)
|
||||
(action (echo "From jbuild/a/b/: ${SCOPE_ROOT}\n"))
|
||||
)
|
||||
)
|
|
@ -0,0 +1,5 @@
|
|||
(alias
|
||||
((name runtest)
|
||||
(action (echo "From jbuild/a/: ${SCOPE_ROOT}\n"))
|
||||
)
|
||||
)
|
|
@ -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: .
|
|
@ -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
|
||||
|
|
|
@ -8,18 +8,18 @@
|
|||
(lint
|
||||
(per_module
|
||||
((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
|
||||
(per_module
|
||||
((pps (reasonppx)) (foo))
|
||||
((pps (reasonppx (-lint false))) (hello))
|
||||
((action (run ./pp/reasononlypp.exe %{<})) (cppome))))))
|
||||
((action (run ./pp/reasononlypp.exe %{first-dep})) (cppome))))))
|
||||
|
||||
(executable
|
||||
((name rbin)
|
||||
(modules rbin)
|
||||
(lint (action (run ./pp/reasononlypp.exe -lint %{<})))
|
||||
(preprocess (action (run ./pp/reasononlypp.exe %{<})))
|
||||
(lint (action (run ./pp/reasononlypp.exe -lint %{first-dep})))
|
||||
(preprocess (action (run ./pp/reasononlypp.exe %{first-dep})))
|
||||
(libraries (rlib))))
|
||||
|
||||
;; we want to make sure that .rei files are present
|
||||
|
@ -31,4 +31,4 @@
|
|||
(alias
|
||||
((name runtest)
|
||||
(deps (rbin.exe))
|
||||
(action (run %{<}))))
|
||||
(action (run %{first-dep}))))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -11,4 +11,4 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(deps main.exe)
|
||||
(action (run %{<})))
|
||||
(action (run %{first-dep})))
|
||||
|
|
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)
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(deps ./test_configurator.exe)
|
||||
(action (run %{<})))
|
||||
(action (run %{first-dep})))
|
||||
|
|
|
@ -19,71 +19,71 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(deps tests.mlt
|
||||
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi)
|
||||
(glob_files %{project_root}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi)
|
||||
(source_tree toolchain.d)
|
||||
(source_tree findlib-db))
|
||||
(action (chdir %{SCOPE_ROOT}
|
||||
(action (chdir %{project_root}
|
||||
(progn
|
||||
(run %{exe:expect_test.exe} %{<})
|
||||
(diff? %{<} %{<}.corrected)))))
|
||||
(run %{exe:expect_test.exe} %{first-dep})
|
||||
(diff? %{first-dep} %{first-dep}.corrected)))))
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
(deps filename.mlt
|
||||
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi))
|
||||
(action (chdir %{SCOPE_ROOT}
|
||||
(glob_files %{project_root}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
||||
(action (chdir %{project_root}
|
||||
(progn
|
||||
(run %{exe:expect_test.exe} %{<})
|
||||
(diff? %{<} %{<}.corrected)))))
|
||||
(run %{exe:expect_test.exe} %{first-dep})
|
||||
(diff? %{first-dep} %{first-dep}.corrected)))))
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
(deps import_dot_map.mlt
|
||||
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi))
|
||||
(action (chdir %{SCOPE_ROOT}
|
||||
(glob_files %{project_root}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
||||
(action (chdir %{project_root}
|
||||
(progn
|
||||
(run %{exe:expect_test.exe} %{<})
|
||||
(diff? %{<} %{<}.corrected)))))
|
||||
(run %{exe:expect_test.exe} %{first-dep})
|
||||
(diff? %{first-dep} %{first-dep}.corrected)))))
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
(deps action.mlt
|
||||
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi))
|
||||
(action (chdir %{SCOPE_ROOT}
|
||||
(glob_files %{project_root}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
||||
(action (chdir %{project_root}
|
||||
(progn
|
||||
(run %{exe:expect_test.exe} %{<})
|
||||
(diff? %{<} %{<}.corrected)))))
|
||||
(run %{exe:expect_test.exe} %{first-dep})
|
||||
(diff? %{first-dep} %{first-dep}.corrected)))))
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
(deps path.mlt
|
||||
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi))
|
||||
(action (chdir %{SCOPE_ROOT}
|
||||
(glob_files %{project_root}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
||||
(action (chdir %{project_root}
|
||||
(progn
|
||||
(run %{exe:expect_test.exe} %{<})
|
||||
(diff? %{<} %{<}.corrected)))))
|
||||
(run %{exe:expect_test.exe} %{first-dep})
|
||||
(diff? %{first-dep} %{first-dep}.corrected)))))
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
(deps sexp.mlt
|
||||
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi))
|
||||
(action (chdir %{SCOPE_ROOT}
|
||||
(glob_files %{project_root}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
||||
(action (chdir %{project_root}
|
||||
(progn
|
||||
(run %{exe:expect_test.exe} %{<})
|
||||
(diff? %{<} %{<}.corrected)))))
|
||||
(run %{exe:expect_test.exe} %{first-dep})
|
||||
(diff? %{first-dep} %{first-dep}.corrected)))))
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
(deps jbuild.mlt
|
||||
(glob_files %{SCOPE_ROOT}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi))
|
||||
(action (chdir %{SCOPE_ROOT}
|
||||
(glob_files %{project_root}/src/.dune.objs/*.cmi)
|
||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
||||
(action (chdir %{project_root}
|
||||
(progn
|
||||
(run %{exe:expect_test.exe} %{<})
|
||||
(diff? %{<} %{<}.corrected)))))
|
||||
(run %{exe:expect_test.exe} %{first-dep})
|
||||
(diff? %{first-dep} %{first-dep}.corrected)))))
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
(alias
|
||||
(name runtest)
|
||||
(deps ./gh637.exe)
|
||||
(action (run %{<})))
|
||||
(action (run %{first-dep})))
|
||||
|
|
Loading…
Reference in New Issue