Skip to content

Commit

Permalink
Merge pull request #17 from victor-abz/ft-work-on-darwin
Browse files Browse the repository at this point in the history
Add darwin(Mac) Support
  • Loading branch information
krypton-byte authored Mar 3, 2024
2 parents 891edc1 + 05dbf64 commit db76bcc
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 195 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,47 @@ jobs:
with:
name: Linux
path: neonize/*.so
darwin:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '^1.21.5'
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y
poetry install
poetry run version ${{ github.event.inputs.version }}
- name: build
run: |
# Set necessary environment variables for building on Darwin
export CGO_ENABLED=1
# Build for Darwin (macOS)
# AMD64/X86_64
export GOOS=darwin
export GOARCH=amd64
export CC=$(which clang)
export CXX=$(which clang++)
poetry run build goneonize
#ARM64/AARCH64
export GOOS=darwin
export GOARCH=arm64
export CC=$(which clang)
export CXX=$(which clang++)
poetry run build goneonize
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: Darwin
path: neonize/*.dylib

release:
runs-on: ubuntu-latest
needs: [android, zig, linux]
Expand All @@ -170,6 +211,7 @@ jobs:
files: |
sharedlib/*.so
sharedlib/*.dll
sharedlib/*.dylib
generate_release_notes: true
tag_name: ${{ github.event.inputs.version }}
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __pycache__/

# C extensions
*.so
*.dylib

# Distribution / packaging
.Python
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions goneonize/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def generated_name(os_name="", arch_name=""):
ext = "dll"
elif os_name == "linux":
ext = "so"
elif os_name == "darwin":
ext = "dylib"
else:
ext = "so"
return f"neonize-{os_name}-{arch_name}.{ext}"
Expand Down Expand Up @@ -74,6 +76,7 @@ def build_neonize():
arch_name = os.environ.get("GOARCH") or platform.machine().lower()
print(f"os: {os_name}, arch: {arch_name}")
filename = generated_name(os_name, arch_name)
print(filename)
subprocess.call(
shlex.split(f"go build -buildmode=c-shared -ldflags=-s -o {filename} "),
cwd=cwd,
Expand Down
1 change: 1 addition & 0 deletions neonize/_binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def load_goneonize():
try:
gocode = ctypes.CDLL(f"{root_dir}/{generated_name()}")
gocode.GetVersion.restype = ctypes.c_char_p
print(f"{root_dir}/{generated_name()}")
if gocode.GetVersion().decode() != importlib.metadata.version("neonize"):
download()
raise Exception("Unmatched version")
Expand Down
2 changes: 2 additions & 0 deletions neonize/utils/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def generated_name(os_name="", arch_name=""):
if is_android:
os_name = "android"
ext = "so"
elif os_name == "darwin":
ext = "dylib"
else:
ext = "so"
return f"neonize-{os_name}-{arch_name}.{ext}"
400 changes: 205 additions & 195 deletions poetry.lock

Large diffs are not rendered by default.

0 comments on commit db76bcc

Please sign in to comment.