In summary this is what it all combined could look like.

**dub.sdl**
```
name "dheaders"
description "generates .di header file for a static library."
authors "public domain"
copyright "Public Domain. No rights reserved."
license "public domain"

configuration "staticLibrary" {
        dflags "-Hf=$PACKAGE_DIR/builds/library.di"
        targetName "library"
        targetType "library"
        targetPath "builds"
        sourceFiles "library.d"       
        extraDependencyFiles "$PACKAGE_DIR/builds/library.di"
}

configuration "staticLibraryNoDIHeader" {
        targetName "library"
        targetType "library"
        targetPath "builds"
        sourceFiles "library.d"
}

buildType "headerFileOnly" {
        extraDependencyFiles "$PACKAGE_DIR/builds/library.di"
        dflags "-Hf=$PACKAGE_DIR/builds/library.di"
        dflags "-o-"
        sourceFiles "library.d"
}
```

**library.d**
```
module library;

int func(int x)
{
    return x+1;
}
```

**Command Line:**
```
dub --build=headerFileOnly
dub --config=staticLibraryNoDIHeader
dub --config=staticLibrary
```

First one creates only `.di` d header file
Second one creates only `.lib` static library file.
Third one creates both `.lib` and `.di` files.

Reply via email to