Skip to content

Commit

Permalink
Merge pull request #3 from bertbroer/feature/add-mac-support
Browse files Browse the repository at this point in the history
feature/add-mac-arm-support
  • Loading branch information
Sauci committed Dec 13, 2023
2 parents b9c4627 + e73265d commit 11a3b73
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
60 changes: 60 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,35 @@ jobs:
- run: |
go get github.com/antlr4-go/antlr/v4
go test ./cmd/a2l/...
test-mac:
runs-on: macos-latest-xlarge
needs:
- generate-antlr-sources
- generate-grpc-sources
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: antlr4
path: pkg/a2l/parser
- uses: actions/download-artifact@v3
with:
name: grpc
path: pkg/a2l
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: "1.21"
cache: true
- run: |
go get github.com/antlr4-go/antlr/v4
go test ./cmd/a2l/...
build-linux:
runs-on: ubuntu-22.04
needs:
- test-linux
- test-windows
- test-mac
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
Expand All @@ -88,6 +112,7 @@ jobs:
needs:
- test-linux
- test-windows
- test-mac
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
Expand All @@ -107,6 +132,36 @@ jobs:
path: |
*.dll
*.h
build-mac:
runs-on: macos-latest-xlarge
needs:
- test-linux
- test-windows
- test-mac
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: antlr4
path: pkg/a2l/parser
- uses: actions/download-artifact@v3
with:
name: grpc
path: pkg/a2l
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: "1.21"
cache: true
- run: |
go get github.com/antlr4-go/antlr/v4
go build --buildmode=c-shared -o a2l_grpc_$(go env GOOS)_$(go env GOARCH).dylib ./cmd/a2l/a2l.go
- uses: actions/upload-artifact@v3
with:
name: mac
path: |
*.dylib
*.h
export-protobuf-definitions:
runs-on: ubuntu-22.04
steps:
Expand All @@ -123,6 +178,7 @@ jobs:
needs:
- build-linux
- build-windows
- build-mac
- export-protobuf-definitions
if: startsWith(github.ref, 'refs/tags/v')
steps:
Expand All @@ -136,6 +192,10 @@ jobs:
with:
name: windows
path: a2l_grpc
- uses: actions/download-artifact@v3
with:
name: mac
path: a2l_grpc
- uses: actions/download-artifact@v3
with:
name: protobuf
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ a2l_grpc.tar.gz
| ├── shared.proto
├── a2l_grpc_(os)_(arch).h
├── a2l_grpc_(os)_(arch).dll
├── a2l_grpc_(os)_(arch).dylib
└── a2l_grpc_(os)_(arch).so
```
The *a2l_grpc.tar.gz/protobuf* folder contains all the *gRPC* data structure definitions. It will be used to generate
Expand All @@ -58,6 +59,7 @@ src
| | ├── shared.proto
| ├── a2l_grpc_(os)_(arch).h
| ├── a2l_grpc_(os)_(arch).dll
| ├── a2l_grpc_(os)_(arch).dylib
| └── a2l_grpc_(os)_(arch).so
├── main.py
```
Expand All @@ -76,6 +78,7 @@ Now that all sources are available, we can start writing the *gRPC* client in *P
```python
import ctypes
import os
import sys

from pya2l.protobuf.API_pb2 import *
from pya2l.protobuf.API_pb2_grpc import *
Expand All @@ -85,7 +88,10 @@ def get_shared_object_name() -> str:
if os.name == 'nt':
shared_object = 'a2l_grpc_windows_amd64.dll'
elif os.name == 'posix':
shared_object = 'a2l_grpc_linux_amd64.so'
if sys.platform == 'darwin':
shared_object = 'a2l_grpc_darwin_arm64.dylib'
else:
shared_object = 'a2l_grpc_linux_amd64.so'
else:
raise Exception(f'unsupported operating system {os.name}')
return shared_object
Expand Down

0 comments on commit 11a3b73

Please sign in to comment.