-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate to new aperturerobotics/common pattern
Signed-off-by: Christian Stewart <[email protected]>
- Loading branch information
Showing
18 changed files
with
47 additions
and
2,431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ __debug* | |
.aider* | ||
|
||
dist/ | ||
/.tools/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,143 +1,31 @@ | ||
# https://github.com/aperturerobotics/template | ||
|
||
PROJECT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
SHELL:=bash | ||
PROTOWRAP=hack/bin/protowrap | ||
PROTOC_GEN_GO=hack/bin/protoc-gen-go-lite | ||
PROTOC_GEN_STARPC=hack/bin/protoc-gen-go-starpc | ||
GOIMPORTS=hack/bin/goimports | ||
GOFUMPT=hack/bin/gofumpt | ||
GOLANGCI_LINT=hack/bin/golangci-lint | ||
GO_MOD_OUTDATED=hack/bin/go-mod-outdated | ||
GOLIST=go list -f "{{ .Dir }}" -m | ||
MAKEFLAGS += --no-print-directory | ||
|
||
GORELEASER=hack/bin/goreleaser | ||
GO_VENDOR_DIR := ./vendor | ||
COMMON_DIR := $(GO_VENDOR_DIR)/github.com/aperturerobotics/common | ||
COMMON_MAKEFILE := $(COMMON_DIR)/Makefile | ||
|
||
export GO111MODULE=on | ||
undefine GOARCH | ||
undefine GOOS | ||
|
||
all: | ||
|
||
vendor: | ||
go mod vendor | ||
|
||
$(PROTOC_GEN_GO): | ||
cd ./hack; \ | ||
go build -v \ | ||
-o ./bin/protoc-gen-go-lite \ | ||
github.com/aperturerobotics/protobuf-go-lite/cmd/protoc-gen-go-lite | ||
|
||
$(GOIMPORTS): | ||
cd ./hack; \ | ||
go build -v \ | ||
-o ./bin/goimports \ | ||
golang.org/x/tools/cmd/goimports | ||
|
||
$(GOFUMPT): | ||
cd ./hack; \ | ||
go build -v \ | ||
-o ./bin/gofumpt \ | ||
mvdan.cc/gofumpt | ||
|
||
$(PROTOWRAP): | ||
cd ./hack; \ | ||
go build -v \ | ||
-o ./bin/protowrap \ | ||
github.com/aperturerobotics/goprotowrap/cmd/protowrap | ||
|
||
$(GOLANGCI_LINT): | ||
cd ./hack; \ | ||
go build -v \ | ||
-o ./bin/golangci-lint \ | ||
github.com/golangci/golangci-lint/cmd/golangci-lint | ||
|
||
$(GO_MOD_OUTDATED): | ||
cd ./hack; \ | ||
go build -v \ | ||
-o ./bin/go-mod-outdated \ | ||
github.com/psampaz/go-mod-outdated | ||
.PHONY: $(MAKECMDGOALS) | ||
|
||
$(PROTOC_GEN_STARPC): | ||
cd ./hack; \ | ||
go build -v \ | ||
-o ./bin/protoc-gen-go-starpc \ | ||
github.com/aperturerobotics/starpc/cmd/protoc-gen-go-starpc | ||
|
||
node_modules: | ||
yarn install | ||
|
||
.PHONY: genproto | ||
genproto: vendor node_modules $(GOIMPORTS) $(PROTOWRAP) $(PROTOC_GEN_GO) $(PROTOC_GEN_STARPC) | ||
shopt -s globstar; \ | ||
set -eo pipefail; \ | ||
export PROJECT=$$(go list -m); \ | ||
export PATH=$$(pwd)/hack/bin:$${PATH}; \ | ||
export OUT=$$(pwd)/vendor; \ | ||
mkdir -p $${OUT}/$$(dirname $${PROJECT}); \ | ||
rm $$(pwd)/vendor/$${PROJECT} || true; \ | ||
ln -s $$(pwd) $$(pwd)/vendor/$${PROJECT} ; \ | ||
protogen() { \ | ||
$(PROTOWRAP) \ | ||
-I $${OUT} \ | ||
--plugin=./node_modules/.bin/protoc-gen-es \ | ||
--plugin=./node_modules/.bin/protoc-gen-es-starpc \ | ||
--go-lite_out=$${OUT} \ | ||
--go-lite_opt=features=marshal+unmarshal+size+equal+json+clone+text \ | ||
--go-starpc_out=$${OUT} \ | ||
--es_out=$${OUT} \ | ||
--es_opt target=ts \ | ||
--es_opt ts_nocheck=false \ | ||
--es-starpc_out=$${OUT} \ | ||
--es-starpc_opt target=ts \ | ||
--es-starpc_opt ts_nocheck=false \ | ||
--proto_path $${OUT} \ | ||
--print_structure \ | ||
--only_specified_files \ | ||
$$(\ | ||
git \ | ||
ls-files "$$1" |\ | ||
xargs printf -- \ | ||
"$$(pwd)/vendor/$${PROJECT}/%s "); \ | ||
}; \ | ||
protogen "./*.proto"; \ | ||
rm $$(pwd)/vendor/$${PROJECT} || true | ||
$(GOIMPORTS) -w ./ | ||
npm run format:js | ||
|
||
.PHONY: gen | ||
gen: genproto | ||
|
||
.PHONY: outdated | ||
outdated: $(GO_MOD_OUTDATED) | ||
go list -mod=mod -u -m -json all | $(GO_MOD_OUTDATED) -update -direct | ||
|
||
.PHONY: list | ||
list: $(GO_MOD_OUTDATED) | ||
go list -mod=mod -u -m -json all | $(GO_MOD_OUTDATED) | ||
|
||
.PHONY: lint | ||
lint: $(GOLANGCI_LINT) | ||
$(GOLANGCI_LINT) run | ||
|
||
.PHONY: fix | ||
fix: $(GOLANGCI_LINT) | ||
$(GOLANGCI_LINT) run --fix | ||
all: | ||
|
||
.PHONY: test | ||
test: | ||
go test -v ./... | ||
$(COMMON_MAKEFILE): vendor | ||
@if [ ! -f $(COMMON_MAKEFILE) ]; then \ | ||
echo "Please add github.com/aperturerobotics/common to your go.mod."; \ | ||
exit 1; \ | ||
fi | ||
|
||
.PHONY: format | ||
format: $(GOFUMPT) $(GOIMPORTS) | ||
$(GOIMPORTS) -w ./ | ||
$(GOFUMPT) -w ./ | ||
$(MAKECMDGOALS): $(COMMON_MAKEFILE) | ||
@$(MAKE) -C $(COMMON_DIR) PROJECT_DIR="$(PROJECT_DIR)" $@ | ||
|
||
$(GORELEASER): | ||
cd ./hack; \ | ||
go build -v \ | ||
-o ./bin/goreleaser \ | ||
github.com/goreleaser/goreleaser | ||
%: $(COMMON_MAKEFILE) | ||
@$(MAKE) -C $(COMMON_DIR) PROJECT_DIR="$(PROJECT_DIR)" $@ | ||
|
||
.PHONY: release | ||
release: $(GORELEASER) | ||
$(GORELEASER) release --clean | ||
vendor: | ||
go mod vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//go:build deps_only | ||
// +build deps_only | ||
|
||
package bifrost | ||
|
||
import ( | ||
// _ imports common with the Makefile and tools | ||
_ "github.com/aperturerobotics/common" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.