Initial Commit (it doesn't work)
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "moonlight-common-c-sys"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.72.0"
|
||||
cmake = "0.1.54"
|
||||
@@ -0,0 +1,47 @@
|
||||
extern crate bindgen;
|
||||
extern crate cmake;
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use bindgen::callbacks::{IntKind, ParseCallbacks};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct CustomCallbacks;
|
||||
|
||||
impl ParseCallbacks for CustomCallbacks {
|
||||
fn int_macro(&self, name: &str, _value: i64) -> Option<IntKind> {
|
||||
match name {
|
||||
"STREAM_CFG_LOCAL" => Some(IntKind::I32),
|
||||
"STREAM_CFG_REMOTE" => Some(IntKind::I32),
|
||||
"STREAM_CFG_AUTO" => Some(IntKind::I32),
|
||||
_ => None, // Default behavior for all others
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Build moonlight-common-c as static library via CMake
|
||||
let dst = cmake::Config::new("moonlight-common-c")
|
||||
.define("CMAKE_POLICY_VERSION_MINIMUM", "3.5")
|
||||
.build();
|
||||
|
||||
// Link to static library
|
||||
println!("cargo:rustc-link-search=native={}/build", dst.display());
|
||||
println!("cargo:rustc-link-lib=moonlight-common-c");
|
||||
|
||||
// Configure bindgen for Limelight.h
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("moonlight-common-c/src/Limelight.h")
|
||||
.clang_arg(format!("-I{}/src", dst.display())) // Include built headers
|
||||
//.parse_callbacks(Box::new(CustomCallbacks))
|
||||
.default_macro_constant_type(bindgen::MacroTypeVariation::Signed)
|
||||
.generate()
|
||||
.expect("Failed to generate bindings");
|
||||
|
||||
// Write bindings to output
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
bindings
|
||||
.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Failed to write bindings");
|
||||
}
|
||||
+1
Submodule moonlight-common-c-sys/moonlight-common-c added at 58902e342f
@@ -0,0 +1 @@
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
@@ -0,0 +1 @@
|
||||
#include <Limelight.h>
|
||||
Reference in New Issue
Block a user