-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade to `windows 0.51` * Go back to `api_gen` depending on `windows-bindgen`, `riddle` remains unpublished
- Loading branch information
Showing
12 changed files
with
373 additions
and
602 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
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,50 +1,7 @@ | ||
use std::io::prelude::*; | ||
|
||
use anyhow::{Context, Result}; | ||
use windows_metadata::reader::File; | ||
use windows_bindgen::{bindgen, Result}; | ||
|
||
fn main() -> Result<()> { | ||
let start = std::time::Instant::now(); | ||
let output_path = std::path::PathBuf::from("src"); | ||
|
||
let winmd_files = [ | ||
File::new(".windows/winmd/Amd.Ext.D3D.winmd")?, | ||
File::new(".windows/winmd/Windows.Win32.winmd")?, | ||
]; | ||
|
||
let _ = std::fs::remove_dir_all(output_path.join("Amd")); | ||
|
||
for namespace in ["Amd", "Amd.Ext", "Amd.Ext.D3D"] { | ||
let path = output_path.join(namespace.replace('.', "/")); | ||
std::fs::create_dir_all(&path)?; | ||
let tokens = windows_bindgen::component(namespace, &winmd_files); | ||
let output = std::fs::File::create(path.join("mod.rs"))?; | ||
fmt_tokens(&tokens, output).context("While formatting tokens")?; | ||
} | ||
|
||
println!("Took {:.1?}", start.elapsed()); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn fmt_tokens(tokens: &str, output: std::fs::File) -> Result<()> { | ||
let mut child = std::process::Command::new("rustfmt") | ||
.stdin(std::process::Stdio::piped()) | ||
.stdout(output) | ||
.spawn() | ||
.context("Failed to spawn `rustfmt`")?; | ||
|
||
let mut stdin = child.stdin.take().context("Failed to open stdin")?; | ||
stdin.write_all(tokens.as_bytes())?; | ||
drop(stdin); | ||
|
||
let output = child.wait_with_output()?; | ||
let stderr = std::str::from_utf8(&output.stderr)?; | ||
anyhow::ensure!(output.status.success(), "rustfmt failed: {}", stderr); | ||
|
||
if !stderr.is_empty() { | ||
eprintln!("rustfmt stderr: {}", stderr) | ||
} | ||
|
||
let log = bindgen(["--etc", "bindings.txt"])?; | ||
println!("{}", log); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--in .windows/winmd/ | ||
--out src/Amd.rs | ||
|
||
--filter | ||
Amd |
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
Oops, something went wrong.