Skip to content

Commit 8ba1732

Browse files
committed
swiftshader for windows
1 parent ea4b7c6 commit 8ba1732

5 files changed

Lines changed: 34 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ target
44
/aot_artifacts*
55
.webrogue
66
/.cache
7+
/aot
8+
/aot.exe
9+
/vk_swiftshader.dll

crates/aot-compiler/src/utils/artifacts.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ impl Artifacts {
4949
Ok(result)
5050
}
5151

52+
pub fn extract<P: AsRef<std::path::Path>>(
53+
&mut self,
54+
out_path: P,
55+
file: &str,
56+
) -> anyhow::Result<()> {
57+
self.inner
58+
.extract(out_path.as_ref(), file)
59+
.with_context(|| format!("Unable to extract {} from archive", file))?;
60+
Ok(())
61+
}
62+
5263
// pub fn extract<P: AsRef<std::path::Path>>(
5364
// &mut self,
5465
// output_path: P,

crates/aot-compiler/src/windows/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ pub fn build(
6363

6464
let wrapp_size = new_size - original_size;
6565
output_file.write_all(&wrapp_size.to_le_bytes())?;
66+
artifacts.extract(
67+
std::path::absolute(output_file_path)?
68+
.parent()
69+
.ok_or_else(|| anyhow::anyhow!("Path error"))?
70+
.join("vk_swiftshader.dll"),
71+
"x86_64-windows-msvc/vk_swiftshader.dll",
72+
)?;
6673
// println!("Generating stripped WRAPP file...");
6774
// webrogue_wrapp::strip(wrapp_file_path, std::fs::File::create(stripped_wrapp_path)?)?;
6875

windows/msvc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/filtered.txt
66
/lib_content.txt
77
/webrogue_aot_lib.lib
8+
/swiftshader

windows/msvc/build_template.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import os
55
import subprocess
6+
import requests
7+
import zipfile
68

79
template_dir = os.path.dirname(os.path.realpath(__file__))
810
repo_dir = os.path.dirname(os.path.dirname(template_dir))
@@ -199,10 +201,20 @@ def batched(iterable, n):
199201
cwd=str(template_dir),
200202
).check_returncode()
201203

204+
if not os.path.exists(os.path.join(template_dir, "swiftshader")):
205+
os.makedirs(os.path.join(template_dir, "swiftshader"))
206+
if not os.path.exists(os.path.join(template_dir, "swiftshader", "x64.zip")):
207+
response = requests.get("https://github.com/webrogue-runtime/swiftshader-builder/releases/download/latest_build/windows_x64.zip")
208+
with open(os.path.join(template_dir, "swiftshader", "x64.zip"), "bw") as destination:
209+
destination.write(response.content)
210+
202211
webrogue_aot_lib_out_path = os.path.join(out_dir, "webrogue_aot_lib.lib")
203212
if os.path.exists(webrogue_aot_lib_out_path):
204213
os.remove(webrogue_aot_lib_out_path)
205214
os.rename(
206215
webrogue_aot_lib_path,
207216
webrogue_aot_lib_out_path,
208217
)
218+
with zipfile.ZipFile(os.path.join(template_dir, "swiftshader", "x64.zip"), "r") as zip_ref:
219+
with open(os.path.join(out_dir, "vk_swiftshader.dll"), "wb") as destination:
220+
destination.write(zip_ref.read("x64/vk_swiftshader.dll"))

0 commit comments

Comments
 (0)