Merged changes from upstream
This commit is contained in:
@@ -79,9 +79,9 @@ dbMapper$(DEP): $(COMMON_DIR)/gddApps.h
|
||||
|
||||
# Rules for generated files
|
||||
#
|
||||
$(COMMON_DIR)/aitConvertGenerated.cc: $(TOOLS)/aitGen$(HOSTEXE)
|
||||
$(call PATH_FILTER, $(TOOLS)/aitGen$(HOSTEXE)) $@
|
||||
$(COMMON_DIR)/aitConvertGenerated.cc: $(EPICS_BASE_HOST_BIN)/aitGen$(HOSTEXE)
|
||||
$(TOOLS)/aitGen$(HOSTEXE) $@
|
||||
|
||||
$(COMMON_DIR)/gddApps.h : $(TOOLS)/genApps$(HOSTEXE)
|
||||
$(call PATH_FILTER, $(TOOLS)/genApps$(HOSTEXE)) $@
|
||||
$(COMMON_DIR)/gddApps.h : $(EPICS_BASE_HOST_BIN)/genApps$(HOSTEXE)
|
||||
$(TOOLS)/genApps$(HOSTEXE) $@
|
||||
|
||||
|
||||
@@ -12,5 +12,5 @@
|
||||
# This is a Makefile fragment, see src/ioc/Makefile.
|
||||
|
||||
$(patsubst %,$(COMMON_DIR)/%,$(BPT_DBD)) : \
|
||||
$(COMMON_DIR)/bpt%.dbd : $(TOOLS)/makeBpt$(HOSTEXE)
|
||||
$(COMMON_DIR)/bpt%.dbd : $(EPICS_BASE_HOST_BIN)/makeBpt$(HOSTEXE)
|
||||
|
||||
|
||||
@@ -76,6 +76,25 @@ static void inherit_severity(const struct pv_link *ppv_link, dbCommon *pdest,
|
||||
}
|
||||
}
|
||||
|
||||
/* How to identify links in error messages */
|
||||
static const char * link_field_name(const struct link *plink)
|
||||
{
|
||||
const struct dbCommon *precord = plink->value.pv_link.precord;
|
||||
const dbRecordType *pdbRecordType = precord->rdes;
|
||||
dbFldDes * const *papFldDes = pdbRecordType->papFldDes;
|
||||
const short *link_ind = pdbRecordType->link_ind;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < pdbRecordType->no_links; i++) {
|
||||
const dbFldDes *pdbFldDes = papFldDes[link_ind[i]];
|
||||
|
||||
if (plink == (DBLINK *)((char *)precord + pdbFldDes->offset))
|
||||
return pdbFldDes->name;
|
||||
}
|
||||
return "????";
|
||||
}
|
||||
|
||||
|
||||
/***************************** Constant Links *****************************/
|
||||
|
||||
static long dbConstLoadLink(struct link *plink, short dbrType, void *pbuffer)
|
||||
@@ -412,9 +431,13 @@ void dbInitLink(struct dbCommon *precord, struct link *plink, short dbfType)
|
||||
|
||||
if (pperiod && strstr(pperiod, "PROC")) {
|
||||
plink->value.pv_link.pvlMask |= pvlOptFWD;
|
||||
} else {
|
||||
errlogPrintf("%s.FLNK is a Channel Access Link "
|
||||
" but does not link to a PROC field\n", precord->name);
|
||||
}
|
||||
else {
|
||||
errlogPrintf("Forward-link uses Channel Access "
|
||||
"without pointing to PROC field\n"
|
||||
" %s.%s => %s\n",
|
||||
precord->name, link_field_name(plink),
|
||||
plink->value.pv_link.pvname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ typedef struct lset {
|
||||
} lset;
|
||||
|
||||
#define dbGetSevr(PLINK, PSEVERITY) \
|
||||
dbGetAlarm((PLINK), NULL, (PSEVERITY));
|
||||
dbGetAlarm((PLINK), NULL, (PSEVERITY))
|
||||
|
||||
epicsShareFunc void dbInitLink(struct dbCommon *precord, struct link *plink,
|
||||
short dbfType);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <osiFileName.h>
|
||||
|
||||
#define MAX_BUFFER_SIZE 4096
|
||||
#define MAX_DEPS 1024
|
||||
|
||||
/* Module to read the template files */
|
||||
typedef struct inputData inputData;
|
||||
@@ -47,12 +48,16 @@ static char *substituteGetReplacements(subInfo *pvt);
|
||||
static char *substituteGetGlobalReplacements(subInfo *pvt);
|
||||
|
||||
/* Forward references to local routines */
|
||||
static void usageExit(void);
|
||||
static void usageExit(int status);
|
||||
static void addMacroReplacements(MAC_HANDLE *macPvt, char *pval);
|
||||
static void makeSubstitutions(inputData *inputPvt, MAC_HANDLE *macPvt, char *templateName);
|
||||
|
||||
/*Global variables */
|
||||
static int opt_V = 0;
|
||||
static int opt_D = 0;
|
||||
|
||||
static char *outFile = 0;
|
||||
static int numDeps = 0, depHashes[MAX_DEPS];
|
||||
|
||||
|
||||
int main(int argc,char **argv)
|
||||
@@ -73,24 +78,26 @@ int main(int argc,char **argv)
|
||||
pval = (narg==1) ? (argv[1]+2) : argv[2];
|
||||
if(strncmp(argv[1],"-I",2)==0) {
|
||||
inputAddPath(inputPvt,pval);
|
||||
} else if (strcmp(argv[1], "-D") == 0) {
|
||||
opt_D = 1;
|
||||
narg = 1; /* no argument for this option */
|
||||
} else if(strncmp(argv[1],"-o",2)==0) {
|
||||
if(freopen(pval,"w",stdout)==NULL) {
|
||||
fprintf(stderr,"msi: Can't open %s for writing: %s\n",
|
||||
pval, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
outFile = epicsStrDup(pval);
|
||||
} else if(strncmp(argv[1],"-M",2)==0) {
|
||||
addMacroReplacements(macPvt,pval);
|
||||
} else if(strncmp(argv[1],"-S",2)==0) {
|
||||
substitutionName = epicsStrDup(pval);
|
||||
} else if(strncmp(argv[1],"-V",2)==0) {
|
||||
} else if (strcmp(argv[1], "-V") == 0) {
|
||||
opt_V = 1;
|
||||
narg = 1; /* no argument for this option */
|
||||
} else if(strncmp(argv[1],"-g",2)==0) {
|
||||
} else if (strcmp(argv[1], "-g") == 0) {
|
||||
localScope = 0;
|
||||
narg = 1; /* no argument for this option */
|
||||
} else if (strcmp(argv[1], "-h") == 0) {
|
||||
usageExit(0);
|
||||
} else {
|
||||
usageExit();
|
||||
fprintf(stderr, "msi: Bad argument \"%s\"\n", argv[1]);
|
||||
usageExit(1);
|
||||
}
|
||||
argc -= narg;
|
||||
for(i=1; i<argc; i++) argv[i] = argv[i + narg];
|
||||
@@ -99,7 +106,19 @@ int main(int argc,char **argv)
|
||||
macSuppressWarning(macPvt,1);
|
||||
if(argc>2) {
|
||||
fprintf(stderr,"msi: Too many arguments\n");
|
||||
usageExit();
|
||||
usageExit(1);
|
||||
}
|
||||
if (opt_D) {
|
||||
if (!outFile) {
|
||||
fprintf(stderr, "msi: Option -D requires -o for Makefile target\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("%s:", outFile);
|
||||
}
|
||||
else if (outFile && freopen(outFile, "w", stdout) == NULL) {
|
||||
fprintf(stderr, "msi: Can't open %s for writing: %s\n",
|
||||
outFile, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
if(argc==2) {
|
||||
templateName = epicsStrDup(argv[1]);
|
||||
@@ -122,7 +141,7 @@ int main(int argc,char **argv)
|
||||
if(templateName) filename = templateName;
|
||||
if(!filename) {
|
||||
fprintf(stderr,"msi: No template file\n");
|
||||
usageExit();
|
||||
usageExit(1);
|
||||
}
|
||||
while((pval = substituteGetReplacements(substitutePvt))){
|
||||
if (localScope) macPushScope(macPvt);
|
||||
@@ -137,24 +156,30 @@ int main(int argc,char **argv)
|
||||
errlogFlush();
|
||||
macDeleteHandle(macPvt);
|
||||
inputDestruct(inputPvt);
|
||||
if (opt_D) {
|
||||
printf("\n");
|
||||
}
|
||||
free(templateName);
|
||||
free(substitutionName);
|
||||
return opt_V & 2;
|
||||
}
|
||||
|
||||
void usageExit(void)
|
||||
void usageExit(int status)
|
||||
{
|
||||
fprintf(stderr,"usage: msi [options] [template]\n");
|
||||
fprintf(stderr,"stdin is used if neither template nor substitution file is given\n");
|
||||
fprintf(stderr,"options:\n");
|
||||
fprintf(stderr," -V Undefined macros generate an error\n");
|
||||
fprintf(stderr," -g All macros have global scope\n");
|
||||
fprintf(stderr," -o<FILE> Save output to <FILE>\n");
|
||||
fprintf(stderr," -I<DIR> Add <DIR> to include file search path\n");
|
||||
fprintf(stderr," -M<SUBST> Add <SUBST> to (global) macro definitions\n");
|
||||
fprintf(stderr," (<SUBST> takes the form VAR=VALUE,...)\n");
|
||||
fprintf(stderr," -S<FILE> Expand the substitutions in FILE\n");
|
||||
exit(1);
|
||||
fprintf(stderr,
|
||||
"Usage: msi [options] [template]\n"
|
||||
" stdin is used if neither template nor substitution file is given\n"
|
||||
" options:\n"
|
||||
" -h Print this help message\n"
|
||||
" -D Output file dependencies, not substitutions\n"
|
||||
" -V Undefined macros generate an error\n"
|
||||
" -g All macros have global scope\n"
|
||||
" -o<FILE> Send output to <FILE>\n"
|
||||
" -I<DIR> Add <DIR> to include file search path\n"
|
||||
" -M<SUBST> Add <SUBST> to (global) macro definitions\n"
|
||||
" (<SUBST> takes the form VAR=VALUE,...)\n"
|
||||
" -S<FILE> Expand the substitutions in FILE\n");
|
||||
exit(status);
|
||||
}
|
||||
|
||||
static void addMacroReplacements(MAC_HANDLE *macPvt,char *pval)
|
||||
@@ -165,13 +190,13 @@ static void addMacroReplacements(MAC_HANDLE *macPvt,char *pval)
|
||||
status = macParseDefns(macPvt,pval,&pairs);
|
||||
if(status==-1) {
|
||||
fprintf(stderr,"msi: Error from macParseDefns\n");
|
||||
usageExit();
|
||||
usageExit(1);
|
||||
}
|
||||
if(status) {
|
||||
status = macInstallMacros(macPvt,pairs);
|
||||
if(!status) {
|
||||
fprintf(stderr,"Error from macInstallMacros\n");
|
||||
usageExit();
|
||||
usageExit(1);
|
||||
}
|
||||
free(pairs);
|
||||
}
|
||||
@@ -249,7 +274,7 @@ static void makeSubstitutions(inputData *inputPvt, MAC_HANDLE *macPvt, char *tem
|
||||
expand = 0;
|
||||
}
|
||||
endif:
|
||||
if (expand) {
|
||||
if (expand && !opt_D) {
|
||||
n = macExpandString(macPvt,input,buffer,MAX_BUFFER_SIZE-1);
|
||||
fputs(buffer,stdout);
|
||||
if (opt_V == 1 && n < 0) {
|
||||
@@ -432,6 +457,32 @@ static void inputOpenFile(inputData *pinputData,char *filename)
|
||||
} else {
|
||||
pinputFile->filename = epicsStrDup("stdin");
|
||||
}
|
||||
|
||||
if (opt_D) {
|
||||
int hash = epicsStrHash(pinputFile->filename, 12345);
|
||||
int i = 0;
|
||||
int match = 0;
|
||||
|
||||
while (i < numDeps) {
|
||||
if (hash == depHashes[i++]) {
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!match) {
|
||||
const char *wrap = numDeps ? " \\\n" : "";
|
||||
|
||||
printf("%s %s", wrap, pinputFile->filename);
|
||||
if (numDeps < MAX_DEPS) {
|
||||
depHashes[numDeps++] = hash;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "msi: More than %d dependencies!\n", MAX_DEPS);
|
||||
depHashes[0] = hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pinputFile->fp = fp;
|
||||
ellInsert(&pinputData->inputFileList,0,&pinputFile->node);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,6 @@ TARGETS += $(TARGETS_$(BUILD_CLASS))
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
|
||||
msi-copy$(EXE): $(INSTALL_BIN)/msi$(EXE) ../Makefile
|
||||
msi-copy$(EXE): $(INSTALL_BIN)/msi$(EXE)
|
||||
@$(RM) $@
|
||||
$(CP) $< $@
|
||||
|
||||
@@ -11,23 +11,40 @@
|
||||
use strict;
|
||||
use Test;
|
||||
|
||||
BEGIN {plan tests => 7}
|
||||
BEGIN {plan tests => 9}
|
||||
|
||||
# Check include/substitute command model
|
||||
ok(msi('-I .. ../t1-template.txt'), slurp('../t1-result.txt'));
|
||||
ok(msi('-I.. -S ../t2-substitution.txt'), slurp('../t2-result.txt'));
|
||||
ok(msi('-I. -I.. -S ../t3-substitution.txt'), slurp('../t3-result.txt'));
|
||||
ok(msi('-g -I.. -S ../t4-substitution.txt'), slurp('../t4-result.txt'));
|
||||
ok(msi('-S ../t5-substitute.txt ../t5-template.txt'), slurp('../t5-result.txt'));
|
||||
ok(msi('-S ../t6-substitute.txt ../t6-template.txt'), slurp('../t6-result.txt'));
|
||||
|
||||
# Check -o works
|
||||
# Substitution file, dbLoadTemplate format
|
||||
ok(msi('-I.. -S ../t2-substitution.txt'), slurp('../t2-result.txt'));
|
||||
|
||||
# Macro scoping
|
||||
ok(msi('-I. -I.. -S ../t3-substitution.txt'), slurp('../t3-result.txt'));
|
||||
|
||||
# Global scope (backwards compatibility check)
|
||||
ok(msi('-g -I.. -S ../t4-substitution.txt'), slurp('../t4-result.txt'));
|
||||
|
||||
# Substitution file, regular format
|
||||
ok(msi('-S ../t5-substitute.txt ../t5-template.txt'), slurp('../t5-result.txt'));
|
||||
|
||||
# Substitution file, pattern format
|
||||
ok(msi('-S../t6-substitute.txt ../t6-template.txt'), slurp('../t6-result.txt'));
|
||||
|
||||
# Output option -o
|
||||
my $out = 't7-output.txt';
|
||||
unlink $out;
|
||||
msi("-I.. -o $out ../t1-template.txt");
|
||||
ok(slurp($out), slurp('../t1-result.txt'));
|
||||
|
||||
# Dependency generation, include/substitute model
|
||||
ok(msi('-I.. -D -o t8.txt ../t1-template.txt'), slurp('../t8-result.txt'));
|
||||
|
||||
# Support routines
|
||||
# Dependency generation, dbLoadTemplate format
|
||||
ok(msi('-I.. -D -ot9.txt -S ../t2-substitution.txt'), slurp('../t9-result.txt'));
|
||||
|
||||
|
||||
# Test support routines
|
||||
|
||||
sub slurp {
|
||||
my ($file) = @_;
|
||||
|
||||
2
src/ioc/dbtemplate/test/t8-result.txt
Normal file
2
src/ioc/dbtemplate/test/t8-result.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
t8.txt: ../t1-template.txt \
|
||||
../t1-include.txt
|
||||
1
src/ioc/dbtemplate/test/t9-result.txt
Normal file
1
src/ioc/dbtemplate/test/t9-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
t9.txt: ../t2-template.txt
|
||||
@@ -16,6 +16,6 @@ asLib$(DEP): asLib_lex.c
|
||||
asLib.c: asLib_lex.c
|
||||
|
||||
# Ensure that lexer and parser are built before they are needed
|
||||
asLib.c: $(TOOLS)/antelope$(HOSTEXE)
|
||||
asLib_lex.c: $(TOOLS)/e_flex$(HOSTEXE)
|
||||
asLib.c: $(EPICS_BASE_HOST_BIN)/antelope$(HOSTEXE)
|
||||
asLib_lex.c: $(EPICS_BASE_HOST_BIN)/e_flex$(HOSTEXE)
|
||||
asLib_lex.c: $(INSTALL_INCLUDE)/flex.skel.static
|
||||
|
||||
@@ -10,4 +10,4 @@
|
||||
# This is a Makefile fragment, see src/libCom/Makefile.
|
||||
|
||||
# Ensure that the lexer is built before it is needed
|
||||
parse.c: $(TOOLS)/antelope$(HOSTEXE)
|
||||
parse.c: $(EPICS_BASE_HOST_BIN)/antelope$(HOSTEXE)
|
||||
|
||||
Reference in New Issue
Block a user