mirror of
https://github.com/italicsjenga/spirv-to-dxil-rs.git
synced 2024-12-23 11:31:31 +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/)
|
||||
* A compatible C and C++ compiler
|
||||
* [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.
|
||||
|
||||
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"
|
||||
cmake = "0.1"
|
||||
|
||||
[features]
|
||||
included-bindings = []
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = []
|
||||
features = ["docsrs"]
|
||||
features = ["included-bindings"]
|
|
@ -9,7 +9,9 @@ fn main() {
|
|||
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");
|
||||
|
||||
|
@ -19,19 +21,26 @@ fn main() {
|
|||
if cfg!(target_os = "windows") {
|
||||
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-lib=static=spirv_to_dxil");
|
||||
println!("cargo:rustc-link-lib=static=vulkan_util");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("native/wrapper.h")
|
||||
.clang_arg(format!("-F{}", header_dst.display()))
|
||||
.clang_arg(format!("-F{}", header_compiler_dst.display()))
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
bindings
|
||||
.write_to_file(out_dir.join("bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
if !cfg!(feature = "included-bindings") {
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("native/wrapper.h")
|
||||
.clang_arg(format!("-F{}", header_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))
|
||||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
bindings
|
||||
.write_to_file(out_dir.join("bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
#[cfg(not(feature = "included-bindings"))]
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
|
||||
#[cfg(feature = "docsrs")]
|
||||
#[cfg(feature = "included-bindings")]
|
||||
mod bindings;
|
||||
|
||||
#[cfg(feature = "docsrs")]
|
||||
#[cfg(feature = "included-bindings")]
|
||||
pub use bindings::*;
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in a new issue