DUB: Sometimes generates .di file and sometimes do not.
BoQsc
vaidas.boqsc at gmail.com
Sun Nov 5 17:05:21 UTC 2023
**Conclusive observation:**
This can be resolved by informing `dub` of `extraDependencyFiles`
to rebuild itself.
`library.di` non-existance simply does not trigger rebuild of the
package and instead only `library.lib` is being copied from the
`cache` folder into `build` folder. Leaving `library.di` not
being generated.
if `cache` folder exists with a output file, it does not trigger
build, only copies from the `\cache`'s `\build` folder. If build
is not triggered, `.di` file is not being generated.
### Observations:
* Happens with `dub.json` as well.
* Mostly `.di` stops generating after the first output of `dub`.
* Making any text changes to content of `dub.sdl` triggers `dub`
to rebuild package and generate`.di`
* Deleting the `cache` output file will trigger to rebuild the
package and generate `.di`
*
`C:\Users\Windows10\AppData\Local\dub\cache\dheaders\~master\build`
* After deleting `library.lib` inside latest cache folder
`build`: The `.di` starts to generate.
### Solution:
> [**excludedSourceFiles**](https://dub.pm/package-format-sdl#build-settings) Files that should be removed for the set of already added source files (takes precedence over "sourceFiles" and "sourcePaths") - Glob matching can be used to pattern match multiple files at once
### Working example:
**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"
}
```
More information about the Digitalmars-d-learn
mailing list