copy-and-add-line-directive --> copy#
This commit is contained in:
parent
7ec081419c
commit
a392b59fcd
|
@ -16,6 +16,8 @@
|
||||||
- Deprecate `per_file` in preprocessing specifications and
|
- Deprecate `per_file` in preprocessing specifications and
|
||||||
rename it `per_module`
|
rename it `per_module`
|
||||||
|
|
||||||
|
- Deprecate `copy-and-add-line-directive` and rename it `copy#`
|
||||||
|
|
||||||
- Inside user actions, `${^}` now includes files matches by
|
- Inside user actions, `${^}` now includes files matches by
|
||||||
`(glob_files ...)` or `(file_recursively_in ...)`
|
`(glob_files ...)` or `(file_recursively_in ...)`
|
||||||
|
|
||||||
|
|
|
@ -914,13 +914,30 @@ The following constructions are available:
|
||||||
- ``(echo <string>)`` to output a string on stdout
|
- ``(echo <string>)`` to output a string on stdout
|
||||||
- ``(cat <file>)`` to print the contents of a file to stdout
|
- ``(cat <file>)`` to print the contents of a file to stdout
|
||||||
- ``(copy <src> <dst>)`` to copy a file
|
- ``(copy <src> <dst>)`` to copy a file
|
||||||
- ``(copy-and-add-line-directive <src> <dst>)`` to copy a file and add a line
|
- ``(copy# <src> <dst>)`` to copy a file and add a line directive at
|
||||||
directive at the beginning
|
the beginning
|
||||||
- ``(system <cmd>)`` to execute a command using the system shell: ``sh`` on Unix
|
- ``(system <cmd>)`` to execute a command using the system shell: ``sh`` on Unix
|
||||||
and ``cmd`` on Windows
|
and ``cmd`` on Windows
|
||||||
- ``(bash <cmd>)`` to execute a command using ``/bin/bash``. This is obviously
|
- ``(bash <cmd>)`` to execute a command using ``/bin/bash``. This is obviously
|
||||||
not very portable
|
not very portable
|
||||||
|
|
||||||
|
As mentioned ``copy#`` inserts a line directive at the beginning of
|
||||||
|
the destination file. More precisely, it inserts the following line:
|
||||||
|
|
||||||
|
.. code:: ocaml
|
||||||
|
|
||||||
|
# 1 "<source file name>"
|
||||||
|
|
||||||
|
Most languages recognize such lines and update their current location,
|
||||||
|
in order to report errors in the original file rather than the
|
||||||
|
copy. This is important as the copy exists only under the ``_build``
|
||||||
|
directory and in order for editors to jump to errors when parsing the
|
||||||
|
output of the build system, errors must point to files that exist in
|
||||||
|
the source tree. In the beta versions of jbuilder, ``copy#`` was
|
||||||
|
called ``copy-and-add-line-directive``. However, most of time one
|
||||||
|
wants this behavior rather than a bare copy, so it was renamed to
|
||||||
|
something shorter.
|
||||||
|
|
||||||
Note: expansion of the special ``${<kind>:...}`` is done relative to the current
|
Note: expansion of the special ``${<kind>:...}`` is done relative to the current
|
||||||
working directory of the part of the DSL being executed. So for instance if you
|
working directory of the part of the DSL being executed. So for instance if you
|
||||||
have this action in a ``src/foo/jbuild``:
|
have this action in a ``src/foo/jbuild``:
|
||||||
|
|
|
@ -138,7 +138,10 @@ struct
|
||||||
(* We don't expose symlink to the user yet since this might complicate things *)
|
(* We don't expose symlink to the user yet since this might complicate things *)
|
||||||
; cstr "symlink" (a @> a @> nil) (fun src dst -> Symlink (dst, Cat src))
|
; cstr "symlink" (a @> a @> nil) (fun src dst -> Symlink (dst, Cat src))
|
||||||
*)
|
*)
|
||||||
; cstr "copy-and-add-line-directive" (path @> path @> nil) (fun src dst ->
|
; cstr "copy#" (path @> path @> nil) (fun src dst ->
|
||||||
|
Copy_and_add_line_directive (src, dst))
|
||||||
|
; cstr_loc "copy-and-add-line-directive" (path @> path @> nil) (fun loc src dst ->
|
||||||
|
Loc.warn loc "copy-and-add-line-directive is deprecated, use copy# instead";
|
||||||
Copy_and_add_line_directive (src, dst))
|
Copy_and_add_line_directive (src, dst))
|
||||||
; cstr "system" (string @> nil) (fun cmd -> System cmd)
|
; cstr "system" (string @> nil) (fun cmd -> System cmd)
|
||||||
; cstr "bash" (string @> nil) (fun cmd -> Bash cmd)
|
; cstr "bash" (string @> nil) (fun cmd -> Bash cmd)
|
||||||
|
@ -169,7 +172,7 @@ struct
|
||||||
| Symlink (x, y) ->
|
| Symlink (x, y) ->
|
||||||
List [Atom "symlink"; path x; path y]
|
List [Atom "symlink"; path x; path y]
|
||||||
| Copy_and_add_line_directive (x, y) ->
|
| Copy_and_add_line_directive (x, y) ->
|
||||||
List [Atom "copy-and-add-line-directive"; path x; path y]
|
List [Atom "copy#"; path x; path y]
|
||||||
| System x -> List [Atom "system"; string x]
|
| System x -> List [Atom "system"; string x]
|
||||||
| Bash x -> List [Atom "bash"; string x]
|
| Bash x -> List [Atom "bash"; string x]
|
||||||
| Update_file (x, y) -> List [Atom "update-file"; path x; string y]
|
| Update_file (x, y) -> List [Atom "update-file"; path x; string y]
|
||||||
|
|
19
src/sexp.ml
19
src/sexp.ml
|
@ -427,17 +427,22 @@ module Of_sexp = struct
|
||||||
{ name : string
|
{ name : string
|
||||||
; args : ('a, 'b) Constructor_args_spec.t
|
; args : ('a, 'b) Constructor_args_spec.t
|
||||||
; rest : ('b, 'c) rest
|
; rest : ('b, 'c) rest
|
||||||
; make : 'a
|
; make : Loc.t -> 'a
|
||||||
}
|
}
|
||||||
|
|
||||||
type 'a t = T : (_, _, 'a) unpacked -> 'a t
|
type 'a t = T : (_, _, 'a) unpacked -> 'a t
|
||||||
end
|
end
|
||||||
|
|
||||||
let cstr_rest name args rest make =
|
let cstr_loc name args make =
|
||||||
|
Constructor_spec.T { name; args; make; rest = No_rest }
|
||||||
|
let cstr_rest_loc name args rest make =
|
||||||
Constructor_spec.T { name; args; make; rest = Many rest }
|
Constructor_spec.T { name; args; make; rest = Many rest }
|
||||||
|
|
||||||
let cstr name args make =
|
let cstr name args make =
|
||||||
Constructor_spec.T { name; args; make; rest = No_rest }
|
cstr_loc name args (fun _ -> make)
|
||||||
|
|
||||||
|
let cstr_rest name args rest make =
|
||||||
|
cstr_rest_loc name args rest (fun _ -> make)
|
||||||
|
|
||||||
let equal_cstr_name a b = Name.compare a b = 0
|
let equal_cstr_name a b = Name.compare a b = 0
|
||||||
|
|
||||||
|
@ -457,17 +462,17 @@ module Of_sexp = struct
|
||||||
|
|
||||||
let sum cstrs sexp =
|
let sum cstrs sexp =
|
||||||
match sexp with
|
match sexp with
|
||||||
| Atom (_, s) -> begin
|
| Atom (loc, s) -> begin
|
||||||
let (Constructor_spec.T c) = find_cstr cstrs sexp s in
|
let (Constructor_spec.T c) = find_cstr cstrs sexp s in
|
||||||
Constructor_args_spec.convert c.args c.rest sexp [] c.make
|
Constructor_args_spec.convert c.args c.rest sexp [] (c.make loc)
|
||||||
end
|
end
|
||||||
| List (_, []) -> of_sexp_error sexp "non-empty list expected"
|
| List (_, []) -> of_sexp_error sexp "non-empty list expected"
|
||||||
| List (_, name_sexp :: args) ->
|
| List (loc, name_sexp :: args) ->
|
||||||
match name_sexp with
|
match name_sexp with
|
||||||
| List _ -> of_sexp_error name_sexp "Atom expected"
|
| List _ -> of_sexp_error name_sexp "Atom expected"
|
||||||
| Atom (_, s) ->
|
| Atom (_, s) ->
|
||||||
let (Constructor_spec.T c) = find_cstr cstrs sexp s in
|
let (Constructor_spec.T c) = find_cstr cstrs sexp s in
|
||||||
Constructor_args_spec.convert c.args c.rest sexp args c.make
|
Constructor_args_spec.convert c.args c.rest sexp args (c.make loc)
|
||||||
|
|
||||||
let enum cstrs sexp =
|
let enum cstrs sexp =
|
||||||
match sexp with
|
match sexp with
|
||||||
|
|
13
src/sexp.mli
13
src/sexp.mli
|
@ -105,6 +105,19 @@ module Of_sexp : sig
|
||||||
-> 'a
|
-> 'a
|
||||||
-> 'c Constructor_spec.t
|
-> 'c Constructor_spec.t
|
||||||
|
|
||||||
|
val cstr_loc
|
||||||
|
: string
|
||||||
|
-> ('a, 'b) Constructor_args_spec.t
|
||||||
|
-> (Loc.t -> 'a)
|
||||||
|
-> 'b Constructor_spec.t
|
||||||
|
|
||||||
|
val cstr_rest_loc
|
||||||
|
: string
|
||||||
|
-> ('a, 'b list -> 'c) Constructor_args_spec.t
|
||||||
|
-> 'b t
|
||||||
|
-> (Loc.t -> 'a)
|
||||||
|
-> 'c Constructor_spec.t
|
||||||
|
|
||||||
val sum
|
val sum
|
||||||
: 'a Constructor_spec.t list
|
: 'a Constructor_spec.t list
|
||||||
-> 'a t
|
-> 'a t
|
||||||
|
|
|
@ -9,4 +9,4 @@
|
||||||
(rule
|
(rule
|
||||||
((targets (opamParserTypes.ml))
|
((targets (opamParserTypes.ml))
|
||||||
(deps (opamParserTypes.mli))
|
(deps (opamParserTypes.mli))
|
||||||
(action (copy-and-add-line-directive ${<} ${@}))))
|
(action (copy# ${<} ${@}))))
|
||||||
|
|
Loading…
Reference in New Issue