Skip to content
Snippets Groups Projects
Unverified Commit 3a6c4894 authored by PG Herveou's avatar PG Herveou Committed by GitHub
Browse files

[pallet-revive] Fix pallet-revive-fixtures build.rs (#7928)


Fix pallet-revive-uapi resolution when building pallet-revive-fixtures
contracts
follow up from https://github.com/paritytech/polkadot-sdk/pull/7844

---------

Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarxermicus <cyrill@parity.io>
parent c7d7a3ef
No related merge requests found
Pipeline #519118 waiting for manual action with stages
in 1 hour, 29 minutes, and 30 seconds
title: Fix pallet-revive-fixtures build.rs
doc:
- audience: Runtime Dev
description: |-
Fix pallet-revive-uapi resolution when building pallet-revive-fixtures
contracts
crates:
- name: pallet-revive-fixtures
bump: patch
......@@ -85,19 +85,30 @@ fn create_cargo_toml<'a>(
let mut cargo_toml: toml::Value = toml::from_str(include_str!("./build/_Cargo.toml"))?;
let uapi_dep = cargo_toml["dependencies"]["uapi"].as_table_mut().unwrap();
let metadata = MetadataCommand::new()
.manifest_path(fixtures_dir.join("Cargo.toml"))
.exec()
.expect("Failed to fetch cargo metadata");
let manifest_path = fixtures_dir.join("Cargo.toml");
let metadata = MetadataCommand::new().manifest_path(&manifest_path).exec().unwrap();
let dependency_graph = metadata.resolve.unwrap();
let mut uapi_pkgs: Vec<_> = metadata
// Resolve the pallet-revive-fixtures package id
let fixtures_pkg_id = metadata
.packages
.iter()
.filter(|pkg| pkg.name == "pallet-revive-uapi")
.collect();
.find(|pkg| pkg.manifest_path.as_std_path() == manifest_path)
.map(|pkg| pkg.id.clone())
.unwrap();
let fixtures_pkg_node =
dependency_graph.nodes.iter().find(|node| node.id == fixtures_pkg_id).unwrap();
// Get the pallet-revive-uapi package id
let uapi_pkg_id = fixtures_pkg_node
.deps
.iter()
.find(|dep| dep.name == "pallet_revive_uapi")
.map(|dep| dep.pkg.clone())
.expect("pallet-revive-uapi is a build dependency of pallet-revive-fixtures; qed");
uapi_pkgs.sort_by(|a, b| b.version.cmp(&a.version));
let uapi_pkg = uapi_pkgs.first().unwrap();
// Get pallet-revive-uapi package
let uapi_pkg = metadata.packages.iter().find(|pkg| pkg.id == uapi_pkg_id).unwrap();
if uapi_pkg.source.is_none() {
uapi_dep.insert(
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment