aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn / boringcactus <melody@boringcactus.com>2021-06-26 22:27:21 -0600
committerMelody Horn / boringcactus <melody@boringcactus.com>2021-06-26 22:27:21 -0600
commit2f8db809abd2a6a8e5bc9e381e12c775ca7681d8 (patch)
tree371cadc0876665721bc79bbad7287f463219462a
downloadriir-wxwidgets-2f8db809abd2a6a8e5bc9e381e12c775ca7681d8.tar.gz
riir-wxwidgets-2f8db809abd2a6a8e5bc9e381e12c775ca7681d8.zip
begin to throw things together
-rw-r--r--.gitignore2
-rw-r--r--Cargo.lock42
-rw-r--r--Cargo.toml9
-rw-r--r--README.md5
-rw-r--r--src/main.rs54
5 files changed, 112 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0a25f36
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/target
+/out
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..66b32ca
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,42 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "clang"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "34c6913be3a1c94f52fb975cdec7ef5a7b69de10a55de66dcbc30d7046b85fa1"
+dependencies = [
+ "clang-sys",
+ "libc",
+]
+
+[[package]]
+name = "clang-sys"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "853eda514c284c2287f4bf20ae614f8781f40a81d32ecda6e91449304dfe077c"
+dependencies = [
+ "glob",
+ "libc",
+]
+
+[[package]]
+name = "glob"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
+
+[[package]]
+name = "libc"
+version = "0.2.97"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
+
+[[package]]
+name = "riir-wxwidgets"
+version = "0.1.0"
+dependencies = [
+ "clang",
+]
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..f9cf65f
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "riir-wxwidgets"
+version = "0.1.0"
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+clang = { version = "1.0.3", features = ["clang_8_0"] }
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..00251cf
--- /dev/null
+++ b/README.md
@@ -0,0 +1,5 @@
+# riir-wxwidgets
+
+## Semi-Automatic C++-to-Rust Translation for the Only Good GUI Library
+
+Swag.
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..5e9a51e
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,54 @@
+use std::env::{current_dir, set_current_dir};
+use std::fs::{create_dir_all, metadata};
+use std::path::Path;
+use std::process::Command;
+
+use clang::{Clang, Index};
+
+const TARGET_TAG: &str = "v3.1.5";
+
+fn main() {
+ assert_eq!(current_dir().unwrap(), Path::new(env!("CARGO_MANIFEST_DIR")), "running in the wrong place");
+ create_dir_all("out").unwrap();
+ set_current_dir("out").unwrap();
+
+ if metadata("orig").is_err() {
+ println!("cloning wxWidgets source...");
+ let git_clone = Command::new("git")
+ .args(&["clone", "--quiet", "https://github.com/wxWidgets/wxWidgets.git", "orig", "--depth", "1"])
+ .status()
+ .unwrap();
+ assert!(git_clone.success());
+ let git_config = Command::new("git")
+ .args(&["-C", "orig", "config", "--local", "advice.detachedHead", "false"])
+ .status()
+ .unwrap();
+ assert!(git_config.success());
+ }
+ let git_tag = Command::new("git").args(&["-C", "orig", "describe"]).output().unwrap();
+ if String::from_utf8(git_tag.stdout).unwrap().trim() != TARGET_TAG {
+ let git_checkout = Command::new("git")
+ .args(&["-C", "orig", "checkout", "--quiet", TARGET_TAG])
+ .status()
+ .unwrap();
+ assert!(git_checkout.success());
+ }
+
+ if metadata("new").is_err() {
+ println!("creating wx crate...");
+ let cargo_new = Command::new("cargo")
+ .args(&["new", "--quiet", "--vcs", "none", "--lib", "--name", "wx", "new"])
+ .status()
+ .unwrap();
+ assert!(cargo_new.success());
+ }
+
+ let clang = Clang::new().unwrap();
+ let index = Index::new(&clang, true, true);
+
+ let mut root_header_parser = index.parser("orig/include/wx/wx.h");
+ root_header_parser.keep_going(true);
+ root_header_parser.arguments(&["-Iorig/include", "-D"]);
+ let root_header = root_header_parser.parse().unwrap();
+ println!("{}", root_header.get_entity().get_pretty_printer().print());
+}