Skip to content

Commit

Permalink
Fix MacOS builds
Browse files Browse the repository at this point in the history
  • Loading branch information
zbx1425 committed Jul 14, 2023
1 parent f37c45f commit 14b970f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
24 changes: 7 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
20 changes: 12 additions & 8 deletions buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand All @@ -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')
}
Expand Down

0 comments on commit 14b970f

Please sign in to comment.