Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #81, adding partial windows build support to aid in skywallet-mcu#342 #82

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
.DEFAULT_GOAL := help
.PHONY: help all clean install
.PHONY: build-go build-js build-c build-py
.PHONY: install-deps-go install-deps-js install-deps-nanopb install-protoc
.PHONY: install-deps-go install-deps-js install-deps-nanopb
.PHONY: install-protoc install-protoc-linux install-protoc-osx install-protoc-win32
.PHONY: clean-go clean-js clean-c clean-py

REPO_ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

UNAME_S = $(shell uname -s)
PYTHON ?= python
PYTHON ?= python3
PIP ?= pip3
PIPARGS ?=
GOPATH ?= $(HOME)/go
Expand All @@ -21,6 +22,11 @@ else
ifeq ($(UNAME_S),Darwin)
OS_NAME=osx
endif
UNAME_W = $(shell uname -s | cut -d "_" -f1 )
ifeq ($(UNAME_W),MINGW64)
OS_NAME=win32
PROTOC_ZIP ?= protoc-$(PROTOC_VERSION)-$(OS_NAME).zip
endif
endif

PROTOC_VERSION ?= 3.6.1
Expand Down Expand Up @@ -66,14 +72,20 @@ OUT_C ?= $(PROTOB_C_DIR)

all: build-go build-js build-c build-py ## Generate protobuf classes for all languages

install: install-deps-go install-deps-js install-deps-nanopb install-protoc ## Install protocol buffer tools
install: install-deps-go install-deps-js install-deps-nanopb install-protoc-$(OS_NAME) ## Install protocol buffer tools

clean: clean-go clean-js clean-c clean-py ## Delete temporary and output files
rm -rf \
$$( find . -name '*.swp' ) \
$$( find . -name '*.swo' ) \
$$( find . -name '*.orig' )

install-protoc-linux: install-protoc

install-protoc-osx: install-protoc

install-protoc-win32: /usr/local/bin/protoc.exe
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this require Win Linux subsystem ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it's pointless to use WSL as it will generate a linux (elf) bin inside windows, it uses the MSYS2 toolchain (based on MINGW32/64) to generate a compatible .exe windows bin

We switch to appveyor (skywallet-mcu#342 original issue) because it can handle a clean MSYS2 toolchain in opposite of travis that use git-windows shell and mixing that with MSYS2 is a PITA and you get unstable results (remember the travis log generating garbage, a side effect of mixing git-win and MSYS2 toolchains on windows)

Also there are some libs we need that are only found in MSYS2.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is /usr/local/bin/protoc.exe then ? It does not look like a Windows file path , right ?


install-protoc: /usr/local/bin/protoc

/usr/local/bin/protoc:
Expand All @@ -83,11 +95,19 @@ install-protoc: /usr/local/bin/protoc
sudo unzip -o $(PROTOC_ZIP) -d /usr/local bin/protoc
rm -f $(PROTOC_ZIP)

/usr/local/bin/protoc.exe:
echo "Downloading protobuf from $(PROTOC_URL)"
curl -OL $(PROTOC_URL)
echo "Installing protoc"
mkdir -p /usr/local/bin
sudo unzip -o $(PROTOC_ZIP) -d /usr/local bin/protoc.exe
rm -f $(PROTOC_ZIP)

#----------------
# Go lang
#----------------

install-deps-go: install-protoc ## Install tools to generate protobuf classes for go lang
install-deps-go: install-protoc-$(OS_NAME) ## Install tools to generate protobuf classes for go lang
@if [ -e $(PROTOB_SRC_DIR) ] ; then \
echo 'Detected $(PROTOC_GOGO_URL) on local file system. Checking v1.2.0' ; \
cd $(PROTOB_SRC_DIR) && git checkout v1.2.0 ; \
Expand Down Expand Up @@ -129,7 +149,7 @@ clean-js:
# C with nanopb
#----------------

install-deps-nanopb: install-protoc ## Install tools to generate protobuf classes for C and Python with nanopb
install-deps-nanopb: install-protoc-$(OS_NAME) ## Install tools to generate protobuf classes for C and Python with nanopb
make -C $(PROTOC_NANOPBGEN_DIR)/proto/
$(PIP) install $(PIPARGS) "protobuf==$(PROTOC_VERSION)" ecdsa

Expand Down