summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-05-20 22:12:23 +0200
committerHampusM <hampus@hampusmat.com>2026-05-20 22:12:23 +0200
commit568883f987415fe989271d61a1309548d6013877 (patch)
tree1b61acc51969b237001f1199ce0e41879dec1e0f /engine
parent88281a99598cb1affeb5361c253781bacd490b5b (diff)
build(engine): use shader-slang fork branch with prebuilt libs
Diffstat (limited to 'engine')
-rw-r--r--engine/Cargo.toml8
-rw-r--r--engine/build.rs81
2 files changed, 61 insertions, 28 deletions
diff --git a/engine/Cargo.toml b/engine/Cargo.toml
index 5fd8219..cd4902f 100644
--- a/engine/Cargo.toml
+++ b/engine/Cargo.toml
@@ -38,9 +38,11 @@ features = ["derive"]
[dependencies.shader-slang]
git = "https://github.com/HampusMat/slang-rs"
-branch = "with_static_linking"
-default-features = false
-features = ["static"]
+branch = "prebuilt-and-artifacts"
[build-dependencies]
cfg_aliases = "0.2.1"
+build-rs = "0.3.4"
+serde = { version = "1.0.228", features = ["derive"] }
+serde_json = "1.0.149"
+
diff --git a/engine/build.rs b/engine/build.rs
index 58029fc..7ad5a9b 100644
--- a/engine/build.rs
+++ b/engine/build.rs
@@ -1,33 +1,58 @@
-// Original file:
-// https://github.com/rust-windowing/glutin/blob/
-// 0433af9018febe0696c485ed9d66c40dad41f2d4/glutin-winit/build.rs
-//
-// Copyright © 2022 Kirill Chibisov
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the “Software”), to deal
-// in the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-// Keep this in sync with glutin's build.rs.
+use std::path::{Path, PathBuf};
+use std::process::Command;
use cfg_aliases::cfg_aliases;
+use serde::Deserialize;
fn main()
{
+ let slang_artifacts = std::env::var("DEP_CRATE_SHADER_SLANG_ARTIFACTS").unwrap();
+
+ let cargo_metadata_output = Command::new(build_rs::input::cargo())
+ .args([
+ "metadata",
+ "--format-version=1",
+ "-q",
+ "--no-deps",
+ "--color=never",
+ "--manifest-path",
+ build_rs::input::cargo_manifest_path().to_str().unwrap(),
+ ])
+ .output()
+ .unwrap();
+
+ if !cargo_metadata_output.status.success() {
+ panic!(
+ "'cargo metadata' command failed:\n\nstdout:\n{}\n\nstderr:\n{}",
+ String::from_utf8_lossy(&cargo_metadata_output.stdout),
+ String::from_utf8_lossy(&cargo_metadata_output.stderr),
+ );
+ }
+
+ let cargo_metadata = serde_json::from_str::<CargoMetadata>(
+ str::from_utf8(&cargo_metadata_output.stdout).unwrap(),
+ )
+ .unwrap();
+
+ let final_artifact_dir = (if build_rs::input::target() == build_rs::input::host() {
+ cargo_metadata.target_directory
+ } else {
+ cargo_metadata
+ .target_directory
+ .join(build_rs::input::target())
+ })
+ .join(build_rs::input::profile());
+
+ for artifact_path in slang_artifacts.split(";") {
+ let artifact_path = Path::new(artifact_path);
+
+ std::fs::copy(
+ artifact_path,
+ final_artifact_dir.join(artifact_path.file_name().unwrap()),
+ )
+ .unwrap();
+ }
+
// Setup alias to reduce `cfg` boilerplate.
cfg_aliases! {
// Systems.
@@ -61,3 +86,9 @@ fn main()
// cgl_backend: { all(macos_platform, not(wasm_platform)) },
}
}
+
+#[derive(Debug, Deserialize)]
+struct CargoMetadata
+{
+ target_directory: PathBuf,
+}