Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions autobuild.pl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
my %data = ();
my %command_table = ();
my $cvs_tag;
my $starting_dir= getcwd ();
my $starting_dir = getcwd ();
my $warn_nonfatal;

##############################################################################
Expand Down Expand Up @@ -161,7 +161,7 @@
elsif ($ARGV[0] =~ m!^(-|/\?)!) {
print "Error: Unknown option $ARGV[0]\n" if ($ARGV[0] !~ m!^(-|/)\?!);
print
"Useage: $0 [-c][-cvs_tag <tag>][-d][-k][-p][-v][-xml] files_to_process.xml [...]\n",
"Usage: $0 [-c][-cvs_tag <tag>][-d][-k][-p][-v][-xml] files_to_process.xml [...]\n",
"where:\n",
" -c Parse and Check each command but don't execute any\n",
" -cvs_tag <tag> Checkout operations use <tag> instead of HEAD\n",
Expand Down Expand Up @@ -195,17 +195,17 @@
# because FindBin does not work on OpenVMS
#
sub which {
my($prog) = shift;
my($exec) = $prog;
my($part) = '';
my $prog = shift;
my $exec = $prog;
my $part = '';
if (defined $ENV{'PATH'}) {
foreach $part (split(/$pathsep/, $ENV{'PATH'})) {
$part .= (( $^O eq 'VMS' ) ? "" : "/" ) . "$prog";
if ( -x $part ) {
$exec = $part;
last;
}
}
foreach $part (split(/$pathsep/, $ENV{'PATH'})) {
$part .= (( $^O eq 'VMS' ) ? "" : "/" ) . "$prog";
if ( -x $part ) {
$exec = $part;
last;
}
}
}
return $exec;
}
Expand Down Expand Up @@ -293,7 +293,7 @@ ($$)
if (!defined $file_handle) {
print STDERR __FILE__,
': ', ($warn_nonfatal ? 'Unable to set' : 'Error setting'),
" status to file ($status_file)", ($warn_nonfatal ? '' : ": $!"), "\n";
" status to file ($status_file)", ($warn_nonfatal ? '' : ": $!"), "\n";

# Non fatal error, so just return.
return;
Expand Down Expand Up @@ -343,7 +343,7 @@ ($$)
# string. In case of undefined variables, also needs the filename and line
# number(s) where the definition of this string was found.
#
sub subsituteVars ($;$$$)
sub substituteVars ($;$$$)
{
my ($inputString, $filename, $lineFrom, $lineTo) = @_;
my $outputString= $inputString;
Expand Down Expand Up @@ -451,7 +451,7 @@ (\%)
$data{VARS}->{BUILD_CONFIG_FILE} = File::Basename::basename ($file);
$data{VARS}->{BUILD_CONFIG_PATH} = File::Basename::dirname ($file);
my $temp_file = $file;
$temp_file =~ s!\\!/!g; ## replace windows seperators with unix ones
$temp_file =~ s!\\!/!g; ## replace windows separators with unix ones
$temp_file =~ s!^.*configs/autobuild!configs/autobuild!;
$data{VARS}->{CVS_CONFIG_FILE} = $temp_file;

Expand All @@ -465,7 +465,7 @@ (\%)
$data{VARS}->{AUTOBUILD_PL_PATH} = $this_file;
$data{VARS}->{AUTOBUILD_ROOT} = File::Basename::dirname ($this_file);

# Setup some other usefull variables before parsing the actual xml file.
# Setup some other useful variables before parsing the actual xml file.
#
$data{VARS}->{'cvs_tag'} = (defined $cvs_tag) ? $cvs_tag : 'HEAD';
#
Expand Down Expand Up @@ -654,10 +654,10 @@ (\%)
if (2 == $SUBVARS &&
defined $cmd_handler->{'substitute_vars_in_options'} &&
$cmd_handler->{'substitute_vars_in_options'} ) {
$command->{SUBVARS}= 1; # Record that we are subsituting
$command->{SUBVARS}= 1; # Record that we are substituting
}

# We must change the environment BEFORE we attempt to subsituteVars
# We must change the environment BEFORE we attempt to substituteVars
# as the function can substitute environment values in place of
# environment names within the variable being substituted.
#
Expand All @@ -670,7 +670,7 @@ (\%)
#
if ("" ne $DIRECTORY) {
$DIRECTORY=
subsituteVars ($DIRECTORY, $FILE, $LINE_FROM, $LINE_TO);
substituteVars ($DIRECTORY, $FILE, $LINE_FROM, $LINE_TO);

if ($DIRECTORY =~ s/^\s*([^\s].*?)\s*$/$1/ &&
!File::Spec->file_name_is_absolute ($DIRECTORY)) {
Expand Down Expand Up @@ -736,6 +736,7 @@ (\%)
my $FILE = $command->{FILE};
my $LINE_FROM = $command->{LINE_FROM};
my $LINE_TO = $command->{LINE_FROM};
my $CONTENTS = $command->{CONTENTS};

my $CMD = "Executing \"$NAME\" line";
if (!defined $LINE_TO || $LINE_FROM == $LINE_TO) {
Expand All @@ -749,7 +750,7 @@ (\%)

print "\n",'=' x 79,"\n===== $CMD\n" if (1 < $verbose);

# We must change the environment BEFORE we attempt to subsituteVars
# We must change the environment BEFORE we attempt to substituteVars
# as the function can substitute environment values in place of
# environment names within the variable being substituted.
#
Expand All @@ -766,7 +767,7 @@ (\%)
# Work out if we are going to execute this command.
#
my $IF_result =
subsituteVars ($IF_TEXT, $FILE, $LINE_FROM, $LINE_TO);
substituteVars ($IF_TEXT, $FILE, $LINE_FROM, $LINE_TO);
if ($IF_result !~ s/^\s*(?:true|)\s*$/1/i) {
$IF_result = eval ($IF_result);
$IF_result = 0 if (!defined $IF_result ||
Expand All @@ -777,17 +778,17 @@ (\%)
# Substitute any <variables> in the command's options string IF desired.
#
$OPTIONS=
subsituteVars ($OPTIONS, $FILE, $LINE_FROM, $LINE_TO) if ($SUBVARS);
substituteVars ($OPTIONS, $FILE, $LINE_FROM, $LINE_TO) if ($SUBVARS);
if ($OPTIONS ne $command->{OPTIONS}) {
print "===== subsitutions: $OPTIONS\n" if (1 < $verbose);
print "===== substitutions: $OPTIONS\n" if (1 < $verbose);
}

# Always substitute any <variables> in the command's directory string
# if a change of directory/root has been specified for the command.
#
if ("" ne $DIRECTORY) {
$DIRECTORY=
subsituteVars ($DIRECTORY, $FILE, $LINE_FROM, $LINE_TO );
substituteVars ($DIRECTORY, $FILE, $LINE_FROM, $LINE_TO );

if ($DIRECTORY =~ s/^\s*([^\s].*?)\s*$/$1/ &&
!File::Spec->file_name_is_absolute ($DIRECTORY)) {
Expand All @@ -804,7 +805,7 @@ (\%)
}
}

if ($command_table{$NAME}->Run ($OPTIONS) == 0) {
if ($command_table{$NAME}->Run ($OPTIONS, $CONTENTS) == 0) {
print STDERR "ERROR: While $CMD $CMD2:\n" if ($verbose <= 1);
print STDERR " The command failed";
if (!$keep_going) {
Expand Down
10 changes: 5 additions & 5 deletions autobuild.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ This command splices together two other named variables and stores the resultant
<relative_env name="environment" base_var="variable" suffix_var="variable" join="text" type="" />
All attributes must be in the order given above although both join and type are optional. This command splices together two other named autobuild variables and stores the resultant string in environment variable being created. The join attribute is optional (defaulting to a null string) and if given its text will be spliced between the two other variable's text to form the result). If the type is given it works just as for the environment tag above.

The <include name="filename" if="test" /> tag can now have an optional if attribute that will be evaluated immediatly during the parse stage.
The <include name="filename" if="test" /> tag can now have an optional if attribute that will be evaluated immediately during the parse stage.
This can sit anywhere in the input file and causes the named file to be opened and parsed at the current point. This file must have it's own <autobuild> and optional <configuration> sections to be processed and any variables, environment and commands will be added to the current file's already processed tags.

<autobuild> .. <autobuild/>
Expand Down Expand Up @@ -156,8 +156,8 @@ joining characters between the original value and the newly defined value;
environment variables do still get treated to the platform's path separating
character.
replace/set which simply resets or creates the environment variable with the value given,
prefix which appends the original value of the environment variable to the end of the string, joind with a "path" separating character as defined by the platform autobuild.pl is running on,
suffix/postfix which appends the value given to the end of the current value of the environment variable again seporated by a "path" character or
prefix which appends the original value of the environment variable to the end of the string, joined with a "path" separating character as defined by the platform autobuild.pl is running on,
suffix/postfix which appends the value given to the end of the current value of the environment variable again separated by a "path" character or
ifundefined/default which will only create a new environment variable with the given value if it does not already exist.
unset/delete/remove which will remove the variable.

Expand All @@ -180,9 +180,9 @@ Join="text" the optional, defaulting to a single space, used to modify (possibly

Root="dir" or directory="dir" optionally specify that this command should have a different root to that defined globally.

Substitute_variables or SubsVars, optionally used to over-ride the default for the individual command, indicating that the resultant options string should have any <Var> variables subsituted prior to use.
Substitute_variables or SubsVars, optionally used to over-ride the default for the individual command, indicating that the resultant options string should have any <Var> variables substituted prior to use.

NoSubsitute_variables or NoSubsVars, optionally used to over-ride the default for the individual command, indicating that the resultant options string should NOT have any <Var> variables susituted.
NoSubstitute_variables or NoSubsVars, optionally used to over-ride the default for the individual command, indicating that the resultant options string should NOT have any <Var> variables substituted.

group="group" optionally states that the command should be using the named environment group, it defaults to "default" which is always created.

Expand Down
6 changes: 6 additions & 0 deletions command/file_manipulation.pm
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ sub Run ($)
{
my $self = shift;
my $options = shift;
my $contents = shift;

my $root = main::GetVariable ('root');

Expand Down Expand Up @@ -684,6 +685,11 @@ sub Run ($)
my $include= []; ### Copytree Default include everything
my $exclude= []; ### Copytree Default exclude nothing

# Use contents of the tags as output if given
if (defined $contents) {
$output = $contents;
}

foreach my $option (@splitOptions) {

### option from=
Expand Down
Loading