Skip to content

Commit

Permalink
added arm64 to support Apple M1 and now using small proto lib
Browse files Browse the repository at this point in the history
  • Loading branch information
jerson committed Mar 13, 2021
1 parent 7f6dedb commit 0105746
Show file tree
Hide file tree
Showing 11 changed files with 312 additions and 809 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/darwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.15.5'
go-version: '1.16.1'
- name: Build
run: make binding_darwin
- name: Compress
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gomobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: '1.14.13'
# using this version to support more Architectures in the fat file: Openpgp are: armv7 i386 x86_64 arm64
# using this version to support more Architectures in the fat file: Rsa are: armv7 i386 x86_64 arm64
- name: Install Gomobile
run: |
go get -u golang.org/x/mobile/cmd/gomobile@33b80540585f2b31e503da24d6b2a02de3c53ff5
Expand Down
25 changes: 22 additions & 3 deletions Makefile.darwin
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
DARWIN_OUTPUT?=darwin
DARWIN_BINDING_OUTPUT?=$(BINDING_OUTPUT)/$(DARWIN_OUTPUT)
DARWIN_TARGET?=10.11
binding_darwin: binding_darwin_x86_64

binding_darwin: binding_darwin_x86_64 binding_darwin_arm64
lipo $(DARWIN_BINDING_OUTPUT)/x86_64.dylib $(DARWIN_BINDING_OUTPUT)/arm64.dylib -create -output $(DARWIN_BINDING_OUTPUT)/$(BINDING_NAME).dylib
rm $(DARWIN_BINDING_OUTPUT)/x86_64.dylib $(DARWIN_BINDING_OUTPUT)/arm64.dylib $(DARWIN_BINDING_OUTPUT)/*.h

binding_darwin_x86_64:
BINDING_FILE=$(DARWIN_OUTPUT)/$(BINDING_NAME).dylib \
BINDING_FILE=$(DARWIN_OUTPUT)/x86_64.dylib \
BUILD_MODE="c-shared" \
CGO_CFLAGS=-mmacosx-version-min=$(DARWIN_TARGET) \
MACOSX_DEPLOYMENT_TARGET=$(DARWIN_TARGET) \
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 \
make binding

binding_darwin_arm64:
BINDING_FILE=$(DARWIN_OUTPUT)/arm64.dylib \
BUILD_MODE="c-shared" \
CGO_CFLAGS=-mmacosx-version-min=$(DARWIN_TARGET) \
MACOSX_DEPLOYMENT_TARGET=$(DARWIN_TARGET) \
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 \
make binding

binding_darwin_archive_x86_64:
BINDING_FILE=$(DARWIN_OUTPUT)/$(BINDING_NAME).a \
BINDING_FILE=$(DARWIN_OUTPUT)/x86_64.a \
BUILD_MODE="c-archive" \
CGO_CFLAGS=-mmacosx-version-min=$(DARWIN_TARGET) \
MACOSX_DEPLOYMENT_TARGET=$(DARWIN_TARGET) \
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 \
make binding

binding_darwin_archive_arm64:
BINDING_FILE=$(DARWIN_OUTPUT)/arm64.a \
BUILD_MODE="c-archive" \
CGO_CFLAGS=-mmacosx-version-min=$(DARWIN_TARGET) \
MACOSX_DEPLOYMENT_TARGET=$(DARWIN_TARGET) \
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 \
make binding
12 changes: 10 additions & 2 deletions Makefile.protobuf
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
proto: proto_dart proto_go

proto_go_deps:
go get github.com/gogo/protobuf/protoc-gen-gofast
go get github.com/gogo/protobuf/proto
go get github.com/gogo/protobuf/protoc-gen-gogofaster
go get github.com/gogo/protobuf/gogoproto

proto_dart_deps:
flutter pub global activate protoc_plugin

proto_dart:
rm -rf output/dart && mkdir -p output/dart
protoc -Iproto --dart_out=grpc:./output/dart proto/*.proto

proto_go:
rm -rf bridge/model && mkdir -p bridge/model
protoc -Iproto --gofast_out=grpc:./bridge/model proto/*.proto
protoc -Iproto --gogofaster_out=./bridge/model proto/*.proto

proto_js:
rm -rf output/js && mkdir -p output/js
protoc -Iproto --js_out=import_style=commonjs,binary:./output/js proto/*.proto
cp output/js/bridge_pb.js wasm/sample/public/bridge_pb.js
2 changes: 1 addition & 1 deletion Makefile.wasm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: wasm
wasm:
mkdir -p output/wasm
GOARCH=wasm GOOS=js go build -ldflags="-s -w" -o output/wasm/rsa.wasm wasm/main.go
cd wasm && GOARCH=wasm GOOS=js go build -ldflags="-s -w" -o ../output/wasm/rsa.wasm main.go
cp $(GOROOT)/misc/wasm/wasm_exec.js output/wasm/wasm_exec.js
cp output/wasm/rsa.wasm wasm/sample/public/rsa.wasm
cp output/wasm/wasm_exec.js wasm/sample/public/wasm_exec.js
2 changes: 1 addition & 1 deletion bridge/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package rsaBridge

import (
"fmt"
"github.com/golang/protobuf/proto"
"github.com/gogo/protobuf/proto"
"github.com/jerson/rsa-mobile/bridge/model"
"github.com/jerson/rsa-mobile/rsa"
)
Expand Down
Loading

0 comments on commit 0105746

Please sign in to comment.