Hi D

I normally work in a *nix environment, typically on server-side code. For many projects I have gnu makefiles that build a small lib along with command line utilities.

Up to now I've been creating a dub.json file for just the sourceLibrary, and then putting embedded dub comments at the top of each of the utility programs. The utilities are built via `dub build --single` and a thin makefile triggers all the dub commands.

This method is inefficient, and it won't work in a typical Windows dev environment, so today I'm trying to remove gnu make from the picture. Going back to basics, does anyone know of a clear example of how to convert this simplified makefile into 1-N dub files?:

```makefile
# Build library + utility programs.
# Lib sources are in "libsrc", 1-file programs in "utils"

# Implicit rule to make a utility program
outdir/%:utils/%.d outdir/mylib.a
    dmd -I libsrc -od=outdir -of=$@ $^

# Top level build rule for everything
build:outdir/mylib.a outdir/prog1 outdir/prog2 | outdir

# Explicit rule to make output directory if not present
outdir:
    @if [ ! -e outdir ]; then mkdir outdir; fi

# Explicit build rule for the library
outdir/mylib.a:libsrc/mod1.d libsrc/mod2.d
    dmd -lib -od=outdir -of=$@ $^
```
This is a paired down example since `make test` and `make install` aren't present, but I hope the main ideas are apparent.

I've been at it now for about four hours, with lots of web-searches (btw, thanks to schveiguy for getting me this far) but I haven't figured out what hierarchy of dub constructs I need to create to order to get the effect of the small make file above.

Thanks for considering the question,


  • Use dub to creat... Chris Piker via Digitalmars-d-learn
    • Re: Use dub... Steven Schveighoffer via Digitalmars-d-learn
      • Re: Use... Chris Piker via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... Chris Piker via Digitalmars-d-learn

Reply via email to