Skip to content

Commit

Permalink
tools: Use forward- instead of backslashes for non-Windows OS-es
Browse files Browse the repository at this point in the history
Using forward slashes makes it so that all the tools generate files into
the proper directories on Linux - otherwise new folders/files with `\\`
in the name are created, and none of the existing files are properly
overwritten.
  • Loading branch information
MarijnS95 committed Oct 28, 2021
1 parent 427aa8e commit e96158e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ exclude = [".github", ".windows", "docs", "tests"]

[workspace]
members = [
"crates/deps/*",
"crates/targets/*",
"crates/tools/*",
"crates/tests/legacy/*",
"crates/tests/metadata/*",
"crates/tests/winrt/*",
"crates/tests/win32/*"]
"crates/deps/*",
"crates/targets/*",
"crates/tools/*",
"crates/tests/legacy/*",
"crates/tests/metadata/*",
"crates/tests/winrt/*",
"crates/tests/win32/*"
]
exclude = ["crates/tests/component"]

[package.metadata.docs.rs]
Expand Down
21 changes: 11 additions & 10 deletions crates/tools/api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io::prelude::*;
fn main() {
let start = std::time::Instant::now();
let mut output = std::path::PathBuf::from(reader::workspace_dir());
output.push("src\\Windows");
output.push("src/Windows");
let _ = std::fs::remove_dir_all(&output);
output.pop();

Expand Down Expand Up @@ -56,13 +56,14 @@ exclude = [".github", ".windows", "docs", "tests"]
[workspace]
members = [
"crates/deps/*",
"crates/targets/*",
"crates/tools/*",
"crates/tests/legacy/*",
"crates/tests/metadata/*",
"crates/tests/winrt/*",
"crates/tests/win32/*"]
"crates/deps/*",
"crates/targets/*",
"crates/tools/*",
"crates/tests/legacy/*",
"crates/tests/metadata/*",
"crates/tests/winrt/*",
"crates/tests/win32/*"
]
exclude = ["crates/tests/component"]
[package.metadata.docs.rs]
Expand Down Expand Up @@ -136,15 +137,15 @@ fn collect_trees<'a>(
.for_each(|tree| collect_trees(output, root, tree, trees));

let mut path = std::path::PathBuf::from(output);
path.push(tree.namespace.replace('.', "\\"));
path.push(tree.namespace.replace('.', "/"));
std::fs::create_dir_all(&path).unwrap();
}

fn gen_tree(output: &std::path::Path, root: &'static str, tree: &reader::TypeTree) {
println!("{}", tree.namespace);
let mut path = std::path::PathBuf::from(output);

path.push(tree.namespace.replace('.', "\\"));
path.push(tree.namespace.replace('.', "/"));
path.push("mod.rs");

let tokens = gen::gen_source_file(root, tree);
Expand Down
2 changes: 1 addition & 1 deletion crates/tools/bindings/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() -> std::io::Result<()> {
};

let mut path: std::path::PathBuf = reader::workspace_dir().into();
path.push("src\\runtime\\bindings.rs");
path.push("src/runtime/bindings.rs");

std::fs::write(&path, tokens)?;

Expand Down
2 changes: 1 addition & 1 deletion crates/tools/gnu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn main() {
load_functions(root, &mut libraries);

let mut output = std::path::PathBuf::from(reader::workspace_dir());
output.push(format!("crates\\targets\\{}\\lib", platform));
output.push(format!("crates/targets/{}/lib", platform));

let _ = std::fs::remove_dir_all(&output);
std::fs::create_dir_all(&output).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/tools/msvc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn main() {
load_functions(root, &mut libraries);

let mut output = std::path::PathBuf::from(reader::workspace_dir());
output.push(format!("crates\\targets\\{}\\lib", platform));
output.push(format!("crates/targets/{}/lib", platform));
let _ = std::fs::remove_dir_all(&output);
std::fs::create_dir_all(&output).unwrap();

Expand Down

0 comments on commit e96158e

Please sign in to comment.