Skip to content

Commit 79cb943

Browse files
committed
adding build versions and consistent version function across modules
1 parent 1d76f6e commit 79cb943

File tree

22 files changed

+203
-87
lines changed

22 files changed

+203
-87
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ bin
22
*.o
33
*.pyc
44
*.a
5+
buildVersion*

mafComparator/src/createVersionSources.py renamed to include/createVersionSources.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
*/
3535
'''
3636
g_git = mtt.which('git')
37-
3837
def runCommand(cmd):
3938
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
4039
pout, perr = p.communicate()
@@ -47,7 +46,6 @@ def getBranch():
4746
return b[2:]
4847
def getSha():
4948
return runCommand([g_git, 'rev-parse', 'HEAD']).strip()
50-
5149
def writeHeader(location):
5250
f = open(os.path.join(location, 'buildVersion.h'), 'w')
5351
f.write(g_BoilerPlate)
@@ -58,7 +56,6 @@ def writeHeader(location):
5856
f.write('extern const char g_build_git_sha[];\n')
5957
f.write('#endif // _BUILD_VERSION_H_\n')
6058
f.close()
61-
6259
def writeSource(location, buildDate, buildBranch, buildSha):
6360
f = open(os.path.join(location, 'buildVersion.c'), 'w')
6461
f.write(g_BoilerPlate)
@@ -67,7 +64,6 @@ def writeSource(location, buildDate, buildBranch, buildSha):
6764
f.write('const char g_build_git_branch[] = "%s";\n' % buildBranch)
6865
f.write('const char g_build_git_sha[] = "%s";\n' % buildSha)
6966
f.close()
70-
7167
def main():
7268
location = os.path.join(os.curdir, 'src')
7369
buildDate = time.strftime('%Y-%m-%dT%H:%M%Z', time.localtime()) # gmtime()

mafBlockDuplicateFilter/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ args = -Wall -Wextra -Werror -std=c99 -pedantic -I ../external -I ../include
44
bin = ../bin
55
PROGS = mafBlockDuplicateFilter
66
dependencies = $(wildcard ../include/common.*) $(wildcard ../include/sharedMaf.*)
7-
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a
8-
testObjects := test/sharedMaf.o test/common.o ../external/CuTest.a
7+
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a src/buildVersion.o
8+
testObjects := test/sharedMaf.o test/common.o ../external/CuTest.a test/buildVersion.o
99

10-
.PHONY: all clean test
10+
.PHONY: all clean test buildVersion
1111

12-
all: $(foreach f,${PROGS}, ${bin}/$f)
12+
all: buildVersion $(foreach f,${PROGS}, ${bin}/$f)
13+
buildVersion:
14+
@python ../include/createVersionSources.py
1315

1416
${bin}/mafBlockDuplicateFilter: src/mafBlockDuplicateFilter.c ${dependencies} ${objects}
1517
mkdir -p $(dir $@)

mafBlockDuplicateFilter/src/mafBlockDuplicateFilter.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
#include <string.h>
3232
#include "common.h"
3333
#include "sharedMaf.h"
34+
#include "buildVersion.h"
35+
36+
const char *g_version = "version 0.1 September 2012";
3437

3538
typedef struct scoredMafLine {
3639
// augmented data structure
@@ -47,6 +50,7 @@ typedef struct duplicate {
4750
} duplicate_t;
4851

4952
void usage(void);
53+
void version(void);
5054
void processBody(mafFileApi_t *mfa);
5155
void checkBlock(mafBlock_t *block);
5256
// void destroyBlock(mafLine_t *m);
@@ -63,20 +67,25 @@ void parseOptions(int argc, char **argv, char *filename) {
6367
int c;
6468
int setMName = 0;
6569
while (1) {
66-
static struct option long_options[] = {
70+
static struct option longOptions[] = {
6771
{"debug", no_argument, 0, 'd'},
6872
{"verbose", no_argument, 0, 'v'},
6973
{"help", no_argument, 0, 'h'},
74+
{"version", no_argument, 0, 0},
7075
{"maf", required_argument, 0, 'm'},
7176
{0, 0, 0, 0}
7277
};
73-
int option_index = 0;
78+
int longIndex = 0;
7479
c = getopt_long(argc, argv, "d:m:h:v",
75-
long_options, &option_index);
80+
longOptions, &longIndex);
7681
if (c == -1)
7782
break;
7883
switch (c) {
7984
case 0:
85+
if (strcmp("version", longOptions[longIndex].name) == 0) {
86+
version();
87+
exit(EXIT_SUCCESS);
88+
}
8089
break;
8190
case 'm':
8291
setMName = 1;
@@ -113,7 +122,12 @@ void parseOptions(int argc, char **argv, char *filename) {
113122
usage();
114123
}
115124
}
125+
void version(void) {
126+
fprintf(stderr, "mafBlockDuplicateFilter, %s\nbuild: %s, %s, %s\n\n", g_version, g_build_date,
127+
g_build_git_branch, g_build_git_sha);
128+
}
116129
void usage(void) {
130+
version();
117131
fprintf(stderr, "Usage: mafBlockDuplicateFilter --maf mafWithDuplicates.maf > pruned.maf \n\n"
118132
"mafBlockDuplicateFilter is a program to filter out duplications from a Multiple \n"
119133
"Alignment Format (maf) file. This program assumes the sequence name field is \n"

mafBlockExtractor/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ args = -Wall -Wextra -std=c99 -pedantic -I ../external -I ../include
44
bin = ../bin
55
PROGS = mafBlockExtractor
66
dependencies = $(wildcard ../include/common.*) $(wildcard ../include/sharedMaf.*) src/mafBlockExtractor.h
7-
API = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a src/mafBlockExtractorAPI.o
8-
testAPI = test/sharedMaf.o ../external/CuTest.a test/common.o test/mafBlockExtractorAPI.o
7+
API = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a src/mafBlockExtractorAPI.o src/buildVersion.o
8+
testAPI = test/sharedMaf.o ../external/CuTest.a test/common.o test/mafBlockExtractorAPI.o test/buildVersion.o
99
testObjects := test/test.mafBlockExtractor.o
1010

11-
.PHONY: all clean test
11+
.PHONY: all clean test buildVersion
1212

13-
all: $(foreach f,${PROGS}, ${bin}/$f)
13+
all: buildVersion $(foreach f,${PROGS}, ${bin}/$f)
14+
buildVersion:
15+
@python ../include/createVersionSources.py
1416

1517
${bin}/mafBlockExtractor: src/mafBlockExtractor.c ${dependencies} ${API}
1618
mkdir -p $(dir $@)

mafBlockExtractor/src/mafBlockExtractor.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,16 @@
3232
#include "sharedMaf.h"
3333
#include "mafBlockExtractor.h"
3434
#include "mafBlockExtractorAPI.h"
35+
#include "buildVersion.h"
3536

37+
const char *g_version = "version 0.2 September 2012";
38+
39+
void version(void) {
40+
fprintf(stderr, "mafBlockExtractor, %s\nbuild: %s, %s, %s\n\n", g_version, g_build_date,
41+
g_build_git_branch, g_build_git_sha);
42+
}
3643
void usage(void) {
44+
version();
3745
fprintf(stderr, "Usage: mafBlockExtractor --maf [maf file] --seq [sequence name (and possibly chr)] "
3846
"--start [start of region, inclusive, 0 based] --stop [end of region, inclusive] "
3947
"[options]\n\n"
@@ -58,42 +66,46 @@ void parseOptions(int argc, char **argv, char *filename, char *seqName, uint32_t
5866
bool setSName = false, setStart = false, setStop = false, setMName = false;
5967
int32_t value = 0;
6068
while (1) {
61-
static struct option long_options[] = {
69+
static struct option longOptions[] = {
6270
{"debug", no_argument, 0, 'd'},
6371
{"verbose", no_argument, 0, 'v'},
6472
{"help", no_argument, 0, 'h'},
73+
{"version", no_argument, 0, 0},
6574
{"maf", required_argument, 0, 'm'},
6675
{"seq", required_argument, 0, 's'},
6776
{"start", required_argument, 0, 0},
6877
{"stop", required_argument, 0, 0},
6978
{"soft", no_argument, 0, 0},
7079
{0, 0, 0, 0}
7180
};
72-
int option_index = 0;
81+
int longIndex = 0;
7382
c = getopt_long(argc, argv, "m:s:h:v:d",
74-
long_options, &option_index);
83+
longOptions, &longIndex);
7584
if (c == -1)
7685
break;
7786
switch (c) {
7887
case 0:
79-
if (strcmp("start", long_options[option_index].name) == 0) {
88+
if (strcmp("start", longOptions[longIndex].name) == 0) {
8089
value = strtoll(optarg, NULL, 10);
8190
if (value < 0) {
8291
fprintf(stderr, "Error, --start %d must be nonnegative.\n", value);
8392
usage();
8493
}
8594
*start = value;
8695
setStart = true;
87-
} else if (strcmp("stop", long_options[option_index].name) == 0) {
96+
} else if (strcmp("stop", longOptions[longIndex].name) == 0) {
8897
value = strtoll(optarg, NULL, 10);
8998
if (value < 0) {
9099
fprintf(stderr, "Error, --stop %d must be nonnegative.\n", value);
91100
usage();
92101
}
93102
*stop = value;
94103
setStop = true;
95-
} else if (strcmp("soft", long_options[option_index].name) == 0) {
104+
} else if (strcmp("soft", longOptions[longIndex].name) == 0) {
96105
*isSoft = true;
106+
} else if (strcmp("version", longOptions[longIndex].name) == 0) {
107+
version();
108+
exit(EXIT_SUCCESS);
97109
}
98110
break;
99111
case 'm':

mafBlockExtractor/src/mafBlockExtractor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "common.h"
3131
#include "sharedMaf.h"
3232

33+
void version(void);
3334
void usage(void);
3435
void parseOptions(int argc, char **argv, char *filename, char *seqName, uint32_t *start,
3536
uint32_t *stop, bool *isSoft);

mafBlockFilter/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ args = -Wall -Wextra -Werror -std=c99 -pedantic -I ../external -I ../include
44
bin = ../bin
55
PROGS = mafBlockFilter
66
dependencies = $(wildcard ../include/common.*) $(wildcard ../include/sharedMaf.*)
7-
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a
8-
testObjects = ./test/common.o ./test/sharedMaf.o ../external/CuTest.a
7+
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a src/buildVersion.o
8+
testObjects = test/common.o test/sharedMaf.o ../external/CuTest.a test/buildVersion.o
99

10-
.PHONY: all clean test
10+
.PHONY: all clean test buildVersion
1111

12-
all: $(foreach f,${PROGS}, ${bin}/$f)
12+
all: buildVersion $(foreach f,${PROGS}, ${bin}/$f)
13+
buildVersion:
14+
@python ../include/createVersionSources.py
1315

1416
${bin}/mafBlockFilter: src/mafBlockFilter.c ${dependencies} ${objects}
1517
mkdir -p $(dir $@)

mafBlockFilter/src/mafBlockFilter.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,22 @@
3636
#include <unistd.h>
3737
#include "common.h"
3838
#include "sharedMaf.h"
39+
#include "buildVersion.h"
3940

41+
const char *g_version = "version 0.1 September 2012";
42+
43+
void version(void);
4044
void usage(void);
4145
void parseOptions(int argc, char **argv, char *filename, char *nameList, bool *isInclude, int64_t *blockDegLT, int64_t *blockDegGT);
4246
void checkRegion(unsigned lineno, char *fullname, uint32_t pos, uint32_t start,
4347
uint32_t length, uint32_t sourceLength, char strand);
4448

49+
void version(void) {
50+
fprintf(stderr, "mafBlockFilter, %s\nbuild: %s, %s, %s\n\n", g_version, g_build_date,
51+
g_build_git_branch, g_build_git_sha);
52+
}
4553
void usage(void) {
54+
version();
4655
fprintf(stderr, "Usage: mafBlockFilter --maf [path to maf] "
4756
"[options]\n\n"
4857
"mafBlockFilter is a program that will look through a\n"
@@ -68,25 +77,30 @@ void parseOptions(int argc, char **argv, char *filename, char *nameList, bool *i
6877
int c;
6978
bool setMafName = false, setNames = false, setBlockLimits = false;
7079
while (1) {
71-
static struct option long_options[] = {
80+
static struct option longOptions[] = {
7281
{"debug", no_argument, &g_debug_flag, 1},
7382
{"verbose", no_argument, 0, 'v'},
7483
{"help", no_argument, 0, 'h'},
84+
{"version", no_argument, 0, 0},
7585
{"maf", required_argument, 0, 'm'},
7686
{"includeSeq", required_argument, 0, 'i'},
7787
{"excludeSeq", required_argument, 0, 'e'},
7888
{"noDegreeGT", required_argument, 0, 'g'},
7989
{"noDegreeLT", required_argument, 0, 'l'},
8090
{0, 0, 0, 0}
8191
};
82-
int option_index = 0;
92+
int longIndex = 0;
8393
c = getopt_long(argc, argv, "m:i:e:g:l:v:h",
84-
long_options, &option_index);
94+
longOptions, &longIndex);
8595
if (c == -1) {
8696
break;
8797
}
8898
switch (c) {
8999
case 0:
100+
if (strcmp("version", longOptions[longIndex].name) == 0) {
101+
version();
102+
exit(EXIT_SUCCESS);
103+
}
90104
break;
91105
case 'm':
92106
setMafName = true;

mafBlockFinder/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ args = -Wall -Wextra -std=c99 -pedantic -I ../external -I ../include
44
bin = ../bin
55
PROGS = mafBlockFinder
66
dependencies = $(wildcard ../include/common.*) $(wildcard ../include/sharedMaf.*)
7-
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a
8-
testObjects = test/common.o test/sharedMaf.o ../external/CuTest.a
7+
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a src/buildVersion.o
8+
testObjects = test/common.o test/sharedMaf.o ../external/CuTest.a test/buildVersion.o
99

10-
.PHONY: all clean test
10+
.PHONY: all clean test buildVersion
1111

12-
all: $(foreach f,${PROGS}, ${bin}/$f)
12+
all: buildVersion $(foreach f,${PROGS}, ${bin}/$f)
13+
buildVersion:
14+
@python ../include/createVersionSources.py
1315

1416
${bin}/mafBlockFinder: src/mafBlockFinder.c ${dependencies} ${objects}
1517
mkdir -p $(dir $@)

0 commit comments

Comments
 (0)