Compare commits
1 Commits
v1.11.0
...
dev/moul/m
Author | SHA1 | Date | |
---|---|---|---|
|
1078f8de8f |
3
.github/renovate.json
vendored
3
.github/renovate.json
vendored
@@ -2,5 +2,6 @@
|
||||
"extends": [
|
||||
"config:base"
|
||||
],
|
||||
"groupName": "all"
|
||||
"groupName": "all",
|
||||
"gomodTidy": true
|
||||
}
|
||||
|
1
AUTHORS
1
AUTHORS
@@ -9,6 +9,7 @@ Guilhem Fanton <guilhem.fanton@gmail.com>
|
||||
Jan Weitz <jan@iosphere.de>
|
||||
jhayotte <julien.hayotte@gmail.com>
|
||||
Julien Hayotte <julien.hayotte@gmail.com>
|
||||
Manfred Touron <94029+moul@users.noreply.github.com>
|
||||
Manfred Touron <m@42.am>
|
||||
Mathieu Acthernoene <zoontek@gmail.com>
|
||||
Mike Lee <mike.lee@safeguardproperties.com>
|
||||
|
@@ -163,8 +163,6 @@ var ProtoHelpersFuncMap = template.FuncMap{
|
||||
"getStore": getStore,
|
||||
"goPkg": goPkg,
|
||||
"goPkgLastElement": goPkgLastElement,
|
||||
"cppType": cppType,
|
||||
"cppTypeWithPackage": cppTypeWithPackage,
|
||||
}
|
||||
|
||||
var pathMap map[interface{}]*descriptor.SourceCodeInfo_Location
|
||||
@@ -911,57 +909,6 @@ func haskellType(pkg string, f *descriptor.FieldDescriptorProto) string {
|
||||
}
|
||||
}
|
||||
|
||||
// Warning does not handle message embedded like goTypeWithGoPackage does.
|
||||
func cppTypeWithPackage(f *descriptor.FieldDescriptorProto) string {
|
||||
pkg := ""
|
||||
if *f.Type == descriptor.FieldDescriptorProto_TYPE_MESSAGE || *f.Type == descriptor.FieldDescriptorProto_TYPE_ENUM {
|
||||
if isTimestampPackage(*f.TypeName) {
|
||||
pkg = "timestamp"
|
||||
} else {
|
||||
pkg = getPackageTypeName(*f.TypeName)
|
||||
}
|
||||
}
|
||||
return cppType(pkg, f)
|
||||
}
|
||||
|
||||
func cppType(pkg string, f *descriptor.FieldDescriptorProto) string {
|
||||
isRepeat := *f.Label == descriptor.FieldDescriptorProto_LABEL_REPEATED
|
||||
typeName := "???"
|
||||
switch *f.Type {
|
||||
case descriptor.FieldDescriptorProto_TYPE_DOUBLE:
|
||||
typeName = "double"
|
||||
case descriptor.FieldDescriptorProto_TYPE_FLOAT:
|
||||
typeName = "float"
|
||||
case descriptor.FieldDescriptorProto_TYPE_INT64:
|
||||
typeName = "int64_t"
|
||||
case descriptor.FieldDescriptorProto_TYPE_UINT64:
|
||||
typeName = "uint64_t"
|
||||
case descriptor.FieldDescriptorProto_TYPE_INT32:
|
||||
typeName = "int32_t"
|
||||
case descriptor.FieldDescriptorProto_TYPE_UINT32:
|
||||
typeName = "uint32_t"
|
||||
case descriptor.FieldDescriptorProto_TYPE_BOOL:
|
||||
typeName = "bool"
|
||||
case descriptor.FieldDescriptorProto_TYPE_STRING:
|
||||
typeName = "std::string"
|
||||
case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
|
||||
if pkg != "" {
|
||||
pkg = pkg + "."
|
||||
}
|
||||
typeName = fmt.Sprintf("%s%s", pkg, shortType(*f.TypeName))
|
||||
case descriptor.FieldDescriptorProto_TYPE_BYTES:
|
||||
typeName = "std::vector<uint8_t>"
|
||||
case descriptor.FieldDescriptorProto_TYPE_ENUM:
|
||||
typeName = fmt.Sprintf("%s%s", pkg, shortType(*f.TypeName))
|
||||
default:
|
||||
break
|
||||
}
|
||||
if isRepeat {
|
||||
return "std::vector<" + typeName + ">"
|
||||
}
|
||||
return typeName
|
||||
}
|
||||
|
||||
func goTypeWithEmbedded(pkg string, f *descriptor.FieldDescriptorProto, p *descriptor.FileDescriptorProto) string {
|
||||
if pkg != "" {
|
||||
pkg = pkg + "."
|
||||
|
101
rules.mk
vendored
101
rules.mk
vendored
@@ -30,6 +30,7 @@ all: help
|
||||
##
|
||||
|
||||
rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
|
||||
check-program = $(foreach exec,$(1),$(if $(shell PATH="$(PATH)" which $(exec)),,$(error "No $(exec) in PATH")))
|
||||
|
||||
##
|
||||
## rules.mk
|
||||
@@ -68,69 +69,99 @@ endif
|
||||
ifdef GOPKG
|
||||
GO ?= go
|
||||
GOPATH ?= $(HOME)/go
|
||||
GOLIBS ?= $(shell find . -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq)
|
||||
GO_INSTALL_OPTS ?=
|
||||
GO_TEST_OPTS ?= -test.timeout=30s
|
||||
GOMOD_DIR ?= .
|
||||
GOCOVERAGE_FILE ?= ./coverage.txt
|
||||
GOTESTJSON_FILE ?= ./go-test.json
|
||||
GOBUILDLOG_FILE ?= ./go-build.log
|
||||
GOINSTALLLOG_FILE ?= ./go-install.log
|
||||
|
||||
ifdef GOBINS
|
||||
.PHONY: go.install
|
||||
go.install:
|
||||
ifeq ($(CI),true)
|
||||
@rm -f /tmp/goinstall.log
|
||||
@set -e; for dir in $(GOBINS); do ( set -xe; \
|
||||
cd $$dir; \
|
||||
$(GO) install -v $(GO_INSTALL_OPTS) .; \
|
||||
); done 2>&1 | tee $(GOINSTALLLOG_FILE)
|
||||
|
||||
else
|
||||
@set -e; for dir in $(GOBINS); do ( set -xe; \
|
||||
cd $$dir; \
|
||||
$(GO) install $(GO_INSTALL_OPTS) .; \
|
||||
); done
|
||||
endif
|
||||
INSTALL_STEPS += go.install
|
||||
|
||||
.PHONY: go.release
|
||||
go.release:
|
||||
$(call check-program, goreleaser)
|
||||
goreleaser --snapshot --skip-publish --rm-dist
|
||||
@echo -n "Do you want to release? [y/N] " && read ans && \
|
||||
if [ $${ans:-N} = y ]; then set -xe; goreleaser --rm-dist; fi
|
||||
RELEASE_STEPS += go.release
|
||||
endif
|
||||
|
||||
.PHONY: go.unittest coverage.txt
|
||||
go.unittest: coverage.txt
|
||||
coverage.txt:
|
||||
@rm -f /tmp/coverage.txt
|
||||
@touch /tmp/coverage.txt
|
||||
@set -e; for dir in $(GOLIBS); do ( set -xe; \
|
||||
cd $$dir; \
|
||||
$(GO) test $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race ./...; \
|
||||
.PHONY: go.unittest
|
||||
go.unittest:
|
||||
ifeq ($(CI),true)
|
||||
@echo "mode: atomic" > /tmp/gocoverage
|
||||
@rm -f $(GOTESTJSON_FILE)
|
||||
@set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do (set -e; (set -euf pipefail; \
|
||||
cd $$dir; \
|
||||
($(GO) test ./... $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race -json | tee -a $(GOTESTJSON_FILE) 3>&1 1>&2 2>&3 | tee -a $(GOBUILDLOG_FILE); \
|
||||
); \
|
||||
if [ -f /tmp/profile.out ]; then \
|
||||
cat /tmp/profile.out >> /tmp/coverage.txt; \
|
||||
cat /tmp/profile.out | sed "/mode: atomic/d" >> /tmp/gocoverage; \
|
||||
rm -f /tmp/profile.out; \
|
||||
fi)); done
|
||||
@mv /tmp/gocoverage $(GOCOVERAGE_FILE)
|
||||
else
|
||||
@echo "mode: atomic" > /tmp/gocoverage
|
||||
@set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do (set -e; (set -xe; \
|
||||
cd $$dir; \
|
||||
$(GO) test ./... $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race); \
|
||||
if [ -f /tmp/profile.out ]; then \
|
||||
cat /tmp/profile.out | sed "/mode: atomic/d" >> /tmp/gocoverage; \
|
||||
rm -f /tmp/profile.out; \
|
||||
fi); done
|
||||
mv /tmp/coverage.txt .
|
||||
@mv /tmp/gocoverage $(GOCOVERAGE_FILE)
|
||||
endif
|
||||
|
||||
.PHONY: go.checkdoc
|
||||
go.checkdoc:
|
||||
go doc $(GOMOD_DIR)
|
||||
|
||||
.PHONY: go.coverfunc
|
||||
go.coverfunc: coverage.txt
|
||||
go tool cover -func=./coverage.txt | grep -v .pb.go: | grep -v .pb.gw.go:
|
||||
go.coverfunc: go.unittest
|
||||
go tool cover -func=$(GOCOVERAGE_FILE) | grep -v .pb.go: | grep -v .pb.gw.go:
|
||||
|
||||
.PHONY: go.lint
|
||||
go.lint:
|
||||
@set -e; for dir in $(GOLIBS); do ( set -xe; \
|
||||
@set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \
|
||||
cd $$dir; \
|
||||
golangci-lint run --verbose ./...; \
|
||||
); done
|
||||
|
||||
.PHONY: go.tidy
|
||||
go.tidy:
|
||||
@set -e; for dir in $(GOLIBS); do ( set -xe; \
|
||||
@set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \
|
||||
cd $$dir; \
|
||||
$(GO) mod tidy; \
|
||||
); done
|
||||
|
||||
.PHONY: go.build
|
||||
go.build:
|
||||
@set -e; for dir in $(GOLIBS); do ( set -xe; \
|
||||
@set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \
|
||||
cd $$dir; \
|
||||
$(GO) build ./...; \
|
||||
); done
|
||||
|
||||
.PHONY: go.bump-deps
|
||||
go.bumpdeps:
|
||||
@set -e; for dir in $(GOLIBS); do ( set -xe; \
|
||||
@set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \
|
||||
cd $$dir; \
|
||||
$(GO) get -u ./...; \
|
||||
); done
|
||||
@@ -138,9 +169,9 @@ go.bumpdeps:
|
||||
.PHONY: go.bump-deps
|
||||
go.fmt:
|
||||
if ! command -v goimports &>/dev/null; then GO111MODULE=off go get golang.org/x/tools/cmd/goimports; fi
|
||||
@set -e; for dir in $(GOLIBS); do ( set -xe; \
|
||||
@set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \
|
||||
cd $$dir; \
|
||||
goimports -w . \
|
||||
goimports -w `go list -f '{{.Dir}}' ./...)` \
|
||||
); done
|
||||
|
||||
BUILD_STEPS += go.build
|
||||
@@ -151,6 +182,20 @@ UNITTEST_STEPS += go.unittest
|
||||
FMT_STEPS += go.fmt
|
||||
endif
|
||||
|
||||
##
|
||||
## Gitattributes
|
||||
##
|
||||
|
||||
ifneq ($(wildcard .gitattributes),)
|
||||
.PHONY: _linguist-ignored
|
||||
_linguist-kept:
|
||||
@git check-attr linguist-vendored $(shell git check-attr linguist-generated $(shell find . -type f | grep -v .git/) | grep unspecified | cut -d: -f1) | grep unspecified | cut -d: -f1 | sort
|
||||
|
||||
.PHONY: _linguist-kept
|
||||
_linguist-ignored:
|
||||
@git check-attr linguist-vendored linguist-ignored `find . -not -path './.git/*' -type f` | grep '\ set$$' | cut -d: -f1 | sort -u
|
||||
endif
|
||||
|
||||
##
|
||||
## Node
|
||||
##
|
||||
@@ -177,6 +222,15 @@ endif
|
||||
## Docker
|
||||
##
|
||||
|
||||
docker_build = docker build \
|
||||
--build-arg VCS_REF=`git rev-parse --short HEAD` \
|
||||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
||||
--build-arg VERSION=`git describe --tags --always` \
|
||||
-t "$2" -f "$1" "$(dir $1)"
|
||||
|
||||
ifndef DOCKERFILE_PATH
|
||||
DOCKERFILE_PATH = ./Dockerfile
|
||||
endif
|
||||
ifndef DOCKER_IMAGE
|
||||
ifneq ($(wildcard Dockerfile),)
|
||||
DOCKER_IMAGE = $(notdir $(PWD))
|
||||
@@ -186,11 +240,8 @@ ifdef DOCKER_IMAGE
|
||||
ifneq ($(DOCKER_IMAGE),none)
|
||||
.PHONY: docker.build
|
||||
docker.build:
|
||||
docker build \
|
||||
--build-arg VCS_REF=`git rev-parse --short HEAD` \
|
||||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
||||
--build-arg VERSION=`git describe --tags --always` \
|
||||
-t $(DOCKER_IMAGE) .
|
||||
$(call check-program, docker)
|
||||
$(call docker_build,$(DOCKERFILE_PATH),$(DOCKER_IMAGE))
|
||||
|
||||
BUILD_STEPS += docker.build
|
||||
endif
|
||||
@@ -255,7 +306,7 @@ generate: $(PRE_GENERATE_STEPS) $(GENERATE_STEPS)
|
||||
endif
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
help::
|
||||
@echo "General commands:"
|
||||
@[ "$(BUILD_STEPS)" != "" ] && echo " build" || true
|
||||
@[ "$(BUMPDEPS_STEPS)" != "" ] && echo " bumpdeps" || true
|
||||
|
Reference in New Issue
Block a user