Repo to repo with deps, test

Signed-off-by: Luca Fulchir <luca.fulchir@runesauth.com>
This commit is contained in:
Luca Fulchir 2024-12-04 16:38:04 +01:00
parent a615ee13ba
commit 081d0ecbc1
Signed by: luca.fulchir
GPG Key ID: 8F6440603D13A78E
5 changed files with 16 additions and 3 deletions

View File

@ -276,7 +276,7 @@ pub(crate) fn deps_build(
*
}
#[::macro_magic::export_tokens(#pkg_trait)]
pub trait #pkg_trait {
pub trait #pkg_trait: ::bok::Repository {
#(fn #deps(&self) -> ::std::boxed::Box<dyn ::bok::Pkg>;)
*
}

View File

@ -227,6 +227,9 @@ pub(crate) fn derive_repository(input: TokenStream) -> TokenStream {
_ => None,
}
}
fn as_any(&self) -> &dyn ::std::any::Any {
self
}
}
}.into()
}

View File

@ -48,7 +48,7 @@ impl ::bok::Pkg for One {
}
fn dependencies_set(
&self,
_repo: ::std::sync::Arc<dyn ::bok::Repository>,
repo: ::std::sync::Arc<dyn ::bok::Repository>,
_build: &::bok::deps::Build,
_runtime: &::bok::deps::Runtime,
) -> Result<(), ()> {

View File

@ -45,10 +45,16 @@ impl ::std::default::Default for Two {
impl ::bok::Pkg for Two {
fn dependencies_set(
&self,
_repo: ::std::sync::Arc<dyn ::bok::Repository>,
repo: ::std::sync::Arc<dyn ::bok::Repository>,
_build: &::bok::deps::Build,
_runtime: &::bok::deps::Runtime,
) -> Result<(), ()> {
let repo_any = repo.as_any();
let Some(actual_repo) = repo_any.downcast_ref::<R>() else {
return Err(());
};
let _ = actual_repo.one();
Ok(())
}
}

View File

@ -52,6 +52,7 @@ pub trait Repository: ::core::fmt::Debug {
fn path(&self) -> Path<RepoName>;
fn pkg_list(&self) -> &[&'static str];
fn get(&self, pkg_name: &str) -> Option<::std::boxed::Box<dyn Pkg>>;
fn as_any(&self) -> &dyn ::std::any::Any;
}
/// This is an empty Package List.
@ -75,6 +76,9 @@ impl Repository for RepositoryEmpty {
fn get(&self, _pkg_name: &str) -> Option<::std::boxed::Box<dyn Pkg>> {
None
}
fn as_any(&self) -> &dyn ::std::any::Any {
self
}
}
/// Print the code of the package