dlang / dub

Package and build management system for D
MIT License
677 stars 227 forks source link

Feature Request: Add provides/replacement tag to dub file #2636

Open LunaTheFoxgirl opened 1 year ago

LunaTheFoxgirl commented 1 year ago

Some projects on the dub database are meant as drop-in replacements and are API compatible with other projects, it would be a good idea to add a provides/replaces tag to the dub file so that during package resolution, if a top level project uses a drop-in replacement sub-packages will use that replacement as well.

This tag should additionally allow specifying a range of versions which are compatible.

Example:

name "i2d-opengl"
description "Dynamic bindings to OpenGL, compatible with -betterC, @nogc, and nothrow."

provides "bindbc-opengl" from="~>1.0.0" to="~>1.0.0"

This file would cause a project using i2d-opengl, to use i2d-opengl for any sub-dependencies using bindbc-opengl, just for the compilation of that package.

Omitting from would make the package resolution count the replacement from all versions from 0.0.0 to to. Omitting to would make the provides be unbounded, replacing any versions after from Omitting both, would make the package replace any version of the package it replaces.

WebFreak001 commented 1 year ago

from and to wouldn't be able to be version ranges here, since it's quite ambiguous what they would actually mean.

Instead we should just use

provides "bindbc-opengl" version=">=1.0.0 <2.0.0"

and use dub's regular version range syntax here