• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

crossbeamパッケージ


Commit MetaInfo

Révision4522dd21266142a9ef58fefc3f9d00b90a28bd75 (tree)
l'heure2020-04-09 01:28:43
Auteurdyknon <dyknon@user...>
Commiterdyknon

Message de Log

deb-crateinfo.pl - add target="cfg(...)" support

Change Summary

Modification

--- a/debian/deb-crateinfo.pl
+++ b/debian/deb-crateinfo.pl
@@ -34,10 +34,15 @@ sub getopt{
3434 },{
3535 name => "req_dev",
3636 long => ["require-dev"],
37+ },{
38+ name => "rust_cfg",
39+ long => ["cfg"],
40+ arg => 1,
3741 }
3842 );
3943 my %ret = (
4044 manifest_path => "Cargo.toml",
45+ rust_cfg => []
4146 );
4247 my $str_arg = sub{
4348 my $name = shift;
@@ -156,12 +161,119 @@ sub list_features_pac{
156161 }(list_features($package));
157162 }
158163
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+
159265 sub expand_dep{
160266 my $dep = shift;
161267 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+ }
163276 }
164- die "dependency with target" if($dep->{target});
165277 ($dep->{name}.($dep->{uses_default_features}?"/default":""), $dep->{req},
166278 map{("$dep->{name}/$_", $dep->{req})}(@{$dep->{features}}));
167279 }
@@ -395,6 +507,10 @@ EOT
395507 }
396508 }
397509 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;
398514 }
399515
400516 my $crate = $comm[1];
--- a/debian/gbp.conf
+++ b/debian/gbp.conf
@@ -1,3 +1,4 @@
11 [DEFAULT]
22 pristine-tar = true
3+debian-tag = deb/%(version)s
34 upstream-tag = upstream/%(version)s