From da5794d9caa47e96679c197610bd8ea2a682c338 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 21 May 2009 18:25:50 +0000 Subject: [PATCH] config-mkvers-xml-20090521 LICENSE IPL10 Add a -x option to mkvers.c to permit generation of XML entities containing a revision tag and tags for each delta Add autogeneration of version.xml to Windows Makefiles --- src/config/NTMakefile.version-CML | 3 +++ src/config/NTMakefile.version-NOCML | 8 ++++++++ src/config/mkvers.c | 41 ++++++++++++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/config/NTMakefile.version-CML b/src/config/NTMakefile.version-CML index 4f709c8..5969a82 100644 --- a/src/config/NTMakefile.version-CML +++ b/src/config/NTMakefile.version-CML @@ -27,3 +27,6 @@ $(VERSFILE).h: $(VERSFILE).txt: $(DESTDIR)\bin\mkvers -o $(VERSFILE).txt -t + +$(VERSFILE).xml: + $(DESTDIR)\bin\mkvers -o $(VERSFILE).xml -x diff --git a/src/config/NTMakefile.version-NOCML b/src/config/NTMakefile.version-NOCML index 9bebb97..c76133f 100644 --- a/src/config/NTMakefile.version-NOCML +++ b/src/config/NTMakefile.version-NOCML @@ -24,3 +24,11 @@ $(VERSFILE).h: $(VERSFILE).txt: echo OpenAFS_$(AFSPRODUCT_VERSION)>$(VERSFILE).txt + +$(VERSFILE).xml: + echo <<$(VERSFILE).xml > NUL + + +$(AFSPRODUCT_VERSION) + +<< KEEP diff --git a/src/config/mkvers.c b/src/config/mkvers.c index 9789175..aea2a40 100644 --- a/src/config/mkvers.c +++ b/src/config/mkvers.c @@ -58,7 +58,8 @@ int nStamps = 0; enum { CF_DEFAULT, CF_VERINFO, - CF_TEXT + CF_TEXT, + CF_XML } cfgFormat = CF_DEFAULT; char *programName; @@ -69,7 +70,7 @@ void Usage(void) { printf - ("Usage: %s [-d directory] [-o output file name] [-c component] [-v | -t]\n", + ("Usage: %s [-d directory] [-o output file name] [-c component] [-v | -t | -x]\n", programName); printf("%s creates the AFS_component_version_number.c file.\n", programName); @@ -81,6 +82,7 @@ Usage(void) ("-c component - if not \"afs\" prefix for cml_version_number variable.\n"); printf("-v generate NT versioninfo style declarations.\n"); printf("-t generate text file style information.\n"); + printf("-x generate XML revision information.\n"); exit(1); } @@ -148,6 +150,13 @@ main(int argc, char **argv) printf("Specify only one alternative output format\n"); Usage(); } + } else if (!strcmp("-x", argv[i])) { + if (cfgFormat == CF_DEFAULT || cfgFormat == CF_XML) { + cfgFormat = CF_XML; + } else { + printf("Specify only one alternative output format\n"); + Usage(); + } } else { printf("%s: Unknown argument.\n", argv[i]); Usage(); @@ -162,6 +171,8 @@ main(int argc, char **argv) strcat(outputFileBuf, ".h"); } else if (cfgFormat == CF_TEXT) { strcat(outputFileBuf, ".txt"); + } else if (cfgFormat == CF_XML) { + strcat(outputFileBuf, ".xml"); } else { strcat(outputFileBuf, ".c"); } @@ -172,7 +183,7 @@ main(int argc, char **argv) if ((code = stat(outputFile, &sbuf)) < 0) { reBuild = 1; - versTime = (time_t) 0; /* inidicates no output file. */ + versTime = (time_t) 0; /* indicates no output file. */ } else { versTime = sbuf.st_mtime; } @@ -289,6 +300,14 @@ PrintStamps(void) } else if (cfgFormat == CF_TEXT) { fprintf(fpVers, "Base configuration %s\n", stateDeltas[i].name); + } else if (cfgFormat == CF_TEXT) { + fprintf(fpVers, + "\n" + "\n" + "\n" + "Base configuration %s\n" + "\n", + stateDeltas[i].name); } else { fprintf(fpVers, "%sBase configuration %s", cml_string, stateDeltas[i].name); @@ -307,6 +326,13 @@ PrintStamps(void) if (cfgFormat == CF_TEXT) { fprintf(fpVers, "%c%s\n", stateDeltas[i].type, stateDeltas[i].name); + } else if (cfgFormat == CF_XML) { + fprintf(fpVers, + "\n" + ";%c%s" + "\n", + stateDeltas[i].type, + stateDeltas[i].name); } else { fprintf(fpVers, ";%c%s", stateDeltas[i].type, stateDeltas[i].name); @@ -323,6 +349,13 @@ PrintStamps(void) if (cfgFormat == CF_TEXT) { fprintf(fpVers, "%c%s\n", stateDeltas[i].type, stateDeltas[i].name); + } else if (cfgFormat == CF_XML) { + fprintf(fpVers, + "\n" + ";%c%s" + "\n", + stateDeltas[i].type, + stateDeltas[i].name); } else { fprintf(fpVers, ";%c%s", stateDeltas[i].type, stateDeltas[i].name); @@ -345,5 +378,7 @@ PrintStamps(void) if (s) *s = '\0'; fprintf(fpVers, "%s%s\";\n", AFS_STRING, c ? c : "Unknown"); + } else if (cfgFormat == CF_XML) { + fprintf(fpVers, "\n"); } } -- 1.9.4