[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 03/25] tools/xenbindgen: Introduce a Xen hypercall IDL generator



To be used for parsing TOML-based hypercall ABI specifications and
generating language-specific items (structs, enums, etc.).

Signed-off-by: Alejandro Vallejo <alejandro.vallejo@xxxxxxxxx>
---
 tools/rust/Makefile               | 29 +++++++++++++++++++++++++++++
 tools/rust/xenbindgen/.gitignore  |  1 +
 tools/rust/xenbindgen/Cargo.toml  | 15 +++++++++++++++
 tools/rust/xenbindgen/src/main.rs | 21 +++++++++++++++++++++
 4 files changed, 66 insertions(+)
 create mode 100644 tools/rust/Makefile
 create mode 100644 tools/rust/xenbindgen/.gitignore
 create mode 100644 tools/rust/xenbindgen/Cargo.toml
 create mode 100644 tools/rust/xenbindgen/src/main.rs

diff --git a/tools/rust/Makefile b/tools/rust/Makefile
new file mode 100644
index 000000000000..f5db0a9c5e81
--- /dev/null
+++ b/tools/rust/Makefile
@@ -0,0 +1,29 @@
+XEN_ROOT=$(CURDIR)/../..
+
+# Path to the Xen hypercall IDL parser
+XENBINDGEN=$(CURDIR)/xenbindgen
+
+# Clippy settings for all Rust projects
+CLIPPY_ARGS=-D warnings \
+            -D missing_docs \
+            -D clippy::missing_docs_in_private_items \
+            -D clippy::all \
+            -D clippy::pedantic
+
+# Not integrated in Xen installations to avoid depending on the Rust toolchain
+.PHONY: all install uninstall clean
+all install uninstall clean:
+
+# Verify Rust crates pass lint checks. This is enforced in CI
+.PHONY: verify
+verify:
+       set -eu; \
+       for i in "${XENBINDGEN}"; do \
+           echo "Verifying $$i"; \
+           cd "$$i"; \
+           cargo fmt -- --check; \
+           cargo clippy -- $(CLIPPY_ARGS); \
+           cargo deny check; \
+           cd -; \
+       done
+
diff --git a/tools/rust/xenbindgen/.gitignore b/tools/rust/xenbindgen/.gitignore
new file mode 100644
index 000000000000..b83d22266ac8
--- /dev/null
+++ b/tools/rust/xenbindgen/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/tools/rust/xenbindgen/Cargo.toml b/tools/rust/xenbindgen/Cargo.toml
new file mode 100644
index 000000000000..4cb3af9ce0de
--- /dev/null
+++ b/tools/rust/xenbindgen/Cargo.toml
@@ -0,0 +1,15 @@
+[package]
+name = "xenbindgen"
+version = "0.2.0"
+edition = "2021"
+license = "MIT"
+
+# See more keys and their definitions at 
https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+clap = { version = "4.5.7", features = ["std", "derive"] }
+convert_case = "0.6.0"
+env_logger = "0.11.3"
+log = "0.4.22"
+serde = { version = "1.0.203", default-features = false, features = ["derive"] 
}
+toml = { version = "0.8.14", default-features = false, features = ["parse"] }
diff --git a/tools/rust/xenbindgen/src/main.rs 
b/tools/rust/xenbindgen/src/main.rs
new file mode 100644
index 000000000000..08fcf8fe4da6
--- /dev/null
+++ b/tools/rust/xenbindgen/src/main.rs
@@ -0,0 +1,21 @@
+//! CLI tool to generate structs in different languages from specially
+//! crafted TOML files. The format of these files follows the following
+//! rules.
+
+use clap::Parser;
+use env_logger::Env;
+use log::info;
+
+/// A CLI tool to generate struct definitions in several languages.
+#[derive(Parser, Debug)]
+#[command(version, about)]
+struct Cli;
+
+fn main() {
+    
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
+
+    let cli = Cli::parse();
+    info!("args: {:?}", cli);
+
+    todo!("read spec files and generate output files");
+}
-- 
2.47.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.