OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Michael van Elst
Root: /e/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-re Date: 13-Nov-2002 10:24:29
Branch: HEAD Handle: 2002111309242900
Modified files:
openpkg-re openpkg-index
Log:
look for external parameters in description
Summary:
Revision Changes Path
1.6 +29 -15 openpkg-re/openpkg-index
____________________________________________________________________________
Index: openpkg-re/openpkg-index
============================================================
$ cvs diff -u -r1.5 -r1.6 openpkg-index
--- openpkg-re/openpkg-index 12 Nov 2002 14:23:18 -0000 1.5
+++ openpkg-re/openpkg-index 13 Nov 2002 09:24:29 -0000 1.6
@@ -98,6 +98,20 @@
}
#
+# deduce external variables from description
+#
+sub find_options ($) {
+ my($descr) = @_;
+ my(%evar);
+
+ %evar = map {
+ $1 => '%{'.$1.'}'
+ } $descr =~ /--define\s*'(\S+)\s*\%\{\1\}'/;
+
+ return \%evar;
+}
+
+#
# translate default section from spec-file
# into a hash
# %if/%ifdef/%define... are translated to #if/#ifdef/#define
@@ -110,11 +124,11 @@
# all attributes are of the form key: value
# repeated attributes are coalesced into a list
#
-sub package2data ($) {
- my($s) = @_;
+sub package2data ($$) {
+ my($s,$evar) = @_;
my(%var);
my(@term, $term);
- my(%attr, %evar);
+ my(%attr);
my($l, $v, $cond, $d, $p);
my($re,@defs);
@@ -128,14 +142,13 @@
$s =~ s/^#\{\!\?([^:]*):\s*(.*?)\s*\}\s*$/#ifndef $1\n$2\n#endif/mg;
#
- # guess what parameters are external conditions by scanning
- # for "default" sections.
+ # guess more external parameters by scanning for "default" sections.
#
$re = '^\#ifndef\s+[\w\_]+\s*\n((?:\#define\s+[\w\_]+\s.*\n)+)\#endif\n';
@defs = $s =~ /$re/gm;
foreach (@defs) {
while (/^\#define\s+([\w\_]+)\s(.*?)\s*$/mg) {
- $evar{$1} = '%{'.$1.'}';
+ $evar->{$1} = '%{'.$1.'}';
}
}
$s =~ s/$re//gm;
@@ -161,10 +174,10 @@
while ($p =~
/(?:(\!|\|\||\&\&|\(|\))|"\%\{([^}]+)\}"\s*==\s*"(yes|no)")/g) {
if (defined $1) {
$term .= " $1 ";
- } elsif (exists $evar{$2}) {
- $term .= ($3 eq 'no' ? '! ' : '').vsub(\%evar,'%{'.$2.'}');
+ } elsif (exists $evar->{$2}) {
+ $term .= ($3 eq 'no' ? '! ' : '').vsub($evar,'%{'.$2.'}');
} else {
- die "ERROR: unknown conditional: $l\n== $v\n";
+ warn "WARNING: unknown conditional '$2':\n< $l\n> $v\n";
}
}
@@ -191,13 +204,13 @@
# define internal variables
# -> store for subsequent substitution
#
- if (exists $evar{$1}) {
+ if (exists $evar->{$1}) {
if ($2 eq 'yes') {
- $evar{$1} = "( \%\{$1\} || ( $cond ) )";
+ $evar->{$1} = "( \%\{$1\} || ( $cond ) )";
} elsif ($2 eq 'no') {
- $evar{$1} = "( %\{$1\} && ! ( $cond ) )";
+ $evar->{$1} = "( %\{$1\} && ! ( $cond ) )";
} else {
- die "ERROR: logic too complex: $l\n== $v\n";
+ warn "WARNING: logic too complex for '$1':\n< $l\n> $v\n";
}
} else {
$var{$1} = $2;
@@ -227,7 +240,7 @@
sub spec2data ($) {
my($s) = @_;
my(%map);
- my($a);
+ my($a,$o);
# remove comments
$s =~ s/^\s*#.*?\n//mg;
@@ -244,7 +257,8 @@
}
}
- $a = package2data($map{'*'});
+ $o = find_options($map{'description'});
+ $a = package2data($map{'*'}, $o);
if (exists $map{'description'}) {
$a->{'Description'} = $map{'description'};
}
______________________________________________________________________
The OpenPKG Project www.openpkg.org
CVS Repository Commit List [EMAIL PROTECTED]