crossbeamパッケージ
Révision | 4522dd21266142a9ef58fefc3f9d00b90a28bd75 (tree) |
---|---|
l'heure | 2020-04-09 01:28:43 |
Auteur | dyknon <dyknon@user...> |
Commiter | dyknon |
deb-crateinfo.pl - add target="cfg(...)" support
@@ -34,10 +34,15 @@ sub getopt{ | ||
34 | 34 | },{ |
35 | 35 | name => "req_dev", |
36 | 36 | long => ["require-dev"], |
37 | + },{ | |
38 | + name => "rust_cfg", | |
39 | + long => ["cfg"], | |
40 | + arg => 1, | |
37 | 41 | } |
38 | 42 | ); |
39 | 43 | my %ret = ( |
40 | 44 | manifest_path => "Cargo.toml", |
45 | + rust_cfg => [] | |
41 | 46 | ); |
42 | 47 | my $str_arg = sub{ |
43 | 48 | my $name = shift; |
@@ -156,12 +161,119 @@ sub list_features_pac{ | ||
156 | 161 | }(list_features($package)); |
157 | 162 | } |
158 | 163 | |
164 | +sub is_cfg_true{ | |
165 | + my $cfg = shift; | |
166 | + if($cfg =~ /^(all|any|not)\(\s*(.*)\)\s*$/){ | |
167 | + if($1 eq "all"){ | |
168 | + return 1 if($2 eq ""); | |
169 | + for(split(/,\s*/, $2)){ | |
170 | + return 0 if(!is_cfg_true($_)); | |
171 | + } | |
172 | + return 1; | |
173 | + }elsif($1 eq "any"){ | |
174 | + return 0 if($2 eq ""); | |
175 | + for(split(/,\s*/, $2)){ | |
176 | + return 1 if(is_cfg_true($_)); | |
177 | + } | |
178 | + return 0; | |
179 | + }elsif($1 eq "not"){ | |
180 | + return !is_cfg_true($2); | |
181 | + }else{ | |
182 | + die; | |
183 | + } | |
184 | + }elsif($cfg =~ /^(?:r#)?([a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)\s*(?:=(.+))?$/){ | |
185 | + my $id = $1; | |
186 | + my $str; | |
187 | + if(defined($2)){ | |
188 | + my $sl = $2; | |
189 | + if($sl =~ /^\s*r(#(?1)#|"(?:[^\r]|\r(?=\n))*?")\s*(.?)/){ | |
190 | + die "cfg(...) syntax error" if(length($2)); | |
191 | + $str = $1 =~ s/^#*"|"#*$//gr; | |
192 | + }elsif($sl =~ m/^ | |
193 | + \s* " | |
194 | + ( | |
195 | + (?: | |
196 | + [^"\\\r] | |
197 | + | \r(?=\n) | |
198 | + | \\ (?: | |
199 | + ["'nrt\\0] | |
200 | + | x[0-7][0-9a-fA-F] | |
201 | + | u\{ (?: [0-9A-Fa-f] _* ){1,6} \} | |
202 | + | \n | |
203 | + ) | |
204 | + )* | |
205 | + ) " \s* (.?) | |
206 | + /x){ | |
207 | + die "cfg(...) syntax error" if(length($2)); | |
208 | + $str = $1 =~ s{ | |
209 | + ([^"\\\r]) | |
210 | + | (\r)(?=\n) | |
211 | + | \\ (?: | |
212 | + (["']) | |
213 | + | ([nrt\\0]) | |
214 | + | x([0-7][0-9a-fA-F]) | |
215 | + | u\{ ( (?: [0-9A-Fa-f] _* ){1,6} ) \} | |
216 | + | \n \ * | |
217 | + ) | |
218 | + }{ | |
219 | + $1//$2//$3//( | |
220 | + defined($4) ? | |
221 | + ( $4 =~ tr/nrt\\0/\n\r\t\\\0/r ) | |
222 | + : defined($5//$6) ? | |
223 | + chr(hex($5//$6 =~ s/_//gr)) | |
224 | + : | |
225 | + "" | |
226 | + ) | |
227 | + }rexg; | |
228 | + }else{ | |
229 | + die "cfg(...) syntax error"; | |
230 | + } | |
231 | + } | |
232 | + | |
233 | + my %cfgs = ( | |
234 | + target_arch => undef, | |
235 | + target_feature => undef, | |
236 | + target_os => undef, | |
237 | + target_family => "unix", | |
238 | + unix => "set", | |
239 | + #windows => debian system is not windows | |
240 | + target_env => undef, | |
241 | + target_endian => undef, | |
242 | + target_pointer_width=> undef, | |
243 | + target_vendor => undef, | |
244 | + test => undef, | |
245 | + debug_assertions => undef, | |
246 | + proc_macro => undef, | |
247 | + ); | |
248 | + for(@{$opts{rust_cfg}}){ | |
249 | + if(/^(.*?)=(.*)$/){ | |
250 | + $cfgs{$1} = $2; | |
251 | + }else{ | |
252 | + $cfgs{$_} = "set"; | |
253 | + } | |
254 | + } | |
255 | + | |
256 | + return 0 if(!exists($cfgs{$id})); | |
257 | + return !defined($str) || $cfgs{$id} eq $str if(defined($cfgs{$id})); | |
258 | + | |
259 | + ... | |
260 | + }else{ | |
261 | + die "cfg(...) syntax error"; | |
262 | + } | |
263 | +} | |
264 | + | |
159 | 265 | sub expand_dep{ |
160 | 266 | my $dep = shift; |
161 | 267 | if(!defined($dep)){ |
162 | - return; | |
268 | + return (); | |
269 | + } | |
270 | + if(defined($dep->{target})){ | |
271 | + if($dep->{target} =~ /^\s*cfg\(\s*(.*)\)\s*$/){ | |
272 | + return () if(!is_cfg_true($1)); | |
273 | + }else{ | |
274 | + die "unhandleable target specific dependency"; | |
275 | + } | |
163 | 276 | } |
164 | - die "dependency with target" if($dep->{target}); | |
165 | 277 | ($dep->{name}.($dep->{uses_default_features}?"/default":""), $dep->{req}, |
166 | 278 | map{("$dep->{name}/$_", $dep->{req})}(@{$dep->{features}})); |
167 | 279 | } |
@@ -395,6 +507,10 @@ EOT | ||
395 | 507 | } |
396 | 508 | } |
397 | 509 | exit; |
510 | +}elsif($comm[0] eq "test-cfg"){ | |
511 | + die "give rust ConfigurationPredicate" if(!$comm[1]); | |
512 | + print(is_cfg_true($comm[1]) ? "true\n" : "false\n"); | |
513 | + exit; | |
398 | 514 | } |
399 | 515 | |
400 | 516 | my $crate = $comm[1]; |
@@ -1,3 +1,4 @@ | ||
1 | 1 | [DEFAULT] |
2 | 2 | pristine-tar = true |
3 | +debian-tag = deb/%(version)s | |
3 | 4 | upstream-tag = upstream/%(version)s |