Signed-off-by: Luca Fulchir <luca.fulchir@runesauth.com>
This commit is contained in:
Luca Fulchir 2024-11-11 22:08:53 +01:00
parent 09cef1ff93
commit 82d43e2829
Signed by: luca.fulchir
GPG Key ID: 8F6440603D13A78E
5 changed files with 41 additions and 5 deletions

View File

@ -271,7 +271,7 @@ pub fn impl_package(_attrs: TokenStream, input: TokenStream) -> TokenStream {
write!(&mut pkg_vars, write!(&mut pkg_vars,
"{:?}", "{:?}",
self, self,
); ).ok();
hasher.update(&pkg_vars); hasher.update(&pkg_vars);
hasher.update(self.to_string()); hasher.update(self.to_string());
let hash = hasher.finalize(); let hash = hasher.finalize();
@ -290,6 +290,9 @@ pub fn impl_package(_attrs: TokenStream, input: TokenStream) -> TokenStream {
for mut impl_item in ast.items.iter_mut() { for mut impl_item in ast.items.iter_mut() {
if let ::syn::ImplItem::Fn(ref mut fn_impl) = &mut impl_item { if let ::syn::ImplItem::Fn(ref mut fn_impl) = &mut impl_item {
if fn_impl.sig.ident.to_string() == "dependencies_set" {
continue;
}
let fn_with_code: ::syn::ImplItemFn = ::syn::parse_quote! { let fn_with_code: ::syn::ImplItemFn = ::syn::parse_quote! {
#[::bok::pkg_fn_to_code] #[::bok::pkg_fn_to_code]
#fn_impl #fn_impl

View File

@ -43,4 +43,12 @@ impl ::bok::Pkg for One {
fn build(&self) -> ::core::result::Result<(), ()> { fn build(&self) -> ::core::result::Result<(), ()> {
ret = ::core::result::Result::Ok(()); ret = ::core::result::Result::Ok(());
} }
fn dependencies_set(
&self,
_repo: ::std::sync::Arc<dyn ::bok::Repository>,
_build: &::bok::deps::Build,
_runtime: &::bok::deps::Runtime,
) -> Result<(), ()> {
Ok(())
}
} }

View File

@ -42,4 +42,12 @@ impl ::bok::Pkg for Three {
fn build(&self) -> ::core::result::Result<(), ()> { fn build(&self) -> ::core::result::Result<(), ()> {
ret = ::core::result::Result::Ok(()); ret = ::core::result::Result::Ok(());
} }
fn dependencies_set(
&self,
_repo: ::std::sync::Arc<dyn ::bok::Repository>,
_build: &::bok::deps::Build,
_runtime: &::bok::deps::Runtime,
) -> Result<(), ()> {
Ok(())
}
} }

View File

@ -38,4 +38,13 @@ impl ::std::default::Default for Two {
} }
} }
#[::bok::impl_package] #[::bok::impl_package]
impl ::bok::Pkg for Two {} impl ::bok::Pkg for Two {
fn dependencies_set(
&self,
_repo: ::std::sync::Arc<dyn ::bok::Repository>,
_build: &::bok::deps::Build,
_runtime: &::bok::deps::Runtime,
) -> Result<(), ()> {
Ok(())
}
}

View File

@ -16,11 +16,13 @@
* limitations under the License. * limitations under the License.
*/ */
use ::std::sync::Arc;
mod collection; mod collection;
mod names; mod names;
pub use collection::Collection; pub use collection::Collection;
pub use names::{Path, PkgName, RepoName}; pub use names::{Path, PkgName, RepoName};
mod deps { pub mod deps {
pub struct Build(pub crate::Collection); pub struct Build(pub crate::Collection);
pub struct Runtime(pub crate::Collection); pub struct Runtime(pub crate::Collection);
} }
@ -123,14 +125,12 @@ pub trait Pkg:
fn base_mut(&mut self) -> ::core::option::Option<&mut dyn Pkg>; fn base_mut(&mut self) -> ::core::option::Option<&mut dyn Pkg>;
fn as_any(&self) -> &dyn ::std::any::Any; fn as_any(&self) -> &dyn ::std::any::Any;
fn as_any_mut(&mut self) -> &mut dyn ::std::any::Any; fn as_any_mut(&mut self) -> &mut dyn ::std::any::Any;
/*
fn dependencies_set( fn dependencies_set(
&self, &self,
repo: Arc<dyn Repository>, repo: Arc<dyn Repository>,
build: &deps::Build, build: &deps::Build,
runtime: &deps::Runtime, runtime: &deps::Runtime,
) -> Result<(), ()>; ) -> Result<(), ()>;
*/
fn prepare(&self) -> ::core::result::Result<(), ()> { fn prepare(&self) -> ::core::result::Result<(), ()> {
self.base().unwrap().prepare() self.base().unwrap().prepare()
} }
@ -245,6 +245,14 @@ impl Pkg for PkgEmpty {
fn as_any_mut(&mut self) -> &mut dyn ::std::any::Any { fn as_any_mut(&mut self) -> &mut dyn ::std::any::Any {
self self
} }
fn dependencies_set(
&self,
_repo: Arc<dyn Repository>,
_build: &deps::Build,
_runtime: &deps::Runtime,
) -> Result<(), ()> {
Ok(())
}
fn prepare(&self) -> ::core::result::Result<(), ()> { fn prepare(&self) -> ::core::result::Result<(), ()> {
::core::result::Result::Ok(()) ::core::result::Result::Ok(())
} }