Makefiles and dub

H. S. Teoh hsteoh at qfbox.info
Fri Nov 4 23:42:07 UTC 2022


On Fri, Nov 04, 2022 at 11:19:17PM +0000, Anonymouse via Digitalmars-d-learn wrote:
> [#20699](https://issues.dlang.org/show_bug.cgi?id=20699) must be
> non-trivial to fix, so I'm exploring makefiles. If possible I'd like
> to keep dub for dependency management though, just not for actual
> compilation.
> 
> Is it at all possible (or even desireable) to construct a makefile
> that builds dependencies from outside of the source tree (namely
> `$HOME/.dub/packages/package_with_unknown_version-1.2.[0-9]+/`)?
> 
> Does anyone have an example `Makefile` I could dissect?
[...]

Don't have a Makefile to show, but I've done the following in the past
when I have dub dependencies but need to use my own build system:

- Create a subdirectory containing a dummy empty dub project (containing
  nothing but an empty main()), whose sole purpose is to declare dub
  dependencies that I need.
- Run dub to retrieve and compile said dependencies, with --vverbose so
  that shows the actual compile commands (for extracting the pathnames
  of the compiled artifacts).
- Copy-n-paste the compiled objects paths into my build system as object
  files / libraries to link against.

In theory, the second step above can be automatically parsed to extract
the needed paths, or even recompile after altering the command-line
options, but I never got that far because I've since shelved the
project (for reasons unrelated to dub).


T

-- 
Holding a grudge is like drinking poison and hoping the other person dies. -- seen on the 'Net


More information about the Digitalmars-d-learn mailing list