From 537660ceb4c21c853746ca7833aa4be2ca912146 Mon Sep 17 00:00:00 2001 From: Tomas Tauber <2410580+tomtau@users.noreply.github.com> Date: Sat, 31 Aug 2024 07:45:52 +0800 Subject: [PATCH] fix `pest_derive` without std under a workspace in Windows (#1034) * windows workaround * bump cargo to 0.81 * fixes for cargo 0.81 * strip prefix * fmt fix --- bootstrap/src/main.rs | 9 +++++++++ meta/Cargo.toml | 2 +- meta/build.rs | 7 +++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bootstrap/src/main.rs b/bootstrap/src/main.rs index ddcc9d38..0c9aadf3 100644 --- a/bootstrap/src/main.rs +++ b/bootstrap/src/main.rs @@ -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` diff --git a/meta/Cargo.toml b/meta/Cargo.toml index b2989b3c..d10bddeb 100644 --- a/meta/Cargo.toml +++ b/meta/Cargo.toml @@ -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 = [] diff --git a/meta/build.rs b/meta/build.rs index 0c8f69ed..b61c53e9 100644 --- a/meta/build.rs +++ b/meta/build.rs @@ -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; @@ -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()