Skip to content

Commit

Permalink
fix pest_derive without std under a workspace in Windows (pest-pars…
Browse files Browse the repository at this point in the history
…er#1034)

* windows workaround

* bump cargo to 0.81

* fixes for cargo 0.81

* strip prefix

* fmt fix
  • Loading branch information
tomtau authored Aug 30, 2024
1 parent 21287a9 commit 537660c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
9 changes: 9 additions & 0 deletions bootstrap/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ fn main() {
env!("CARGO_MANIFEST_DIR"),
"/../meta/src/grammar.pest"
));

// workaround for Windows
// TODO: use `normpath` or a different workaround on Windows?
let pest_ref = pest.to_string_lossy();
let normalized_path = pest_ref
.strip_prefix(r#"\\?\"#)
.unwrap_or_else(|| &pest_ref);
let pest = Path::new(&normalized_path);

// Path on which we should write generated grammar file.
// In case `not-bootstrap-in-src` is:
// * OFF -> in `grammar.rs` next to `grammar.pest`
Expand Down
2 changes: 1 addition & 1 deletion meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ once_cell = "1.8.0"

[build-dependencies]
sha2 = { version = "0.10", default-features = false }
cargo = { version = "0.72.2", optional = true }
cargo = { version = "0.81.0", optional = true }

[features]
default = []
Expand Down
7 changes: 3 additions & 4 deletions meta/build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#[cfg(feature = "not-bootstrap-in-src")]
use cargo::{
core::{resolver::CliFeatures, Workspace},
ops,
ops::{CompileOptions, Packages},
ops::{self, CompileOptions, Packages},
util::command_prelude::CompileMode,
Config,
GlobalContext,
};
use sha2::{Digest, Sha256};
use std::env;
Expand Down Expand Up @@ -82,7 +81,7 @@ fn main() {

#[cfg(feature = "not-bootstrap-in-src")]
{
let config = Config::default().expect("cargo config");
let config = GlobalContext::default().expect("cargo config");
let workspace_manifest = manifest_dir
.join("../Cargo.toml")
.canonicalize()
Expand Down

0 comments on commit 537660c

Please sign in to comment.