Skip to content

Commit

Permalink
add support for building artfact for osx-arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
smdn committed May 26, 2024
1 parent 7a04e99 commit f3729f8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
runs-ons: ${{ steps.runs-on-os-list.outputs.runs-ons }}
base-branch: ${{ steps.base-branch.outputs.base-branch }}
env:
RUNS_ON_OS_LIST_DEFAULT: "['ubuntu-22.04', 'ubuntu-20.04', 'macos-12']"
RUNS_ON_OS_LIST_DEFAULT: "['ubuntu-22.04', 'ubuntu-20.04', 'macos-14']"

steps:
- name: Determine OS list which run the build on
Expand Down Expand Up @@ -94,6 +94,11 @@ jobs:
$target_rid = 'ubuntu.20.04'
}
elseif ('${{ matrix.os }}' -eq 'macos-12') {
# osx-x64
$target_rid = 'osx'
}
elseif ('${{ matrix.os }}' -eq 'macos-14') {
# osx-arm64
$target_rid = 'osx'
}
Expand Down
15 changes: 13 additions & 2 deletions src/highlight/configure.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function Build-ConfigMk {
$lines += "NATIVE_BINARY_OUTPUT_PATH_UBUNTU_22_04_X64 := ${NATIVE_BINARY_OUTPUT_BASEDIR}ubuntu.22.04-x64/native/lib${BINDINGS_DLLIMPORTNAME}.so"
$lines += "NATIVE_BINARY_OUTPUT_PATH_UBUNTU_20_04_X64 := ${NATIVE_BINARY_OUTPUT_BASEDIR}ubuntu.20.04-x64/native/lib${BINDINGS_DLLIMPORTNAME}.so"
$lines += "NATIVE_BINARY_OUTPUT_PATH_MACOS_X64 := ${NATIVE_BINARY_OUTPUT_BASEDIR}osx-x64/native/lib${BINDINGS_DLLIMPORTNAME}.dylib"
$lines += "NATIVE_BINARY_OUTPUT_PATH_MACOS_ARM64 := ${NATIVE_BINARY_OUTPUT_BASEDIR}osx-arm64/native/lib${BINDINGS_DLLIMPORTNAME}.dylib"
$lines += "NATIVE_BINARY_OUTPUT_PATH_WINDOWS_X64 := ${NATIVE_BINARY_OUTPUT_BASEDIR}win-x64/native/${BINDINGS_DLLIMPORTNAME}.dll"
$lines += "NATIVE_BINARY_OUTPUT_PATH_LUA_WINDOWS_X64 := ${NATIVE_BINARY_OUTPUT_BASEDIR}win-x64/native/${MINGW_LUA_DLL_FILENAME}"

Expand Down Expand Up @@ -125,8 +126,18 @@ function Build-ConfigMk {
elseif (
[System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::OSX)
) {
# Target 'osx-x64'
$artifact_rid = "osx-x64"
if (
[System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture -eq [System.Runtime.InteropServices.Architecture]::Arm64
) {
# Target 'osx-arm64'
$artifact_rid = "osx-arm64"
$lines += "NATIVE_BINARIES := `$(NATIVE_BINARY_OUTPUT_PATH_MACOS_ARM64)"
}
else {
# Target 'osx-x64'
$artifact_rid = "osx-x64"
}

$lines += "NATIVE_BINARIES := `$(NATIVE_BINARY_OUTPUT_PATH_MACOS_X64)"
}
else {
Expand Down
11 changes: 11 additions & 0 deletions src/highlight/native-binaries.mk
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ ${NATIVE_BINARY_OUTPUT_PATH_MACOS_X64}:
NATIVE_BINARY_OUTPUT_PATH="$@" \
library-native

${NATIVE_BINARY_OUTPUT_PATH_MACOS_ARM64}: CXX := g++
${NATIVE_BINARY_OUTPUT_PATH_MACOS_ARM64}: CFLAGS := $(CFLAGS_COMMON) -arch arm64
${NATIVE_BINARY_OUTPUT_PATH_MACOS_ARM64}: LDFLAGS := -shared -dynamiclib
${NATIVE_BINARY_OUTPUT_PATH_MACOS_ARM64}:
$(MAKE) -f $(THIS_FILE) \
CXX="$(CXX)" \
CFLAGS="$(CFLAGS)" \
LDFLAGS="$(LDFLAGS)" \
NATIVE_BINARY_OUTPUT_PATH="$@" \
library-native

highlight-x64.res: highlight.rc
x86_64-w64-mingw32-windres --input=$< --input-format=rc --output=$@ --output-format=coff

Expand Down

0 comments on commit f3729f8

Please sign in to comment.