summaryrefslogtreecommitdiff
path: root/modules/Creator.pm
diff options
context:
space:
mode:
authorhudson_d <hudson_d@a3e5c962-4219-0410-a828-e124f845ac39>2011-04-05 13:04:47 +0000
committerhudson_d <hudson_d@a3e5c962-4219-0410-a828-e124f845ac39>2011-04-05 13:04:47 +0000
commitfc9ca9dceb9d685eb389300d11fc54f076e7d3fa (patch)
tree9480271cfb3225aa0d78edd39ca0a172d50f3520 /modules/Creator.pm
parent12ed022370211de2bfadf015a8ff2de6d9a3ea60 (diff)
downloadMPC-fc9ca9dceb9d685eb389300d11fc54f076e7d3fa.tar.gz
Tue Apr 5 12:57:22 UTC 2011 Don Hudson <hudsond@ociweb.com>
* docs/html/MakeProjectCreator.html: Added bracketed (multiline) assigments to documentation, i.e., assignment of form: keyword <operator> [optional flags] { This is a multiline assignment. } Optional flags are \s to retain leading white space and \n to retain new lines. These flags are be combined. * docs/templates/rpmspec.txt: Added rpm_pre_cmd keyword for %pre section of the RPM spec file and rpm_url for the URL tag in the RPM spec file. * modules/AutomakeWorkspaceCreator.pm: Changed to default to cacheok of false as some intermediate project files are deleted must be regenerated if a project is regenerated. This was causing an error, but the error was only being logged. Changed to return an error code and message when workspace generation fails in some cases where an error message was only logged. * modules/Creator.pm: Added parse_assignment() that pre-parses bracketed assigments (see comment on docs/html/MakeProjectCreator.html) before calling SUPER::parse_assignment(). This method takes an optional file handle that must be used for bracketed assignment support. * modules/DirectoryManager.pm: Corrected typo in comment. * modules/Parser.pm: Added strip_comments(), strip_lt_whitespace(), and is_blank_line(). * modules/ProjectCreator.pm: Added file handle parse_assignment and related method calls for bracketed assignment support. See comment on modules/Creator.pm. Added case sensitivity logic to already_added() similar to other places in code. * modules/RpmSpecWorkspaceCreator.pm: Changed write_and_compare_file() to return 1 instead of undef as method must now return status. Added %pre section and URL tag to RPM spec file generation. * modules/StringProcessor.pm: Changed parse_assignment() to not strip ending new line as later parsing may need it. * modules/WorkspaceCreator.pm: Added file handle parse_assignment and related method calls for bracketed assignment support. See comment on modules/Creator.pm. Changed to return an error code and message when workspace generation fails in some cases where an error message was only logged. Added default_cacheok() which returns true and is used to set 'cacheok' so this method can be overridden when 'cacheok' needs to be false.
Diffstat (limited to 'modules/Creator.pm')
-rw-r--r--modules/Creator.pm53
1 files changed, 49 insertions, 4 deletions
diff --git a/modules/Creator.pm b/modules/Creator.pm
index 803db3c1..111da2de 100644
--- a/modules/Creator.pm
+++ b/modules/Creator.pm
@@ -215,7 +215,7 @@ sub parse_parents {
sub parse_known {
- my($self, $line) = @_;
+ my($self, $line, $fh) = @_;
my $status = 1;
my $errorString;
my $type = $self->{'grammar_type'};
@@ -263,7 +263,7 @@ sub parse_known {
$errorString = "No $type was defined";
$status = 0;
}
- elsif ($self->parse_assignment($line, \@values)) {
+ elsif ($self->parse_assignment($line, \@values, $fh)) {
## If this returns true, then we've found an assignment
}
elsif ($line =~ /^(\w+)\s*(\([^\)]+\))?\s*(:.*)?\s*{$/) {
@@ -289,6 +289,51 @@ sub parse_known {
return $status, $errorString, @values;
}
+## Parse an assignment that is bracketed by curly braces so it can span multiple lines.
+## This method parses the bracketed assignment into a regular assignment
+## and then calls SUPER::parse_assigment.
+##
+## A bracketed assigment has the form of:
+##
+## keyword <operator> [optional flags] {
+## This spans
+## multiple lines
+## }
+##
+## Optional flags are \s to retain leading white space and
+## \n to retain new lines. These flags are be combined.
+sub parse_assignment {
+ my($self, $line, $values, $fh) = @_;
+
+ if ($line =~ /^(\w+)\s*([\-+]?=)\s*(\\[sn]{1,2})?\s*{$/) {
+ my $comp = lc($1);
+ my $op = $2;
+ my $keep_leading_whitespace = ($3 eq "\\s" || $3 eq "\\ns" || $3 eq "\\sn");
+ my $keep_new_lines = ($3 eq "\\n" || $3 eq "\\ns" || $3 eq "\\sn");
+
+ my $bracketed_assignment;
+ while(<$fh>) {
+ ## This is not an error,
+ ## this is the end of the bracketed assignment.
+ last if ($_ =~ /^\s*}\s*$/);
+
+ ## Strip comments.
+ my $current_line = $self->strip_comments($_);
+ ## Skip blank lines unless we're keeping new lines.
+ next if (!$keep_new_lines && $self->is_blank_line($current_line));
+
+ $bracketed_assignment .= "\n" if defined $bracketed_assignment && $keep_new_lines;
+
+ $bracketed_assignment .= $self->strip_lt_whitespace($current_line, $keep_leading_whitespace);
+ }
+
+ if (defined $bracketed_assignment) {
+ $line = $comp . $op . $bracketed_assignment;
+ }
+ }
+
+ return $self->SUPER::parse_assignment($line, \@$values);
+}
sub parse_scope {
my($self, $fh, $name, $type, $validNames, $flags, $elseflags) = @_;
@@ -332,7 +377,7 @@ sub parse_scope {
}
else {
my @values;
- if (defined $validNames && $self->parse_assignment($line, \@values)) {
+ if (defined $validNames && $self->parse_assignment($line, \@values, $fh)) {
if (defined $$validNames{$values[1]}) {
## If $type is not defined, we don't even need to bother with
## processing the assignment as we will be throwing the value
@@ -1161,7 +1206,7 @@ sub relative {
my $ovalue = $value;
my($rel, $how) = $self->get_initial_relative_values();
$value = $self->expand_variables($value, $rel,
- $expand_template, $scope, $how);
+ $expand_template, $scope, $how, 0);
if ($ovalue eq $value || index($value, '$') >= 0) {
($rel, $how) = $self->get_secondary_relative_values();