From 14b970f7280741518bc4a50d99cf43adf3909297 Mon Sep 17 00:00:00 2001 From: zbx1425 Date: Fri, 14 Jul 2023 21:32:42 +0800 Subject: [PATCH] Fix MacOS builds --- .github/workflows/ci.yml | 24 ++++++------------- .../groovy/tool/generator/GenerateLibs.groovy | 20 +++++++++------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f50e3270..481cd48c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,25 +90,12 @@ jobs: sudo make sudo make install - - name: Build Setup Mac xcode - if: matrix.os == 'macos-latest' - run: | - # See https://github.com/actions/virtual-environments/issues/2557 - sudo mv /Library/Developer/CommandLineTools/SDKs/* /tmp - sudo mv /Applications/Xcode.app /Applications/Xcode.app.bak - sudo mv /Applications/Xcode_12.4.app /Applications/Xcode.app - sudo xcode-select -switch /Applications/Xcode.app - /usr/bin/xcodebuild -version - sudo mkdir /opt/freetype - - name: FreeType - Install (MacOS) - if: matrix.os == 'macos-latest' && matrix.freetype == true - working-directory: /opt/freetype + if: matrix.os == 'macos-latest' && matrix.type == 'macosarm64' && matrix.freetype == true run: | - # freetype download and untar and install - sudo wget -O freetype.tar.gz ${{ env.FREETYPE_URL }} - sudo tar -xzf freetype.tar.gz -C . --strip-components=1 - + sudo mkdir /opt/freetype + sudo tar -xzf ./vendor/freetype-2.12.1.tar.gz -C /opt/freetype --strip-components=1 + cd /opt/freetype sudo ./configure CFLAGS="-arch arm64 -arch x86_64" --with-zlib=no --with-bzip2=no --with-png=no --with-harfbuzz=no --with-brotli=no sudo make sudo make install @@ -117,6 +104,9 @@ jobs: - name: Build run: ./gradlew imgui-binding:generateLibs -Denvs=${{ matrix.type }} -Dfreetype=${{ matrix.freetype }} + - name: List Built Files + run: find /tmp/imgui/libsNative + - name: Upload Artifacts uses: actions/upload-artifact@v3 with: diff --git a/buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy b/buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy index e0406101..cd9ece31 100644 --- a/buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy +++ b/buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy @@ -19,6 +19,7 @@ class GenerateLibs extends DefaultTask { private final boolean forWindows = buildEnvs?.contains('windows') private final boolean forLinux = buildEnvs?.contains('linux') private final boolean forMac = buildEnvs?.contains('macos') + private final boolean forMacArm64 = buildEnvs?.contains('macosarm64') private static final boolean isARM = System.getProperty("os.arch").equals("arm") || System.getProperty("os.arch").startsWith("aarch64"); private final boolean isLocal = System.properties.containsKey('local') @@ -104,13 +105,16 @@ class GenerateLibs extends DefaultTask { mac64.linkerFlags = mac64.linkerFlags.replace('10.7', minMacOsVersion) addFreeTypeIfEnabled(mac64) buildTargets += mac64 + } - def macM1 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true, true) - macM1.cppFlags += ' -std=c++14' - macM1.cppFlags = macM1.cppFlags.replace('10.7', minMacOsVersion) - macM1.linkerFlags = macM1.linkerFlags.replace('10.7', minMacOsVersion) - addFreeTypeIfEnabled(macM1) - buildTargets += macM1 + if (forMacArm64) { + def minMacOsVersion = '10.15' + def macArm64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true, true) + macArm64.cppFlags += ' -std=c++14' + macArm64.cppFlags = macArm64.cppFlags.replace('10.7', minMacOsVersion) + macArm64.linkerFlags = macArm64.linkerFlags.replace('10.7', minMacOsVersion) + addFreeTypeIfEnabled(macArm64) + buildTargets += macArm64 } new AntScriptGenerator().generate(buildConfig, buildTargets) @@ -124,10 +128,10 @@ class GenerateLibs extends DefaultTask { BuildExecutor.executeAnt(jniDir + '/build-windows64.xml', commonParams) if (forLinux) BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', commonParams) - if (forMac) { + if (forMac) BuildExecutor.executeAnt(jniDir + '/build-macosx64.xml', commonParams) + if (forMacArm64) BuildExecutor.executeAnt(jniDir + '/build-macosxarm64.xml', commonParams) - } BuildExecutor.executeAnt(jniDir + '/build.xml', '-v', 'pack-natives') }