-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Enforce custom LDFLAGS within makefile #684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
LGTM |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little late to the game, but anyhow 🙂
@@ -11,7 +11,7 @@ BINDATA := modules/{options,public,templates}/bindata.go | |||
STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less) | |||
JAVASCRIPTS := | |||
|
|||
LDFLAGS += -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')" | |||
LDFLAGS ?= -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only makes it set LDFLAGS if it's is not set already
If you’d like a variable to be set to a value only if it’s not already set, then you can use the shorthand operator ‘?=’ instead of ‘=’
https://www.gnu.org/software/make/manual/html_node/Setting.html#Setting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make with LDFLAGS
$ LDFLAGS="-X 'main.Version=1'" make clean build
go clean -i ./...
rm -rf gitea dist modules/{options,public,templates}/bindata.go
go build -v -tags '' -ldflags '-s -w -X 'main.Version=1'' -o gitea
missing LDFLAGS
$ make clean build
go clean -i ./...
rm -rf gitea dist modules/{options,public,templates}/bindata.go
go build -v -tags '' -ldflags '-s -w -X "main.Version=1.0.0+138-g68f7246"' -o gitea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, it needs to be changed to LDFLAGS =
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LDFLAGS :=
and this is solved in another PR, #709
Fixes #540