-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
analysis: Introduce Vulkan XML parser
- Loading branch information
Showing
7 changed files
with
760 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ version = "2.0.0" | |
edition = "2021" | ||
|
||
[dependencies] | ||
roxmltree = "0.19" | ||
log = "0.4" |
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,9 +1,36 @@ | ||
use std::path::Path; | ||
mod xml; | ||
|
||
pub struct Analysis {} | ||
use log::debug; | ||
use std::{fs, path::Path}; | ||
|
||
#[derive(Debug)] | ||
pub struct Analysis { | ||
pub vk: Library, | ||
pub video: Library, | ||
} | ||
|
||
impl Analysis { | ||
pub fn new(_vulkan_headers_path: impl AsRef<Path>) -> Analysis { | ||
Analysis {} | ||
pub fn new(vulkan_headers_path: impl AsRef<Path>) -> Analysis { | ||
let vulkan_headers_path = vulkan_headers_path.as_ref(); | ||
Analysis { | ||
vk: Library::new(vulkan_headers_path.join("registry/vk.xml")), | ||
video: Library::new(vulkan_headers_path.join("registry/video.xml")), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct Library { | ||
_xml: xml::Registry, | ||
} | ||
|
||
impl Library { | ||
fn new(xml_path: impl AsRef<Path>) -> Library { | ||
debug!("parsing {:?}", xml_path.as_ref()); | ||
// We leak the input string here for convenience, to avoid explicit lifetimes. | ||
let xml_input = Box::leak(fs::read_to_string(xml_path).unwrap().into_boxed_str()); | ||
Library { | ||
_xml: xml::Registry::parse(xml_input, "vulkan"), | ||
} | ||
} | ||
} |
Oops, something went wrong.