Skip to content

DUB aggregates and fetch all dependencies regardless of selected configuration #1706

@schveiguy

Description

@schveiguy

Currently when dub is run on a project that has multiple configurations, some of which select optional dependencies, dub will determine packages that should be downloaded in case those dependencies are selected, and download them proactively. However, this makes little sense if the configuration is not intended to be used in common cases. For example, vibe.d's tls:botan configuration will select botan to download, even if you never intend to compile the botan version.

In addition, different configurations may require different versions of dependencies, creating a conflict of which version of a package should be downloaded for those versions. This can even happen within subconfigurations of packages that you will NEVER build. For example, the test configurations for 2 dependency projects may depend on DIFFERENT versions of a subdependency, even if I'm not going to build the specific subconfiguration.

Example:

...
         "dependencies": {
		"mysql-native": "~>2.3.0"
	},
        "configurations" : [
            {
                "name" : "unittest",
                "dependencies" : {
                    "unit-threaded": "==0.7.37"
                }
            }
        ]
...

To solve this problem, I propose that we:

  1. Do not download packages until needed for build (this will save from unnecessarily downloading never-used packages)
  2. Change dub.selections.json into a key/value array, where the specific dub.selections.json configuration depends on which configurations were selected for building. In practice, you mainly only build one or two configurations, so this will still make the dub.selections.json file relatively static.

For an example of the proposed format, it might be something like:

{
    "fileVersion": 2,
    "selections" : [
        {
            "configuration" : {
                "myproj" : "unittest",
                "mysql-native" : "default",
                "unit-threaded" : "default"
            },
            "versions" : {
                "mysql-native" : "2.3.0",
                "unit-threaded" : "0.7.40"
            }
        },
        ...
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions