1 Star 0 Fork 1

EdgexFoundry/device-sdk-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Makefile 2.37 KB
一键复制 编辑 原始数据 按行查看 历史
Jack Chen 提交于 2024-11-08 11:00 +08:00 . fix: Only one ldflags flag is allowed
.PHONY: build test clean docker unittest lint
# change the following boolean flag to enable or disable the Full RELRO (RELocation Read Only) for linux ELF (Executable and Linkable Format) binaries
ENABLE_FULL_RELRO=true
# change the following boolean flag to enable or disable PIE for linux binaries which is needed for ASLR (Address Space Layout Randomization) on Linux, the ASLR support on Windows is enabled by default
ENABLE_PIE=true
ARCH=$(shell uname -m)
MICROSERVICES=example/cmd/device-simple/device-simple
.PHONY: $(MICROSERVICES)
VERSION=$(shell cat ./VERSION 2>/dev/null || echo 0.0.0)
SDKVERSION=$(VERSION)
DOCKER_TAG=$(VERSION)-dev
ifeq ($(ENABLE_FULL_RELRO), true)
ENABLE_FULL_RELRO_GOFLAGS = -bindnow
endif
GOFLAGS=-ldflags "-X github.com/edgexfoundry/device-sdk-go/v4.Version=$(VERSION) \
-X github.com/edgexfoundry/device-sdk-go/v4/internal/common.SDKVersion=$(SDKVERSION) \
$(ENABLE_FULL_RELRO_GOFLAGS)" -trimpath -mod=readonly
GOTESTFLAGS?=-race
GIT_SHA=$(shell git rev-parse HEAD)
ifeq ($(ENABLE_PIE), true)
GOFLAGS += -buildmode=pie
endif
build: $(MICROSERVICES)
tidy:
go mod tidy
# CGO is enabled by default and cause docker builds to fail due to no gcc,
# but is required for test with -race, so must disable it for the builds only
example/cmd/device-simple/device-simple:
CGO_ENABLED=0 go build $(GOFLAGS) -o $@ ./example/cmd/device-simple
docker:
docker build \
-f example/cmd/device-simple/Dockerfile \
--label "git_sha=$(GIT_SHA)" \
-t edgexfoundry/device-simple:$(GIT_SHA) \
-t edgexfoundry/device-simple:$(DOCKER_TAG) \
.
unittest:
go test $(GOTESTFLAGS) -coverprofile=coverage.out ./...
lint:
@which golangci-lint >/dev/null || echo "WARNING: go linter not installed. To install, run make install-lint"
@if [ "z${ARCH}" = "zx86_64" ] && which golangci-lint >/dev/null ; then golangci-lint run --config .golangci.yml ; else echo "WARNING: Linting skipped (not on x86_64 or linter not installed)"; fi
install-lint:
sudo curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.61.0
test: unittest lint
GO111MODULE=on go vet ./...
gofmt -l $$(find . -type f -name '*.go'| grep -v "/vendor/")
[ "`gofmt -l $$(find . -type f -name '*.go'| grep -v "/vendor/")`" = "" ]
./bin/test-attribution-txt.sh
clean:
rm -f $(MICROSERVICES)
vendor:
go mod vendor
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/EdgexFoundry/device-sdk-go.git
git@gitee.com:EdgexFoundry/device-sdk-go.git
EdgexFoundry
device-sdk-go
device-sdk-go
main

搜索帮助