This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,43 @@
|
|||
Including a file in the install stanza which includes another file
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.5)
|
||||
> (package (name hello))
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (executable
|
||||
> (public_name hello))
|
||||
>
|
||||
> (install
|
||||
> (files (include foo.sexp))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ cat >hello.ml <<EOF
|
||||
> let () = print_endline "Hello, World!"
|
||||
> EOF
|
||||
|
||||
$ cat >foo.sexp <<EOF
|
||||
> ((include bar.sexp))
|
||||
> EOF
|
||||
|
||||
$ cat >bar.sexp <<EOF
|
||||
> (a.txt)
|
||||
> EOF
|
||||
|
||||
$ touch a.txt
|
||||
|
||||
$ dune build @install
|
||||
|
||||
$ cat _build/default/hello.install
|
||||
lib: [
|
||||
"_build/install/default/lib/hello/META"
|
||||
"_build/install/default/lib/hello/dune-package"
|
||||
]
|
||||
bin: [
|
||||
"_build/install/default/bin/hello"
|
||||
]
|
||||
share: [
|
||||
"_build/install/default/share/hello/a.txt"
|
||||
]
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
Example of including a file in the dirs field of the install stanza
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.5)
|
||||
> (package (name hello))
|
||||
> (using directory-targets 0.1)
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (dirs (include baz.sexp))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ mkdir -p foo
|
||||
|
||||
$ cat >foo/dune <<EOF
|
||||
> (rule
|
||||
> (target (dir bar))
|
||||
> (action (bash "mkdir %{target} && touch %{target}/a")))
|
||||
> EOF
|
||||
|
||||
$ cat >baz.sexp <<EOF
|
||||
> (foo/bar)
|
||||
> EOF
|
||||
|
||||
$ dune build @install
|
||||
|
||||
$ cat _build/default/hello.install
|
||||
lib: [
|
||||
"_build/install/default/lib/hello/META"
|
||||
"_build/install/default/lib/hello/dune-package"
|
||||
]
|
||||
share: [
|
||||
"_build/install/default/share/hello/bar/a" {"bar/a"}
|
||||
]
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
Include a file which contains the (foo as bar) syntax for renaming a file
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.5)
|
||||
> (package (name hello))
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (executable
|
||||
> (public_name hello))
|
||||
>
|
||||
> (install
|
||||
> (files (include foo.sexp))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ cat >hello.ml <<EOF
|
||||
> let () = print_endline "Hello, World!"
|
||||
> EOF
|
||||
|
||||
$ cat >foo.sexp <<EOF
|
||||
> ((a.txt as b/c.txt))
|
||||
> EOF
|
||||
|
||||
$ touch a.txt
|
||||
|
||||
$ dune build @install
|
||||
|
||||
$ cat _build/default/hello.install
|
||||
lib: [
|
||||
"_build/install/default/lib/hello/META"
|
||||
"_build/install/default/lib/hello/dune-package"
|
||||
]
|
||||
bin: [
|
||||
"_build/install/default/bin/hello"
|
||||
]
|
||||
share: [
|
||||
"_build/install/default/share/hello/b/c.txt" {"b/c.txt"}
|
||||
]
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
Including a file in the install stanza which is generated by a rule
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.5)
|
||||
> (package (name hello))
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (executable
|
||||
> (public_name hello))
|
||||
>
|
||||
> (rule
|
||||
> (target foo.sexp)
|
||||
> (action
|
||||
> (with-stdout-to foo.sexp (echo "(a.txt)"))))
|
||||
>
|
||||
> (install
|
||||
> (files (include foo.sexp))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ cat >hello.ml <<EOF
|
||||
> let () = print_endline "Hello, World!"
|
||||
> EOF
|
||||
|
||||
$ touch a.txt
|
||||
|
||||
$ dune build @install
|
||||
|
||||
$ cat _build/default/hello.install
|
||||
lib: [
|
||||
"_build/install/default/lib/hello/META"
|
||||
"_build/install/default/lib/hello/dune-package"
|
||||
]
|
||||
bin: [
|
||||
"_build/install/default/bin/hello"
|
||||
]
|
||||
share: [
|
||||
"_build/install/default/share/hello/a.txt"
|
||||
]
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
Test that `(include ...)` composes with `(glob_files ...)`
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.6)
|
||||
> (package (name foo))
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files
|
||||
> (include foo.sexp))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ cat >foo.sexp <<EOF
|
||||
> ((glob_files dir1/*.txt)
|
||||
> (glob_files_rec dir2/*.txt))
|
||||
> EOF
|
||||
|
||||
$ mkdir -p dir1 dir2/foo/bar
|
||||
$ touch dir1/a.txt dir1/b.txt dir2/c.txt dir2/foo/d.txt dir2/foo/bar/e.txt
|
||||
|
||||
$ dune build @install
|
||||
|
||||
$ cat _build/default/foo.install
|
||||
lib: [
|
||||
"_build/install/default/lib/foo/META"
|
||||
"_build/install/default/lib/foo/dune-package"
|
||||
]
|
||||
share: [
|
||||
"_build/install/default/share/foo/dir1/a.txt" {"dir1/a.txt"}
|
||||
"_build/install/default/share/foo/dir1/b.txt" {"dir1/b.txt"}
|
||||
"_build/install/default/share/foo/dir2/c.txt" {"dir2/c.txt"}
|
||||
"_build/install/default/share/foo/dir2/foo/bar/e.txt" {"dir2/foo/bar/e.txt"}
|
||||
"_build/install/default/share/foo/dir2/foo/d.txt" {"dir2/foo/d.txt"}
|
||||
]
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
Including a file in the install stanza which does not contain a sexp list
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.5)
|
||||
> (package (name hello))
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (executable
|
||||
> (public_name hello))
|
||||
>
|
||||
> (install
|
||||
> (files (include foo.sexp))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ cat >hello.ml <<EOF
|
||||
> let () = print_endline "Hello, World!"
|
||||
> EOF
|
||||
|
||||
$ cat >foo.sexp <<EOF
|
||||
> a.txt
|
||||
> EOF
|
||||
|
||||
$ dune build @install
|
||||
File "_build/default/foo.sexp", line 1, characters 0-5:
|
||||
1 | a.txt
|
||||
^^^^^
|
||||
Error: Expected list, got:
|
||||
a.txt
|
||||
|
||||
[1]
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
(install
|
||||
(files (include resources.sexp))
|
||||
(section share))
|
||||
|
||||
(rule
|
||||
(deps (source_tree resources) list_dir.ml)
|
||||
(action
|
||||
(with-stdout-to resources.sexp
|
||||
(run ocaml list_dir.ml resources))))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(lang dune 3.5)
|
||||
(package (name foo))
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
(* Prints a sexp listing the contents of a given directory in the form:
|
||||
|
||||
((dir/foo as dir/foo)
|
||||
(dir/bar as dir/bar)
|
||||
(dir/baz as dir/baz)
|
||||
...)
|
||||
|
||||
where foo, bar, baz, ... are files in the given directory. *)
|
||||
|
||||
let list_dir dir =
|
||||
Sys.readdir dir
|
||||
|> Array.to_list
|
||||
|> List.map (fun f -> String.concat "/" [dir; f])
|
||||
|
||||
let () =
|
||||
list_dir (Sys.argv.(1))
|
||||
|> List.map (fun f -> Printf.sprintf "(%s as %s)" f f )
|
||||
|> String.concat " "
|
||||
|> Printf.printf "(%s)"
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
Include a file generated by listing the contents of a directory.
|
||||
|
||||
$ dune build @install
|
||||
|
||||
$ cat _build/default/foo.install
|
||||
lib: [
|
||||
"_build/install/default/lib/foo/META"
|
||||
"_build/install/default/lib/foo/dune-package"
|
||||
]
|
||||
share: [
|
||||
"_build/install/default/share/foo/resources/a.txt" {"resources/a.txt"}
|
||||
"_build/install/default/share/foo/resources/b.txt" {"resources/b.txt"}
|
||||
"_build/install/default/share/foo/resources/c.txt" {"resources/c.txt"}
|
||||
]
|
||||
$ find _build/install/default/share | sort
|
||||
_build/install/default/share
|
||||
_build/install/default/share/foo
|
||||
_build/install/default/share/foo/resources
|
||||
_build/install/default/share/foo/resources/a.txt
|
||||
_build/install/default/share/foo/resources/b.txt
|
||||
_build/install/default/share/foo/resources/c.txt
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
Detect include loops in files included in the install stanza
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.5)
|
||||
> (package (name hello))
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (executable
|
||||
> (public_name hello))
|
||||
>
|
||||
> (install
|
||||
> (files (include foo.sexp))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ cat >hello.ml <<EOF
|
||||
> let () = print_endline "Hello, World!"
|
||||
> EOF
|
||||
|
||||
$ cat >foo.sexp <<EOF
|
||||
> ((include bar.sexp))
|
||||
> EOF
|
||||
|
||||
$ cat >bar.sexp <<EOF
|
||||
> ((include foo.sexp))
|
||||
> EOF
|
||||
|
||||
$ dune build @install
|
||||
File "_build/default/bar.sexp", line 1, characters 10-18:
|
||||
1 | ((include foo.sexp))
|
||||
^^^^^^^^
|
||||
Error: Include loop detected via: _build/default/foo.sexp
|
||||
[1]
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
Simple example of including a file in the install stanza
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.4)
|
||||
> (package (name hello))
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (executable
|
||||
> (public_name hello))
|
||||
>
|
||||
> (install
|
||||
> (files a.txt (include foo.sexp))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ cat >hello.ml <<EOF
|
||||
> let () = print_endline "Hello, World!"
|
||||
> EOF
|
||||
|
||||
$ touch a.txt
|
||||
|
||||
$ dune build @install
|
||||
File "dune", line 5, characters 14-32:
|
||||
5 | (files a.txt (include foo.sexp))
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
Error: 'include' is only available since version 3.5 of the dune language.
|
||||
Please update your dune-project file to have (lang dune 3.5).
|
||||
[1]
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.5)
|
||||
> (package (name hello))
|
||||
> EOF
|
||||
|
||||
$ dune build @install
|
||||
File "_unknown_", line 1, characters 0-0:
|
||||
Error: No rule found for foo.sexp
|
||||
[1]
|
||||
|
||||
$ cat >foo.sexp <<EOF
|
||||
> (b.txt c.txt)
|
||||
> EOF
|
||||
|
||||
$ touch b.txt
|
||||
|
||||
$ dune build @install
|
||||
File "_build/default/foo.sexp", line 1, characters 7-12:
|
||||
1 | (b.txt c.txt)
|
||||
^^^^^
|
||||
Error: No rule found for c.txt
|
||||
[1]
|
||||
|
||||
$ touch c.txt
|
||||
|
||||
$ dune build @install
|
||||
|
||||
$ cat _build/default/hello.install
|
||||
lib: [
|
||||
"_build/install/default/lib/hello/META"
|
||||
"_build/install/default/lib/hello/dune-package"
|
||||
]
|
||||
bin: [
|
||||
"_build/install/default/bin/hello"
|
||||
]
|
||||
share: [
|
||||
"_build/install/default/share/hello/a.txt"
|
||||
"_build/install/default/share/hello/b.txt"
|
||||
"_build/install/default/share/hello/c.txt"
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue