DUB: Sometimes generates .di file and sometimes do not.

BoQsc vaidas.boqsc at gmail.com
Mon Nov 6 10:51:32 UTC 2023


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.


More information about the Digitalmars-d-learn mailing list