diff --git a/pilota-build/src/lib.rs b/pilota-build/src/lib.rs index e68b3273..09ca7cac 100644 --- a/pilota-build/src/lib.rs +++ b/pilota-build/src/lib.rs @@ -86,6 +86,7 @@ pub struct Builder { keep_unknown_fields: Vec, dedups: Vec, nonstandard_snake_case: bool, + common_crate_name: FastStr, } impl Builder { @@ -105,6 +106,7 @@ impl Builder { keep_unknown_fields: Vec::default(), dedups: Vec::default(), nonstandard_snake_case: false, + common_crate_name: "common".into(), } } } @@ -126,6 +128,7 @@ impl Builder { keep_unknown_fields: Vec::default(), dedups: Vec::default(), nonstandard_snake_case: false, + common_crate_name: "common".into(), } } } @@ -144,6 +147,11 @@ where self.nonstandard_snake_case = flag; self } + + pub fn common_crate_name(mut self, name: FastStr) -> Self { + self.common_crate_name = name; + self + } } impl Builder { @@ -159,6 +167,7 @@ impl Builder { keep_unknown_fields: self.keep_unknown_fields, dedups: self.dedups, nonstandard_snake_case: self.nonstandard_snake_case, + common_crate_name: self.common_crate_name, } } @@ -262,6 +271,7 @@ where keep_unknown_fields: Vec, dedups: Vec, nonstandard_snake_case: bool, + common_crate_name: FastStr, ) -> Context { let mut db = RootDatabase::default(); parser.inputs(services.iter().map(|s| &s.path)); @@ -336,6 +346,7 @@ where change_case, dedups, nonstandard_snake_case, + common_crate_name, ) } @@ -353,6 +364,7 @@ where self.keep_unknown_fields, self.dedups, self.nonstandard_snake_case, + self.common_crate_name, ); cx.exec_plugin(BoxedPlugin); @@ -434,6 +446,7 @@ where self.keep_unknown_fields, self.dedups, self.nonstandard_snake_case, + self.common_crate_name, ); std::thread::scope(|_scope| { diff --git a/pilota-build/src/middle/context.rs b/pilota-build/src/middle/context.rs index e1e96527..bb34e34e 100644 --- a/pilota-build/src/middle/context.rs +++ b/pilota-build/src/middle/context.rs @@ -70,6 +70,7 @@ pub struct Context { pub plugin_gen: DashMap, pub(crate) dedups: Vec, pub(crate) nonstandard_snake_case: bool, + pub(crate) common_crate_name: FastStr, } impl Clone for Context { @@ -89,6 +90,7 @@ impl Clone for Context { plugin_gen: self.plugin_gen.clone(), dedups: self.dedups.clone(), nonstandard_snake_case: self.nonstandard_snake_case, + common_crate_name: self.common_crate_name.clone(), } } } @@ -426,6 +428,7 @@ impl ContextBuilder { change_case: bool, dedups: Vec, nonstandard_snake_case: bool, + common_crate_name: FastStr, ) -> Context { Context { adjusts: Default::default(), @@ -445,6 +448,7 @@ impl ContextBuilder { plugin_gen: Default::default(), dedups, nonstandard_snake_case, + common_crate_name, } } } @@ -956,7 +960,7 @@ impl Context { .into() }) } - DefLocation::Dynamic => "common".into(), + DefLocation::Dynamic => self.common_crate_name.clone(), } } } diff --git a/pilota-build/src/middle/resolver.rs b/pilota-build/src/middle/resolver.rs index 7fd4511f..363e0b11 100644 --- a/pilota-build/src/middle/resolver.rs +++ b/pilota-build/src/middle/resolver.rs @@ -123,7 +123,7 @@ impl PathResolver for WorkspacePathResolver { path.extend(prefix.iter().cloned()); path } - super::context::DefLocation::Dynamic => ["common".into()] + super::context::DefLocation::Dynamic => [cx.common_crate_name.clone().into()] .iter() .chain(DefaultPathResolver.mod_prefix(cx, def_id).iter()) .cloned()