From 526cfdc9e7a17c97ff24c52379fb549d97a6ccd7 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 8 Mar 2010 17:31:19 -0600 Subject: [PATCH] Warn if the IOC's TOP changed since building. If the IOC's registerRecordDeviceDriver routine sees a different path to TOP than the one used at build-time, we tell the user. --- configure/RULES.Db | 7 ++- src/registry/registerRecordDeviceDriver.pl | 61 ++++++++++++++-------- 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/configure/RULES.Db b/configure/RULES.Db index a5fc1858e..6a0a9685f 100644 --- a/configure/RULES.Db +++ b/configure/RULES.Db @@ -367,14 +367,17 @@ $(foreach file, $(DB_INSTALLS), $(eval $(call DB_INSTALLS_template, $(file)))) ##################################################### register record,device,driver support +IOC_INST_TOP := $(firstword $(IOCS_APPL_TOP) \ + $(shell $(PERL) $(TOOLS)/fullPathName.pl $(INSTALL_LOCATION) ) ) + %_registerRecordDeviceDriver.cpp: $(COMMON_DIR)/%.dbd @$(RM) $@ temp.cpp - $(REGISTERRECORDDEVICEDRIVER) $< $(basename $@) > temp.cpp + $(REGISTERRECORDDEVICEDRIVER) $< $(basename $@) $(IOC_INST_TOP) > temp.cpp $(MV) temp.cpp $@ %_registerRecordDeviceDriver.cpp: %.dbd @$(RM) $@ temp.cpp - $(REGISTERRECORDDEVICEDRIVER) $< $(basename $@) > temp.cpp + $(REGISTERRECORDDEVICEDRIVER) $< $(basename $@) $(IOC_INST_TOP) > temp.cpp $(MV) temp.cpp $@ .PRECIOUS: %_registerRecordDeviceDriver.cpp diff --git a/src/registry/registerRecordDeviceDriver.pl b/src/registry/registerRecordDeviceDriver.pl index fb6d348ba..87f6ba985 100755 --- a/src/registry/registerRecordDeviceDriver.pl +++ b/src/registry/registerRecordDeviceDriver.pl @@ -9,7 +9,7 @@ eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*- # in file LICENSE that is included with this distribution. #************************************************************************* -($file, $subname) = @ARGV; +($file, $subname, $bldTop) = @ARGV; $numberRecordType = 0; $numberDeviceSupport = 0; $numberDriverSupport = 0; @@ -47,14 +47,20 @@ close(INP) or die "$! closing file"; # beginning of generated routine -print "/* THIS IS A GENERATED FILE. DO NOT EDIT! */\n", - "/* Generated from $file */\n", - "\n", - "#include \"registryCommon.h\"\n", - "#include \"iocsh.h\"\n", - "#include \"iocshRegisterCommon.h\"\n", - "\n", - "extern \"C\" {\n"; +print << "END" ; +/* THIS IS A GENERATED FILE. DO NOT EDIT! */ +/* Generated from $file */ + +#include + +#include "epicsStdlib.h" +#include "iocsh.h" +#include "iocshRegisterCommon.h" +#include "registryCommon.h" + +extern "C" { + +END #definitions for recordtype if($numberRecordType>0) { @@ -151,13 +157,26 @@ if (@variables) { #Now actual registration code. +print "int $subname(DBBASE *pbase)\n{\n"; + +print << "END" if ($bldTop ne '') ; + const char *bldTop = "$bldTop"; + const char *envTop = getenv("TOP"); + + if (envTop && strcmp(envTop, bldTop)) { + printf("Warning: IOC is booting with TOP = \\"%s\\"\\n" + " but was built with TOP = \\"%s\\"\\n", + envTop, bldTop); + } + +END + print << "END" ; -int $subname(DBBASE *pbase) -{ if (!pbase) { printf("pdbbase is NULL; you must load a DBD file first.\\n"); return -1; } + END if($numberRecordType>0) { @@ -199,16 +218,12 @@ static void registerRecordDeviceDriverCallFunc(const iocshArgBuf *) /* * Register commands on application startup */ -class IoccrfReg { - public: - IoccrfReg() { - iocshRegisterCommon(); - iocshRegister(®isterRecordDeviceDriverFuncDef,registerRecordDeviceDriverCallFunc); - } -}; -#if !defined(__GNUC__) || !(__GNUC__<2 || (__GNUC__==2 && __GNUC_MINOR__<=95)) -namespace { IoccrfReg iocshReg; } -#else -IoccrfReg iocshReg; -#endif +static int Registration() { + iocshRegisterCommon(); + iocshRegister(®isterRecordDeviceDriverFuncDef, + registerRecordDeviceDriverCallFunc); + return 0; +} + +static int done = Registration(); END