Skip to content

Commit 70d1a8e

Browse files
committed
oh come
1 parent 940d455 commit 70d1a8e

5 files changed

Lines changed: 105 additions & 5 deletions

File tree

.github/workflows/build.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,51 @@ jobs:
2929
if: contains(matrix.os, 'ubuntu')
3030
run: |
3131
sudo apt-get update
32-
sudo apt-get install -y libgles2-mesa-dev glslang-tools
32+
sudo apt-get install -y libgles2-mesa-dev libvulkan-dev glslang-tools
3333
3434
- name: Install Dependencies (macOS)
3535
if: contains(matrix.os, 'macos')
3636
run: brew install glslang
3737

38-
- name: Install Dependencies (Windows)
38+
- name: Install Vulkan SDK (Windows)
39+
if: contains(matrix.os, 'windows')
40+
shell: pwsh
41+
run: |
42+
$ErrorActionPreference = 'Stop'
43+
44+
function Find-VulkanSdkDir {
45+
$patterns = @(
46+
'C:\VulkanSDK\*',
47+
'C:\Program Files\VulkanSDK\*',
48+
"$env:USERPROFILE\VulkanSDK\*"
49+
)
50+
foreach ($pattern in $patterns) {
51+
$dir = Get-ChildItem -Path $pattern -Directory -ErrorAction SilentlyContinue |
52+
Sort-Object Name -Descending | Select-Object -First 1
53+
if ($dir) { return $dir.FullName }
54+
}
55+
return $null
56+
}
57+
58+
$installed = $false
59+
try {
60+
winget install --id KhronosGroup.VulkanSDK --accept-package-agreements --accept-source-agreements --disable-interactivity
61+
if ($LASTEXITCODE -eq 0) { $installed = $true }
62+
} catch {
63+
Write-Host "winget install failed: $($_.Exception.Message)"
64+
}
65+
if (-not $installed) {
66+
choco install vulkan-sdk -y
67+
}
68+
69+
$sdkDir = Find-VulkanSdkDir
70+
if (-not $sdkDir) { throw "Vulkan SDK not found after installation." }
71+
72+
Write-Host "Using Vulkan SDK: $sdkDir"
73+
"VULKAN_SDK=$sdkDir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
74+
(Join-Path $sdkDir 'Bin') | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
75+
76+
- name: Install glslang (Windows)
3977
if: contains(matrix.os, 'windows')
4078
shell: pwsh
4179
run: |
@@ -84,7 +122,14 @@ jobs:
84122
$toolDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
85123
& $tool.FullName --version
86124
125+
- name: Build Desktop (Require Vulkan on windows-x64/linux-x64)
126+
if: matrix.os == 'windows-latest' || matrix.os == 'ubuntu-latest'
127+
env:
128+
LIVE2D_REQUIRE_VULKAN: "ON"
129+
run: python3 scripts/build.py desktop
130+
87131
- name: Build Desktop
132+
if: matrix.os != 'windows-latest' && matrix.os != 'ubuntu-latest'
88133
run: python3 scripts/build.py desktop
89134

90135
- name: Upload Artifacts

.github/workflows/release.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,51 @@ jobs:
3939
if: contains(matrix.os, 'ubuntu')
4040
run: |
4141
sudo apt-get update
42-
sudo apt-get install -y libgles2-mesa-dev glslang-tools
42+
sudo apt-get install -y libgles2-mesa-dev libvulkan-dev glslang-tools
4343
4444
- name: Install Dependencies (macOS)
4545
if: contains(matrix.os, 'macos')
4646
run: brew install glslang
4747

48-
- name: Install Dependencies (Windows)
48+
- name: Install Vulkan SDK (Windows)
49+
if: contains(matrix.os, 'windows')
50+
shell: pwsh
51+
run: |
52+
$ErrorActionPreference = 'Stop'
53+
54+
function Find-VulkanSdkDir {
55+
$patterns = @(
56+
'C:\VulkanSDK\*',
57+
'C:\Program Files\VulkanSDK\*',
58+
"$env:USERPROFILE\VulkanSDK\*"
59+
)
60+
foreach ($pattern in $patterns) {
61+
$dir = Get-ChildItem -Path $pattern -Directory -ErrorAction SilentlyContinue |
62+
Sort-Object Name -Descending | Select-Object -First 1
63+
if ($dir) { return $dir.FullName }
64+
}
65+
return $null
66+
}
67+
68+
$installed = $false
69+
try {
70+
winget install --id KhronosGroup.VulkanSDK --accept-package-agreements --accept-source-agreements --disable-interactivity
71+
if ($LASTEXITCODE -eq 0) { $installed = $true }
72+
} catch {
73+
Write-Host "winget install failed: $($_.Exception.Message)"
74+
}
75+
if (-not $installed) {
76+
choco install vulkan-sdk -y
77+
}
78+
79+
$sdkDir = Find-VulkanSdkDir
80+
if (-not $sdkDir) { throw "Vulkan SDK not found after installation." }
81+
82+
Write-Host "Using Vulkan SDK: $sdkDir"
83+
"VULKAN_SDK=$sdkDir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
84+
(Join-Path $sdkDir 'Bin') | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
85+
86+
- name: Install glslang (Windows)
4987
if: contains(matrix.os, 'windows')
5088
shell: pwsh
5189
run: |
@@ -94,7 +132,14 @@ jobs:
94132
$toolDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
95133
& $tool.FullName --version
96134
135+
- name: Build Desktop (Require Vulkan on windows-x64/linux-x64)
136+
if: matrix.os == 'windows-latest' || matrix.os == 'ubuntu-latest'
137+
env:
138+
LIVE2D_REQUIRE_VULKAN: "ON"
139+
run: python3 scripts/build.py desktop
140+
97141
- name: Build Desktop
142+
if: matrix.os != 'windows-latest' && matrix.os != 'ubuntu-latest'
98143
run: python3 scripts/build.py desktop
99144

100145
- name: Upload Artifacts

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ target/
1818

1919
# Python
2020
__pycache__/
21+
*.pyc
2122
# Java crash logs
2223
hs_err_pid*.log
2324
replay_pid*.log

native/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ project(live2d_jni)
33

44
set(CMAKE_CXX_STANDARD 14)
55
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
6+
option(LIVE2D_REQUIRE_VULKAN "Fail configure if Vulkan backend cannot be enabled on supported desktop targets." OFF)
67

78
find_package(JNI REQUIRED)
89

@@ -28,6 +29,10 @@ elseif((WIN32 OR (UNIX AND NOT APPLE)) AND CMAKE_SIZEOF_VOID_P EQUAL 8)
2829
message(STATUS "Vulkan backend disabled: only linux-x64/windows-x64 are supported.")
2930
endif()
3031

32+
if(LIVE2D_REQUIRE_VULKAN AND (WIN32 OR (UNIX AND NOT APPLE)) AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND LIVE2D_ARCH_IS_X64 AND NOT ENABLE_VULKAN)
33+
message(FATAL_ERROR "LIVE2D_REQUIRE_VULKAN=ON but Vulkan SDK/dev package was not found. Install Vulkan SDK (Windows) or libvulkan-dev (Linux x64).")
34+
endif()
35+
3136
if(WIN32)
3237
set(CORE_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../sdk/Core/lib/windows/x86_64/143/Live2DCubismCore_MD.lib")
3338
set(SHIM_SRC "src/gles2_shim.c")

scripts/build.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ def build_desktop():
139139
root = os.getcwd()
140140
nb = os.path.join(root, "native/build")
141141
os.makedirs(nb, exist_ok=True)
142-
run_cmd(["cmake", ".."], nb)
142+
cmake_cmd = ["cmake", ".."]
143+
require_vulkan = os.environ.get("LIVE2D_REQUIRE_VULKAN", "").strip().lower()
144+
if require_vulkan in ("1", "true", "on", "yes"):
145+
cmake_cmd.append("-DLIVE2D_REQUIRE_VULKAN=ON")
146+
run_cmd(cmake_cmd, nb)
143147
run_cmd(["cmake", "--build", ".", "--config", "Release"], nb)
144148

145149
out_res = os.path.join(root, "out", "native_res", tag)

0 commit comments

Comments
 (0)