Re: Local libraries/packages with dub: How?
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
Re: Local libraries/packages with dub: How?
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;``.
Re: Local libraries/packages with dub: How?
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»)}
Re: Local libraries/packages with dub: How?
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