nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.27k stars 324 forks source link

Go: Use Homebrew include paths #1017

Closed danielledeleo closed 7 months ago

danielledeleo commented 7 months ago

This patch adds include paths for libunit installed via Homebrew only when built on Darwin (macOS). I don't know if Linux Homebrew uses the same paths, so this shouldn't get in the way in that edge case.

Small note, the syntax used on line 1 is the preferred syntax as of go1.18 and the old style of // +build should be go fixd across the repository in the future.

Fixes nginx/unit#967

ac000 commented 7 months ago

Don't forget to update the issue link in the commit message... (you can force push here)

thresheek commented 7 months ago

Would it be possible for a user to redefine those flags to make it possible to build with custom Unit installs even if you have Unit via Homebrew installed?

danielledeleo commented 7 months ago

Would it be possible for a user to redefine those flags to make it possible to build with custom Unit installs even if you have Unit via Homebrew installed?

Yes. I can confirm that setting the CGO_ environment variables overrides those set in the .go file. With Unit built from source and installed with make libunit-install these flags work. It is pretty opaque though.

CGO_LDFLAGS="-L/usr/local/lib" CGO_CFLAGS="-I/usr/local/include" go build
danielledeleo commented 7 months ago

Actually... this isn't ideal. If artifacts from a source build are present in the default includepath, the Homebrew libraries will not be used unless specified as per #967.

So, if no source builds are present in the default includepath, a Homebrew install will work with a simple go build, otherwise it will have to be overridden.

If this behaviour is acceptable, I'm okay to merge this.

ac000 commented 7 months ago

Actually... this isn't ideal. If artifacts from a source build are present in the default includepath, the Homebrew libraries will not be used unless specified as per #967.

Assuming I'm understanding correctly (and it's entirely possible I'm not), might that not be desirable? If you want to try with a newer version of Unit built from source...

danielledeleo commented 7 months ago

might that not be desirable? If you want to try with a newer version of Unit built from source...

Yeah that would be the behaviour!

ac000 commented 7 months ago

On Tue, 05 Dec 2023 10:57:31 -0800 Dani De Leo @.***> wrote:

might that not be desirable? If you want to try with a newer version of Unit built from source...

Yeah that would be the behaviour!

Sounds reasonable to me...