-
Notifications
You must be signed in to change notification settings - Fork 1
195 lines (177 loc) · 8.59 KB
/
build-vcpkg.yml
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Build using vcpkg
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
BUILD_TYPE: Release
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, windows-2019, windows-2022, macos-latest ]
runs-on: ${{ matrix.os }}
name: "${{ github.workflow }}: ${{ matrix.os }}"
env:
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg/bincache
sgl_REPO_DIR: ${{ github.workspace }}/sgl-repo
sgl_DIR: ${{ github.workspace }}/sgl
steps:
- name: Set up vcpkg environment variables
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
echo "VCPKG_COPY_TRIPLET=x64-linux" >> $GITHUB_ENV
echo "VCPKG_DEFAULT_TRIPLET=x64-linux-release-only" >> $GITHUB_ENV
elif [ "$RUNNER_OS" == "Windows" ]; then
echo "VCPKG_COPY_TRIPLET=x64-windows" >> $GITHUB_ENV
echo "VCPKG_DEFAULT_TRIPLET=x64-windows-release-only" >> $GITHUB_ENV
elif [ "$RUNNER_OS" == "macOS" ]; then
echo "VCPKG_COPY_TRIPLET=x64-osx" >> $GITHUB_ENV
echo "VCPKG_DEFAULT_TRIPLET=x64-osx-release-only" >> $GITHUB_ENV
else
echo "$RUNNER_OS is not supported."
exit 1
fi
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/checkout@v2
with:
repository: chrismile/sgl
path: sgl-repo
submodules: true
- uses: lukka/get-cmake@latest
- name: Install Vulkan SDK
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
distro_code_name="$(lsb_release -c | grep -oP "\:\s+\K\S+")"
os_arch="$(uname -m)"
if ! curl -s -I "https://packages.lunarg.com/vulkan/dists/${distro_code_name}/" | grep "2 404" > /dev/null; then
echo "Installing Vulkan SDK from a PPA..."
wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-${distro_code_name}.list \
https://packages.lunarg.com/vulkan/lunarg-vulkan-${distro_code_name}.list
sudo apt update
sudo apt install vulkan-sdk
else
echo "Unpacking Vulkan SDK from an archive file..."
curl --silent --show-error --fail -O https://sdk.lunarg.com/sdk/download/latest/linux/vulkan-sdk.tar.gz
mkdir -p VulkanSDK
tar -xf vulkan-sdk.tar.gz -C VulkanSDK
# Fix pkgconfig file.
shaderc_pkgconfig_file="VulkanSDK/$(ls VulkanSDK)/$os_arch/lib/pkgconfig/shaderc.pc"
if [ -f $shaderc_pkgconfig_file ]; then
prefix_path=$(realpath "VulkanSDK/$(ls VulkanSDK)/$os_arch")
sed -i '3s;.*;prefix=\"'$prefix_path'\";' "$shaderc_pkgconfig_file"
sed -i '5s;.*;libdir=${prefix}/lib;' "$shaderc_pkgconfig_file"
echo "PKG_CONFIG_PATH=\"$(realpath "VulkanSDK/$(ls VulkanSDK)/$os_arch/lib/pkgconfig")\"" >> $GITHUB_ENV
fi
fi
# Also install the dependencies for building GLEW here.
sudo apt install libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev
elif [ "$RUNNER_OS" == "Windows" ]; then
# Chocolatey is broken as of 2023-07-07
#choco install vulkan-sdk
curl -O https://sdk.lunarg.com/sdk/download/1.3.250.1/windows/VulkanSDK-1.3.250.1-Installer.exe
./VulkanSDK-1.3.250.1-Installer.exe --accept-licenses --default-answer --confirm-command install
elif [ "$RUNNER_OS" == "macOS" ]; then
vulkansdk_filename=$(curl -sIkL https://sdk.lunarg.com/sdk/download/latest/mac/vulkan-sdk.dmg | sed -r '/filename=/!d;s/.*filename=(.*)$/\1/')
VULKAN_SDK_VERSION=$(echo $vulkansdk_filename | sed -r 's/^.*vulkansdk-macos-(.*)\.dmg.*$/\1/')
curl -O https://sdk.lunarg.com/sdk/download/latest/mac/vulkan-sdk.dmg
sudo hdiutil attach vulkan-sdk.dmg
# The directory was changed from '/Volumes/VulkanSDK' to, e.g., 'vulkansdk-macos-1.3.261.0'.
vulkan_dir=$(find /Volumes -maxdepth 1 -name '[Vv]ulkan*' -not -path "/Volumes/VMware*" || true)
sudo "${vulkan_dir}/InstallVulkan.app/Contents/MacOS/InstallVulkan" \
--root ~/VulkanSDK/$VULKAN_SDK_VERSION --accept-licenses --default-answer --confirm-command install
cd ~/VulkanSDK/$VULKAN_SDK_VERSION
sudo ./install_vulkan.py || true
sudo hdiutil unmount "${vulkan_dir}"
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
brew update
#rm /usr/local/bin/2to3 || true
#rm /usr/local/bin/idle3 || true
#rm /usr/local/bin/pydoc3 || true
#rm /usr/local/bin/python3 || true
#rm /usr/local/bin/python3-config || true
brew install --force --overwrite llvm libomp pkg-config
else
echo "$RUNNER_OS is not supported."
exit 1
fi
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: '4cac260c4b7331538d31886f57739fea0bffa27e'
doNotCacheOnWorkflowFailure: true
- name: Create custom vcpkg triplet
run: |
cp "${{env.VCPKG_ROOT}}/triplets/${{env.VCPKG_COPY_TRIPLET}}.cmake" "${{env.VCPKG_ROOT}}/triplets/community/${{env.VCPKG_DEFAULT_TRIPLET}}.cmake"
echo "set(VCPKG_BUILD_TYPE release)" >> "${{env.VCPKG_ROOT}}/triplets/community/${{env.VCPKG_DEFAULT_TRIPLET}}.cmake"
- name: Configure CMake (sgl)
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
if [ "${{env.PKG_CONFIG_PATH}}" != "" ]; then
VK_LAYER_PATH=""
source "VulkanSDK/$(ls VulkanSDK)/setup-env.sh"
export PKG_CONFIG_PATH="${{env.PKG_CONFIG_PATH}}"
else
export VULKAN_SDK="/usr"
fi
elif [ "$RUNNER_OS" == "Windows" ]; then
export VULKAN_SDK="C:/VulkanSDK/$(ls C:/VulkanSDK)"
elif [ "$RUNNER_OS" == "macOS" ]; then
source "$HOME/VulkanSDK/$(ls $HOME/VulkanSDK)/setup-env.sh"
fi
cmake "${{env.sgl_REPO_DIR}}" -B "${{env.sgl_REPO_DIR}}/build" -DCMAKE_TOOLCHAIN_FILE="${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DVCPKG_TARGET_TRIPLET=${{env.VCPKG_DEFAULT_TRIPLET}} -DCMAKE_INSTALL_PREFIX="${{env.sgl_DIR}}"
- name: Build (sgl)
run: cmake --build ${{env.sgl_REPO_DIR}}/build --config ${{env.BUILD_TYPE}} --parallel 4
- name: Install (sgl)
run: cmake --build ${{env.sgl_REPO_DIR}}/build --config ${{env.BUILD_TYPE}} --target install
- name: Configure CMake (CloudRendering)
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
if [ "${{matrix.linking}}" == "dynamic" ]; then
cp "${{env.sgl_REPO_DIR}}/build/libsgl.so" "${{env.sgl_DIR}}/lib/libsgl.so"
fi
if [ "${{env.PKG_CONFIG_PATH}}" != "" ]; then
VK_LAYER_PATH=""
source "VulkanSDK/$(ls VulkanSDK)/setup-env.sh"
export PKG_CONFIG_PATH="${{env.PKG_CONFIG_PATH}}"
else
export VULKAN_SDK="/usr"
fi
elif [ "$RUNNER_OS" == "Windows" ]; then
export VULKAN_SDK="C:/VulkanSDK/$(ls C:/VulkanSDK)"
elif [ "$RUNNER_OS" == "macOS" ]; then
source "$HOME/VulkanSDK/$(ls $HOME/VulkanSDK)/setup-env.sh"
fi
cmake -B "${{github.workspace}}/build" -DCMAKE_TOOLCHAIN_FILE="${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DVCPKG_TARGET_TRIPLET=${{env.VCPKG_DEFAULT_TRIPLET}} -Dsgl_DIR=${{env.sgl_DIR}}/lib/cmake/sgl
- name: Build (CloudRendering)
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
if [ "${{env.PKG_CONFIG_PATH}}" != "" ]; then
VK_LAYER_PATH=""
source "VulkanSDK/$(ls VulkanSDK)/setup-env.sh"
export PKG_CONFIG_PATH="${{env.PKG_CONFIG_PATH}}"
else
export VULKAN_SDK="/usr"
fi
fi
cmake --build "${{github.workspace}}/build" --config ${{env.BUILD_TYPE}} --parallel 4
- name: Remove symbolic links before caching (Windows only)
if: runner.os == 'Windows'
shell: bash
run: |
find "${{env.VCPKG_ROOT}}/buildtrees" -type l -exec echo {} \;
find "${{env.VCPKG_ROOT}}/buildtrees" -type l -exec rm {} \;
# Recently, there were some "There is not enough space on the disk" errors after having added OpenCL support.
# Remove some temporary files to make sure the vcpkg build artifacts can be packaged without out-of-memory errors.
rm -rf "${{env.VCPKG_ROOT}}/downloads"