Skip to content

Commit

Permalink
adding build versions and consistent version function across modules
Browse files Browse the repository at this point in the history
  • Loading branch information
dentearl committed Sep 6, 2012
1 parent 1d76f6e commit 79cb943
Show file tree
Hide file tree
Showing 22 changed files with 203 additions and 87 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ bin
*.o
*.pyc
*.a
buildVersion*
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
*/
'''
g_git = mtt.which('git')

def runCommand(cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
pout, perr = p.communicate()
Expand All @@ -47,7 +46,6 @@ def getBranch():
return b[2:]
def getSha():
return runCommand([g_git, 'rev-parse', 'HEAD']).strip()

def writeHeader(location):
f = open(os.path.join(location, 'buildVersion.h'), 'w')
f.write(g_BoilerPlate)
Expand All @@ -58,7 +56,6 @@ def writeHeader(location):
f.write('extern const char g_build_git_sha[];\n')
f.write('#endif // _BUILD_VERSION_H_\n')
f.close()

def writeSource(location, buildDate, buildBranch, buildSha):
f = open(os.path.join(location, 'buildVersion.c'), 'w')
f.write(g_BoilerPlate)
Expand All @@ -67,7 +64,6 @@ def writeSource(location, buildDate, buildBranch, buildSha):
f.write('const char g_build_git_branch[] = "%s";\n' % buildBranch)
f.write('const char g_build_git_sha[] = "%s";\n' % buildSha)
f.close()

def main():
location = os.path.join(os.curdir, 'src')
buildDate = time.strftime('%Y-%m-%dT%H:%M%Z', time.localtime()) # gmtime()
Expand Down
10 changes: 6 additions & 4 deletions mafBlockDuplicateFilter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ args = -Wall -Wextra -Werror -std=c99 -pedantic -I ../external -I ../include
bin = ../bin
PROGS = mafBlockDuplicateFilter
dependencies = $(wildcard ../include/common.*) $(wildcard ../include/sharedMaf.*)
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a
testObjects := test/sharedMaf.o test/common.o ../external/CuTest.a
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a src/buildVersion.o
testObjects := test/sharedMaf.o test/common.o ../external/CuTest.a test/buildVersion.o

.PHONY: all clean test
.PHONY: all clean test buildVersion

all: $(foreach f,${PROGS}, ${bin}/$f)
all: buildVersion $(foreach f,${PROGS}, ${bin}/$f)
buildVersion:
@python ../include/createVersionSources.py

${bin}/mafBlockDuplicateFilter: src/mafBlockDuplicateFilter.c ${dependencies} ${objects}
mkdir -p $(dir $@)
Expand Down
20 changes: 17 additions & 3 deletions mafBlockDuplicateFilter/src/mafBlockDuplicateFilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#include <string.h>
#include "common.h"
#include "sharedMaf.h"
#include "buildVersion.h"

const char *g_version = "version 0.1 September 2012";

typedef struct scoredMafLine {
// augmented data structure
Expand All @@ -47,6 +50,7 @@ typedef struct duplicate {
} duplicate_t;

void usage(void);
void version(void);
void processBody(mafFileApi_t *mfa);
void checkBlock(mafBlock_t *block);
// void destroyBlock(mafLine_t *m);
Expand All @@ -63,20 +67,25 @@ void parseOptions(int argc, char **argv, char *filename) {
int c;
int setMName = 0;
while (1) {
static struct option long_options[] = {
static struct option longOptions[] = {
{"debug", no_argument, 0, 'd'},
{"verbose", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 0},
{"maf", required_argument, 0, 'm'},
{0, 0, 0, 0}
};
int option_index = 0;
int longIndex = 0;
c = getopt_long(argc, argv, "d:m:h:v",
long_options, &option_index);
longOptions, &longIndex);
if (c == -1)
break;
switch (c) {
case 0:
if (strcmp("version", longOptions[longIndex].name) == 0) {
version();
exit(EXIT_SUCCESS);
}
break;
case 'm':
setMName = 1;
Expand Down Expand Up @@ -113,7 +122,12 @@ void parseOptions(int argc, char **argv, char *filename) {
usage();
}
}
void version(void) {
fprintf(stderr, "mafBlockDuplicateFilter, %s\nbuild: %s, %s, %s\n\n", g_version, g_build_date,
g_build_git_branch, g_build_git_sha);
}
void usage(void) {
version();
fprintf(stderr, "Usage: mafBlockDuplicateFilter --maf mafWithDuplicates.maf > pruned.maf \n\n"
"mafBlockDuplicateFilter is a program to filter out duplications from a Multiple \n"
"Alignment Format (maf) file. This program assumes the sequence name field is \n"
Expand Down
10 changes: 6 additions & 4 deletions mafBlockExtractor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ args = -Wall -Wextra -std=c99 -pedantic -I ../external -I ../include
bin = ../bin
PROGS = mafBlockExtractor
dependencies = $(wildcard ../include/common.*) $(wildcard ../include/sharedMaf.*) src/mafBlockExtractor.h
API = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a src/mafBlockExtractorAPI.o
testAPI = test/sharedMaf.o ../external/CuTest.a test/common.o test/mafBlockExtractorAPI.o
API = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a src/mafBlockExtractorAPI.o src/buildVersion.o
testAPI = test/sharedMaf.o ../external/CuTest.a test/common.o test/mafBlockExtractorAPI.o test/buildVersion.o
testObjects := test/test.mafBlockExtractor.o

.PHONY: all clean test
.PHONY: all clean test buildVersion

all: $(foreach f,${PROGS}, ${bin}/$f)
all: buildVersion $(foreach f,${PROGS}, ${bin}/$f)
buildVersion:
@python ../include/createVersionSources.py

${bin}/mafBlockExtractor: src/mafBlockExtractor.c ${dependencies} ${API}
mkdir -p $(dir $@)
Expand Down
24 changes: 18 additions & 6 deletions mafBlockExtractor/src/mafBlockExtractor.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,16 @@
#include "sharedMaf.h"
#include "mafBlockExtractor.h"
#include "mafBlockExtractorAPI.h"
#include "buildVersion.h"

const char *g_version = "version 0.2 September 2012";

void version(void) {
fprintf(stderr, "mafBlockExtractor, %s\nbuild: %s, %s, %s\n\n", g_version, g_build_date,
g_build_git_branch, g_build_git_sha);
}
void usage(void) {
version();
fprintf(stderr, "Usage: mafBlockExtractor --maf [maf file] --seq [sequence name (and possibly chr)] "
"--start [start of region, inclusive, 0 based] --stop [end of region, inclusive] "
"[options]\n\n"
Expand All @@ -58,42 +66,46 @@ void parseOptions(int argc, char **argv, char *filename, char *seqName, uint32_t
bool setSName = false, setStart = false, setStop = false, setMName = false;
int32_t value = 0;
while (1) {
static struct option long_options[] = {
static struct option longOptions[] = {
{"debug", no_argument, 0, 'd'},
{"verbose", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 0},
{"maf", required_argument, 0, 'm'},
{"seq", required_argument, 0, 's'},
{"start", required_argument, 0, 0},
{"stop", required_argument, 0, 0},
{"soft", no_argument, 0, 0},
{0, 0, 0, 0}
};
int option_index = 0;
int longIndex = 0;
c = getopt_long(argc, argv, "m:s:h:v:d",
long_options, &option_index);
longOptions, &longIndex);
if (c == -1)
break;
switch (c) {
case 0:
if (strcmp("start", long_options[option_index].name) == 0) {
if (strcmp("start", longOptions[longIndex].name) == 0) {
value = strtoll(optarg, NULL, 10);
if (value < 0) {
fprintf(stderr, "Error, --start %d must be nonnegative.\n", value);
usage();
}
*start = value;
setStart = true;
} else if (strcmp("stop", long_options[option_index].name) == 0) {
} else if (strcmp("stop", longOptions[longIndex].name) == 0) {
value = strtoll(optarg, NULL, 10);
if (value < 0) {
fprintf(stderr, "Error, --stop %d must be nonnegative.\n", value);
usage();
}
*stop = value;
setStop = true;
} else if (strcmp("soft", long_options[option_index].name) == 0) {
} else if (strcmp("soft", longOptions[longIndex].name) == 0) {
*isSoft = true;
} else if (strcmp("version", longOptions[longIndex].name) == 0) {
version();
exit(EXIT_SUCCESS);
}
break;
case 'm':
Expand Down
1 change: 1 addition & 0 deletions mafBlockExtractor/src/mafBlockExtractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "common.h"
#include "sharedMaf.h"

void version(void);
void usage(void);
void parseOptions(int argc, char **argv, char *filename, char *seqName, uint32_t *start,
uint32_t *stop, bool *isSoft);
Expand Down
10 changes: 6 additions & 4 deletions mafBlockFilter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ args = -Wall -Wextra -Werror -std=c99 -pedantic -I ../external -I ../include
bin = ../bin
PROGS = mafBlockFilter
dependencies = $(wildcard ../include/common.*) $(wildcard ../include/sharedMaf.*)
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a
testObjects = ./test/common.o ./test/sharedMaf.o ../external/CuTest.a
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a src/buildVersion.o
testObjects = test/common.o test/sharedMaf.o ../external/CuTest.a test/buildVersion.o

.PHONY: all clean test
.PHONY: all clean test buildVersion

all: $(foreach f,${PROGS}, ${bin}/$f)
all: buildVersion $(foreach f,${PROGS}, ${bin}/$f)
buildVersion:
@python ../include/createVersionSources.py

${bin}/mafBlockFilter: src/mafBlockFilter.c ${dependencies} ${objects}
mkdir -p $(dir $@)
Expand Down
20 changes: 17 additions & 3 deletions mafBlockFilter/src/mafBlockFilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,22 @@
#include <unistd.h>
#include "common.h"
#include "sharedMaf.h"
#include "buildVersion.h"

const char *g_version = "version 0.1 September 2012";

void version(void);
void usage(void);
void parseOptions(int argc, char **argv, char *filename, char *nameList, bool *isInclude, int64_t *blockDegLT, int64_t *blockDegGT);
void checkRegion(unsigned lineno, char *fullname, uint32_t pos, uint32_t start,
uint32_t length, uint32_t sourceLength, char strand);

void version(void) {
fprintf(stderr, "mafBlockFilter, %s\nbuild: %s, %s, %s\n\n", g_version, g_build_date,
g_build_git_branch, g_build_git_sha);
}
void usage(void) {
version();
fprintf(stderr, "Usage: mafBlockFilter --maf [path to maf] "
"[options]\n\n"
"mafBlockFilter is a program that will look through a\n"
Expand All @@ -68,25 +77,30 @@ void parseOptions(int argc, char **argv, char *filename, char *nameList, bool *i
int c;
bool setMafName = false, setNames = false, setBlockLimits = false;
while (1) {
static struct option long_options[] = {
static struct option longOptions[] = {
{"debug", no_argument, &g_debug_flag, 1},
{"verbose", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 0},
{"maf", required_argument, 0, 'm'},
{"includeSeq", required_argument, 0, 'i'},
{"excludeSeq", required_argument, 0, 'e'},
{"noDegreeGT", required_argument, 0, 'g'},
{"noDegreeLT", required_argument, 0, 'l'},
{0, 0, 0, 0}
};
int option_index = 0;
int longIndex = 0;
c = getopt_long(argc, argv, "m:i:e:g:l:v:h",
long_options, &option_index);
longOptions, &longIndex);
if (c == -1) {
break;
}
switch (c) {
case 0:
if (strcmp("version", longOptions[longIndex].name) == 0) {
version();
exit(EXIT_SUCCESS);
}
break;
case 'm':
setMafName = true;
Expand Down
10 changes: 6 additions & 4 deletions mafBlockFinder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ args = -Wall -Wextra -std=c99 -pedantic -I ../external -I ../include
bin = ../bin
PROGS = mafBlockFinder
dependencies = $(wildcard ../include/common.*) $(wildcard ../include/sharedMaf.*)
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a
testObjects = test/common.o test/sharedMaf.o ../external/CuTest.a
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a src/buildVersion.o
testObjects = test/common.o test/sharedMaf.o ../external/CuTest.a test/buildVersion.o

.PHONY: all clean test
.PHONY: all clean test buildVersion

all: $(foreach f,${PROGS}, ${bin}/$f)
all: buildVersion $(foreach f,${PROGS}, ${bin}/$f)
buildVersion:
@python ../include/createVersionSources.py

${bin}/mafBlockFinder: src/mafBlockFinder.c ${dependencies} ${objects}
mkdir -p $(dir $@)
Expand Down
14 changes: 14 additions & 0 deletions mafBlockFinder/src/mafBlockFinder.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@
#include <unistd.h>
#include "common.h"
#include "sharedMaf.h"
#include "buildVersion.h"

const char *g_version = "version 0.1 September 2012";

void version(void);
void usage(void);
void parseOptions(int argc, char **argv, char *filename, char *seqName, uint32_t *position);
void checkRegion(unsigned lineno, char *fullname, uint32_t pos, uint32_t start,
uint32_t length, uint32_t sourceLength, char strand);
void searchInput(mafFileApi_t *mfa, char *fullname, unsigned long pos);

void version(void) {
fprintf(stderr, "mafBlockDuplicateFilter, %s\nbuild: %s, %s, %s\n\n", g_version, g_build_date,
g_build_git_branch, g_build_git_sha);
}
void usage(void) {
version();
fprintf(stderr, "Usage: mafBlockFinder --maf [path to maf] "
"--seq [sequence name (and possibly chr)] "
"--pos [position to search for, zero based coords] [options]\n\n"
Expand Down Expand Up @@ -72,6 +81,7 @@ void parseOptions(int argc, char **argv, char *filename, char *seqName, uint32_t
{"debug", no_argument, &g_debug_flag, 1},
{"verbose", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 0},
{"maf", required_argument, 0, 'm'},
{"seq", required_argument, 0, 's'},
{"sequence", required_argument, 0, 's'},
Expand All @@ -87,6 +97,10 @@ void parseOptions(int argc, char **argv, char *filename, char *seqName, uint32_t
}
switch (c) {
case 0:
if (strcmp("version", long_options[option_index].name) == 0) {
version();
exit(EXIT_SUCCESS);
}
break;
case 'm':
setMName = 1;
Expand Down
10 changes: 6 additions & 4 deletions mafBlockSorter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ args = -Wall -Wextra -Werror -std=c99 -pedantic -I ../external -I ../include
bin = ../bin
PROGS = mafBlockSorter
dependencies = $(wildcard ../include/common.*) $(wildcard ../include/sharedMaf.*)
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a
testObjects = ./test/common.o ./test/sharedMaf.o ../external/CuTest.a
objects = ../include/common.o ../include/sharedMaf.o ../external/CuTest.a src/buildVersion.o
testObjects = ./test/common.o ./test/sharedMaf.o ../external/CuTest.a test/buildVersion.o

.PHONY: all clean test
.PHONY: all clean test buildVersion

all: $(foreach f,${PROGS}, ${bin}/$f)
all: buildVersion $(foreach f,${PROGS}, ${bin}/$f)
buildVersion:
@python ../include/createVersionSources.py

${bin}/mafBlockSorter: src/mafBlockSorter.c ${dependencies} ${objects}
mkdir -p $(dir $@)
Expand Down
Loading

0 comments on commit 79cb943

Please sign in to comment.