From 3c96f9e6ceb6324eaa232fa89eb2c3a15f59b089 Mon Sep 17 00:00:00 2001 From: OndrejSladky Date: Tue, 3 Oct 2023 18:28:00 +0200 Subject: [PATCH 1/3] Added automatic versioning --- .gitignore | 1 + Makefile | 7 ++++++- create-version.sh | 2 ++ src/main.cpp | 13 +++++++++++-- src/version | 1 + 5 files changed, 21 insertions(+), 3 deletions(-) create mode 100755 create-version.sh create mode 100644 src/version diff --git a/.gitignore b/.gitignore index 835c4bf..32fb374 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ kmers kmerstest kmercamel kmercameltest +src/version.h 🐫 bin/ diff --git a/Makefile b/Makefile index 4e18851..55124eb 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ cpptest: kmercameltest converttest: convert_superstring_unittest.py ./convert_superstring_unittest.py -kmercamel: $(SRC)/main.cpp $(SRC)/$(wildcard *.cpp *.h *.hpp) +kmercamel: $(SRC)/main.cpp $(SRC)/$(wildcard *.cpp *.h *.hpp) src/version $(CXX) $(CXXFLAGS) $(SRC)/main.cpp -o $@ $(LDFLAGS) cp kmercamel 🐫 || true @@ -32,9 +32,14 @@ kmercameltest: $(SRC)/unittest.cpp gtest-all.o $(SRC)/$(wildcard *.cpp *.h *.hpp gtest-all.o: $(GTEST)/src/gtest-all.cc $(wildcard *.cpp *.h *.hpp) $(CXX) $(CXXFLAGS) -isystem $(GTEST)/include -I $(GTEST)/include -I $(GTEST) -DGTEST_CREATE_SHARED_LIBRARY=1 -c -pthread $(GTEST)/src/gtest-all.cc -o $@ +src/version.h: src/version + ./create-version.sh + + clean: rm -f kmercamel rm -f 🐫 || true rm -f kmercameltest rm -r -f ./bin rm -f gtest-all.o + rm -f src/version.h diff --git a/create-version.sh b/create-version.sh new file mode 100755 index 0000000..766d5af --- /dev/null +++ b/create-version.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +cat <(echo "#define VERSION \"") src/version <(echo -) <(git rev-parse HEAD) <(echo \") | tr -d '\n' > src/version.h diff --git a/src/main.cpp b/src/main.cpp index d28f15f..e31bc34 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,9 +9,10 @@ #include #include #include "unistd.h" +#include "version.h" void Help() { - std::cerr << "KmerCamel v0.2" << std::endl; + std::cerr << "KmerCamel version " << VERSION << std::endl; std::cerr << "Accepted arguments:" << std::endl; std::cerr << " -p path_to_fasta - required; valid path to fasta file" << std::endl; std::cerr << " -k k_value - required; integer value for k" << std::endl; @@ -20,10 +21,15 @@ void Help() { std::cerr << " -d d_value - integer value for d_max; default 5" << std::endl; std::cerr << " -c - treat k-mer and its reverse complement as equal" << std::endl; std::cerr << " -h - print help" << std::endl; + std::cerr << " -v - print version" << std::endl; std::cerr << "Example usage: ./kmercamel -p path_to_fasta -k 13 -d 5 -a local" << std::endl; std::cerr << "Possible algorithms: global globalAC local localAC streaming" << std::endl; } +void Version() { + std::cerr << VERSION << std::endl; +} + int main(int argc, char **argv) { std::string path; int k = 0; @@ -35,7 +41,7 @@ int main(int argc, char **argv) { bool d_set = false; int opt; try { - while ((opt = getopt(argc, argv, "p:k:d:a:o:hc")) != -1) { + while ((opt = getopt(argc, argv, "p:k:d:a:o:hcv")) != -1) { switch(opt) { case 'p': path = optarg; @@ -62,6 +68,9 @@ int main(int argc, char **argv) { case 'c': complements = true; break; + case 'v': + Version(); + return 0; case 'h': default: Help(); diff --git a/src/version b/src/version new file mode 100644 index 0000000..3b04cfb --- /dev/null +++ b/src/version @@ -0,0 +1 @@ +0.2 From 0770b966d33c04f1f3363923f0dd634c25811b75 Mon Sep 17 00:00:00 2001 From: OndrejSladky Date: Tue, 3 Oct 2023 18:29:49 +0200 Subject: [PATCH 2/3] [Makefile] fixed rule for version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 55124eb..155d194 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ cpptest: kmercameltest converttest: convert_superstring_unittest.py ./convert_superstring_unittest.py -kmercamel: $(SRC)/main.cpp $(SRC)/$(wildcard *.cpp *.h *.hpp) src/version +kmercamel: $(SRC)/main.cpp $(SRC)/$(wildcard *.cpp *.h *.hpp) src/version.h $(CXX) $(CXXFLAGS) $(SRC)/main.cpp -o $@ $(LDFLAGS) cp kmercamel 🐫 || true From 4f64e0014b9daf4bd5e515bb3c2e617ef72c2cfc Mon Sep 17 00:00:00 2001 From: OndrejSladky Date: Tue, 3 Oct 2023 20:47:54 +0200 Subject: [PATCH 3/3] [create_version] Six characters is all you need --- create-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create-version.sh b/create-version.sh index 766d5af..1561dd2 100755 --- a/create-version.sh +++ b/create-version.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -cat <(echo "#define VERSION \"") src/version <(echo -) <(git rev-parse HEAD) <(echo \") | tr -d '\n' > src/version.h +cat <(echo "#define VERSION \"") src/version <(echo -) <(git rev-parse HEAD | head -c6) <(echo \") | tr -d '\n' > src/version.h