Thread overview
Local libraries/packages with dub: How?
Dec 01, 2020
z
Dec 01, 2020
rikki cattermole
Dec 01, 2020
z
Dec 01, 2020
rikki cattermole
Dec 01, 2020
z
December 01, 2020
How does one set up a dub package so that it contains multiple sublibraries that may or may not depend on these same libraries?(but never co-dependant)
So far i've tried using add-local and add-path with subpackage declarations in the root folder's dub.sdl but to no avail.
(dub does not complain but silently doesn't add dependencies with -v, dmd just errors out with the standard file not found error "module y is in file y.d which cannot be read", with the path of my libraries absent from import paths.)

Alternatively, is there an equivalent of -version= for DUB's build command?(for when a package author didn't add a config that incorporates the desired versions.)

Big thanks and my apologies if this is the wrong place for DUB discussion.
December 01, 2020
dub add-local, adds a directory as a known package that it can use as a dependency (or to be executed).

You need to specify in the package that depends on the dependency what dependencies you have.

I.e.

See the dependencies key:

{
	"name": "myproject",
	"description": "A little web service of mine.",
	"authors": ["Peter Parker"],
	"homepage": "http://myproject.example.com",
	"license": "GPL-2.0",
	"dependencies": {
		"vibe-d": "~>0.7.23"
	}
}

See[0] how to specify the dependency itself.

To have different sets of dependencies/code you can use sub packages or configurations. But I would suggest to just focus on one set for now, while you are getting the hang of the basics.

[0] https://dub.pm/package-format-json#version-specs
December 01, 2020
On Tuesday, 1 December 2020 at 04:50:03 UTC, rikki cattermole wrote:
> ...

What puzzles me is that the dependencies are indeed declared, but "dub describe" refuses to recognize the dependencies and "dub build" fails.
"dub list" does recognize the root folder, but trying to get a subpackage to import another fails because the dependency isn't imported.(dmd only sees the "source" and phobos/runtime import paths)

The root dub.sdl roughly contains this :
>name "fldr"
>dependencies "fldr:spkg1" "fldr:spkg2" "fldr:spkg3" // tried with and without "fldr:"
>subPackage "./spkg1/"
>subPackage "./spkg2/"
>subPackage "./spkg3/"
>targetType "none"
While for example, "spkg3"'s dub.sdl contains this :
>>name "spkg3"
>>dependencies "fldr:spkg2"
 And its source/*.d file contains this :
>>>import std.stdio, fldr.spkg2; //tried with and without "fldr."
>>>void main() {writeln(«function from spkg2»)}
December 01, 2020
On 01/12/2020 7:39 PM, z wrote:
> On Tuesday, 1 December 2020 at 04:50:03 UTC, rikki cattermole wrote:
>> ...
> 
> What puzzles me is that the dependencies are indeed declared, but "dub describe" refuses to recognize the dependencies and "dub build" fails.
> "dub list" does recognize the root folder, but trying to get a subpackage to import another fails because the dependency isn't imported.(dmd only sees the "source" and phobos/runtime import paths)
> 
> The root dub.sdl roughly contains this :
>> name "fldr"
>> dependencies "fldr:spkg1" "fldr:spkg2" "fldr:spkg3" // tried with and without "fldr:"

That isn't right.

dependency "fldr:spkg1" version="*"
dependency "fldr:spkg2" version="*"
dependency "fldr:spkg3" version="*"

>> subPackage "./spkg1/"
>> subPackage "./spkg2/"
>> subPackage "./spkg3/"

>> targetType "none"

That probably isn't what you want. Either library or executable.
Either that, or you shouldn't be adding the dependencies.

> While for example, "spkg3"'s dub.sdl contains this :
>>> name "spkg3"
>>> dependencies "fldr:spkg2"

dependency "fldr:spkg2" version="*"

>   And its source/*.d file contains this :
>>>> import std.stdio, fldr.spkg2; //tried with and without "fldr."
>>>> void main() {writeln(«function from spkg2»)}

Don't forget to specify the module name. Every file should declare its module full package + module name.

So in this case ``module fldr.spkg2;``.
December 01, 2020
On Tuesday, 1 December 2020 at 07:39:31 UTC, rikki cattermole wrote:
> 
> That isn't right.
>
Thank you, this was the problem apparently. Dub ignored the malformed dependency declaration instead of displaying a warning or an error.(this is apparently a bug.[0][1])

[0] https://github.com/dlang/dub/issues/614
[1] https://github.com/dlang/dub/issues/1382