What's the proper way to add a local file dependence to dub?

Jim Balter Jim at Balter.name
Sat Jan 6 08:57:31 UTC 2024


On Monday, 12 March 2018 at 10:20:20 UTC, Seb wrote:
> On Sunday, 4 March 2018 at 16:46:56 UTC, Marc wrote:
>> then copy it to sources folder?
>>
>> let's say I have a small library folder at C:\mylibrary\D 
>> where I want to use dir.d from it. How do I add that file 
>> dependence to dub? But I do not want to that file be passed 
>> directly to dmd, I want to that file be copied to 
>> application's source folder (so it's easy to distribuite, with 
>> the dependences together as possible) then compiled. So, what 
>> I want to some extension is dub work with loca files.
>> Is this possible to do solely with dub? I know I can easily 
>> write a script to run before dub which copies the dependence 
>> files from C:\mylibrary to application's source but I'm 
>> looking for a more elegant
>>  approach as possible; I'm afraid of rewriting a makefile-like 
>> soon (I find cmake/make/makefiles just ugly).
>
> You can also add a simple dub.sdl to your local files and then 
> use `dub add-local` to add the package to your dub environment.
> Dub will only rebuild the dependency on your local files if 
> they changed (or you use a different compiler / build settings).

Why is there no documentation for this? The dub documentation 
should have a filesystem layout page, with examples of how to 
structure local libraries, how to register them, how to add them 
to projects. AFAICT no such documentation exists. I've tried to 
follow the structure of libraries I've loaded into dub's packages 
directory, but it seems to treat local packages differently. And 
dub add-package is useless ... for one thing, it *overwrites* 
local-packages.json rather than adding to it.



More information about the Digitalmars-d-learn mailing list