capi: move header generation to postbuild
This commit is contained in:
parent
212d5fd7eb
commit
843c438e31
6 changed files with 57 additions and 230 deletions
199
Cargo.lock
generated
199
Cargo.lock
generated
|
@ -8,17 +8,6 @@ version = "1.0.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "auto_ops"
|
||||
version = "0.3.0"
|
||||
|
@ -82,25 +71,6 @@ version = "1.4.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||
|
||||
[[package]]
|
||||
name = "cbindgen"
|
||||
version = "0.24.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6358dedf60f4d9b8db43ad187391afe959746101346fe51bb978126bec61dfb"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"heck",
|
||||
"indexmap",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn",
|
||||
"tempfile",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.73"
|
||||
|
@ -116,30 +86,6 @@ version = "1.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.2.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
||||
dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.48"
|
||||
|
@ -240,15 +186,6 @@ dependencies = [
|
|||
"threadpool",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499"
|
||||
dependencies = [
|
||||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fixedbitset"
|
||||
version = "0.4.2"
|
||||
|
@ -388,12 +325,6 @@ version = "0.12.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
|
@ -432,21 +363,6 @@ dependencies = [
|
|||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.25"
|
||||
|
@ -509,7 +425,6 @@ dependencies = [
|
|||
name = "librashader-capi"
|
||||
version = "0.1.0-alpha.4"
|
||||
dependencies = [
|
||||
"cbindgen",
|
||||
"gl",
|
||||
"librashader",
|
||||
"paste",
|
||||
|
@ -780,12 +695,6 @@ version = "1.15.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.9"
|
||||
|
@ -894,24 +803,6 @@ dependencies = [
|
|||
"num_cpus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "remove_dir_all"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "roxmltree"
|
||||
version = "0.14.1"
|
||||
|
@ -947,12 +838,6 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
|
||||
|
||||
[[package]]
|
||||
name = "scoped_threadpool"
|
||||
version = "0.1.9"
|
||||
|
@ -965,37 +850,6 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.147"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.147"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shaderc"
|
||||
version = "0.8.0"
|
||||
|
@ -1053,12 +907,6 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.102"
|
||||
|
@ -1070,35 +918,6 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"remove_dir_all",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.37"
|
||||
|
@ -1139,15 +958,6 @@ dependencies = [
|
|||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.5"
|
||||
|
@ -1242,15 +1052,6 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
|
|
|
@ -8,6 +8,7 @@ members = [
|
|||
"librashader-runtime",
|
||||
"librashader-runtime-d3d11",
|
||||
"librashader-runtime-gl",
|
||||
"librashader-runtime-vk",
|
||||
"librashader-capi",
|
||||
]
|
||||
|
||||
|
|
22
README.md
22
README.md
|
@ -15,9 +15,9 @@ of DirectX and OpenGL, as well as Metal, are not supported (but pull-requests ar
|
|||
| **API** | **Status** | **`librashader` feature** |
|
||||
|-------------|------------|---------------------------|
|
||||
| OpenGL 3.3+ | ✔ | `gl` |
|
||||
| OpenGL 4.6 | ✔ | `gl46` |
|
||||
| OpenGL 4.6 | ✔ | `gl` |
|
||||
| Vulkan | 🚧 | `vk` |
|
||||
| Direct3D11 | ✔ | `d3d11` |
|
||||
| Direct3D11 | ✔ | `d3d11` |
|
||||
| Direct3D12 | 🚧 | `d3d12` |
|
||||
| OpenGL 2 | ❌ | |
|
||||
| DirectX 9 | ❌ | |
|
||||
|
@ -30,10 +30,26 @@ of DirectX and OpenGL, as well as Metal, are not supported (but pull-requests ar
|
|||
librashader provides both a Rust API under the `librashader` crate, and a C API. Both APIs are first-class, fully supported.
|
||||
|
||||
The librashader C API is best used by linking statically with `librashader_ld`, which implements a loader that dynamically
|
||||
loads the librashader (`librashader.so` or `rashader.dll`) implementation in the search path.
|
||||
loads the librashader (`librashader.so` or `librashader.dll`) implementation in the search path.
|
||||
|
||||
Note that the Rust crate requires nightly Rust to build.
|
||||
|
||||
### C ABI Compatibility
|
||||
Since the recommended way of integrating `librashader` is by the `librashader_ld` single header library, ABI stability
|
||||
is important to ensure that updates to librashader do not break existing consumers.
|
||||
|
||||
Pre-1.0, nothing is guaranteed to be stable, but the following APIs are unlikely to change their ABI.
|
||||
|
||||
* `libra_preset_*`
|
||||
* `libra_error_*`
|
||||
|
||||
The following APIs, mostly runtime, are more likely to change their ABI.
|
||||
|
||||
* `libra_gl_*`
|
||||
* `libra_vk_*`
|
||||
* `libra_d3d11_*`
|
||||
* `libra_d3d12_*`
|
||||
|
||||
## Compatibility
|
||||
|
||||
librashader implements the entire RetroArch shader pipeline and is highly compatible with existing shaders,
|
||||
|
|
|
@ -12,8 +12,7 @@ keywords = ["shader", "retroarch", "SPIR-V"]
|
|||
description = "RetroArch shaders for all."
|
||||
|
||||
[lib]
|
||||
name = "rashader"
|
||||
crate-type = [ "cdylib", "staticlib", "lib" ]
|
||||
crate-type = [ "cdylib", "staticlib" ]
|
||||
|
||||
[features]
|
||||
default = ["runtime-opengl", "runtime-d3d11"]
|
||||
|
@ -43,6 +42,5 @@ features = [
|
|||
]
|
||||
optional = true
|
||||
|
||||
|
||||
[build-dependencies]
|
||||
[package.metadata.cargo-post.dependencies]
|
||||
cbindgen = "0.24.3"
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{BufWriter, Write};
|
||||
|
||||
pub fn main() {
|
||||
// Do not update files on docsrs
|
||||
if env::var("DOCS_RS").is_ok() {
|
||||
return;
|
||||
}
|
||||
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
let mut buf = BufWriter::new(Vec::new());
|
||||
cbindgen::generate(crate_dir)
|
||||
.expect("Unable to generate bindings")
|
||||
.write(&mut buf);
|
||||
|
||||
let bytes = buf.into_inner().expect("Unable to extract bytes");
|
||||
let string = String::from_utf8(bytes).expect("Unable to create string");
|
||||
// let string = string.replace("CHD_ERROR_", "CHDERR_");
|
||||
File::create("librashader.h")
|
||||
.expect("Unable to open file")
|
||||
.write_all(string.as_bytes())
|
||||
.expect("Unable to write bindings.")
|
||||
}
|
35
librashader-capi/post_build.rs
Normal file
35
librashader-capi/post_build.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
use std::{env, fs};
|
||||
use std::fs::File;
|
||||
use std::io::{BufWriter, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub fn main() {
|
||||
// Do not update files on docsrs
|
||||
if env::var("DOCS_RS").is_ok() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create headers.
|
||||
let crate_dir = env::var("CRATE_MANIFEST_DIR").unwrap();
|
||||
let mut buf = BufWriter::new(Vec::new());
|
||||
cbindgen::generate(crate_dir)
|
||||
.expect("Unable to generate bindings")
|
||||
.write(&mut buf);
|
||||
|
||||
let bytes = buf.into_inner().expect("Unable to extract bytes");
|
||||
let string = String::from_utf8(bytes).expect("Unable to create string");
|
||||
// let string = string.replace("CHD_ERROR_", "CHDERR_");
|
||||
File::create(PathBuf::from(env::var("CRATE_OUT_DIR").unwrap()).join("librashader.h"))
|
||||
.expect("Unable to open file")
|
||||
.write_all(string.as_bytes())
|
||||
.expect("Unable to write bindings.");
|
||||
|
||||
|
||||
if cfg!(target_os = "linux") {
|
||||
let artifacts = &["liblibrashader.so", "liblibrashader.a"];
|
||||
for artifact in artifacts {
|
||||
let ext = artifact.strip_prefix("lib").unwrap();
|
||||
fs::rename(PathBuf::from(env::var("CRATE_OUT_DIR").unwrap()).join(artifact), PathBuf::from(env::var("CRATE_OUT_DIR").unwrap()).join(ext)).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue