build: Append existing CFLAGS and LDFLAGS for CGO #367
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Underlying
go build
commands can pass customCFLAGS
andLDFLAGS
to CGO invocations, which GoPy uses in order to pass some of its own command-line arguments to builds.However, there are cases where additional, build-specific parameters may need to be used (e.g. in the case where we're linking against a static library which itself links to other dynamic libraries, which aren't set as options in the packages themselves); this commit respects any existing uses of the
CGO_CFLAGS
andCGO_LDFLAGS
environment variables, and appends their values to ones used internally by GoPy if needed.My own, specific use-case here is using GoPy in
slidge-whatsapp
, and usinggo-fitz
, which links againstlibmupdf
, which in turn requires a number of different libraries (libjpeg
,libharfbuzz
, etc.)Infuriatingly enough, Debian doesn't provide a package containing a shared library for MuPDF, only a static library, which requires that we declare any shared libraries specifically at the time of compilation; otherwise builds work but you get
undefined reference
errors at runtime.