Skip to content

Commit 54bf5e4

Browse files
committed
Add build system for the deps
1 parent 8e07b6d commit 54bf5e4

File tree

257 files changed

+65
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

257 files changed

+65
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "shader-compiler-rs"
2+
name = "shader-compiler"
33
version = "0.1.0"
44
edition = "2021"
55

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main() {}

sys/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9+
10+
[build-dependencies]
11+
cc = { version = "1.0.79", features = ["parallel"] }
12+
glob = "0.3.1"

sys/build.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
use cc::Build;
2+
3+
const LIBSIRIT: &str = "libsirit.a";
4+
const LIBSHADER_COMPILER: &str = "libshader_compiler.a";
5+
6+
fn build_sirit() {
7+
let mut build = Build::new();
8+
9+
build
10+
.cpp(true)
11+
.include("sirit/externals/SPIRV-Headers/include")
12+
.include("sirit/include")
13+
.include("sirit/src")
14+
.files(
15+
glob::glob("sirit/src/**/*.cpp")
16+
.unwrap()
17+
.map(|v| v.unwrap()),
18+
);
19+
20+
if build.get_compiler().is_like_msvc() {
21+
build.flag("/std:c++20");
22+
} else {
23+
build.flag("-std=c++20");
24+
}
25+
26+
build.compile(LIBSIRIT);
27+
}
28+
29+
fn build_shader_compiler() {
30+
let mut build = Build::new();
31+
32+
build
33+
.cpp(true)
34+
.include("range-v3/include")
35+
.include("sirit/externals/SPIRV-Headers/include")
36+
.include("sirit/include")
37+
.include(".") // to make sure shader_compiler is on include path
38+
.files(
39+
glob::glob("shader_compiler/**/*.cpp")
40+
.unwrap()
41+
.map(|v| v.unwrap()),
42+
);
43+
44+
if build.get_compiler().is_like_msvc() {
45+
build.flag("/std:c++20");
46+
} else {
47+
build.flag("-std=c++20").flag("-Wno-pragmas");
48+
}
49+
50+
build.compile(LIBSHADER_COMPILER);
51+
}
52+
53+
fn main() {
54+
build_sirit();
55+
build_shader_compiler();
56+
57+
println!("cargo:rustc-link-lib=static={}", LIBSIRIT);
58+
println!("cargo:rustc-link-lib=static={}", LIBSHADER_COMPILER);
59+
}

sys/shader-compiler/include/shader_compiler

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)