From f3729f8069e2a77f554e4912e668ca7c5088d10e Mon Sep 17 00:00:00 2001 From: smdn Date: Sun, 26 May 2024 18:53:59 +0900 Subject: [PATCH] add support for building artfact for osx-arm64 --- .github/workflows/build-artifact.yml | 7 ++++++- src/highlight/configure.ps1 | 15 +++++++++++++-- src/highlight/native-binaries.mk | 11 +++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-artifact.yml b/.github/workflows/build-artifact.yml index 633f010..557c3c6 100644 --- a/.github/workflows/build-artifact.yml +++ b/.github/workflows/build-artifact.yml @@ -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 @@ -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' } diff --git a/src/highlight/configure.ps1 b/src/highlight/configure.ps1 index fabb37c..0e04784 100755 --- a/src/highlight/configure.ps1 +++ b/src/highlight/configure.ps1 @@ -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}" @@ -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 { diff --git a/src/highlight/native-binaries.mk b/src/highlight/native-binaries.mk index eeefd90..e3f340d 100644 --- a/src/highlight/native-binaries.mk +++ b/src/highlight/native-binaries.mk @@ -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