From 396ff3c484681c2ab4bcfa8b5703d9ea8395243e Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 28 Apr 2016 18:49:10 -0500 Subject: [PATCH 1/5] Add EPICS_TARGET_ARCH parameter Set its default value automatically in the generated envData.c --- src/libCom/env/RULES | 5 +++-- src/libCom/env/bldEnvData.pl | 23 +++++++++++++++++------ src/libCom/env/envDefs.h | 1 + 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/libCom/env/RULES b/src/libCom/env/RULES index f63475d25..db7fa7656 100644 --- a/src/libCom/env/RULES +++ b/src/libCom/env/RULES @@ -8,5 +8,6 @@ # This is a Makefile fragment, see src/libCom/Makefile. envData.c: $(LIBCOM)/env/envDefs.h $(LIBCOM)/env/bldEnvData.pl \ - $(CONFIG)/CONFIG_ENV $(CONFIG)/CONFIG_SITE_ENV - $(PERL) $(LIBCOM)/env/bldEnvData.pl $(INSTALL_QUIETLY) $(CONFIG) + $(CONFIG)/CONFIG_ENV $(CONFIG)/CONFIG_SITE_ENV \ + $(wildcard $(CONFIG)/os/CONFIG_SITE_ENV.$(T_A)) + $(PERL) $(LIBCOM)/env/bldEnvData.pl $(INSTALL_QUIETLY) -t $(T_A) $(CONFIG) diff --git a/src/libCom/env/bldEnvData.pl b/src/libCom/env/bldEnvData.pl index 993c36cee..177dcf976 100644 --- a/src/libCom/env/bldEnvData.pl +++ b/src/libCom/env/bldEnvData.pl @@ -26,13 +26,13 @@ use Text::Wrap; my $tool = basename($0); -our ($opt_h, $opt_q); +our ($opt_h, $opt_q, $opt_t); our $opt_o = 'envData.c'; $Getopt::Std::OUTPUT_HELP_VERSION = 1; $Text::Wrap::columns = 75; -&HELP_MESSAGE unless getopts('ho:q') && @ARGV == 1; +&HELP_MESSAGE unless getopts('ho:qt:') && @ARGV == 1; &HELP_MESSAGE if $opt_h; my $config = AbsPath(shift); @@ -53,14 +53,24 @@ while () { 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); +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_TARGET_ARCH} = $opt_t; +} + # Warn about any vars with no value # my @undefs = grep {!exists $values{$_}} @vars; @@ -73,13 +83,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; + print OUT << "END"; /* Generated file $opt_o * * Created from - * $env_defs - * $config_env - * $config_site_env +$configs */ #include @@ -112,6 +122,7 @@ sub HELP_MESSAGE { " -h Help: Print this message\n", " -q Quiet: Only print errors\n", " -o file Output filename, default is $opt_o\n", + " -t arch Target architecture \$(T_A) name\n", "\n"; exit 1; diff --git a/src/libCom/env/envDefs.h b/src/libCom/env/envDefs.h index dfa911115..cb140c1fe 100644 --- a/src/libCom/env/envDefs.h +++ b/src/libCom/env/envDefs.h @@ -58,6 +58,7 @@ epicsShareExtern const ENV_PARAM EPICS_CAS_SERVER_PORT; epicsShareExtern const ENV_PARAM EPICS_CA_BEACON_PERIOD; /* deprecated */ epicsShareExtern const ENV_PARAM EPICS_CAS_BEACON_PERIOD; epicsShareExtern const ENV_PARAM EPICS_CAS_BEACON_PORT; +epicsShareExtern const ENV_PARAM EPICS_TARGET_ARCH; epicsShareExtern const ENV_PARAM EPICS_TIMEZONE; epicsShareExtern const ENV_PARAM EPICS_TS_NTP_INET; epicsShareExtern const ENV_PARAM EPICS_IOC_LOG_PORT; From 230603f4acf03a8cf147e502626e01a87dae66ce Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 28 Apr 2016 18:50:41 -0500 Subject: [PATCH 2/5] Remove ARCH from cdCommands and envPaths files Set it in iocshRegisterCommon() instead. Remove ARCH from iocBoot/ioc/Makefile@Common templates. --- configure/RULES.ioc | 8 ++++++-- src/ioc/misc/iocshRegisterCommon.c | 6 ++++++ src/template/base/top/exampleBoot/ioc/Makefile@Common | 1 - src/template/base/top/iocBoot/ioc/Makefile@Common | 1 - src/tools/convertRelease.pl | 4 +--- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/configure/RULES.ioc b/configure/RULES.ioc index 1024fcb22..da314a406 100644 --- a/configure/RULES.ioc +++ b/configure/RULES.ioc @@ -24,11 +24,15 @@ else clean$(DIVIDER)$(ARCH) clean: endif -cdCommands envPaths dllPath.bat relPaths.sh: \ +cdCommands dllPath.bat relPaths.sh: \ $(wildcard $(TOP)/configure/RELEASE*) \ - $(wildcard $(TOP)/configure/CONFIG_SITE*) $(INSTALL_BIN) + $(wildcard $(TOP)/configure/CONFIG_SITE*) | $(INSTALL_BIN) $(CONVERTRELEASE) -a $(ARCH) -t $(IOCS_APPL_TOP) $@ +envPaths: $(wildcard $(TOP)/configure/RELEASE*) \ + $(wildcard $(TOP)/configure/CONFIG_SITE*) | $(INSTALL_BIN) + $(CONVERTRELEASE) -t $(IOCS_APPL_TOP) $@ + realclean: $(RM) cdCommands envPaths dllPath.bat relPaths.sh diff --git a/src/ioc/misc/iocshRegisterCommon.c b/src/ioc/misc/iocshRegisterCommon.c index 0341dfbd6..9e0936e2b 100644 --- a/src/ioc/misc/iocshRegisterCommon.c +++ b/src/ioc/misc/iocshRegisterCommon.c @@ -7,6 +7,7 @@ * in file LICENSE that is included with this distribution. \*************************************************************************/ +#include "envDefs.h" #include "iocsh.h" #include "libComRegister.h" @@ -24,6 +25,11 @@ void iocshRegisterCommon(void) { iocshPpdbbase = &pdbbase; + const char *targetArch = envGetConfigParamPtr(&EPICS_TARGET_ARCH); + + if (targetArch) { + epicsEnvSet("ARCH", targetArch); + } dbStaticIocRegister(); registryIocRegister(); diff --git a/src/template/base/top/exampleBoot/ioc/Makefile@Common b/src/template/base/top/exampleBoot/ioc/Makefile@Common index 64a3e8bf7..e064d7344 100644 --- a/src/template/base/top/exampleBoot/ioc/Makefile@Common +++ b/src/template/base/top/exampleBoot/ioc/Makefile@Common @@ -1,5 +1,4 @@ TOP = ../.. include $(TOP)/configure/CONFIG -ARCH = _ARCH_ TARGETS = envPaths include $(TOP)/configure/RULES.ioc diff --git a/src/template/base/top/iocBoot/ioc/Makefile@Common b/src/template/base/top/iocBoot/ioc/Makefile@Common index 64a3e8bf7..e064d7344 100644 --- a/src/template/base/top/iocBoot/ioc/Makefile@Common +++ b/src/template/base/top/iocBoot/ioc/Makefile@Common @@ -1,5 +1,4 @@ TOP = ../.. include $(TOP)/configure/CONFIG -ARCH = _ARCH_ TARGETS = envPaths include $(TOP)/configure/RULES.ioc diff --git a/src/tools/convertRelease.pl b/src/tools/convertRelease.pl index abf63c3ec..f4eb3f798 100644 --- a/src/tools/convertRelease.pl +++ b/src/tools/convertRelease.pl @@ -134,6 +134,7 @@ sub relPaths { } sub binDirs { + die "Architecture not set (use -a option)\n" unless ($arch); my @includes = grep !m/^ (RULES | TEMPLATE_TOP) $/x, @apps; my @path; foreach my $app (@includes) { @@ -165,7 +166,6 @@ sub cdCommands { my $ioc = $cwd; $ioc =~ s/^.*\///; # iocname is last component of directory name - print OUT "putenv(\"ARCH=$arch\")\n"; print OUT "putenv(\"IOC=$ioc\")\n"; foreach my $app (@includes) { @@ -188,7 +188,6 @@ sub cdCommands { # Include parentheses anyway in case CEXP users want to use this. # sub envPaths { - die "Architecture not set (use -a option)" unless ($arch); my @includes = grep !m/^ (RULES | TEMPLATE_TOP) $/x, @apps; unlink($outfile); @@ -197,7 +196,6 @@ sub envPaths { my $ioc = $cwd; $ioc =~ s/^.*\///; # iocname is last component of directory name - print OUT "epicsEnvSet(\"ARCH\",\"$arch\")\n"; print OUT "epicsEnvSet(\"IOC\",\"$ioc\")\n"; foreach my $app (@includes) { From 0e5dc2a21cc868912f9840a8213b33df99ec0d50 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 28 Apr 2016 18:56:03 -0500 Subject: [PATCH 3/5] More build parameters. Renamed EPICS_TARGET_ARCH to EPICS_BUILD_TARGET_ARCH Added EPICS_BUILD_OS_CLASS and EPICS_BUILD_COMPILER_CLASS --- src/ioc/misc/iocshRegisterCommon.c | 2 +- src/libCom/env/RULES | 3 ++- src/libCom/env/bldEnvData.pl | 11 ++++++++--- src/libCom/env/envDefs.h | 6 ++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/ioc/misc/iocshRegisterCommon.c b/src/ioc/misc/iocshRegisterCommon.c index 9e0936e2b..4bcd6d816 100644 --- a/src/ioc/misc/iocshRegisterCommon.c +++ b/src/ioc/misc/iocshRegisterCommon.c @@ -25,7 +25,7 @@ void iocshRegisterCommon(void) { iocshPpdbbase = &pdbbase; - const char *targetArch = envGetConfigParamPtr(&EPICS_TARGET_ARCH); + const char *targetArch = envGetConfigParamPtr(&EPICS_BUILD_TARGET_ARCH); if (targetArch) { epicsEnvSet("ARCH", targetArch); diff --git a/src/libCom/env/RULES b/src/libCom/env/RULES index db7fa7656..07f71a5a0 100644 --- a/src/libCom/env/RULES +++ b/src/libCom/env/RULES @@ -10,4 +10,5 @@ envData.c: $(LIBCOM)/env/envDefs.h $(LIBCOM)/env/bldEnvData.pl \ $(CONFIG)/CONFIG_ENV $(CONFIG)/CONFIG_SITE_ENV \ $(wildcard $(CONFIG)/os/CONFIG_SITE_ENV.$(T_A)) - $(PERL) $(LIBCOM)/env/bldEnvData.pl $(INSTALL_QUIETLY) -t $(T_A) $(CONFIG) + $(PERL) $(LIBCOM)/env/bldEnvData.pl $(INSTALL_QUIETLY) -t $(T_A) \ + -c $(CMPLR_CLASS) -s $(OS_CLASS) $(CONFIG) diff --git a/src/libCom/env/bldEnvData.pl b/src/libCom/env/bldEnvData.pl index 177dcf976..daa679b42 100644 --- a/src/libCom/env/bldEnvData.pl +++ b/src/libCom/env/bldEnvData.pl @@ -26,13 +26,13 @@ use Text::Wrap; my $tool = basename($0); -our ($opt_h, $opt_q, $opt_t); +our ($opt_h, $opt_q, $opt_t, $opt_s, $opt_c); our $opt_o = 'envData.c'; $Getopt::Std::OUTPUT_HELP_VERSION = 1; $Text::Wrap::columns = 75; -&HELP_MESSAGE unless getopts('ho:qt:') && @ARGV == 1; +&HELP_MESSAGE unless getopts('ho:qt:s:c:') && @ARGV == 1; &HELP_MESSAGE if $opt_h; my $config = AbsPath(shift); @@ -68,9 +68,12 @@ if ($opt_t) { readReleaseFiles($config_arch_env, \%values); } - $values{EPICS_TARGET_ARCH} = $opt_t; + $values{EPICS_BUILD_TARGET_ARCH} = $opt_t; } +$values{EPICS_BUILD_COMPILER_CLASS} = $opt_c if $opt_c; +$values{EPICS_BUILD_OS_CLASS} = $opt_s if $opt_s; + # Warn about any vars with no value # my @undefs = grep {!exists $values{$_}} @vars; @@ -123,6 +126,8 @@ sub HELP_MESSAGE { " -q Quiet: Only print errors\n", " -o file Output filename, default is $opt_o\n", " -t arch Target architecture \$(T_A) name\n", + " -s os Operating system \$(OS_CLASS)\n", + " -c comp Compiler class \$(CMPLR_CLASS)\n", "\n"; exit 1; diff --git a/src/libCom/env/envDefs.h b/src/libCom/env/envDefs.h index cb140c1fe..437e688e3 100644 --- a/src/libCom/env/envDefs.h +++ b/src/libCom/env/envDefs.h @@ -40,7 +40,7 @@ typedef struct envParam { } ENV_PARAM; /* - * bldEnvData looks for "epicsShareExtern const ENV_PARAM" + * bldEnvData.pl looks for "epicsShareExtern const ENV_PARAM ;" */ epicsShareExtern const ENV_PARAM EPICS_CA_ADDR_LIST; epicsShareExtern const ENV_PARAM EPICS_CA_CONN_TMO; @@ -58,7 +58,9 @@ epicsShareExtern const ENV_PARAM EPICS_CAS_SERVER_PORT; epicsShareExtern const ENV_PARAM EPICS_CA_BEACON_PERIOD; /* deprecated */ epicsShareExtern const ENV_PARAM EPICS_CAS_BEACON_PERIOD; epicsShareExtern const ENV_PARAM EPICS_CAS_BEACON_PORT; -epicsShareExtern const ENV_PARAM EPICS_TARGET_ARCH; +epicsShareExtern const ENV_PARAM EPICS_BUILD_COMPILER_CLASS; +epicsShareExtern const ENV_PARAM EPICS_BUILD_OS_CLASS; +epicsShareExtern const ENV_PARAM EPICS_BUILD_TARGET_ARCH; epicsShareExtern const ENV_PARAM EPICS_TIMEZONE; epicsShareExtern const ENV_PARAM EPICS_TS_NTP_INET; epicsShareExtern const ENV_PARAM EPICS_IOC_LOG_PORT; From 5a605fa0c3fcc7674c70e6a49ff8a0ee84c4fd4c Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 28 Apr 2016 18:58:07 -0500 Subject: [PATCH 4/5] Set various EPICS_VERSION_* environment variables These are set at the same time as the ARCH variable. Had to add EPICS_VERSION_SHORT and EPICS_VERSION_FULL to epicsVersion.h. This uses more uniform names, should we change epicsVersion.h names? We would continue to support the old names in parallel for some time. --- src/ioc/misc/iocshRegisterCommon.c | 15 +++++++++++++++ src/libCom/misc/makeEpicsVersion.pl | 10 +++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/ioc/misc/iocshRegisterCommon.c b/src/ioc/misc/iocshRegisterCommon.c index 4bcd6d816..f5f339f46 100644 --- a/src/ioc/misc/iocshRegisterCommon.c +++ b/src/ioc/misc/iocshRegisterCommon.c @@ -8,6 +8,7 @@ \*************************************************************************/ #include "envDefs.h" +#include "epicsVersion.h" #include "iocsh.h" #include "libComRegister.h" @@ -22,15 +23,29 @@ #include "registryIocRegister.h" #include "rsrvIocRegister.h" +#define quote(v) #v +#define str(v) quote(v) + void iocshRegisterCommon(void) { iocshPpdbbase = &pdbbase; const char *targetArch = envGetConfigParamPtr(&EPICS_BUILD_TARGET_ARCH); + /* This uses a config param so the user can override it */ if (targetArch) { epicsEnvSet("ARCH", targetArch); } + /* Base build version variables */ + epicsEnvSet("EPICS_VERSION_MAJOR", str(EPICS_VERSION)); + epicsEnvSet("EPICS_VERSION_MIDDLE", str(EPICS_REVISION)); + epicsEnvSet("EPICS_VERSION_MINOR", str(EPICS_MODIFICATION)); + epicsEnvSet("EPICS_VERSION_PATCH", str(EPICS_PATCH_LEVEL)); + epicsEnvSet("EPICS_VERSION_SNAPSHOT", EPICS_DEV_SNAPSHOT); + epicsEnvSet("EPICS_VERSION_SITE", EPICS_SITE_VERSION); + epicsEnvSet("EPICS_VERSION_SHORT", EPICS_VERSION_SHORT); + epicsEnvSet("EPICS_VERSION_FULL", EPICS_VERSION_FULL); + dbStaticIocRegister(); registryIocRegister(); dbIocRegister(); diff --git a/src/libCom/misc/makeEpicsVersion.pl b/src/libCom/misc/makeEpicsVersion.pl index 2a720e86d..f7f134f87 100644 --- a/src/libCom/misc/makeEpicsVersion.pl +++ b/src/libCom/misc/makeEpicsVersion.pl @@ -47,8 +47,11 @@ map { die "$tool: Variable missing from $infile" unless defined $_; } $ver, $rev, $mod, $patch, $snapshot, $commit_date; +$commit_date =~ s/^\$\$Date$\$$/\1/; + my $ver_str = "$ver.$rev.$mod"; $ver_str .= ".$patch" if $patch > 0; +my $ver_short = $ver_str; $ver_str .= $snapshot if $snapshot ne ''; $ver_str .= "-$opt_v" if $opt_v; @@ -71,10 +74,15 @@ print $OUT <<"END"; #define EPICS_PATCH_LEVEL $patch #define EPICS_DEV_SNAPSHOT "$snapshot" #define EPICS_SITE_VERSION "$opt_v" + +#define EPICS_VERSION_SHORT "$ver_short" +#define EPICS_VERSION_FULL "$ver_str" #define EPICS_VERSION_STRING "EPICS $ver_str" #define epicsReleaseVersion "EPICS R$ver_str $commit_date" -#define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) +#ifndef VERSION_INT +# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) +#endif #define EPICS_VERSION_INT VERSION_INT($ver, $rev, $mod, $patch) #endif /* INC_${obase}_H */ From 08fd987c601e15f581fb71c189af70a315936793 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 28 Apr 2016 19:00:37 -0500 Subject: [PATCH 5/5] Perl script clean-up --- src/libCom/env/bldEnvData.pl | 51 ++++++++++++++++++++---------------- src/tools/convertRelease.pl | 4 +-- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/libCom/env/bldEnvData.pl b/src/libCom/env/bldEnvData.pl index daa679b42..a23907dc8 100644 --- a/src/libCom/env/bldEnvData.pl +++ b/src/libCom/env/bldEnvData.pl @@ -52,29 +52,31 @@ while () { } 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 @@ -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", diff --git a/src/tools/convertRelease.pl b/src/tools/convertRelease.pl index f4eb3f798..70f38ed57 100644 --- a/src/tools/convertRelease.pl +++ b/src/tools/convertRelease.pl @@ -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};