Skip to content

Commit

Permalink
chore(deps): update cargo_toml for edition 2024 [fix tauri-apps#10412] (
Browse files Browse the repository at this point in the history
tauri-apps#12270)

Co-authored-by: Fabian-Lars <[email protected]>
  • Loading branch information
aurelj and FabianLars authored Jan 6, 2025
1 parent ae75a35 commit 848d0e0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .changes/change-pr-12270.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-build": "patch:bug"
---

Update `cargo_toml` to `0.21.0`. This adds compatibility with Rust's 2024 Edition.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/tauri-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ tauri-utils = { version = "2.1.1", path = "../tauri-utils", features = [
"build",
"resources",
] }
cargo_toml = "0.17"
cargo_toml = "0.21"
serde = "1"
serde_json = "1"
heck = "0.5"
Expand Down
35 changes: 2 additions & 33 deletions crates/tauri-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,19 +506,8 @@ pub fn try_build(attributes: Attributes) -> Result<()> {

cfg_alias("dev", is_dev());

let ws_path = get_workspace_dir()?;
let mut manifest =
Manifest::<cargo_toml::Value>::from_slice_with_metadata(&fs::read("Cargo.toml")?)?;

if let Ok(ws_manifest) = Manifest::from_path(ws_path.join("Cargo.toml")) {
Manifest::complete_from_path_and_workspace(
&mut manifest,
Path::new("Cargo.toml"),
Some((&ws_manifest, ws_path.as_path())),
)?;
} else {
Manifest::complete_from_path(&mut manifest, Path::new("Cargo.toml"))?;
}
let cargo_toml_path = Path::new("Cargo.toml").canonicalize()?;
let mut manifest = Manifest::<cargo_toml::Value>::from_path_with_metadata(cargo_toml_path)?;

let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());

Expand Down Expand Up @@ -701,23 +690,3 @@ pub fn try_build(attributes: Attributes) -> Result<()> {

Ok(())
}

#[derive(serde::Deserialize)]
struct CargoMetadata {
workspace_root: PathBuf,
}

fn get_workspace_dir() -> Result<PathBuf> {
let output = std::process::Command::new("cargo")
.args(["metadata", "--no-deps", "--format-version", "1"])
.output()?;

if !output.status.success() {
return Err(anyhow::anyhow!(
"cargo metadata command exited with a non zero exit code: {}",
String::from_utf8(output.stderr)?
));
}

Ok(serde_json::from_slice::<CargoMetadata>(&output.stdout)?.workspace_root)
}
2 changes: 1 addition & 1 deletion crates/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
tauri = { path = ".", default-features = false, features = ["wry"] }
tokio = { version = "1", features = ["full"] }
cargo_toml = "0.17"
cargo_toml = "0.21"
http-range = "0.1.5"

# macOS
Expand Down

0 comments on commit 848d0e0

Please sign in to comment.