1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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());
}
|