mirror of
https://github.com/ultravioletrs/cocos.git
synced 2026-08-07 07:14:50 +00:00
f9a2fd0b96
The Makefile was updated to fix the version and commit variables. Previously, the VERSION variable was using "git describe" to get the latest tag, but it was failing when there were no tags available. The updated VERSION variable now uses "git describe --always" to fallback to the commit hash if no tags are available. The COMMIT variable was also updated to use "git rev-parse HEAD" to get the commit hash. Summary: Fix Makefile version and commit variables Body: - Update VERSION variable to use "git describe --always" to fallback to commit hash - Update COMMIT variable to use "git rev-parse HEAD" to get commit hash Signed-off-by: SammyOina <sammyoina@gmail.com>
33 lines
904 B
Makefile
33 lines
904 B
Makefile
BUILD_DIR = build
|
|
SERVICES = manager agent cli
|
|
CGO_ENABLED ?= 0
|
|
GOARCH ?= amd64
|
|
VERSION ?= $(shell git describe --abbrev=0 --tags --always)
|
|
COMMIT ?= $(shell git rev-parse HEAD)
|
|
TIME ?= $(shell date +%F_%T)
|
|
CLI_SOURCE = ./cmd/cli/main.go
|
|
CLI_BIN = ${BUILD_DIR}/cocos-cli
|
|
|
|
|
|
define compile_service
|
|
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \
|
|
go build -mod=vendor -ldflags "-s -w \
|
|
-X 'github.com/mainflux/mainflux.BuildTime=$(TIME)' \
|
|
-X 'github.com/mainflux/mainflux.Version=$(VERSION)' \
|
|
-X 'github.com/mainflux/mainflux.Commit=$(COMMIT)'" \
|
|
-o ${BUILD_DIR}/cocos-$(1) cmd/$(1)/main.go
|
|
endef
|
|
|
|
.PHONY: all $(SERVICES)
|
|
|
|
all: $(SERVICES)
|
|
|
|
$(SERVICES):
|
|
$(call compile_service,$(@))
|
|
|
|
install-cli: cli
|
|
cp ${CLI_BIN} ~/.local/bin/cocos-cli
|
|
|
|
protoc:
|
|
protoc -I. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative agent/agent.proto
|