Perl script clean-up

This commit is contained in:
Andrew Johnson
2016-04-28 19:00:37 -05:00
parent 5a605fa0c3
commit 08fd987c60
2 changed files with 31 additions and 24 deletions
+29 -22
View File
@@ -52,29 +52,31 @@ while (<SRC>) {
}
close SRC;
# Read the values from the CONFIG_ENV and CONFIG_SITE_ENV files
my $config_env = "$config/CONFIG_ENV";
my $config_site_env = "$config/CONFIG_SITE_ENV";
my @configs = ($env_defs, $config_env, $config_site_env);
my %values;
readReleaseFiles($config_env, \%values);
readReleaseFiles($config_site_env, \%values);
# A list of configure/CONFIG_* files to read
#
my @configs = ("$config/CONFIG_ENV", "$config/CONFIG_SITE_ENV");
if ($opt_t) {
my $config_arch_env = "$config/os/CONFIG_SITE_ENV.$opt_t";
if (-f $config_arch_env) {
push @configs, $config_arch_env;
readReleaseFiles($config_arch_env, \%values);
}
$values{EPICS_BUILD_TARGET_ARCH} = $opt_t;
push @configs, $config_arch_env
if -f $config_arch_env;
}
my @sources = ($env_defs, @configs);
# Get values from the config files
#
my (%values, @dummy);
readRelease($_, \%values, \@dummy) foreach @configs;
expandRelease(\%values);
# Get values from the command-line
#
$values{EPICS_BUILD_COMPILER_CLASS} = $opt_c if $opt_c;
$values{EPICS_BUILD_OS_CLASS} = $opt_s if $opt_s;
$values{EPICS_BUILD_TARGET_ARCH} = $opt_t if $opt_t;
# Warn about any vars with no value
# Warn about vars with no configured value
#
my @undefs = grep {!exists $values{$_}} @vars;
warn "$tool: No value given for $_\n" foreach @undefs;
@@ -86,13 +88,13 @@ print "Generating $opt_o\n" unless $opt_q;
open OUT, '>', $opt_o
or die "$tool: Cannot create $opt_o: $!\n";
my $configs = join "\n", map {" * $_"} @configs;
my $sources = join "\n", map {" * $_"} @sources;
print OUT << "END";
/* Generated file $opt_o
*
* Created from
$configs
$sources
*/
#include <stddef.h>
@@ -101,18 +103,23 @@ $configs
END
# Define all parameters, giving variable name and default value
# Define a default value for each named parameter
#
foreach my $var (@vars) {
my $default = $values{$var} || '';
$default =~ s/^"//;
$default =~ s/"$//;
my $default = $values{$var};
if (defined $default) {
$default =~ s/^"//;
$default =~ s/"$//;
}
else {
$default = '';
}
print OUT "epicsShareDef const ENV_PARAM $var =\n",
" {\"$var\", \"$default\"};\n";
}
# Now create a list of all those parameters
# Also provide a list of all defined parameters
#
print OUT "\n",
"epicsShareDef const ENV_PARAM* env_param_list[] = {\n",
+2 -2
View File
@@ -75,7 +75,7 @@ my @apps = ('TOP'); # Records the order of definitions in RELEASE file
my $relfile = "$top/configure/RELEASE";
die "Can't find $relfile" unless (-f $relfile);
readReleaseFiles($relfile, \%macros, \@apps, $arch);
expandRelease(\%macros, \@apps);
expandRelease(\%macros);
# This is a perl switch statement:
@@ -221,7 +221,7 @@ sub checkRelease {
my @order = ();
my $relfile = "$path/configure/RELEASE";
readReleaseFiles($relfile, \%check, \@order, $arch);
expandRelease(\%check, \@order);
expandRelease(\%check);
delete $check{TOP};
delete $check{EPICS_HOST_ARCH};