From 82d43e28294f39710256f59f319574a61526b42c Mon Sep 17 00:00:00 2001 From: Luca Fulchir Date: Mon, 11 Nov 2024 22:08:53 +0100 Subject: [PATCH] Deps Signed-off-by: Luca Fulchir --- bok-macro/src/lib.rs | 5 ++++- bok-utils/src/pkgs/one.rs | 8 ++++++++ bok-utils/src/pkgs/three.rs | 8 ++++++++ bok-utils/src/pkgs/two.rs | 11 ++++++++++- bok/src/lib.rs | 14 +++++++++++--- 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/bok-macro/src/lib.rs b/bok-macro/src/lib.rs index 968ad85..e135deb 100644 --- a/bok-macro/src/lib.rs +++ b/bok-macro/src/lib.rs @@ -271,7 +271,7 @@ pub fn impl_package(_attrs: TokenStream, input: TokenStream) -> TokenStream { write!(&mut pkg_vars, "{:?}", self, - ); + ).ok(); hasher.update(&pkg_vars); hasher.update(self.to_string()); 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() { 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! { #[::bok::pkg_fn_to_code] #fn_impl diff --git a/bok-utils/src/pkgs/one.rs b/bok-utils/src/pkgs/one.rs index 634b8a4..3e9ca01 100644 --- a/bok-utils/src/pkgs/one.rs +++ b/bok-utils/src/pkgs/one.rs @@ -43,4 +43,12 @@ impl ::bok::Pkg for One { fn build(&self) -> ::core::result::Result<(), ()> { ret = ::core::result::Result::Ok(()); } + fn dependencies_set( + &self, + _repo: ::std::sync::Arc, + _build: &::bok::deps::Build, + _runtime: &::bok::deps::Runtime, + ) -> Result<(), ()> { + Ok(()) + } } diff --git a/bok-utils/src/pkgs/three.rs b/bok-utils/src/pkgs/three.rs index b2432f6..04d727b 100644 --- a/bok-utils/src/pkgs/three.rs +++ b/bok-utils/src/pkgs/three.rs @@ -42,4 +42,12 @@ impl ::bok::Pkg for Three { fn build(&self) -> ::core::result::Result<(), ()> { ret = ::core::result::Result::Ok(()); } + fn dependencies_set( + &self, + _repo: ::std::sync::Arc, + _build: &::bok::deps::Build, + _runtime: &::bok::deps::Runtime, + ) -> Result<(), ()> { + Ok(()) + } } diff --git a/bok-utils/src/pkgs/two.rs b/bok-utils/src/pkgs/two.rs index 4d7a70c..3d4767f 100644 --- a/bok-utils/src/pkgs/two.rs +++ b/bok-utils/src/pkgs/two.rs @@ -38,4 +38,13 @@ impl ::std::default::Default for Two { } } #[::bok::impl_package] -impl ::bok::Pkg for Two {} +impl ::bok::Pkg for Two { + fn dependencies_set( + &self, + _repo: ::std::sync::Arc, + _build: &::bok::deps::Build, + _runtime: &::bok::deps::Runtime, + ) -> Result<(), ()> { + Ok(()) + } +} diff --git a/bok/src/lib.rs b/bok/src/lib.rs index cd4d2db..1a7bd06 100644 --- a/bok/src/lib.rs +++ b/bok/src/lib.rs @@ -16,11 +16,13 @@ * limitations under the License. */ +use ::std::sync::Arc; + mod collection; mod names; pub use collection::Collection; pub use names::{Path, PkgName, RepoName}; -mod deps { +pub mod deps { pub struct Build(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 as_any(&self) -> &dyn ::std::any::Any; fn as_any_mut(&mut self) -> &mut dyn ::std::any::Any; - /* fn dependencies_set( &self, repo: Arc, build: &deps::Build, runtime: &deps::Runtime, ) -> Result<(), ()>; - */ fn prepare(&self) -> ::core::result::Result<(), ()> { self.base().unwrap().prepare() } @@ -245,6 +245,14 @@ impl Pkg for PkgEmpty { fn as_any_mut(&mut self) -> &mut dyn ::std::any::Any { self } + fn dependencies_set( + &self, + _repo: Arc, + _build: &deps::Build, + _runtime: &deps::Runtime, + ) -> Result<(), ()> { + Ok(()) + } fn prepare(&self) -> ::core::result::Result<(), ()> { ::core::result::Result::Ok(()) }