Skip to content

Commit fae8a42

Browse files
committed
add MoltenVK
1 parent 87132ce commit fae8a42

2 files changed

Lines changed: 186 additions & 0 deletions

File tree

configs/libs/moltenvk.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#! /usr/bin/env bash
2+
#
3+
# Copyright (C) 2021 Matt Reach<qianlongxu@gmail.com>
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
#
18+
19+
export LIB_NAME='MoltenVK'
20+
export LIPO_LIBS="libMoltenVK"
21+
export GIT_LOCAL_REPO=extra/MoltenVK
22+
export GIT_COMMIT=v1.4.1
23+
export REPO_DIR=MoltenVK
24+
export GIT_REPO_VERSION=v1.4.1
25+
26+
# you can export GIT_MOLTENVK_UPSTREAM=git@xx:yy/MoltenVK.git use your mirror
27+
if [[ "$GIT_MOLTENVK_UPSTREAM" != "" ]] ;then
28+
export GIT_UPSTREAM="$GIT_MOLTENVK_UPSTREAM"
29+
else
30+
export GIT_UPSTREAM=https://github.com/KhronosGroup/MoltenVK.git
31+
fi
32+
33+
# pre compiled
34+
export PRE_COMPILE_TAG_TVOS=
35+
export PRE_COMPILE_TAG_MACOS=
36+
export PRE_COMPILE_TAG_IOS=
37+
export PRE_COMPILE_TAG_ANDROID=

do-compile/apple/moltenvk.sh

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#! /usr/bin/env bash
2+
#
3+
# Copyright (C) 2021 Matt Reach<qianlongxu@gmail.com>
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
set -e
19+
20+
THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd)
21+
cd "$THIS_DIR"
22+
23+
echo "----------------------"
24+
echo "[*] fetch dependencies for $LIB_NAME"
25+
echo "----------------------"
26+
27+
cd $MR_BUILD_SOURCE
28+
if [ -d "External" ]; then
29+
echo "dependencies already exist"
30+
else
31+
if [ -f "./fetchDependencies" ]; then
32+
echo "fetching dependencies..."
33+
chmod +x ./fetchDependencies
34+
./fetchDependencies
35+
else
36+
echo "fetchDependencies script not found, trying with CMake..."
37+
fi
38+
fi
39+
40+
cd "$THIS_DIR"
41+
42+
pf=
43+
dest=
44+
scheme_suffix=
45+
arch_param=
46+
if [[ "$MR_PLAT" == 'ios' ]];then
47+
if [[ $_MR_ARCH == 'arm64_simulator' ]];then
48+
pf='SIMULATORARM64'
49+
dest='iOS Simulator'
50+
arch_param='arm64'
51+
elif [[ $_MR_ARCH == 'x86_64_simulator' ]];then
52+
pf='SIMULATOR64'
53+
dest='iOS Simulator'
54+
arch_param='x86_64'
55+
else
56+
pf='OS64'
57+
dest='iOS'
58+
arch_param='arm64'
59+
fi
60+
scheme_suffix='iOS only'
61+
export MR_DEPLOYMENT_TARGET_VER=14.0
62+
elif [[ "$MR_PLAT" == 'tvos' ]];then
63+
if [[ $_MR_ARCH == 'arm64_simulator' ]];then
64+
pf='SIMULATORARM64_TVOS'
65+
dest='tvOS Simulator'
66+
arch_param='arm64'
67+
elif [[ $_MR_ARCH == 'x86_64_simulator' ]];then
68+
pf='SIMULATOR_TVOS'
69+
dest='tvOS Simulator'
70+
arch_param='x86_64'
71+
else
72+
pf='TVOS'
73+
dest='tvOS'
74+
arch_param='arm64'
75+
fi
76+
scheme_suffix='tvOS only'
77+
export MR_DEPLOYMENT_TARGET_VER=14.0
78+
elif [[ "$MR_PLAT" == 'macos' ]];then
79+
if [[ $_MR_ARCH == 'arm64' ]];then
80+
pf='MAC_ARM64'
81+
arch_param='arm64'
82+
elif [[ $_MR_ARCH == 'x86_64' ]];then
83+
pf='MAC'
84+
arch_param='x86_64'
85+
fi
86+
dest='macOS'
87+
scheme_suffix='macOS only'
88+
export MR_DEPLOYMENT_TARGET_VER=11.0
89+
fi
90+
91+
xc_proj="MoltenVKPackaging.xcodeproj"
92+
scheme="MoltenVK Package ($scheme_suffix)"
93+
94+
echo "----------------------"
95+
echo "[*] configurate $LIB_NAME"
96+
echo "[*] PLATFORM: $pf"
97+
echo "[*] destination: $dest"
98+
echo "[*] deployment target: $MR_DEPLOYMENT_TARGET_VER"
99+
echo "----------------------"
100+
101+
echo "----------------------"
102+
echo "[*] compile $LIB_NAME"
103+
echo "[*] arch: $arch_param"
104+
echo "----------------------"
105+
106+
mkdir -p "$MR_BUILD_PREFIX/lib"
107+
108+
xcodebuild -project "$MR_BUILD_SOURCE/$xc_proj" \
109+
-scheme "$scheme" \
110+
-destination "generic/platform=$dest" \
111+
-configuration Release \
112+
-parallelizeTargets \
113+
ONLY_ACTIVE_ARCH=YES \
114+
ARCHS="$arch_param" \
115+
CODE_SIGNING_ALLOWED=NO \
116+
build || true
117+
118+
dd_dir=$(find ~/Library/Developer/Xcode/DerivedData -maxdepth 1 -type d -name "MoltenVKPackaging-*" 2>/dev/null | head -1)/Build/Products/Release
119+
120+
if [[ -f "$dd_dir/libMoltenVK.a" ]]; then
121+
cp "$dd_dir/libMoltenVK.a" "$MR_BUILD_PREFIX/lib/"
122+
echo "Copied libMoltenVK.a to $MR_BUILD_PREFIX/lib/"
123+
else
124+
echo "libMoltenVK.a not found in $dd_dir"
125+
exit 1
126+
fi
127+
128+
alt_header_dir="$MR_BUILD_SOURCE/MoltenVK/include"
129+
if [[ -d "$alt_header_dir" ]]; then
130+
mkdir -p "$MR_BUILD_PREFIX/include"
131+
# -L: follow symbolic links, copy actual files instead of symlinks
132+
# This is needed because the source includes symlinks to External dependencies
133+
cp -RL "$alt_header_dir"/* "$MR_BUILD_PREFIX/include/"
134+
echo "Copied headers from source to $MR_BUILD_PREFIX/include/"
135+
fi
136+
137+
vulkan_headers="$MR_BUILD_SOURCE/External/Vulkan-Headers/include/vulkan"
138+
if [[ -d "$vulkan_headers" ]]; then
139+
mkdir -p "$MR_BUILD_PREFIX/include/vulkan"
140+
cp -RL "$vulkan_headers"/* "$MR_BUILD_PREFIX/include/vulkan/"
141+
echo "Copied Vulkan headers to $MR_BUILD_PREFIX/include/vulkan/"
142+
fi
143+
144+
vk_video_headers="$MR_BUILD_SOURCE/External/Vulkan-Headers/include/vk_video"
145+
if [[ -d "$vk_video_headers" ]]; then
146+
mkdir -p "$MR_BUILD_PREFIX/include/vk_video"
147+
cp -RL "$vk_video_headers"/* "$MR_BUILD_PREFIX/include/vk_video/"
148+
echo "Copied vk_video headers to $MR_BUILD_PREFIX/include/vk_video/"
149+
fi

0 commit comments

Comments
 (0)