forked from veldrid/veldrid-spirv
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-native.sh
executable file
·101 lines (81 loc) · 3.34 KB
/
build-native.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
scriptPath="$( cd "$(dirname "$0")" ; pwd -P )"
_CMakeBuildType=Debug
_CMakeEnableBitcode=
_OutputPathPrefix=
_CMakeBuildTarget=veldrid-spirv
_CMakeOsxArchitectures=
_CMakeGenerator=
_CMakeExtraBuildArgs=
_OSDir=
while :; do
if [ $# -le 0 ]; then
break
fi
lowerI="$(echo $1 | awk '{print tolower($0)}')"
case $lowerI in
debug|-debug)
_CMakeBuildType=Debug
;;
release|-release)
_CMakeBuildType=Release
;;
osx)
_CMakeOsxArchitectures=$2
_OSDir=osx
shift
;;
linux-x64)
_OSDir=linux-x64
;;
ios)
_CMakeEnableBitcode=-DENABLE_BITCODE=0
_CMakeBuildTarget=veldrid-spirv
_CMakeGenerator="-G Xcode"
_CMakeExtraBuildArgs="--config Release"
_OSDir=ios
;;
*)
__UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
esac
shift
done
_OutputPath=$scriptPath/build/$_CMakeBuildType/$_OSDir
_PythonExePath=$(which python3)
if [[ $_PythonExePath == "" ]]; then
echo Build failed: could not locate python executable.
exit 1
fi
mkdir -p $_OutputPath
pushd $_OutputPath
if [[ $_OSDir == "ios" ]]; then
mkdir -p device-build
pushd device-build
cmake ../../../.. -DIOS=ON -DCMAKE_BUILD_TYPE=$_CMakeBuildType $_CMakeGenerator -DPLATFORM=OS64 -DDEPLOYMENT_TARGET=13.4 $_CMakeEnableBitcode -DPYTHON_EXECUTABLE=$_PythonExePath -DCMAKE_OSX_ARCHITECTURES="$_CMakeOsxArchitectures"
cmake --build . --target $_CMakeBuildTarget $_CMakeExtraBuildArgs
popd
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
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
fi
popd