This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,41 @@
|
|||
Globs with absolute paths result in an error
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.6)
|
||||
> (package (name foo))
|
||||
> EOF
|
||||
|
||||
Put $PWD in a file that can be read with the %{read:...} pform, so that the underline
|
||||
in the error message is of consisntent length on different systems.
|
||||
$ printf $PWD > pwd
|
||||
|
||||
$ touch foo.txt bar.txt
|
||||
|
||||
Absolute paths work in non-recursive globs, but are not permitted in the install stanza.
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files %{read:pwd}/*.txt))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ dune build @install
|
||||
File "dune", line 2, characters 20-37:
|
||||
2 | (files (glob_files %{read:pwd}/*.txt))
|
||||
^^^^^^^^^^^^^^^^^
|
||||
Error: Absolute paths are not allowed in the install stanza.
|
||||
[1]
|
||||
|
||||
Absolute paths are not supported in recursive globs.
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files_rec %{read:pwd}/*.txt))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ dune build @install
|
||||
File "dune", line 2, characters 24-41:
|
||||
2 | (files (glob_files_rec %{read:pwd}/*.txt))
|
||||
^^^^^^^^^^^^^^^^^
|
||||
Error: Absolute paths in recursive globs are not supported.
|
||||
[1]
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
Test that the `glob_files` terms are only accepted in the `files` field and not in
|
||||
the `dirs` field
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.6)
|
||||
> (package (name foo))
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (dirs (glob_files *))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ dune build @install
|
||||
File "dune", line 2, characters 7-21:
|
||||
2 | (dirs (glob_files *))
|
||||
^^^^^^^^^^^^^^
|
||||
Error: Invalid format, <name> or (<name> as <install-as>) expected
|
||||
[1]
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (dirs (glob_files_rec *))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ dune build @install
|
||||
File "dune", line 2, characters 7-25:
|
||||
2 | (dirs (glob_files_rec *))
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
Error: Invalid format, <name> or (<name> as <install-as>) expected
|
||||
[1]
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
Test that `glob_files_rec` can recursively find files
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.5)
|
||||
> (package (name foo))
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files_rec b/*.txt))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
Make a file outside of the "b" directory. This file should be skipped.
|
||||
$ touch a.txt
|
||||
|
||||
Create a hierarchy of files and directories which should be included.
|
||||
$ mkdir b
|
||||
$ touch b/b.txt
|
||||
$ mkdir b/c
|
||||
$ touch b/c/c.txt
|
||||
|
||||
Make sure we don't crash on empty directories.
|
||||
$ mkdir b/c/empty-dir
|
||||
|
||||
Add some files which don't match the glob.
|
||||
$ touch b/b
|
||||
$ touch b/txt
|
||||
$ mkdir b/d
|
||||
$ touch b/d/d
|
||||
|
||||
$ dune build
|
||||
File "dune", line 2, characters 8-32:
|
||||
2 | (files (glob_files_rec b/*.txt))
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: 'glob_files_rec' is only available since version 3.6 of the dune
|
||||
language. Please update your dune-project file to have (lang dune 3.6).
|
||||
[1]
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.6)
|
||||
> (package (name foo))
|
||||
> EOF
|
||||
|
||||
$ dune build
|
||||
|
||||
$ 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/b/b.txt" {"b/b.txt"}
|
||||
"_build/install/default/share/foo/b/c/c.txt" {"b/c/c.txt"}
|
||||
]
|
||||
|
||||
$ find _build/install | sort
|
||||
_build/install
|
||||
_build/install/default
|
||||
_build/install/default/lib
|
||||
_build/install/default/lib/foo
|
||||
_build/install/default/lib/foo/META
|
||||
_build/install/default/lib/foo/dune-package
|
||||
_build/install/default/share
|
||||
_build/install/default/share/foo
|
||||
_build/install/default/share/foo/b
|
||||
_build/install/default/share/foo/b/b.txt
|
||||
_build/install/default/share/foo/b/c
|
||||
_build/install/default/share/foo/b/c/c.txt
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
Install a glob pattern that uses a relative path.
|
||||
|
||||
Test that dune detects an error when we use a pattern such as ../foo/* in the
|
||||
install stanza. The problem with this pattern is its destination refers to a
|
||||
path outside the package's install directory.
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.11)
|
||||
> (package (name foo))
|
||||
> EOF
|
||||
|
||||
$ mkdir -p stanza stuff/xy
|
||||
$ touch stuff/foo.txt stuff/xy/bar.txt
|
||||
|
||||
normal install stanza in the share directory of the package:
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (section share)
|
||||
> (files stuff/foo.txt))
|
||||
> EOF
|
||||
|
||||
Incorrect install stanza that would place files outside the package's install directory
|
||||
$ cat >stanza/dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files_rec ../stuff/*.txt))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ dune build foo.install
|
||||
File "stanza/dune", line 2, characters 24-38:
|
||||
2 | (files (glob_files_rec ../stuff/*.txt))
|
||||
^^^^^^^^^^^^^^
|
||||
Warning: The destination path ../stuff/foo.txt begins with .. which will
|
||||
become an error in a future version of Dune. Destinations of files in install
|
||||
stanzas beginning with .. will be disallowed to prevent a package's installed
|
||||
files from escaping that package's install directories.
|
||||
Hint: To disable this warning, add the following to your dune-project file:
|
||||
(warnings (escaping_paths_in_install_stanza disabled))
|
||||
File "stanza/dune", line 2, characters 24-38:
|
||||
2 | (files (glob_files_rec ../stuff/*.txt))
|
||||
^^^^^^^^^^^^^^
|
||||
Warning: The destination path ../stuff/xy/bar.txt begins with .. which will
|
||||
become an error in a future version of Dune. Destinations of files in install
|
||||
stanzas beginning with .. will be disallowed to prevent a package's installed
|
||||
files from escaping that package's install directories.
|
||||
Hint: To disable this warning, add the following to your dune-project file:
|
||||
(warnings (escaping_paths_in_install_stanza disabled))
|
||||
|
||||
Test that we can disable the warning:
|
||||
$ cat >>dune-project <<EOF
|
||||
> (warnings (escaping_paths_in_install_stanza disabled))
|
||||
> EOF
|
||||
$ dune build foo.install
|
||||
|
||||
Now we remove disabling the warning
|
||||
$ sed -i.bak '$d' dune-project
|
||||
|
||||
Correction to the above which uses `with_prefix` to change the install destination:
|
||||
$ cat >stanza/dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files_rec (../stuff/*.txt with_prefix stuff)))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ dune build foo.install
|
||||
|
||||
|
||||
$ grep txt _build/default/foo.install
|
||||
"_build/install/default/share/foo/foo.txt"
|
||||
"_build/install/default/share/foo/stuff/foo.txt" {"stuff/foo.txt"}
|
||||
"_build/install/default/share/foo/stuff/xy/bar.txt" {"stuff/xy/bar.txt"}
|
||||
|
||||
$ dune install foo --prefix _foo
|
||||
$ find _foo | sort | grep txt
|
||||
_foo/share/foo/foo.txt
|
||||
_foo/share/foo/stuff/foo.txt
|
||||
_foo/share/foo/stuff/xy/bar.txt
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
Make sure we can handle globs in dune files inside subdirectories
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.6)
|
||||
> (package (name foo))
|
||||
> EOF
|
||||
|
||||
$ mkdir -p sub-dir/x/y/z
|
||||
|
||||
$ cat >sub-dir/dune <<EOF
|
||||
> (install
|
||||
> (files a.txt (glob_files_rec x/*.txt))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ touch sub-dir/a.txt
|
||||
$ touch sub-dir/b.txt
|
||||
$ touch sub-dir/x/foo.txt
|
||||
$ touch sub-dir/x/y/foo.txt
|
||||
$ touch sub-dir/x/y/z/foo.txt
|
||||
|
||||
$ dune build @sub-dir/all
|
||||
|
||||
$ find _build/default/sub-dir | sort
|
||||
_build/default/sub-dir
|
||||
_build/default/sub-dir/a.txt
|
||||
_build/default/sub-dir/x
|
||||
_build/default/sub-dir/x/foo.txt
|
||||
_build/default/sub-dir/x/y
|
||||
_build/default/sub-dir/x/y/foo.txt
|
||||
_build/default/sub-dir/x/y/z
|
||||
_build/default/sub-dir/x/y/z/foo.txt
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(install
|
||||
(files
|
||||
(glob_files style/*.css)
|
||||
(glob_files_rec content/*.html))
|
||||
(section share))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(lang dune 3.6)
|
||||
(package (name blog))
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
Simple example of installing website files
|
||||
|
||||
$ dune build @install
|
||||
|
||||
$ cat _build/default/blog.install
|
||||
lib: [
|
||||
"_build/install/default/lib/blog/META"
|
||||
"_build/install/default/lib/blog/dune-package"
|
||||
]
|
||||
share: [
|
||||
"_build/install/default/share/blog/content/about.html" {"content/about.html"}
|
||||
"_build/install/default/share/blog/content/posts/1.html" {"content/posts/1.html"}
|
||||
"_build/install/default/share/blog/content/posts/2.html" {"content/posts/2.html"}
|
||||
"_build/install/default/share/blog/content/posts/3.html" {"content/posts/3.html"}
|
||||
"_build/install/default/share/blog/style/bar.css" {"style/bar.css"}
|
||||
"_build/install/default/share/blog/style/foo.css" {"style/foo.css"}
|
||||
]
|
||||
|
||||
$ find _build/install | sort
|
||||
_build/install
|
||||
_build/install/default
|
||||
_build/install/default/lib
|
||||
_build/install/default/lib/blog
|
||||
_build/install/default/lib/blog/META
|
||||
_build/install/default/lib/blog/dune-package
|
||||
_build/install/default/share
|
||||
_build/install/default/share/blog
|
||||
_build/install/default/share/blog/content
|
||||
_build/install/default/share/blog/content/about.html
|
||||
_build/install/default/share/blog/content/posts
|
||||
_build/install/default/share/blog/content/posts/1.html
|
||||
_build/install/default/share/blog/content/posts/2.html
|
||||
_build/install/default/share/blog/content/posts/3.html
|
||||
_build/install/default/share/blog/style
|
||||
_build/install/default/share/blog/style/bar.css
|
||||
_build/install/default/share/blog/style/foo.css
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
Examples of the with-prefix feature
|
||||
|
||||
$ touch a.txt b.txt c.txt d.md e.md
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files (*.txt with_prefix bar)))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
Test that the feature is unavailable before 3.11
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.10)
|
||||
> (package
|
||||
> (name foo))
|
||||
> EOF
|
||||
$ dune build foo.install && cat _build/default/foo.install
|
||||
File "dune", line 2, characters 20-43:
|
||||
2 | (files (glob_files (*.txt with_prefix bar)))
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: This syntax is only available since version 3.11 of the dune language.
|
||||
Please update your dune-project file to have (lang dune 3.11).
|
||||
[1]
|
||||
|
||||
Basic example of using this feature:
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.11)
|
||||
> (package
|
||||
> (name foo))
|
||||
> EOF
|
||||
$ dune build foo.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/bar/a.txt" {"bar/a.txt"}
|
||||
"_build/install/default/share/foo/bar/b.txt" {"bar/b.txt"}
|
||||
"_build/install/default/share/foo/bar/c.txt" {"bar/c.txt"}
|
||||
]
|
||||
|
||||
Test with multiple with_prefix blocks in a single files entry:
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files
|
||||
> (glob_files (*.txt with_prefix txt))
|
||||
> (glob_files (*.md with_prefix md)))
|
||||
> (section share))
|
||||
> EOF
|
||||
$ dune build foo.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/md/d.md" {"md/d.md"}
|
||||
"_build/install/default/share/foo/md/e.md" {"md/e.md"}
|
||||
"_build/install/default/share/foo/txt/a.txt" {"txt/a.txt"}
|
||||
"_build/install/default/share/foo/txt/b.txt" {"txt/b.txt"}
|
||||
"_build/install/default/share/foo/txt/c.txt" {"txt/c.txt"}
|
||||
]
|
||||
|
||||
Use "." as the prefix:
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files (*.txt with_prefix .)))
|
||||
> (section share))
|
||||
> EOF
|
||||
$ dune build foo.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/a.txt" {"./a.txt"}
|
||||
"_build/install/default/share/foo/b.txt" {"./b.txt"}
|
||||
"_build/install/default/share/foo/c.txt" {"./c.txt"}
|
||||
]
|
||||
|
||||
Use a pform in the prefix:
|
||||
$ printf baz > prefix
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files (*.txt with_prefix %{read:prefix})))
|
||||
> (section share))
|
||||
> EOF
|
||||
$ dune build foo.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/baz/a.txt" {"baz/a.txt"}
|
||||
"_build/install/default/share/foo/baz/b.txt" {"baz/b.txt"}
|
||||
"_build/install/default/share/foo/baz/c.txt" {"baz/c.txt"}
|
||||
]
|
||||
|
||||
Use a prefix with a recursive glob:
|
||||
$ mkdir -p a/b/c
|
||||
$ touch a/x.txt a/b/y.txt a/b/c/z.txt
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files_rec (*.txt with_prefix qux)))
|
||||
> (section share))
|
||||
> EOF
|
||||
$ dune build foo.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/qux/a.txt" {"qux/a.txt"}
|
||||
"_build/install/default/share/foo/qux/a/b/c/z.txt" {"qux/a/b/c/z.txt"}
|
||||
"_build/install/default/share/foo/qux/a/b/y.txt" {"qux/a/b/y.txt"}
|
||||
"_build/install/default/share/foo/qux/a/x.txt" {"qux/a/x.txt"}
|
||||
"_build/install/default/share/foo/qux/b.txt" {"qux/b.txt"}
|
||||
"_build/install/default/share/foo/qux/c.txt" {"qux/c.txt"}
|
||||
]
|
||||
|
||||
Demonstrating behaviour of `with_prefix` on globs with a prefix:
|
||||
$ mkdir -p path/to/files
|
||||
$ touch path/to/files/foo.txt path/to/files/bar.txt path/to/files/baz.txt
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files (path/to/files/*.txt with_prefix some/new/path/)))
|
||||
> (section share))
|
||||
> EOF
|
||||
$ dune build foo.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/some/new/path/bar.txt" {"some/new/path/bar.txt"}
|
||||
"_build/install/default/share/foo/some/new/path/baz.txt" {"some/new/path/baz.txt"}
|
||||
"_build/install/default/share/foo/some/new/path/foo.txt" {"some/new/path/foo.txt"}
|
||||
]
|
||||
|
||||
Replacing the prefix with the empty string works the same as with ".".
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files_rec (*.txt with_prefix "")))
|
||||
> (section share))
|
||||
> EOF
|
||||
$ dune build foo.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/a.txt"
|
||||
"_build/install/default/share/foo/a/b/c/z.txt" {"a/b/c/z.txt"}
|
||||
"_build/install/default/share/foo/a/b/y.txt" {"a/b/y.txt"}
|
||||
"_build/install/default/share/foo/a/x.txt" {"a/x.txt"}
|
||||
"_build/install/default/share/foo/b.txt"
|
||||
"_build/install/default/share/foo/c.txt"
|
||||
"_build/install/default/share/foo/path/to/files/bar.txt" {"path/to/files/bar.txt"}
|
||||
"_build/install/default/share/foo/path/to/files/baz.txt" {"path/to/files/baz.txt"}
|
||||
"_build/install/default/share/foo/path/to/files/foo.txt" {"path/to/files/foo.txt"}
|
||||
]
|
||||
|
||||
It's an error to use an absolute path as the prefix.
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files_rec (*.txt with_prefix /some/absolute/path)))
|
||||
> (section share))
|
||||
> EOF
|
||||
$ dune build foo.install && cat _build/default/foo.install
|
||||
File "dune", line 2, characters 43-62:
|
||||
2 | (files (glob_files_rec (*.txt with_prefix /some/absolute/path)))
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
Error: Absolute paths are not allowed in the install stanza.
|
||||
[1]
|
||||
|
||||
The root directory is treated like an absolute path (ie. it's an error).
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files_rec (*.txt with_prefix /)))
|
||||
> (section share))
|
||||
> EOF
|
||||
$ dune build foo.install && cat _build/default/foo.install
|
||||
File "dune", line 2, characters 43-44:
|
||||
2 | (files (glob_files_rec (*.txt with_prefix /)))
|
||||
^
|
||||
Error: Absolute paths are not allowed in the install stanza.
|
||||
[1]
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
Simple example of using a glob to specify files to install
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.5)
|
||||
> (package (name foo))
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (install
|
||||
> (files (glob_files *.txt))
|
||||
> (section share))
|
||||
> EOF
|
||||
|
||||
$ touch a.txt b.txt c.txt
|
||||
|
||||
$ dune build @install
|
||||
File "dune", line 2, characters 8-26:
|
||||
2 | (files (glob_files *.txt))
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
Error: 'glob_files' is only available since version 3.6 of the dune language.
|
||||
Please update your dune-project file to have (lang dune 3.6).
|
||||
[1]
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.6)
|
||||
> (package (name foo))
|
||||
> EOF
|
||||
|
||||
$ 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/a.txt"
|
||||
"_build/install/default/share/foo/b.txt"
|
||||
"_build/install/default/share/foo/c.txt"
|
||||
]
|
||||
|
||||
$ find _build/install | sort
|
||||
_build/install
|
||||
_build/install/default
|
||||
_build/install/default/lib
|
||||
_build/install/default/lib/foo
|
||||
_build/install/default/lib/foo/META
|
||||
_build/install/default/lib/foo/dune-package
|
||||
_build/install/default/share
|
||||
_build/install/default/share/foo
|
||||
_build/install/default/share/foo/a.txt
|
||||
_build/install/default/share/foo/b.txt
|
||||
_build/install/default/share/foo/c.txt
|
||||
Loading…
Add table
Add a link
Reference in a new issue