History

ci/win32: build shaderc

Instead of linking binary blobs, build everything ourselves.

Kacper Michajłow committed 2 years ago

Commit 2b4c64e1 parent 85db6a91 file · +51 −19Browse files

Unified · Split

ci/build-win32.ps1+51−19
@@ -13,28 +13,60 @@ if (-not (Test-Path "$subprojects/packagefiles/ffmpeg")) { · 12 unmodified lines
1313 Invoke-WebRequest -Uri "https://github.com/FFmpeg/FFmpeg/commit/e06ce6d2b45edac4a2df04f304e18d4727417d24.patch" `
1414 -OutFile "$subprojects/packagefiles/ffmpeg/e06ce6d2b45edac4a2df04f304e18d4727417d24.patch"
1515
16−# Download pre-built shaderc, it is quite big to build each time
17−# For download link see https://github.com/google/shaderc/blob/main/downloads.md
18−$url = "https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2019_release.html"
19−$shaderc = "shaderc.zip"
20−$resp = Invoke-WebRequest -Uri $url
21−if ($resp.Content -match '<meta http-equiv="refresh" content="\d+; url=(?<url>[^"]+)"') {
22− $url = $matches['url']
16+# Wrap shaderc to run git-sync-deps and patch unsupported generator expression
17+if (-not (Test-Path "$subprojects/shaderc_cmake")) {
18+ git clone https://github.com/google/shaderc --depth 1 $subprojects/shaderc_cmake
19+ Set-Content -Path "$subprojects/shaderc_cmake/p.diff" -Value @'
20+diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
21+index d44f62a..54d4719 100644
22+--- a/third_party/CMakeLists.txt
23++++ b/third_party/CMakeLists.txt
24+@@ -87,7 +87,11 @@ if (NOT TARGET glslang)
25+ # Glslang tests are off by default. Turn them on if testing Shaderc.
26+ set(GLSLANG_TESTS ON)
27+ endif()
28+- set(GLSLANG_ENABLE_INSTALL $<NOT:${SKIP_GLSLANG_INSTALL}>)
29++ if (SKIP_GLSLANG_INSTALL)
30++ set(GLSLANG_ENABLE_INSTALL OFF)
31++ else()
32++ set(GLSLANG_ENABLE_INSTALL ON)
33++ endif()
34+ add_subdirectory(${SHADERC_GLSLANG_DIR} glslang)
35+ endif()
36+ if (NOT TARGET glslang)
37+'@
38+ git -C $subprojects/shaderc_cmake apply --ignore-whitespace p.diff
2339 }
24−Invoke-WebRequest -Uri $url -OutFile $shaderc
25−if (Test-Path "$subprojects/shaderc") {
26− Remove-Item -LiteralPath "$subprojects/shaderc" -Force -Recurse
40+if (-not (Test-Path "$subprojects/shaderc")) {
41+ New-Item -Path "$subprojects/shaderc" -ItemType Directory | Out-Null
2742 }
28−Expand-Archive -Path $shaderc -DestinationPath "$subprojects/shaderc"
29−Move-Item -Path "$subprojects/shaderc/install/*" -Destination "$subprojects/shaderc"
30−
3143 Set-Content -Path "$subprojects/shaderc/meson.build" -Value @"
32−project('shaderc', 'c', version: '2024.1')
33−cc = meson.get_compiler('c')
34−shaderc_dep = declare_dependency(
35− dependencies: cc.find_library('shaderc_combined', dirs: meson.current_source_dir() / 'lib'),
36− include_directories: include_directories('include')
37−)
44+project('shaderc', 'cpp', version: '2024.1')
45+
46+python = find_program('python3')
47+run_command(python, '../shaderc_cmake/utils/git-sync-deps', check: true)
48+
49+cmake = import('cmake')
50+opts = cmake.subproject_options()
51+opts.add_cmake_defines({
52+ 'CMAKE_MSVC_RUNTIME_LIBRARY': 'MultiThreaded',
53+ 'CMAKE_POLICY_DEFAULT_CMP0091': 'NEW',
54+ 'SHADERC_SKIP_INSTALL': 'ON',
55+ 'SHADERC_SKIP_TESTS': 'ON',
56+ 'SHADERC_SKIP_EXAMPLES': 'ON',
57+ 'SHADERC_SKIP_COPYRIGHT_CHECK': 'ON'
58+})
59+shaderc_proj = cmake.subproject('shaderc_cmake', options: opts)
60+shaderc_dep = declare_dependency(dependencies: [
61+ shaderc_proj.dependency('shaderc'),
62+ shaderc_proj.dependency('shaderc_util'),
63+ shaderc_proj.dependency('SPIRV'),
64+ shaderc_proj.dependency('SPIRV-Tools-static'),
65+ shaderc_proj.dependency('SPIRV-Tools-opt'),
66+ shaderc_proj.dependency('glslang'),
67+ shaderc_proj.dependency('GenericCodeGen'),
68+ shaderc_proj.dependency('MachineIndependent'),
69+])
3870 meson.override_dependency('shaderc', shaderc_dep)
3971 "@
4072

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t