Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove warning about empty packages pre 3.0 #5120

Merged
1 commit merged into from Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Unreleased
- Fix jsoo builds when dynamically linked foreign archives are disabled
(@hhugo, #5049)

- Warn on empty packages for projects < 3.0 and disallow them starting from 3.0
Empty packages may be re-enabled by adding the `(allow_empty)` to the package
stanza in the dune-project file. (#4867, fix #2882, @kit-ty-kate, @rgrinberg)
- Disallow empty packages starting from 3.0. Empty packages may be
re-enabled by adding the `(allow_empty)` to the package stanza in
the dune-project file. (#4867, fix #2882, @kit-ty-kate, @rgrinberg)

- Add `link_flags` field to the `executable` field of `inline_tests` (#5088,
fix #1530, @jvillard)
Expand Down
36 changes: 12 additions & 24 deletions otherlibs/build-info/test/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Test embedding of build information
$ for i in a b c d; do
> mkdir -p $i
> cat >$i/dune-project <<EOF
> (lang dune 3.0)
> (lang dune 2.0)
> (name $i)
> (package (name $i) (allow_empty))
> (package (name $i))
> EOF
> (cd $i;
> git init -q;
Expand Down Expand Up @@ -52,15 +52,7 @@ Test embedding of build information
> EOF

$ dune build
Error: Package c is missing the following package dependencies
- a
- b
-> required by _build/default/c/c.install
-> required by alias c/all
-> required by alias default
[1]
$ dune install --prefix _install 2> /dev/null
[1]

Inside _build, we have no version information:

Expand All @@ -79,15 +71,16 @@ Inside _build, we have no version information:
Once installed, we have the version information:

$ _install/bin/c | sed 's/build-info: .*/build-info: XXX/'
_install/bin/c: No such file or directory
1.0+c
lib a: 1.0+a
lib b: 1.0+b
lib dune-build-info: XXX

$ grep version _install/lib/a/dune-package
grep: _install/lib/a/dune-package: No such file or directory
[2]
(version 1.0+a)

$ grep version _install/lib/a/META
grep: _install/lib/a/META: No such file or directory
[2]
version = "1.0+a"

Check what the generated build info module looks like:

Expand Down Expand Up @@ -156,14 +149,9 @@ Version is picked from dune-project if available

$ echo '(version project-version)' >> c/dune-project
$ dune build
Error: Package c is missing the following package dependencies
- a
- b
-> required by _build/default/c/c.install
-> required by alias c/all
-> required by alias default
[1]
$ dune install --prefix _install 2> /dev/null
[1]
$ _install/bin/c | sed 's/build-info: .*/build-info: XXX/'
_install/bin/c: No such file or directory
project-version
lib a: 1.0+a
lib b: 1.0+b
lib dune-build-info: XXX
3 changes: 1 addition & 2 deletions otherlibs/site/test/bug_4219.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ Test when sites name which are ocaml keyword
---------------------------------

$ cat >dune-project <<EOF
> (lang dune 3.0)
> (lang dune 2.9)
> (using dune_site 0.1)
> (package
> (name my-package)
> (allow_empty)
> (sites (lib include)))
> EOF

Expand Down
158 changes: 79 additions & 79 deletions otherlibs/site/test/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ Test embedding of sites locations information
$ for i in a b d; do
> mkdir -p $i
> cat >$i/dune-project <<EOF
> (lang dune 3.0)
> (lang dune 2.9)
> (generate_opam_files true)
> (using dune_site 0.1)
> (name $i)
> (version 0.$i)
> (package (name $i) (sites (share data)) (allow_empty))
> (package (name $i) (sites (share data)))
> EOF
> done

$ for i in c; do
> mkdir -p $i
> cat >$i/dune-project <<EOF
> (lang dune 3.0)
> (lang dune 2.9)
> (generate_opam_files true)
> (using dune_site 0.1)
> (name $i)
> (package (name $i) (allow_empty) (sites (share data) (lib plugins)))
> (package (name $i) (sites (share data) (lib plugins)))
> EOF
> done

Expand Down Expand Up @@ -139,7 +139,7 @@ Test with an opam like installation
opam-version: "2.0"
version: "0.a"
depends: [
"dune" {>= "3.0"}
"dune" {>= "2.9"}
"odoc" {with-doc}
]
build: [
Expand Down Expand Up @@ -178,54 +178,63 @@ Build everything
----------------

$ dune build
Error: Package b is missing the following package dependencies
- c
-> required by _build/default/b/b.install
-> required by alias b/all
-> required by alias default
Error: Package c is missing the following package dependencies
- a
-> required by _build/default/c/c.install
-> required by alias c/all
-> required by alias default
[1]

Test with a normal installation
--------------------------------

$ dune install --prefix _install 2> /dev/null
[1]

Once installed, we have the sites information:

$ OCAMLPATH=_install/lib:$OCAMLPATH _install/bin/c
_install/bin/c: No such file or directory
[127]
run a
a: $TESTCASE_ROOT/_install/share/a/data
run c: a linked registered:.
no sourceroot
c: $TESTCASE_ROOT/_install/share/c/data
b is available: true
run b
b: $TESTCASE_ROOT/_install/share/b/data
info.txt is found: true
run c: registered:b.

Test with a relocatable installation
--------------------------------

$ dune install --prefix _install_relocatable --relocatable 2> /dev/null
[1]

Once installed, we have the sites information:

$ _install_relocatable/bin/c
_install_relocatable/bin/c: No such file or directory
[127]
run a
a: $TESTCASE_ROOT/_install_relocatable/share/a/data
run c: a linked registered:.
no sourceroot
c: $TESTCASE_ROOT/_install_relocatable/share/c/data
b is available: true
run b
b: $TESTCASE_ROOT/_install_relocatable/share/b/data
info.txt is found: true
run c: registered:b.

Test after moving a relocatable installation
--------------------------------

$ mv _install_relocatable _install_relocatable2
mv: cannot stat '_install_relocatable': No such file or directory
[1]

Once installed, we have the sites information:

$ _install_relocatable2/bin/c
_install_relocatable2/bin/c: No such file or directory
[127]
run a
a: $TESTCASE_ROOT/_install_relocatable2/share/a/data
run c: a linked registered:.
no sourceroot
c: $TESTCASE_ROOT/_install_relocatable2/share/c/data
b is available: true
run b
b: $TESTCASE_ROOT/_install_relocatable2/share/b/data
info.txt is found: true
run c: registered:b.

Test substitution when promoting
--------------------------------
Expand All @@ -247,11 +256,6 @@ development because b is not promoted
Test within dune rules
--------------------------------
$ dune build c/out.log
Error: Package c is missing the following package dependencies
- a
-> required by alias c/.c-files
-> required by _build/default/c/out.log
[1]

$ cat _build/default/c/out.log
run a
Expand Down Expand Up @@ -319,49 +323,66 @@ Test compiling an external plugin

$ OCAMLPATH=$(pwd)/_install/lib:$OCAMLPATH dune build --root=e
Entering directory 'e'
File "dune", line 5, characters 47-58:
5 | (plugin (name c-plugins-e) (libraries e) (site (c plugins)))
^^^^^^^^^^^
Error: The package c is not found
[1]

$ OCAMLPATH=$(pwd)/_install/lib:$OCAMLPATH PATH=$(pwd)/_install/bin:$PATH dune exec --root=e -- c
Entering directory 'e'
File "dune", line 5, characters 47-58:
5 | (plugin (name c-plugins-e) (libraries e) (site (c plugins)))
^^^^^^^^^^^
Error: The package c is not found
[1]
run a
a: $TESTCASE_ROOT/_install/share/a/data
run c: a linked registered:.
no sourceroot
c: $TESTCASE_ROOT/_install/share/c/data
b is available: true
run b
b: $TESTCASE_ROOT/_install/share/b/data
info.txt is found: true
run e
e: $TESTCASE_ROOT/e/_build/install/default/share/e/data
info.txt is found: true
run c: registered:e,b.

$ OCAMLPATH=$(pwd)/_install/lib:$OCAMLPATH dune install --root=e --prefix $(pwd)/_install 2> /dev/null
[1]

$ OCAMLPATH=_install/lib:$OCAMLPATH _install/bin/c
_install/bin/c: No such file or directory
[127]
run a
a: $TESTCASE_ROOT/_install/share/a/data
run c: a linked registered:.
no sourceroot
c: $TESTCASE_ROOT/_install/share/c/data
b is available: true
run b
b: $TESTCASE_ROOT/_install/share/b/data
info.txt is found: true
run e
e: $TESTCASE_ROOT/_install/share/e/data
info.txt is found: true
run c: registered:e,b.

$ OCAMLPATH=_install/lib:$OCAMLPATH dune build @runtest
Error: Package b is missing the following package dependencies
- c
-> required by alias b/.b-files
-> required by alias e/runtest in e/dune:7
Error: Package c is missing the following package dependencies
- a
-> required by alias c/.c-files
-> required by alias e/runtest in e/dune:7
[1]
run a
a: $TESTCASE_ROOT/_build/install/default/share/a/data
run c: a linked registered:.
sourceroot is "$TESTCASE_ROOT"
c: $TESTCASE_ROOT/_build/install/default/share/c/data
b is available: true
run b
b: $TESTCASE_ROOT/_build/install/default/share/b/data
info.txt is found: true
run e
e: $TESTCASE_ROOT/_build/install/default/share/e/data
info.txt is found: true
run c: registered:e,b.

Test %{version:installed-pkg}
-----------------------------

$ for i in f; do
> mkdir -p $i
> cat >$i/dune-project <<EOF
> (lang dune 3.0)
> (lang dune 2.9)
> (using dune_site 0.1)
> (name $i)
> (version 0.$i)
> (package (name $i) (allow_empty) (sites (share data) (lib plugins)))
> (package (name $i) (sites (share data) (lib plugins)))
> EOF
> done

Expand All @@ -377,20 +398,9 @@ Test %{version:installed-pkg}

$ OCAMLPATH=_install/lib:$OCAMLPATH dune build --root=f
Entering directory 'f'
File "dune", line 6, characters 15-27:
6 | (echo "a = %{version:a}\n")
^^^^^^^^^^^^
Error: Package "a" doesn't exist in the current project and isn't installed
either.
File "dune", line 7, characters 15-27:
7 | (echo "e = %{version:e}\n")))))
^^^^^^^^^^^^
Error: Package "e" doesn't exist in the current project and isn't installed
either.
[1]
$ cat $(pwd)/f/_build/default/test.target
cat: $TESTCASE_ROOT/f/_build/default/test.target: No such file or directory
[1]
a = 0.a
e =

$ cat f/dune | sed 's/version:a/version:a.test/' > f/dune.tmp && mv f/dune.tmp f/dune
$ OCAMLPATH=_install/lib:$OCAMLPATH dune build --root=f
Expand All @@ -400,11 +410,6 @@ Test %{version:installed-pkg}
^^^^^^^^^^^^^^^^^
Error: Library names are not allowed in this position. Only package names are
allowed
File "dune", line 7, characters 15-27:
7 | (echo "e = %{version:e}\n")))))
^^^^^^^^^^^^
Error: Package "e" doesn't exist in the current project and isn't installed
either.
[1]

$ rm f/dune
Expand Down Expand Up @@ -433,12 +438,7 @@ Test error location
> (generate_sites_module (module sites) (sites non-existent))
> EOF

$ dune build -j1
Error: Package b is missing the following package dependencies
- c
-> required by _build/default/b/b.install
-> required by alias b/all
-> required by alias default
$ dune build
File "a/dune", line 4, characters 45-57:
4 | (generate_sites_module (module sites) (sites non-existent))
^^^^^^^^^^^^
Expand Down
8 changes: 7 additions & 1 deletion src/dune_engine/package.ml
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,12 @@ let decode ~dir =
and+ allow_empty =
field_b "allow_empty"
~check:(Dune_lang.Syntax.since Stanza.syntax (3, 0))
and+ lang_version = Dune_lang.Syntax.get_exn Stanza.syntax in
let allow_empty =
if lang_version < (3, 0) then
This conversation was marked as resolved.
Show resolved Hide resolved
true
else
allow_empty
in
let id = { Id.name; dir } in
{ id
Expand Down Expand Up @@ -790,7 +796,7 @@ let load_opam_file file name =
; tags = Option.value (get_many "tags") ~default:[]
; deprecated_package_names = Name.Map.empty
; sites = Section.Site.Map.empty
; allow_empty = false
; allow_empty = true
}

let equal = Poly.equal
Expand Down
Loading