Install multiple executables with DUB

drug drug2004 at bk.ru
Fri Sep 4 07:55:30 UTC 2020


On 9/4/20 10:27 AM, glis-glis wrote:
> On Thursday, 3 September 2020 at 14:34:48 UTC, Jacob Carlborg wrote:
>> Oh, multiple binaries, I missed that. You can try to add multiple 
>> configurations [1]. Or if you have executables depending on only one 
>> source file, you can use single-file packages [2].
> 
> Thanks, but this still means I would have to write an install-script 
> running
> 
> `dub build --single`
> 
> on each script, right?
> I looked at tsv-utils [1] which seems to be a similar use-case as mine, 
> and they declare each tool as a subpackage. The main package runs a 
> d-file called `dub_build.d` which compiles all subpackages. Fells like 
> an overkill to me, I'll probably just stick to a makefile.
> 
> 
> [1] 
> https://github.com/eBay/tsv-utils/blob/master/docs/AboutTheCode.md#building-and-makefile 
> 

I don't know is it suitable for your use case but I do the following:
1. add a recipe in every tool files like:
```
drug at drug: ~/utils$ cat ./tools/count.d
#!/usr/bin/env dub
/+ dub.sdl:
	name        "count"
	targetType  "executable"
	targetPath  "../bin"
	targetName  "count"

	dependency "abcdLibrary" version="*" path="path/to/abcdLibrary"
+/

int main()
{
	...
}
```
2. place all tool files into one directory `tools`
3. build them using `dub build --single tools/count.d`
4. Now I have all binary in `bin` directory, all sources in `tools` 
directory and have no subpackages at all


More information about the Digitalmars-d-learn mailing list