Skip to content

Commit

Permalink
PMM-12899 pass NO_VCS parameter to go build
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Nov 5, 2024
1 parent 69899db commit 03df05e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions admin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ PMM_RELEASE_VERSION ?= $(shell git describe --always --dirty | cut -b2-)
PMM_RELEASE_TIMESTAMP ?= $(shell date '+%s')
PMM_RELEASE_FULLCOMMIT ?= $(shell git rev-parse HEAD)
PMM_RELEASE_BRANCH ?= $(shell git describe --always --contains --all)

ifdef NO_VCS
NO_VCS := -buildvcs=false
endif
ifeq ($(GOBIN),)
GOBIN := $(shell go env GOPATH)/bin
endif
Expand All @@ -31,8 +35,8 @@ clean: ## Remove generated files
find . -name *_reform.go -delete

release: ## Build pmm-admin release binary
env CGO_ENABLED=0 go build -v $(LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm-admin ./cmd/pmm-admin/
env CGO_ENABLED=0 go build -v $(LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm ./cmd/pmm/
env CGO_ENABLED=0 go build -v $(NO_VCS) $(LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm-admin ./cmd/pmm-admin/
env CGO_ENABLED=0 go build -v $(NO_VCS) $(LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm ./cmd/pmm/

install: ## Install pmm & pmm-admin binary
go build -v $(LD_FLAGS) -o $(GOBIN)/pmm-admin ./cmd/pmm-admin/
Expand Down
8 changes: 6 additions & 2 deletions agent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ PMM_RELEASE_TIMESTAMP ?= $(shell date '+%s')
PMM_RELEASE_FULLCOMMIT ?= $(shell git rev-parse HEAD)
PMM_RELEASE_BRANCH ?= $(shell git describe --always --contains --all)
PMM_DEV_SERVER_PORT ?= 8443

ifdef NO_VCS
NO_VCS := -buildvcs=false
endif
ifeq ($(GOBIN),)
GOBIN := $(shell go env GOPATH)/bin
endif
Expand All @@ -25,8 +29,8 @@ VERSION_FLAGS = -X 'github.com/percona/pmm/version.ProjectName=pmm-agent' \
-X 'github.com/percona/pmm/version.Branch=$(PMM_RELEASE_BRANCH)'

release: ## Build static pmm-agent release binary (Linux only)
env CGO_ENABLED=1 go build -v -ldflags "-extldflags '-static' $(VERSION_FLAGS)" -tags 'osusergo netgo static_build' -o $(PMM_RELEASE_PATH)/pmm-agent
go build -v -ldflags "-extldflags '-static' $(VERSION_FLAGS)" -tags 'osusergo netgo static_build' -o $(PMM_RELEASE_PATH)/pmm-agent-entrypoint ./cmd/pmm-agent-entrypoint
env CGO_ENABLED=1 go build -v $(NO_VCS) -ldflags "-extldflags '-static' $(VERSION_FLAGS)" -tags 'osusergo netgo static_build' -o $(PMM_RELEASE_PATH)/pmm-agent
go build -v $(NO_VCS) -ldflags "-extldflags '-static' $(VERSION_FLAGS)" -tags 'osusergo netgo static_build' -o $(PMM_RELEASE_PATH)/pmm-agent-entrypoint ./cmd/pmm-agent-entrypoint
$(PMM_RELEASE_PATH)/pmm-agent --version
ldd $(PMM_RELEASE_PATH)/pmm-agent 2>&1 | grep -Fq 'not a dynamic executable'

Expand Down
2 changes: 1 addition & 1 deletion build/local/build
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ main() {
run_build_script build-client-rpm
fi

# Building client docker image takes 17s
# Building client docker image takes from 17s (using docker cache) to 43s (no docker cache).
export DOCKER_CLIENT_TAG=percona/pmm-client:${GIT_COMMIT}
if [ "$NO_CLIENT_DOCKER" -eq 0 ]; then
run_build_script build-client-docker
Expand Down

0 comments on commit 03df05e

Please sign in to comment.