-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
component
helper function to simplify component development (#1840
- Loading branch information
Showing
4 changed files
with
49 additions
and
28 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,25 +1,12 @@ | ||
use std::fs::*; | ||
use std::io::prelude::*; | ||
use std::process::*; | ||
|
||
fn main() -> std::io::Result<()> { | ||
create_dir_all(".windows/winmd")?; | ||
copy("../component/.windows/winmd/component.winmd", ".windows/winmd/component.winmd")?; | ||
|
||
std::fs::remove_file("src/bindings.rs").ok(); | ||
let mut bindings = File::create("src/bindings.rs")?; | ||
|
||
// TODO: this needs to be simpler | ||
let files = vec![metadata::reader::File::new("../../libs/metadata/default/Windows.winmd").unwrap(), metadata::reader::File::new(".windows/winmd/component.winmd").unwrap()]; | ||
let reader = &metadata::reader::Reader::new(&files); | ||
let tree = reader.tree("test_component", &[]).expect("`test_component` namespace not found"); | ||
let mut gen = bindgen::Gen::new(reader); | ||
gen.namespace = tree.namespace; | ||
gen.component = true; | ||
bindings.write_all(bindgen::namespace(&gen, &tree).as_bytes())?; | ||
|
||
drop(bindings); | ||
|
||
write("src/bindings.rs", bindgen::component("test_component", &files))?; | ||
Command::new("rustfmt").arg("src/bindings.rs").status()?; | ||
Ok(()) | ||
} |
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