Skip to content

Commit

Permalink
analysis: Introduce Vulkan XML parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Friz64 committed Jan 20, 2024
1 parent 92084df commit 8035d4d
Show file tree
Hide file tree
Showing 7 changed files with 760 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
- name: Install Vulkan loader
run: sudo apt-get install libvulkan-dev
- uses: actions/checkout@v4
- name: Checkout submodule
# Manually update submodules with --checkout because they are configured with update=none and will be skipped otherwise
run: git submodule update --recursive --init --force --checkout
- name: Test all targets
run: cargo test --workspace --all-targets
- name: Test docs
Expand Down
2 changes: 2 additions & 0 deletions analysis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ version = "2.0.0"
edition = "2021"

[dependencies]
roxmltree = "0.19"
log = "0.4"
35 changes: 31 additions & 4 deletions analysis/src/lib.rs
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"),
}
}
}
Loading

0 comments on commit 8035d4d

Please sign in to comment.