1use std::path::Path;
2
3pub struct LinkPathsArgsIter<P, T>
4where
5 P: AsRef<Path>,
6 T: Iterator<Item = P>,
7{
8 inner: T,
9}
10
11impl<P, T> From<T> for LinkPathsArgsIter<P, T>
12where
13 P: AsRef<Path>,
14 T: Iterator<Item = P>,
15{
16 #[inline]
17 fn from(inner: T) -> Self {
18 Self { inner }
19 }
20}
21
22impl<P, T> Iterator for LinkPathsArgsIter<P, T>
23where
24 P: AsRef<Path>,
25 T: Iterator<Item = P>,
26{
27 type Item = String;
28
29 #[inline]
30 fn next(&mut self) -> Option<Self::Item> {
31 Some(format!("-L{}", self.inner.next()?.as_ref().display()))
32 }
33}
34
35pub struct IncludePathsArgsIter<P, T>
36where
37 P: AsRef<Path>,
38 T: Iterator<Item = P>,
39{
40 inner: T,
41}
42
43impl<P, T> From<T> for IncludePathsArgsIter<P, T>
44where
45 P: AsRef<Path>,
46 T: Iterator<Item = P>,
47{
48 #[inline]
49 fn from(inner: T) -> Self {
50 Self { inner }
51 }
52}
53
54impl<P, T> Iterator for IncludePathsArgsIter<P, T>
55where
56 P: AsRef<Path>,
57 T: Iterator<Item = P>,
58{
59 type Item = String;
60
61 #[inline]
62 fn next(&mut self) -> Option<Self::Item> {
63 Some(format!("-I{}", self.inner.next()?.as_ref().display()))
64 }
65}
66
67pub struct FrameworkPathsArgsIter<P, T>
68where
69 P: AsRef<Path>,
70 T: Iterator<Item = P>,
71{
72 inner: T,
73}
74
75impl<P, T> From<T> for FrameworkPathsArgsIter<P, T>
76where
77 P: AsRef<Path>,
78 T: Iterator<Item = P>,
79{
80 #[inline]
81 fn from(inner: T) -> Self {
82 Self { inner }
83 }
84}
85
86impl<P, T> Iterator for FrameworkPathsArgsIter<P, T>
87where
88 P: AsRef<Path>,
89 T: Iterator<Item = P>,
90{
91 type Item = String;
92
93 #[inline]
94 fn next(&mut self) -> Option<Self::Item> {
95 Some(format!("-F{}", self.inner.next()?.as_ref().display()))
96 }
97}
98
99pub struct FrameworksArgsIter<P, T>
100where
101 P: AsRef<str>,
102 T: Iterator<Item = P>,
103{
104 inner: T,
105 next: Option<P>,
106}
107
108impl<P, T> From<T> for FrameworksArgsIter<P, T>
109where
110 P: AsRef<str>,
111 T: Iterator<Item = P>,
112{
113 #[inline]
114 fn from(inner: T) -> Self {
115 Self { inner, next: None }
116 }
117}
118
119impl<P, T> Iterator for FrameworksArgsIter<P, T>
120where
121 P: AsRef<str>,
122 T: Iterator<Item = P>,
123{
124 type Item = String;
125
126 fn next(&mut self) -> Option<Self::Item> {
127 if let Some(x) = self.next.take() {
128 Some(x.as_ref().to_string())
129 } else {
130 self.next = Some(self.inner.next()?);
131 Some("-framework".to_string())
132 }
133 }
134}
135
136pub struct LibsArgsIter<P, T>
137where
138 P: AsRef<str>,
139 T: Iterator<Item = P>,
140{
141 inner: T,
142}
143
144impl<P, T> From<T> for LibsArgsIter<P, T>
145where
146 P: AsRef<str>,
147 T: Iterator<Item = P>,
148{
149 #[inline]
150 fn from(inner: T) -> Self {
151 Self { inner }
152 }
153}
154
155impl<P, T> Iterator for LibsArgsIter<P, T>
156where
157 P: AsRef<str>,
158 T: Iterator<Item = P>,
159{
160 type Item = String;
161
162 #[inline]
163 fn next(&mut self) -> Option<Self::Item> {
164 Some(format!("-l{}", self.inner.next()?.as_ref()))
165 }
166}
167
168pub struct LdArgsArgsIter<P, I, T>
169where
170 P: AsRef<str>,
171 I: Iterator<Item = P>,
172 T: Iterator<Item = I>,
173{
174 inner: T,
175}
176
177impl<P, I, T> From<T> for LdArgsArgsIter<P, I, T>
178where
179 P: AsRef<str>,
180 I: Iterator<Item = P>,
181 T: Iterator<Item = I>,
182{
183 #[inline]
184 fn from(inner: T) -> Self {
185 Self { inner }
186 }
187}
188
189impl<P, I, T> Iterator for LdArgsArgsIter<P, I, T>
190where
191 P: AsRef<str>,
192 I: Iterator<Item = P>,
193 T: Iterator<Item = I>,
194{
195 type Item = String;
196
197 fn next(&mut self) -> Option<Self::Item> {
198 loop {
199 let arg = self
200 .inner
201 .next()?
202 .fold(String::new(), |a, b| a + b.as_ref());
203
204 if !arg.is_empty() {
205 return Some(format!("-Wl,{}", arg));
206 }
207 }
208 }
209}
210
211pub struct DefinesArgsIter<'a, S1, S2, T>
212where
213 S1: AsRef<str> + 'a,
214 S2: AsRef<str> + 'a,
215 T: Iterator<Item = (S1, &'a Option<S2>)> + 'a,
216{
217 inner: T,
218}
219
220impl<'a, S1, S2, T> From<T> for DefinesArgsIter<'a, S1, S2, T>
221where
222 S1: AsRef<str> + 'a,
223 S2: AsRef<str> + 'a,
224 T: Iterator<Item = (S1, &'a Option<S2>)> + 'a,
225{
226 #[inline]
227 fn from(inner: T) -> Self {
228 Self { inner }
229 }
230}
231
232impl<'a, S1, S2, T> Iterator for DefinesArgsIter<'a, S1, S2, T>
233where
234 S1: AsRef<str> + 'a,
235 S2: AsRef<str> + 'a,
236 T: Iterator<Item = (S1, &'a Option<S2>)> + 'a,
237{
238 type Item = String;
239
240 fn next(&mut self) -> Option<Self::Item> {
241 let (k, v) = self.inner.next()?;
242 Some(if let Some(v) = v {
243 format!("-D{}={}", k.as_ref(), v.as_ref())
244 } else {
245 format!("-D{}", k.as_ref())
246 })
247 }
248}