Skip to content

Commit

Permalink
Fix build script
Browse files Browse the repository at this point in the history
  • Loading branch information
sorokya committed Dec 27, 2023
1 parent bc2cbe0 commit 3a645c6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/target
/Cargo.lock
/src/protocol/**/*.rs
18 changes: 8 additions & 10 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,6 @@ fn main() {
}
}

// clear the protocol directory
if Path::new("src/protocol").exists() {
std::fs::remove_dir_all("src/protocol").unwrap();
}

let enums: Vec<Enum> = protocols
.iter()
.map(|(protocol, _)| {
Expand Down Expand Up @@ -469,11 +464,13 @@ fn generate_packet_file(
code.push_str("\n");
}

let path_name = path.to_str().unwrap();

// either Server or Client
let source = match path.to_str().unwrap() {
"src/protocol/net/server" => "Server",
"src/protocol/net/client" => "Client",
_ => panic!("Unknown protocol path: {}", path.to_string_lossy()),
let source = if path_name.ends_with("server") {
"Server"
} else {
"Client"
};

let name = format!("{}{}{}Packet", packet.family, packet.action, source);
Expand Down Expand Up @@ -1668,7 +1665,8 @@ fn append_doc_comments(code: &mut String, comments: Vec<&str>) {
}

fn get_output_directory(base: &Path) -> PathBuf {
Path::new("src/protocol").join(
let out_dir = std::env::var_os("OUT_DIR").unwrap();
Path::new(&out_dir).join(
base.parent()
.unwrap()
.strip_prefix("eo-protocol/xml")
Expand Down
1 change: 1 addition & 0 deletions src/protocol.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include!(concat!(env!("OUT_DIR"), "/mod.rs"));

0 comments on commit 3a645c6

Please sign in to comment.