Skip to content

Commit 4cb19d8

Browse files
author
Dennis Waldherr
committed
chore: Updated bindgen, and edition
1 parent daf326a commit 4cb19d8

8 files changed

Lines changed: 418 additions & 7417 deletions

File tree

Cargo.lock

Lines changed: 373 additions & 332 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "rsbwapi"
33
version.workspace = true
44
authors = ["Dennis Waldherr <bytekeeper@mailbox.org>"]
55
description = "BWAPI client to write AI players for Starcraft Broodwar"
6-
edition = "2021"
6+
edition = "2024"
77
license = "MIT OR Apache-2.0"
88
homepage = "https://github.com/Bytekeeper/rsbwapi/"
99
repository = "https://github.com/Bytekeeper/rsbwapi/"

bwapi_wrapper/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "bwapi_wrapper"
33
version.workspace = true
44
authors = ["Dennis Waldherr <bytekeeper@mailbox.org>"]
5-
edition = "2021"
5+
edition = "2024"
66
homepage = "https://github.com/Bytekeeper/rsbwapi/"
77
license = "LGPL-3.0-or-later"
88
repository = "https://github.com/Bytekeeper/rsbwapi/"
@@ -23,6 +23,5 @@ derive_more.workspace = true
2323

2424

2525
[build-dependencies]
26-
# bindgen = "0.69"
27-
# regex = "1"
28-
26+
bindgen = "0.72"
27+
regex = "1"

bwapi_wrapper/build.rs

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
// use bindgen::Formatter;
2-
// use regex::Regex;
3-
// use std::env;
4-
// use std::fs::File;
5-
// use std::io::Write;
6-
// use std::path::PathBuf;
1+
use bindgen::Formatter;
2+
use regex::Regex;
3+
use std::env;
4+
use std::fs::File;
5+
use std::io::Write;
6+
use std::path::PathBuf;
77

88
fn main() {
99
// To "fix" it not working on github and to reduce build requirements - this will not be called
1010
// in every build.
11-
/*
1211
should_replace1();
1312
should_replace2();
1413

@@ -23,27 +22,27 @@ fn main() {
2322
.default_enum_style(bindgen::EnumVariation::Rust {
2423
non_exhaustive: false,
2524
})
26-
.allowlist_type("BWAPI::.*")
27-
// .whitelist_type("BWAPI::.*GameTable")
28-
// .whitelist_type("BWAPI::.*Enum")
25+
.allowlist_type("BWAPI::(GameTable|.*Enum|MouseButton|Key|UnitData|RegionData|GameData)")
26+
.allowlist_type("BWAPIC::(UnitCommand|.*Enum)")
2927
.ignore_methods()
3028
.ignore_functions()
3129
.opaque_type("std::.*")
3230
.formatter(Formatter::Rustfmt)
3331
// .derive_default(true)
34-
.derive_eq(true)
32+
// .derive_eq(true)
3533
.derive_hash(true)
3634
// .disable_name_namespacing()
3735
// The input header we would like to generate
3836
// bindings for.
3937
.header("wrapper.h")
38+
// .clang_arg("--target=i686-unknown-linux-gnu")
4039
// Finish the builder and generate the bindings.
4140
.generate()
4241
// Unwrap the Result and panic on failure.
4342
.expect("Unable to generate bindings");
4443

4544
// Write the bindings to the $OUT_DIR/bindings.rs file.
46-
todo!("Target src/");
45+
// todo!("Target src/");
4746
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
4847
let result = bindings.to_string();
4948
let mut file = File::create(out_path.join("bindings.rs")).unwrap();
@@ -52,29 +51,34 @@ fn main() {
5251
assert_ne!(changed, result, "Could not add FromPrimitive to bindings!");
5352
file.write_all(changed.as_bytes())
5453
.expect("Couldn't write bindings!");
55-
*/
5654
}
5755

58-
// fn should_replace1() {
59-
// // GIVEN
60-
// let test = "# [ derive ( Debug , Copy , Clone , PartialEq , Eq , Hash ) ] pub enum std_deque__bindgen_ty_1";
56+
fn should_replace1() {
57+
// GIVEN
58+
let test = "# [ derive ( Debug , Copy , Clone , PartialEq , Eq , Hash ) ] pub enum std_deque__bindgen_ty_1";
6159

62-
// // WHEN
63-
// let re = Regex::new(r"#\s*\[\s*derive\s*\((?P<d>[^)]+)\)\s*\]\s*pub\s+enum").unwrap();
64-
// let changed = re.replace_all(test, "#[derive($d, FromPrimitive)]\npub enum");
60+
// WHEN
61+
let re = Regex::new(r"#\s*\[\s*derive\s*\((?P<d>[^)]+)\)\s*\]\s*pub\s+enum").unwrap();
62+
let changed = re.replace_all(test, "#[derive($d, FromPrimitive)]\npub enum");
6563

66-
// // THEN
67-
// assert_eq!("#[derive( Debug , Copy , Clone , PartialEq , Eq , Hash , FromPrimitive)]\npub enum std_deque__bindgen_ty_1", changed);
68-
// }
64+
// THEN
65+
assert_eq!(
66+
"#[derive( Debug , Copy , Clone , PartialEq , Eq , Hash , FromPrimitive)]\npub enum std_deque__bindgen_ty_1",
67+
changed
68+
);
69+
}
6970

70-
// fn should_replace2() {
71-
// // GIVEN
72-
// let test = "# [ derive ( Debug , Copy , Clone , PartialEq , Eq , Hash ) ] pub enum BWAPI_Text_Size_Enum # [ derive ( Debug , Copy , Clone , PartialEq , Eq , Hash ) ] pub enum BWAPIC_CommandType_Enum ";
71+
fn should_replace2() {
72+
// GIVEN
73+
let test = "# [ derive ( Debug , Copy , Clone , PartialEq , Eq , Hash ) ] pub enum BWAPI_Text_Size_Enum # [ derive ( Debug , Copy , Clone , PartialEq , Eq , Hash ) ] pub enum BWAPIC_CommandType_Enum ";
7374

74-
// // WHEN
75-
// let re = Regex::new(r"#\s*\[\s*derive\s*\((?P<d>[^)]+)\)\s*\]\s*pub\s+enum").unwrap();
76-
// let changed = re.replace_all(test, "#[derive($d, FromPrimitive)]\npub enum");
75+
// WHEN
76+
let re = Regex::new(r"#\s*\[\s*derive\s*\((?P<d>[^)]+)\)\s*\]\s*pub\s+enum").unwrap();
77+
let changed = re.replace_all(test, "#[derive($d, FromPrimitive)]\npub enum");
7778

78-
// // THEN
79-
// assert_eq!("#[derive( Debug , Copy , Clone , PartialEq , Eq , Hash , FromPrimitive)]\npub enum BWAPI_Text_Size_Enum #[derive( Debug , Copy , Clone , PartialEq , Eq , Hash , FromPrimitive)]\npub enum BWAPIC_CommandType_Enum ", changed);
80-
// }
79+
// THEN
80+
assert_eq!(
81+
"#[derive( Debug , Copy , Clone , PartialEq , Eq , Hash , FromPrimitive)]\npub enum BWAPI_Text_Size_Enum #[derive( Debug , Copy , Clone , PartialEq , Eq , Hash , FromPrimitive)]\npub enum BWAPIC_CommandType_Enum ",
82+
changed
83+
);
84+
}

0 commit comments

Comments
 (0)