How to have a separate package or common module within DUB?

monkyyy crazymonkyyy at gmail.com
Fri Dec 5 20:19:33 UTC 2025


On Friday, 5 December 2025 at 19:49:35 UTC, Ian wrote:
> On Friday, 5 December 2025 at 19:03:52 UTC, monkyyy wrote:
>> On Friday, 5 December 2025 at 18:47:50 UTC, Ian wrote:
>>> ...
>>
>> dub was not made to do this and the docs remain: 
>> https://dub.pm/dub-reference/subpackages/ "unfinished" and 
>> will remain unfished
>>
>> as far as I know adr's code is the futherest dub has been 
>> pushed *and he hates it*; 
>> https://github.com/adamdruppe/arsd/blob/master/dub.json when I 
>> followed his advice to not do that shit, it took 50 lines of 
>> code for my own build script. I bet ai can just do it in a 
>> single prompt by now.
>>
>> You can make a "subpackage", copy someone elses file 
>> structure, but id suggest jumping ship if the json line count 
>> expands past 50 and you run into a single piece of complexity 
>> no one has yet solved.
>
> I see. Well I'm happy to do something different. How do I do 
> libraries / shared code at all?

`dmd -i -run` will run the majority of files and d allows for the 
first line of code to be `#!` which on linux makes it a "script"

Add -unittest and -l and its probaly most of what you want, its 
not perfect but d has a fantastic compiler api by comparision.

id suggest having whatever makes your executable runs should be a 
`#!dmd ...` if you need linker flags or whatever just look them 
up and put them there; from a clean slate thats what I suggest

if you have something complex `std.process` is a bit verbose but 
its how you call executables(like the compiler), append some 
strings together and throw it at it. I use a wrapper I copy and 
paste around.

If youve only used dub, your probably used to an src folder, you 
mostly just flatten your folders by 1 and it makes `-i` 
automagically work, if you then want folder of executables try to 
get by with `./foo/bar.d`.

it can be a bit tricky to be that simple so you may need to do a 
build script; Im not following my own advice here but this is 
what I was doing a year ago see biuld.d and exmaples/ : 
https://github.com/crazymonkyyy/raylib-2024 , kap may have a more 
resent and better example with his parin lib.(maybe)


More information about the Digitalmars-d-learn mailing list