Skip to content

Commit 11a3b73

Browse files
authored
Merge pull request #3 from bertbroer/feature/add-mac-support
feature/add-mac-arm-support
2 parents b9c4627 + e73265d commit 11a3b73

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

.github/workflows/build.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,35 @@ jobs:
5959
- run: |
6060
go get github.com/antlr4-go/antlr/v4
6161
go test ./cmd/a2l/...
62+
test-mac:
63+
runs-on: macos-latest-xlarge
64+
needs:
65+
- generate-antlr-sources
66+
- generate-grpc-sources
67+
steps:
68+
- uses: actions/checkout@v3
69+
- uses: actions/download-artifact@v3
70+
with:
71+
name: antlr4
72+
path: pkg/a2l/parser
73+
- uses: actions/download-artifact@v3
74+
with:
75+
name: grpc
76+
path: pkg/a2l
77+
- name: Set up Go 1.21
78+
uses: actions/setup-go@v4
79+
with:
80+
go-version: "1.21"
81+
cache: true
82+
- run: |
83+
go get github.com/antlr4-go/antlr/v4
84+
go test ./cmd/a2l/...
6285
build-linux:
6386
runs-on: ubuntu-22.04
6487
needs:
6588
- test-linux
6689
- test-windows
90+
- test-mac
6791
steps:
6892
- uses: actions/checkout@v3
6993
- uses: actions/download-artifact@v3
@@ -88,6 +112,7 @@ jobs:
88112
needs:
89113
- test-linux
90114
- test-windows
115+
- test-mac
91116
steps:
92117
- uses: actions/checkout@v3
93118
- uses: actions/download-artifact@v3
@@ -107,6 +132,36 @@ jobs:
107132
path: |
108133
*.dll
109134
*.h
135+
build-mac:
136+
runs-on: macos-latest-xlarge
137+
needs:
138+
- test-linux
139+
- test-windows
140+
- test-mac
141+
steps:
142+
- uses: actions/checkout@v3
143+
- uses: actions/download-artifact@v3
144+
with:
145+
name: antlr4
146+
path: pkg/a2l/parser
147+
- uses: actions/download-artifact@v3
148+
with:
149+
name: grpc
150+
path: pkg/a2l
151+
- name: Set up Go 1.21
152+
uses: actions/setup-go@v4
153+
with:
154+
go-version: "1.21"
155+
cache: true
156+
- run: |
157+
go get github.com/antlr4-go/antlr/v4
158+
go build --buildmode=c-shared -o a2l_grpc_$(go env GOOS)_$(go env GOARCH).dylib ./cmd/a2l/a2l.go
159+
- uses: actions/upload-artifact@v3
160+
with:
161+
name: mac
162+
path: |
163+
*.dylib
164+
*.h
110165
export-protobuf-definitions:
111166
runs-on: ubuntu-22.04
112167
steps:
@@ -123,6 +178,7 @@ jobs:
123178
needs:
124179
- build-linux
125180
- build-windows
181+
- build-mac
126182
- export-protobuf-definitions
127183
if: startsWith(github.ref, 'refs/tags/v')
128184
steps:
@@ -136,6 +192,10 @@ jobs:
136192
with:
137193
name: windows
138194
path: a2l_grpc
195+
- uses: actions/download-artifact@v3
196+
with:
197+
name: mac
198+
path: a2l_grpc
139199
- uses: actions/download-artifact@v3
140200
with:
141201
name: protobuf

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ a2l_grpc.tar.gz
3434
| ├── shared.proto
3535
├── a2l_grpc_(os)_(arch).h
3636
├── a2l_grpc_(os)_(arch).dll
37+
├── a2l_grpc_(os)_(arch).dylib
3738
└── a2l_grpc_(os)_(arch).so
3839
```
3940
The *a2l_grpc.tar.gz/protobuf* folder contains all the *gRPC* data structure definitions. It will be used to generate
@@ -58,6 +59,7 @@ src
5859
| | ├── shared.proto
5960
| ├── a2l_grpc_(os)_(arch).h
6061
| ├── a2l_grpc_(os)_(arch).dll
62+
| ├── a2l_grpc_(os)_(arch).dylib
6163
| └── a2l_grpc_(os)_(arch).so
6264
├── main.py
6365
```
@@ -76,6 +78,7 @@ Now that all sources are available, we can start writing the *gRPC* client in *P
7678
```python
7779
import ctypes
7880
import os
81+
import sys
7982

8083
from pya2l.protobuf.API_pb2 import *
8184
from pya2l.protobuf.API_pb2_grpc import *
@@ -85,7 +88,10 @@ def get_shared_object_name() -> str:
8588
if os.name == 'nt':
8689
shared_object = 'a2l_grpc_windows_amd64.dll'
8790
elif os.name == 'posix':
88-
shared_object = 'a2l_grpc_linux_amd64.so'
91+
if sys.platform == 'darwin':
92+
shared_object = 'a2l_grpc_darwin_arm64.dylib'
93+
else:
94+
shared_object = 'a2l_grpc_linux_amd64.so'
8995
else:
9096
raise Exception(f'unsupported operating system {os.name}')
9197
return shared_object

0 commit comments

Comments
 (0)