mirror of
https://github.com/italicsjenga/spirv-to-dxil-rs.git
synced 2024-12-23 19:41:29 +11:00
build: allow using included bindings
This commit is contained in:
parent
3a74e07031
commit
37d0e5a0d5
|
@ -9,6 +9,7 @@ spirv-to-dxil-rs builds a copy of spirv-to-dxil statically from Mesa. Many of th
|
||||||
* [Meson](https://mesonbuild.com/)
|
* [Meson](https://mesonbuild.com/)
|
||||||
* A compatible C and C++ compiler
|
* A compatible C and C++ compiler
|
||||||
* [MSVC 2019 16.11 or later](https://docs.mesa3d.org/install.html) is required to build on Windows.
|
* [MSVC 2019 16.11 or later](https://docs.mesa3d.org/install.html) is required to build on Windows.
|
||||||
|
* [clang](https://clang.llvm.org/) is required for Linux.
|
||||||
* [Python 3.6](https://www.python.org/) or later.
|
* [Python 3.6](https://www.python.org/) or later.
|
||||||
|
|
||||||
Lex and Yacc are not required. Additionally, [CMake 3.6](https://cmake.org/) or later is required to run the build script.
|
Lex and Yacc are not required. Additionally, [CMake 3.6](https://cmake.org/) or later is required to run the build script.
|
||||||
|
|
|
@ -13,6 +13,9 @@ keywords = ["SPIR-V", "DXIL"]
|
||||||
bindgen = "0.63.0"
|
bindgen = "0.63.0"
|
||||||
cmake = "0.1"
|
cmake = "0.1"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
included-bindings = []
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = []
|
targets = []
|
||||||
features = ["docsrs"]
|
features = ["included-bindings"]
|
|
@ -9,7 +9,9 @@ fn main() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cmake_dst = Config::new("native").build_target("mesa").build();
|
let cmake_dst = Config::new("native")
|
||||||
|
.build_target("mesa")
|
||||||
|
.build();
|
||||||
|
|
||||||
let object_dst = cmake_dst.join("build/mesa/lib");
|
let object_dst = cmake_dst.join("build/mesa/lib");
|
||||||
|
|
||||||
|
@ -19,15 +21,21 @@ fn main() {
|
||||||
if cfg!(target_os = "windows") {
|
if cfg!(target_os = "windows") {
|
||||||
println!("cargo:rustc-link-lib=Version");
|
println!("cargo:rustc-link-lib=Version");
|
||||||
}
|
}
|
||||||
|
if cfg!(target_os = "linux") {
|
||||||
|
println!("cargo:rustc-link-lib=stdc++");
|
||||||
|
}
|
||||||
|
|
||||||
println!("cargo:rustc-link-search=native={}", object_dst.display());
|
println!("cargo:rustc-link-search=native={}", object_dst.display());
|
||||||
println!("cargo:rustc-link-lib=static=spirv_to_dxil");
|
println!("cargo:rustc-link-lib=static=spirv_to_dxil");
|
||||||
println!("cargo:rustc-link-lib=static=vulkan_util");
|
println!("cargo:rustc-link-lib=static=vulkan_util");
|
||||||
|
|
||||||
|
if !cfg!(feature = "included-bindings") {
|
||||||
let bindings = bindgen::Builder::default()
|
let bindings = bindgen::Builder::default()
|
||||||
.header("native/wrapper.h")
|
.header("native/wrapper.h")
|
||||||
.clang_arg(format!("-F{}", header_dst.display()))
|
.clang_arg(format!("-F{}", header_dst.display()))
|
||||||
.clang_arg(format!("-F{}", header_compiler_dst.display()))
|
.clang_arg(format!("-F{}", header_compiler_dst.display()))
|
||||||
|
.clang_arg(format!("-I{}", header_dst.display()))
|
||||||
|
.clang_arg(format!("-I{}", header_compiler_dst.display()))
|
||||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||||
.generate()
|
.generate()
|
||||||
.expect("Unable to generate bindings");
|
.expect("Unable to generate bindings");
|
||||||
|
@ -35,3 +43,4 @@ fn main() {
|
||||||
.write_to_file(out_dir.join("bindings.rs"))
|
.write_to_file(out_dir.join("bindings.rs"))
|
||||||
.expect("Couldn't write bindings!");
|
.expect("Couldn't write bindings!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
|
#[cfg(not(feature = "included-bindings"))]
|
||||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||||
|
|
||||||
#[cfg(feature = "docsrs")]
|
#[cfg(feature = "included-bindings")]
|
||||||
mod bindings;
|
mod bindings;
|
||||||
|
|
||||||
#[cfg(feature = "docsrs")]
|
#[cfg(feature = "included-bindings")]
|
||||||
pub use bindings::*;
|
pub use bindings::*;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in a new issue