Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Sep 2013 14:22:29 +0000 (UTC)
From:      Dag-Erling Smørgrav <des@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r255790 - user/des/tinderbox
Message-ID:  <201309221422.r8MEMT1g060372@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: des
Date: Sun Sep 22 14:22:28 2013
New Revision: 255790
URL: http://svnweb.freebsd.org/changeset/base/255790

Log:
  Add support for include statements.

Modified:
  user/des/tinderbox/tbmaster.1
  user/des/tinderbox/tbmaster.pl

Modified: user/des/tinderbox/tbmaster.1
==============================================================================
--- user/des/tinderbox/tbmaster.1	Sun Sep 22 14:21:40 2013	(r255789)
+++ user/des/tinderbox/tbmaster.1	Sun Sep 22 14:22:28 2013	(r255790)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 22, 2013
+.Dd September 23, 2013
 .Dt TBMASTER 1
 .Os
 .Sh NAME
@@ -110,7 +110,14 @@ Whitespace around the equal sign and aro
 multiple values is optional.
 .Pp
 Blank lines are ignored, as is anything following a hash sign
-.Pq Dq # .
+.Pq Sq # .
+.Pp
+Additionally, the
+.Cm include
+statement can be used to include one configuration in another:
+.Bl -tag
+.It Cm include Ar otherconfig
+.El
 .Pp
 The following configuration variables are defined:
 .Bl -tag -width 12n
@@ -166,7 +173,7 @@ A list of environment variables to pass 
 script.
 Each value is the name and value of an environment variable, separated
 by an equal sign
-.Pq Dq = .
+.Pq Sq = .
 No default value.
 .It HOME
 .Pq Vt single
@@ -224,7 +231,7 @@ No default value.
 Which architectures and machines to build for.
 Each value is the name of an architecture, optionally followed by a
 forward slash
-.Pq Dq /
+.Pq Sq /
 and a machine name.
 If the machine name is not specified, it is assumed to be identical to
 the architecture name.

Modified: user/des/tinderbox/tbmaster.pl
==============================================================================
--- user/des/tinderbox/tbmaster.pl	Sun Sep 22 14:21:40 2013	(r255789)
+++ user/des/tinderbox/tbmaster.pl	Sun Sep 22 14:22:28 2013	(r255790)
@@ -154,6 +154,7 @@ sub clearconf() {
 #
 # Read in a configuration file
 #
+sub readconf($);
 sub readconf($) {
     my $fn = shift;
 
@@ -167,34 +168,39 @@ sub readconf($) {
 	s/\s*(\#.*)?$//;
 	$line .= $_;
 	if (length($line) && $line !~ s/\\$/ /) {
-	    die("$fn: syntax error on line $n\n")
-		unless ($line =~ m/^(\w+)\s*([+]?=)\s*(.*)$/);
-	    my ($key, $op, $val) = (uc($1), $2, $3);
-	    $val = ''
-		unless defined($val);
-	    die("$fn: unknown keyword on line $n\n")
-		unless (exists($CONFIG{$key}));
-	    if (ref($CONFIG{$key})) {
-		my @a = split(/\s*,\s*/, $val);
-		foreach (@a) {
-		    s/^\'([^\']*)\'$/$1/;
-		}
-		if ($op eq '=') {
-		    $CONFIG{$key} = \@a;
-		} elsif ($op eq '+=') {
-		    push(@{$CONFIG{$key}}, @a);
+	    if ($line =~ m/^include\s+([\w-]+)$/) {
+		readconf("$1.rc")
+		    or die("$fn: include $1: $!\n");
+	    } elsif ($line =~ m/^(\w+)\s*([+]?=)\s*(.*)$/) {
+		my ($key, $op, $val) = (uc($1), $2, $3);
+		$val = ''
+		    unless defined($val);
+		die("$fn: $key is not a known keyword on line $n\n")
+		    unless (exists($CONFIG{$key}));
+		if (ref($CONFIG{$key})) {
+		    my @a = split(/\s*,\s*/, $val);
+		    foreach (@a) {
+			s/^\'([^\']*)\'$/$1/;
+		    }
+		    if ($op eq '=') {
+			$CONFIG{$key} = \@a;
+		    } elsif ($op eq '+=') {
+			push(@{$CONFIG{$key}}, @a);
+		    } else {
+			die("can't happen\n");
+		    }
 		} else {
-		    die("can't happen\n");
+		    $val =~ s/^\'([^\']*)\'$/$1/;
+		    if ($op eq '=') {
+			$CONFIG{$key} = $val;
+		    } elsif ($op eq '+=') {
+			die("$fn: $key is not an array on line $n\n");
+		    } else {
+			die("can't happen\n");
+		    }
 		}
 	    } else {
-		$val =~ s/^\'([^\']*)\'$/$1/;
-		if ($op eq '=') {
-		    $CONFIG{$key} = $val;
-		} elsif ($op eq '+=') {
-		    die("$fn: invalid operator on line $n\n");
-		} else {
-		    die("can't happen\n");
-		}
+		die("$fn: syntax error on line $n\n")
 	    }
 	    $line = "";
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309221422.r8MEMT1g060372>