-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate rust-c bindings automatically
- Loading branch information
Showing
14 changed files
with
88 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
{ | ||
"rust-analyzer.linkedProjects": ["src/crates/Cargo.toml"] | ||
"rust-analyzer.linkedProjects": [ | ||
"src/crates/Cargo.toml" | ||
], | ||
"files.associations": { | ||
"quickjs-rs.h": "c", | ||
"js-array.h": "c", | ||
"types.h": "c", | ||
"list.h": "c", | ||
"js-function.h": "c" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
target/ | ||
target/ | ||
include/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ resolver = "2" | |
members = [ | ||
"quickjs", | ||
"quickjs_gc" | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Whether cbindgen's default C/C++ standard imports should be suppressed. These | ||
# imports are included by default because our generated headers tend to require | ||
# them (e.g. for uint32_t). Currently, the generated imports are: | ||
# | ||
# * for C: <stdarg.h>, <stdbool.h>, <stdint.h>, <stdlib.h>, <uchar.h> | ||
# | ||
# * for C++: <cstdarg>, <cstdint>, <cstdlib>, <new>, <cassert> (depending on config) | ||
# | ||
# default: false | ||
no_includes = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::env; | ||
use std::path::PathBuf; | ||
use std::process::Command; | ||
|
||
fn main() { | ||
env::set_var("RUST_BACKTRACE", "1"); | ||
let current_dir = env::current_dir().unwrap(); | ||
let working_dir = current_dir.parent().unwrap(); | ||
|
||
let home_dir = env::var("HOME").expect("HOME environment variable not found."); | ||
let cbindgen_bin_path = PathBuf::from(&home_dir).join(".cargo/bin/cbindgen"); | ||
|
||
let output = Command::new(cbindgen_bin_path) | ||
.current_dir(&working_dir) | ||
.arg("--config") | ||
.arg("cbindgen.toml") | ||
.arg("--crate") | ||
.arg("quickjs_gc") // quickjs_gc | ||
.arg("--lang") | ||
.arg("c") | ||
.arg("--output") | ||
.arg("include/quickjs-rs.h") | ||
.output() | ||
.expect("FAiled"); | ||
|
||
println!("{}", String::from_utf8_lossy(&output.stdout)); | ||
eprintln!("{}", String::from_utf8_lossy(&output.stderr)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pub use quickjs_gc::{print_gc_objects}; | ||
pub use quickjs_gc::print_gc_objects; |