-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci] refs #1 - Initial Makefile including following targets:
- help - install-deps-{go,js,nanopb} : Install dependencies for language-specific code generation - build-{go,js,nanopb} : Generate source for a given language
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
# Temporary files | ||
*.swp | ||
*.swo | ||
*.orig | ||
.DS_Store | ||
|
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,64 @@ | ||
.DEFAULT_GOAL := help | ||
.PHONY: help | ||
.PHONY: build-go build-js build-nanopb | ||
.PHONY: install-go install-js install-nanopb | ||
|
||
REPO_ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
UNAME_S = $(shell uname -s) | ||
|
||
ifeq ($(TRAVIS),true) | ||
OS_NAME=$(TRAVIS_OS_NAME) | ||
else ifeq ($(UNAME_S,Linux)) | ||
OS_NAME=linux | ||
else ifeq ($(UNAME_S,Darwin)) | ||
OS_NAME=osx | ||
endif | ||
|
||
PROTOB_SPEC_DIR = $(REPO_ROOT)/protob | ||
|
||
PROTOC_VERSION ?= 3.6.1 | ||
PROTOC_ZIP ?= protoc-$(PROTOC_VERSION)-$(OS_NAME)-x86_64.zip | ||
PROTOC_URL ?= https://github.com/google/protobuf/releases/download/v$(PROTOC_VERSION)/$(PROTOC_ZIP) | ||
|
||
PROTO_FILES = $(shell find $(PROTOB_SPEC_DIR) -type f -name "*.go") | ||
|
||
all: build-go build-js build-nanopb ## Generate protobuf classes for all languages | ||
|
||
install-protoc: | ||
echo "Downloading protobuf from $(PROTOC_URL)" | ||
curl -OL $(PROTOC_URL) | ||
"Installing protoc" | ||
sudo unzip -o $(PROTOC_ZIP) -d /usr/local bin/protoc | ||
rm -f $(PROTOC_ZIP) | ||
|
||
#---------------- | ||
# Go lang | ||
#---------------- | ||
|
||
install-deps-go: install-protoc ## Install tools to generate protobuf classes for go lang | ||
git clone --branch v1.2.0 --depth 1 https://github.com/gogo/protobuf $(GOPATH)/src/github.com/gogo/protobuf | ||
( cd $(GOPATH)/src/github.com/gogo/protobuf/protoc-gen-gogofast && go install ) | ||
|
||
build-go: install-go ## Generate protobuf classes for go lang | ||
protoc -I protob --gogofast_out=go/ device-wallet/messages/messages.proto device-wallet/messages/types.proto device-wallet/messages/descriptor.proto | ||
|
||
#---------------- | ||
# Javascript | ||
#---------------- | ||
|
||
install-deps-js: ## Install tools to generate protobuf classes for javascript | ||
|
||
build-js: install-js ## Generate protobuf classes for javascript | ||
|
||
#---------------- | ||
# C with nanopb | ||
#---------------- | ||
|
||
install-deps-nanopb: ## Install tools to generate protobuf classes for C with nanopb | ||
|
||
build-nanopb: install-nanopb ## Generate protobuf classes for C with nanopb | ||
|
||
help: | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|