1use core::{
2 cmp, fmt,
4 hash,
5};
6use std::{
7 path::PathBuf, sync::Arc,
9};
10
11use crate::{
12 link_type::LinkPtr, project::Project,
14};
15
16pub trait Target: fmt::Debug + Send + Sync {
17 fn name(&self) -> &str;
18 fn output_name(&self) -> &str;
19 fn project(&self) -> Arc<Project>;
20}
21
22pub trait LinkTarget: Target {
23 fn public_includes(&self) -> Vec<PathBuf>;
24 fn public_includes_recursive(&self) -> Vec<PathBuf>;
25
26 fn public_defines(&self) -> Vec<String>;
27 fn public_defines_recursive(&self) -> Vec<String>;
28
29 fn public_link_flags(&self) -> Vec<String>;
30 fn public_link_flags_recursive(&self) -> Vec<String>;
31
32 fn public_links(&self) -> Vec<LinkPtr>;
33 fn public_links_recursive(&self) -> Vec<LinkPtr>;
34}
35
36#[derive(Clone)]
37pub(super) struct LinkTargetPtr(pub Arc<dyn LinkTarget>);
38
39impl cmp::PartialEq for LinkTargetPtr {
40 fn eq(&self, other: &LinkTargetPtr) -> bool {
41 core::ptr::eq(Arc::as_ptr(&self.0) as *const (), Arc::as_ptr(&other.0) as *const ())
42 }
43}
44impl cmp::Eq for LinkTargetPtr {}
45impl hash::Hash for LinkTargetPtr {
46 fn hash<H>(&self, hasher: &mut H)
47 where
48 H: std::hash::Hasher,
49 {
50 (Arc::as_ptr(&self.0) as *const ()).hash(hasher)
51 }
52}