-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dependencies/dub: First try to describe local project
The current approach of determining dub dependencies is by specifying a name and, optionally, a version. Dub will then be called to generate a json summary of the package and code in meson will parse that and extract relevant information. This can be insufficient because dub packages can provide multiple configurations for multiple use-cases, examples include providing a configuration for an executable and a configuration for a library. As a practical example, the dub package itself provides an application configuration and multiple library configurations, the json description of dub will, by default, be for the application configuration which will make dub as a library unusable in meson. This can be solved without modifying the meson build interface by having dub describe the entire local project and collecting dependencies information from that. This way dub will generate information based on the project's 'dub.json' file, which is free to require dependencies in any way accepted by dub, by specifying configurations, by modifying compilation flags etc. This is all transparent to meson as dub's main purpose is to provide a path to the library file generated by the dependency in addition to other command-line arguments for the compiler. This change will, however, require that projects that want to build with meson also provided a 'dub.json' file in which dependency information is recorded. Failure to do so will not break existing projects that didn't use a 'dub.json', but they will be limited to what the previous implementation offered. Projects that already have a 'dub.json' should be fine, so long as the file is valid and the information in it matches the one in 'meson.build'. For example for a 'dependency()' call in 'meson.build' that dependency must exist in 'dub.json', otherwise the call will now fail when it worked previously. Using a 'dub.json' also has as a consequence that the version of the dependencies that are found are the ones specified in 'dub.selections.json', which can be helpful for projects that already provide a 'dub.json' in addition to 'meson.build' to de-duplicate code. In terms of other code changes: - multiple version requirements for a dub dependency now work, though they can only be used when a 'dub.json' is present in which case the version of dependencies is already pinned by 'dub.selections.json' - the 'd/11 dub' test case has been changed to auto-generate the 'dub.json' config outside of the source directory, as the auto-generated file triggers warning when parsed by dub, which upsets the new code as the warnings interfere with the legitimate output. Signed-off-by: Andrei Horodniceanu <[email protected]>
- Loading branch information
Showing
22 changed files
with
228 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,11 +38,13 @@ chmod +x /ci/env_vars.sh | |
|
||
source /ci/env_vars.sh | ||
|
||
dub_fetch urld | ||
dub build urld --compiler=dmd | ||
dub_fetch dubtestproject | ||
dub_fetch [email protected] | ||
dub build dubtestproject:test1 --compiler=dmd | ||
dub build dubtestproject:test2 --compiler=dmd | ||
dub build dubtestproject:test3 --compiler=dmd | ||
dub_fetch [email protected] | ||
dub build urld --compiler=dmd | ||
|
||
|
||
# Cleanup | ||
zypper --non-interactive clean --all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,11 +45,12 @@ eatmydata apt-get -y install --no-install-recommends wine-stable # Wine is spec | |
install_python_packages hotdoc | ||
|
||
# dub stuff | ||
dub_fetch urld | ||
dub build urld --compiler=gdc | ||
dub_fetch dubtestproject | ||
dub_fetch [email protected] | ||
dub build dubtestproject:test1 --compiler=ldc2 | ||
dub build dubtestproject:test2 --compiler=ldc2 | ||
dub build dubtestproject:test3 --compiler=gdc | ||
dub_fetch [email protected] | ||
dub build urld --compiler=gdc | ||
|
||
# Remove debian version of Rust and install latest with rustup. | ||
# This is needed to get the cross toolchain as well. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
17-dub-meson-project* | ||
lib17-dub-meson-project* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "17-dub-meson-project", | ||
"dependencies": { | ||
"urld": ">=3.0.0 <3.0.1", | ||
"dubtestproject:test3": "1.2.0", | ||
":multi-configuration": "*" | ||
}, | ||
"subPackages": [ | ||
"multi-configuration" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"fileVersion": 1, | ||
"versions": { | ||
"dubtestproject": "1.2.0", | ||
"urld": "3.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
project('Dub dependency respects dub.selections.json', 'd') | ||
|
||
dub_exe = find_program('dub', required : false) | ||
if not dub_exe.found() | ||
error('MESON_SKIP_TEST: Dub not found') | ||
endif | ||
|
||
dub_ver = dub_exe.version() | ||
if not dub_ver.version_compare('>=1.35.0') | ||
error('MESON_SKIP_TEST: test requires dub >=1.35.0') | ||
endif | ||
|
||
# Multiple versions supported | ||
urld = dependency('urld', method: 'dub', version: [ '>=3.0.0', '<3.0.1' ]) | ||
|
||
# The version we got is the one in dub.selections.json | ||
version = urld.version() | ||
if version != '3.0.0' | ||
error(f'Expected urld version to be the one selected in dub.selections.json but got @version@') | ||
endif | ||
|
||
# dependency calls from subdirectories respect meson.source_root()/dub.selections.json | ||
subdir('x/y/z') | ||
|
||
# dependencies respect their configuration selected in dub.json | ||
run_command(dub_exe, 'build', '--deep', ':multi-configuration', | ||
'--compiler', meson.get_compiler('d').cmd_array()[0], | ||
'--arch', host_machine.cpu_family(), | ||
'--root', meson.source_root(), | ||
'--config', 'lib', | ||
check: true) | ||
found = dependency('17-dub-meson-project:multi-configuration', method: 'dub') |
2 changes: 2 additions & 0 deletions
2
test cases/d/17 dub and meson project/multi-configuration/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
libmulti-configuration* | ||
multi-configuration* |
14 changes: 14 additions & 0 deletions
14
test cases/d/17 dub and meson project/multi-configuration/dub.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "multi-configuration", | ||
"configurations": { | ||
"app": { | ||
"targetType": "executable" | ||
}, | ||
"lib": { | ||
"targetType": "library", | ||
"excludedSourceFiles": [ | ||
"source/app.d" | ||
] | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
test cases/d/17 dub and meson project/multi-configuration/dub.selections.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"fileVersion": 1, | ||
"versions": { | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
test cases/d/17 dub and meson project/multi-configuration/source/app.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
void main () {} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
void main () {} |
Oops, something went wrong.