Thread overview
using dub to compile plugins
Dec 19, 2018
Codifies
Dec 19, 2018
Codifies
Dec 19, 2018
Andre Pany
Dec 19, 2018
Codifies
Dec 19, 2018
Andre Pany
Dec 19, 2018
Codifies
Dec 19, 2018
Neia Neutuladh
Dec 21, 2018
Atila Neves
Dec 21, 2018
Neia Neutuladh
December 19, 2018
I am currently using this dub.sdl

name        "runz80"
targetType  "executable"
lflags      "libz80/libz80.a"

however I will be creating a number of plugins, each plugin will consist of a single source file, I'd like the plugin source directory to be separate from main source directory and compile the plugins (.so) to a (binary) plugins directory

(the plugins will be dynamically loaded at runtime - I've previously done this in C so I don't anticipate any particular issues - famous last words!)

I could do this with a few simple rules in a Makefile, but I have no clue how to achieve this using dub.

can someone show me a concrete example of doing this ? Ideally just dropping a new source file into the plugins source folder should produce a new .so the next time dub is run, without having to explicitly add each plugin to the dub file...
December 19, 2018
oh forgot to add just for extra pain.... while the main application won't need gtk, most of the plugins will...
December 19, 2018
On Wednesday, 19 December 2018 at 12:57:14 UTC, Codifies wrote:
> I am currently using this dub.sdl
>
> name        "runz80"
> targetType  "executable"
> lflags      "libz80/libz80.a"
>
> however I will be creating a number of plugins, each plugin will consist of a single source file, I'd like the plugin source directory to be separate from main source directory and compile the plugins (.so) to a (binary) plugins directory
>
> (the plugins will be dynamically loaded at runtime - I've previously done this in C so I don't anticipate any particular issues - famous last words!)
>
> I could do this with a few simple rules in a Makefile, but I have no clue how to achieve this using dub.
>
> can someone show me a concrete example of doing this ? Ideally just dropping a new source file into the plugins source folder should produce a new .so the next time dub is run, without having to explicitly add each plugin to the dub file...

You can use dub sub packages. Each plugin will be a dub package with its own dub descriptor (sdl) file.
For your main dub sdl you set targetType to None.

Kind regards
Andre
December 19, 2018
On Wednesday, 19 December 2018 at 13:14:20 UTC, Andre Pany wrote:
> On Wednesday, 19 December 2018 at 12:57:14 UTC, Codifies wrote:
>> [...]
>
> You can use dub sub packages. Each plugin will be a dub package with its own dub descriptor (sdl) file.
> For your main dub sdl you set targetType to None.
>
> Kind regards
> Andre

how could I have multiple dub files in the same directory for each plugin ???
December 19, 2018
On Wed, 19 Dec 2018 12:57:14 +0000, Codifies wrote:
> I could do this with a few simple rules in a Makefile, but I have no clue how to achieve this using dub.

If you need dub, you can create a wrapper script that generates the dub file for the plugins directory.

Make is a lot better for this kind of thing.
December 19, 2018
On Wednesday, 19 December 2018 at 14:08:10 UTC, Codifies wrote:
> On Wednesday, 19 December 2018 at 13:14:20 UTC, Andre Pany wrote:
>> On Wednesday, 19 December 2018 at 12:57:14 UTC, Codifies wrote:
>>> [...]
>>
>> You can use dub sub packages. Each plugin will be a dub package with its own dub descriptor (sdl) file.
>> For your main dub sdl you set targetType to None.
>>
>> Kind regards
>> Andre
>
> how could I have multiple dub files in the same directory for each plugin ???

You have sub folders in which you create the dub.sdl files. In your main dub.sdl you include these folders as sub packages.

Regarding the automatic logic you ideally want to have: there is the plan to add dub extension plugins. Unfortunately a hero is needed to implement it.

Kind regards
Andre
December 19, 2018
On Wednesday, 19 December 2018 at 16:31:57 UTC, Andre Pany wrote:
> On Wednesday, 19 December 2018 at 14:08:10 UTC, Codifies wrote:
>> On Wednesday, 19 December 2018 at 13:14:20 UTC, Andre Pany wrote:
>>> On Wednesday, 19 December 2018 at 12:57:14 UTC, Codifies wrote:
>>>> [...]
>>>
>>> You can use dub sub packages. Each plugin will be a dub package with its own dub descriptor (sdl) file.
>>> For your main dub sdl you set targetType to None.
>>>
>>> Kind regards
>>> Andre
>>
>> how could I have multiple dub files in the same directory for each plugin ???
>
> You have sub folders in which you create the dub.sdl files. In your main dub.sdl you include these folders as sub packages.
>
> Regarding the automatic logic you ideally want to have: there is the plan to add dub extension plugins. Unfortunately a hero is needed to implement it.
>
> Kind regards
> Andre

I was planning to have all the plugin sources in one directory otherwise I'd have loads of folders all over the place...

I think Make is the way forward!
December 21, 2018
On Wednesday, 19 December 2018 at 12:57:14 UTC, Codifies wrote:
> I am currently using this dub.sdl
>
> name        "runz80"
> targetType  "executable"
> lflags      "libz80/libz80.a"
>
> however I will be creating a number of plugins, each plugin will consist of a single source file, I'd like the plugin source directory to be separate from main source directory and compile the plugins (.so) to a (binary) plugins directory
>
> (the plugins will be dynamically loaded at runtime - I've previously done this in C so I don't anticipate any particular issues - famous last words!)
>
> I could do this with a few simple rules in a Makefile, but I have no clue how to achieve this using dub.
>
> can someone show me a concrete example of doing this ? Ideally just dropping a new source file into the plugins source folder should produce a new .so the next time dub is run, without having to explicitly add each plugin to the dub file...

Unless the plugins have dub dependencies, don't use dub for it. Plugins that do can have their own dub.sdl/json with targetType "dynamicLibrary".

> Ideally just dropping a new source file into the plugins source folder should produce a new .so the next time dub is run, without having to explicitly add each plugin to the dub file...

I don't see how you can do this with dub, and I wouldn't attempt it either. Just use make, and have make call dub for the main project (and potentially any plugins that need it). Remember to make the dub targets `.PHONY` since you don't want to be managing the D dependencies by hand.
December 21, 2018
On Fri, 21 Dec 2018 10:56:39 +0000, Atila Neves wrote:
> I don't see how you can do this with dub, and I wouldn't attempt it either. Just use make, and have make call dub for the main project (and potentially any plugins that need it). Remember to make the dub targets `.PHONY` since you don't want to be managing the D dependencies by hand.

Or you could have it depend on dub.sdl, dub.selections.json, your D source files, and your string import files. Which is a bit more work but will result in a little less recompilation.