Rename %{<} to %{deps[0]} and implement %{deps[i]}
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
97fba5537d
commit
204b21f4fb
|
@ -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} %{deps[0]})))
|
||||||
|
|
||||||
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 %{targets})))
|
(action (run %{bin:cppo} %{deps[0]} -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 %{deps[0]} -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 %{targets})))
|
(action (run %{deps[0]} -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 %{deps[0]})))
|
||||||
|
|
||||||
And run the tests with:
|
And run the tests with:
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
((fallback)
|
((fallback)
|
||||||
(targets (config))
|
(targets (config))
|
||||||
(deps (config.defaults))
|
(deps (config.defaults))
|
||||||
(action (copy %{<} %{targets}))))
|
(action (copy %{deps[0]} %{targets}))))
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
((targets (config.full))
|
((targets (config.full))
|
||||||
|
|
|
@ -8,5 +8,5 @@
|
||||||
(rule
|
(rule
|
||||||
((targets (config.ml))
|
((targets (config.ml))
|
||||||
(deps (../config.full))
|
(deps (../config.full))
|
||||||
(action (copy %{<} %{targets}))))
|
(action (copy %{deps[0]} %{targets}))))
|
||||||
|
|
||||||
|
|
2
src/dune
2
src/dune
|
@ -11,7 +11,7 @@
|
||||||
which_program)
|
which_program)
|
||||||
(synopsis "Internal Dune library, do not use!"))
|
(synopsis "Internal Dune library, do not use!"))
|
||||||
|
|
||||||
(ocamllex meta_lexer glob_lexer dune_lexer)
|
(ocamllex meta_lexer glob_lexer dune_lexer dune_vars)
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(targets setup.ml)
|
(targets setup.ml)
|
||||||
|
|
|
@ -1243,7 +1243,7 @@ module Rule = struct
|
||||||
[ S.virt_text __POS__ "-q"
|
[ S.virt_text __POS__ "-q"
|
||||||
; S.virt_text __POS__ "-o"
|
; S.virt_text __POS__ "-o"
|
||||||
; S.virt_var __POS__ "targets"
|
; S.virt_var __POS__ "targets"
|
||||||
; S.virt_var __POS__"<"
|
; S.virt_var __POS__"deps[0]"
|
||||||
])))
|
])))
|
||||||
; 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__ "deps[0]"])))
|
||||||
; mode
|
; mode
|
||||||
; locks = []
|
; locks = []
|
||||||
; loc
|
; loc
|
||||||
|
|
|
@ -807,16 +807,20 @@ module Action = struct
|
||||||
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 dep i =
|
||||||
|
match List.nth deps_written_by_user i with
|
||||||
|
| None ->
|
||||||
|
Loc.warn loc "Variable '%s' used with no explicit \
|
||||||
|
dependencies@." key;
|
||||||
|
[Value.String ""]
|
||||||
|
| Some v -> [Path v]
|
||||||
|
in
|
||||||
match key with
|
match key with
|
||||||
| "<" ->
|
| "<" ->
|
||||||
Some
|
if syntax_version < (1, 0) then
|
||||||
(match deps_written_by_user with
|
Some (dep 0)
|
||||||
| [] ->
|
else
|
||||||
Loc.warn loc "Variable '<' used with no explicit \
|
Loc.fail loc "Variable '<' is renamed to 'deps[0]' in dune"
|
||||||
dependencies@.";
|
|
||||||
[Value.String ""]
|
|
||||||
| dep :: _ ->
|
|
||||||
[Path dep])
|
|
||||||
| "^" ->
|
| "^" ->
|
||||||
if syntax_version < (1, 0) then
|
if syntax_version < (1, 0) then
|
||||||
Some (Value.L.paths deps_written_by_user)
|
Some (Value.L.paths deps_written_by_user)
|
||||||
|
@ -824,7 +828,11 @@ module Action = struct
|
||||||
Loc.fail loc "Variable %%{^} has been renamed to %%{deps}"
|
Loc.fail loc "Variable %%{^} has been renamed to %%{deps}"
|
||||||
| "deps" when syntax_version >= (1, 0) ->
|
| "deps" when syntax_version >= (1, 0) ->
|
||||||
Some (Value.L.paths deps_written_by_user)
|
Some (Value.L.paths deps_written_by_user)
|
||||||
| _ -> None)
|
| _ ->
|
||||||
|
if syntax_version < (1, 0) then
|
||||||
|
None
|
||||||
|
else
|
||||||
|
Option.map (Dune_vars.deps key) ~f:dep)
|
||||||
|
|
||||||
let run sctx ~loc ?(extra_vars=String.Map.empty)
|
let run sctx ~loc ?(extra_vars=String.Map.empty)
|
||||||
t ~dir ~dep_kind ~targets:targets_written_by_user ~scope
|
t ~dir ~dep_kind ~targets:targets_written_by_user ~scope
|
||||||
|
|
|
@ -4,4 +4,4 @@
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
(deps f.exe)
|
(deps f.exe)
|
||||||
(action (run %{<})))
|
(action (run %{deps[0]})))
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(name runtest)
|
(name runtest)
|
||||||
(package lib1)
|
(package lib1)
|
||||||
(deps test1.exe)
|
(deps test1.exe)
|
||||||
(action (run %{<})))
|
(action (run %{deps[0]})))
|
||||||
|
|
||||||
(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 %{deps[0]})))
|
||||||
|
|
||||||
(executable
|
(executable
|
||||||
(name test2)
|
(name test2)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
(deps main.exe)
|
(deps main.exe)
|
||||||
(action (run %{<})))
|
(action (run %{deps[0]})))
|
||||||
|
|
||||||
(executable (name main))
|
(executable (name main))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
(deps main.exe)
|
(deps main.exe)
|
||||||
(action (run %{<})))
|
(action (run %{deps[0]})))
|
||||||
|
|
||||||
(executable (name main))
|
(executable (name main))
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
(rule
|
(rule
|
||||||
(targets dynamic.exe)
|
(targets dynamic.exe)
|
||||||
(deps dynamic.c)
|
(deps dynamic.c)
|
||||||
(action (run %{CC} -o %{targets} %{<} %{ocaml-config:native_c_libraries})))
|
(action (run %{CC} -o %{targets} %{deps[0]} %{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 ./%{deps[0]})))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
(deps test%{ext_dll})
|
(deps test%{ext_dll})
|
||||||
(action (run ./dynamic.exe ./%{<})))
|
(action (run ./dynamic.exe ./%{deps[0]})))
|
||||||
|
|
|
@ -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 %{deps[0]})) (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 %{deps[0]})) (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 %{deps[0]})))
|
||||||
(preprocess (action (run ./pp/reasononlypp.exe %{<})))
|
(preprocess (action (run ./pp/reasononlypp.exe %{deps[0]})))
|
||||||
(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 %{deps[0]}))))
|
||||||
|
|
|
@ -11,4 +11,4 @@
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
(deps main.exe)
|
(deps main.exe)
|
||||||
(action (run %{<})))
|
(action (run %{deps[0]})))
|
||||||
|
|
|
@ -5,4 +5,4 @@
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
(deps ./test_configurator.exe)
|
(deps ./test_configurator.exe)
|
||||||
(action (run %{<})))
|
(action (run %{deps[0]})))
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
(source_tree findlib-db))
|
(source_tree findlib-db))
|
||||||
(action (chdir %{project_root}
|
(action (chdir %{project_root}
|
||||||
(progn
|
(progn
|
||||||
(run %{exe:expect_test.exe} %{<})
|
(run %{exe:expect_test.exe} %{deps[0]})
|
||||||
(diff? %{<} %{<}.corrected)))))
|
(diff? %{deps[0]} %{deps[0]}.corrected)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
|
@ -35,8 +35,8 @@
|
||||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
||||||
(action (chdir %{project_root}
|
(action (chdir %{project_root}
|
||||||
(progn
|
(progn
|
||||||
(run %{exe:expect_test.exe} %{<})
|
(run %{exe:expect_test.exe} %{deps[0]})
|
||||||
(diff? %{<} %{<}.corrected)))))
|
(diff? %{deps[0]} %{deps[0]}.corrected)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
|
@ -45,8 +45,8 @@
|
||||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
||||||
(action (chdir %{project_root}
|
(action (chdir %{project_root}
|
||||||
(progn
|
(progn
|
||||||
(run %{exe:expect_test.exe} %{<})
|
(run %{exe:expect_test.exe} %{deps[0]})
|
||||||
(diff? %{<} %{<}.corrected)))))
|
(diff? %{deps[0]} %{deps[0]}.corrected)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
|
@ -55,8 +55,8 @@
|
||||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
||||||
(action (chdir %{project_root}
|
(action (chdir %{project_root}
|
||||||
(progn
|
(progn
|
||||||
(run %{exe:expect_test.exe} %{<})
|
(run %{exe:expect_test.exe} %{deps[0]})
|
||||||
(diff? %{<} %{<}.corrected)))))
|
(diff? %{deps[0]} %{deps[0]}.corrected)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
|
@ -65,8 +65,8 @@
|
||||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
||||||
(action (chdir %{project_root}
|
(action (chdir %{project_root}
|
||||||
(progn
|
(progn
|
||||||
(run %{exe:expect_test.exe} %{<})
|
(run %{exe:expect_test.exe} %{deps[0]})
|
||||||
(diff? %{<} %{<}.corrected)))))
|
(diff? %{deps[0]} %{deps[0]}.corrected)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
|
@ -75,8 +75,8 @@
|
||||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
||||||
(action (chdir %{project_root}
|
(action (chdir %{project_root}
|
||||||
(progn
|
(progn
|
||||||
(run %{exe:expect_test.exe} %{<})
|
(run %{exe:expect_test.exe} %{deps[0]})
|
||||||
(diff? %{<} %{<}.corrected)))))
|
(diff? %{deps[0]} %{deps[0]}.corrected)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
|
@ -85,5 +85,5 @@
|
||||||
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
(glob_files %{project_root}/src/stdune/.stdune.objs/*.cmi))
|
||||||
(action (chdir %{project_root}
|
(action (chdir %{project_root}
|
||||||
(progn
|
(progn
|
||||||
(run %{exe:expect_test.exe} %{<})
|
(run %{exe:expect_test.exe} %{deps[0]})
|
||||||
(diff? %{<} %{<}.corrected)))))
|
(diff? %{deps[0]} %{deps[0]}.corrected)))))
|
||||||
|
|
|
@ -5,4 +5,4 @@
|
||||||
(alias
|
(alias
|
||||||
(name runtest)
|
(name runtest)
|
||||||
(deps ./gh637.exe)
|
(deps ./gh637.exe)
|
||||||
(action (run %{<})))
|
(action (run %{deps[0]})))
|
||||||
|
|
Loading…
Reference in New Issue