Skip to content

Commit

Permalink
Merge pull request #8 from frenzibyte/iossimulator-arm64
Browse files Browse the repository at this point in the history
Add arm64 simulator target to iOS builds
  • Loading branch information
smoogipoo authored Aug 9, 2024
2 parents ca6cec7 + bfc1ba2 commit 0c0fcee
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: CI
on:
workflow_dispatch:
create: # when tags are created
push:
branches: [ master ]
Expand All @@ -9,6 +10,7 @@ jobs:
native_builds:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
Expand All @@ -35,7 +37,7 @@ jobs:
build_args: release linux-x64
build_target: linux-x64
artifact_name: build/Release/linux-x64/libveldrid-spirv.so
- os: macos-11
- os: macos-latest
build_args: release osx 'arm64;x86_64'
build_target: osx
artifact_name: build/Release/osx/libveldrid-spirv.dylib
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required (VERSION 3.0)
cmake_policy(SET CMP0057 NEW)

if(IOS)
include(ios/ios.toolchain.cmake)
Expand Down
2 changes: 1 addition & 1 deletion build-native.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set _CMAKE_GENERATOR_PLATFORM=x64
set _NDK_DIR=
set _ANDROID_ABI=arm64-v8a
set _OS_DIR=
set _ANDROID_PLATFORM=android-16
set _ANDROID_PLATFORM=android-21

:ArgLoop
if [%1] == [] goto LocateVS
Expand Down
28 changes: 24 additions & 4 deletions build-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ while :; do
ios)
_CMakeEnableBitcode=-DENABLE_BITCODE=0
_CMakeBuildTarget=veldrid-spirv
_CMakeGenerator="-G Xcode -T buildsystem=1"
_CMakeGenerator="-G Xcode"
_CMakeExtraBuildArgs="--config Release"
_OSDir=ios
;;
Expand Down Expand Up @@ -64,15 +64,35 @@ if [[ $_OSDir == "ios" ]]; then

popd

mkdir -p simulator-build
pushd simulator-build
mkdir -p simulator-build-arm64
pushd simulator-build-arm64

cmake ../../../.. -DIOS=ON -DCMAKE_BUILD_TYPE=$_CMakeBuildType $_CMakeGenerator -DPLATFORM=SIMULATORARM64 -DDEPLOYMENT_TARGET=13.4 $_CMakeEnableBitcode -DPYTHON_EXECUTABLE=$_PythonExePath -DCMAKE_OSX_ARCHITECTURES="$_CMakeOsxArchitectures"
cmake --build . --target $_CMakeBuildTarget $_CMakeExtraBuildArgs

popd

mkdir -p simulator-build-x64
pushd simulator-build-x64

cmake ../../../.. -DIOS=ON -DCMAKE_BUILD_TYPE=$_CMakeBuildType $_CMakeGenerator -DPLATFORM=SIMULATOR64 -DDEPLOYMENT_TARGET=13.4 $_CMakeEnableBitcode -DPYTHON_EXECUTABLE=$_PythonExePath -DCMAKE_OSX_ARCHITECTURES="$_CMakeOsxArchitectures"
cmake --build . --target $_CMakeBuildTarget $_CMakeExtraBuildArgs

popd

xcodebuild -create-xcframework -framework ./device-build/Release-iphoneos/veldrid-spirv.framework -framework ./simulator-build/Release-iphonesimulator/veldrid-spirv.framework -output ./veldrid-spirv.xcframework
mkdir -p simulator-build-combined/veldrid-spirv.framework

cp ./simulator-build-arm64/Release-iphonesimulator/veldrid-spirv.framework/Info.plist ./simulator-build-combined/veldrid-spirv.framework/Info.plist

lipo -create \
./simulator-build-arm64/Release-iphonesimulator/veldrid-spirv.framework/veldrid-spirv \
./simulator-build-x64/Release-iphonesimulator/veldrid-spirv.framework/veldrid-spirv \
-output ./simulator-build-combined/veldrid-spirv.framework/veldrid-spirv

xcodebuild -create-xcframework \
-framework ./device-build/Release-iphoneos/veldrid-spirv.framework \
-framework ./simulator-build-combined/veldrid-spirv.framework \
-output ./veldrid-spirv.xcframework
else
cmake ../../.. -DCMAKE_BUILD_TYPE=$_CMakeBuildType $_CMakeGenerator $_CMakeEnableBitcode -DPYTHON_EXECUTABLE=$_PythonExePath -DCMAKE_OSX_ARCHITECTURES="$_CMakeOsxArchitectures"
cmake --build . --target $_CMakeBuildTarget $_CMakeExtraBuildArgs
Expand Down
2 changes: 1 addition & 1 deletion ext/SPIRV-Cross
Submodule SPIRV-Cross updated 1595 files
13 changes: 13 additions & 0 deletions ext/sync-shaderc.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,16 @@
@echo off

python %~dp0update_shaderc_sources.py --dir %~dp0shaderc --file %~dp0known_good.json

:: Android NDK 27+ need this policy set on shaderc (as well as other tools)
move /y %~dp0shaderc\CMakeLists.txt %~dp0shaderc\CMakeLists.tmp

setlocal enableDelayedExpansion
set p=
for /f "tokens=* delims=" %%a in (%~dp0shaderc\CMakeLists.tmp) do (
if "!p!"=="cmake_minimum_required(VERSION 2.8.12)" echo cmake_policy(SET CMP0057 NEW^)>>%~dp0shaderc\CMakeLists.txt
(echo %%a) >>%~dp0shaderc\CMakeLists.txt
set p=%%a
)
del %~dp0shaderc\CMakeLists.tmp

14 changes: 7 additions & 7 deletions ext/update_shaderc_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from operator import attrgetter
import argparse
import json
import distutils.dir_util
import pathlib
import os.path
import subprocess
import sys
Expand All @@ -32,7 +32,7 @@ def command_output(cmd, directory, fail_ok=False):
Raises a RuntimeError if the command fails to launch or otherwise fails.
"""
if VERBOSE:
print('In {d}: {cmd}'.format(d=directory, cmd=cmd))
print(('In {d}: {cmd}'.format(d=directory, cmd=cmd)))
p = subprocess.Popen(cmd,
cwd=directory,
stdout=subprocess.PIPE)
Expand Down Expand Up @@ -75,7 +75,7 @@ def HasCommit(self):
self.commit + '^{commit}'],
cwd=self.subdir)
def Clone(self):
distutils.dir_util.mkpath(self.subdir)
pathlib.Path(self.subdir).mkdir(parents=True, exist_ok=True)
command_output(['git', 'clone', self.GetUrl(), '.'], self.subdir)
def Fetch(self):
command_output(['git', 'fetch', 'known-good'], self.subdir)
Expand All @@ -99,14 +99,14 @@ def main():
help="The file containing known-good commits. Default is \'' + KNOWN_GOOD_FILE + '\'.")
args = parser.parse_args()
commits = GetGoodCommits(args.known_good_file)
distutils.dir_util.mkpath(args.dir)
print('Change directory to {d}'.format(d=args.dir))
pathlib.Path(args.dir).mkdir(parents=True, exist_ok=True)
print(('Change directory to {d}'.format(d=args.dir)))
os.chdir(args.dir)
# Create the subdirectories in sorted order so that parent git repositories
# are created first.
for c in sorted(commits, key=attrgetter('subdir')):
print('Get {n}\n'.format(n=c.name))
print(('Get {n}\n'.format(n=c.name)))
c.Checkout()
sys.exit(0)
if __name__ == '__main__':
main()
main()

0 comments on commit 0c0fcee

Please sign in to comment.