mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
Renames frame crate to polkadot-sdk-frame (#3813)
Step in https://github.com/paritytech/polkadot-sdk/issues/3155 Needed for https://github.com/paritytech/eng-automation/issues/6 This PR renames `frame` crate to `polkadot-sdk-frame` as `frame` is not available on crates.io --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -54,15 +54,19 @@ pub fn generate_crate_access(unique_id: &str, def_crate: &str) -> TokenStream {
|
||||
///
|
||||
/// This will usually check the output of [`generate_access_from_frame_or_crate`].
|
||||
/// We want to know if whatever the `path` takes us to, is exported from `frame` or not. In that
|
||||
/// case `path` would start with `frame`, something like `frame::x::y:z`.
|
||||
/// case `path` would start with `frame`, something like `polkadot_sdk_frame::x::y:z` or
|
||||
/// frame::x::y:z.
|
||||
pub fn is_using_frame_crate(path: &syn::Path) -> bool {
|
||||
path.segments.first().map(|s| s.ident == "frame").unwrap_or(false)
|
||||
path.segments
|
||||
.first()
|
||||
.map(|s| s.ident == "polkadot_sdk_frame" || s.ident == "frame")
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Generate the crate access for the crate using 2018 syntax.
|
||||
///
|
||||
/// If `frame` is in scope, it will use `frame::deps::<def_crate>`. Else, it will try and find
|
||||
/// `<def_crate>` directly.
|
||||
/// If `frame` is in scope, it will use `polkadot_sdk_frame::deps::<def_crate>`. Else, it will try
|
||||
/// and find `<def_crate>` directly.
|
||||
pub fn generate_access_from_frame_or_crate(def_crate: &str) -> Result<syn::Path, Error> {
|
||||
if let Some(path) = get_frame_crate_path(def_crate) {
|
||||
Ok(path)
|
||||
@@ -114,7 +118,9 @@ pub fn generate_hidden_includes(unique_id: &str, def_crate: &str) -> TokenStream
|
||||
/// Generates the path to the frame crate deps.
|
||||
fn get_frame_crate_path(def_crate: &str) -> Option<syn::Path> {
|
||||
// This does not work if the frame crate is renamed.
|
||||
if let Ok(FoundCrate::Name(name)) = crate_name(&"frame") {
|
||||
if let Ok(FoundCrate::Name(name)) =
|
||||
crate_name(&"polkadot-sdk-frame").or_else(|_| crate_name(&"frame"))
|
||||
{
|
||||
let path = format!("{}::deps::{}", name, def_crate.to_string().replace("-", "_"));
|
||||
Some(syn::parse_str::<syn::Path>(&path).expect("is a valid path; qed"))
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user