Skip to content

Commit

Permalink
add version bump script and have CMake use it
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Patro committed Feb 4, 2019
1 parent 4c6b80f commit 113ef3d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 22 deletions.
44 changes: 33 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,49 @@ enable_testing()

project (RapMap)

set(CPACK_PACKAGE_VERSION "0.6.0")
SET(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "6")
set(CPACK_PACKAGE_VERSION_PATCH "0")
# auto-populate version:
# from https://stackoverflow.com/questions/47066115/cmake-get-version-from-multi-line-text-file
file(READ "current_version.txt" ver)

string(REGEX MATCH "VERSION_MAJOR ([0-9]*)" _ ${ver})
set(ver_major ${CMAKE_MATCH_1})

string(REGEX MATCH "VERSION_MINOR ([0-9]*)" _ ${ver})
set(ver_minor ${CMAKE_MATCH_1})

string(REGEX MATCH "VERSION_PATCH ([0-9]*)" _ ${ver})
set(ver_patch ${CMAKE_MATCH_1})

set(CPACK_PACKAGE_VERSION_MAJOR ${ver_major})
set(CPACK_PACKAGE_VERSION_MINOR ${ver_minor})
set(CPACK_PACKAGE_VERSION_PATCH ${ver_patch})

set(CPACK_PACKAGE_VERSION "${ver_major}.${ver_minor}.${ver_patch}")
message("version: ${CPACK_PACKAGE_VERSION}")

set(PROJECT_VERSION ${CPACK_PACKAGE_VERSION})
set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_PACKAGE_VENDOR "Stony Brook University")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "RapMap - Wicked-fast quasi-mapping")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "rapmap - fast transcriptome mapping")
set(CPACK_PACKAGE_NAME
"${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-Source")

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
#include(FindSSE)
#FindSSE ()
#if(SSE4_2_FOUND)
# message("Enabling popcount")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2 -DEMPHF_USE_POPCOUNT")
#endif(SSE4_2_FOUND)

# Set a default build type if none was specified
set(default_build_type "Release")

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release")
endif()

include(CheckIPOSupported)

Expand Down
3 changes: 3 additions & 0 deletions current_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VERSION_MAJOR 0
VERSION_MINOR 6
VERSION_PATCH 0
25 changes: 25 additions & 0 deletions scripts/bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

HERE="$( cd "$(dirname "$0")" ; pwd -P )"

major_v=`${HERE}/../build/src/rapmap -v | cut -d ' ' -f 2 | cut -d '.' -f 1`
minor_v=`${HERE}/../build/src/rapmap -v | cut -d ' ' -f 2 | cut -d '.' -f 2`
patch_v=`${HERE}/../build/src/rapmap -v | cut -d ' ' -f 2 | cut -d '.' -f 3`

echo "VERSION : ${major_v}.${minor_v}.${patch_v}"

# update docker file
#awk -v majv=${major_v} -v minv=${minor_v} -v patchv=${patch_v} '{ if ($0 ~ /ENV SALMON_VERSION/) { print "ENV SALMON_VERSION " majv"."minv"."patchv; } else { print $0; }}' \
# ${HERE}/../docker/Dockerfile > ${HERE}/../docker/Dockerfile.new && mv ${HERE}/../docker/Dockerfile.new ${HERE}/../docker/Dockerfile

# update docker build script
#awk -v majv=${major_v} -v minv=${minor_v} -v patchv=${patch_v} '{ if ($0 ~ /SALMON_VERSION=/) { print "SALMON_VERSION="majv"."minv"."patchv; } else { print $0; }}' \
# ${HERE}/../docker/build_test.sh > ${HERE}/../docker/build_test.sh.new && mv ${HERE}/../docker/build_test.sh.new ${HERE}/../docker/build_test.sh

# update version file (which feeds cmake)
echo -e "VERSION_MAJOR ${major_v}\nVERSION_MINOR ${minor_v}\nVERSION_PATCH ${patch_v}" > ${HERE}/../current_version.txt

# update conf.py
#awk -v majv=${major_v} -v minv=${minor_v} -v patchv=${patch_v} \
# '{ if ($0 ~ /version = /) { print "version = '\''" majv"."minv"'\''"; } else if ($0 ~ /release = /) { print "release = '\''" majv"."minv"."patchv"'\''"; } else { print $0; }}' \
# ${HERE}/../doc/source/conf.py > ${HERE}/../doc/source/conf.py.new && mv ${HERE}/../doc/source/conf.py.new ${HERE}/../doc/source/conf.py
22 changes: 11 additions & 11 deletions src/RapMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ int rapMapSAMap(int argc, char* argv[]);

void printUsage() {
std::string versionString = rapmap::version;
std::cerr << "RapMap Transcriptome Aligner v"
std::cerr << "rapmap v"
<< versionString << '\n';
std::cerr << "=====================================\n";
auto usage =
R"(
There are currently 2 RapMap subcommands
quasiindex --- builds a suffix array-based (SA) index
quasimap --- map reads using the SA-based index
There are currently 2 rapmap subcommands
quasiindex --- builds a quasi-mapping index on the reference
quasimap --- maps reads to a quasi-mapping index
Run a corresponding command "rapmap <cmd> -h" for
more information on each of the possible RapMap
Expand Down Expand Up @@ -77,14 +77,14 @@ int main(int argc, char* argv[]) {
std::exit(0);
}

if (std::string(argv[1]) == "pseudoindex") {
std::cerr << "This mode not enabled in this branch\n";
return 1;//rapMapIndex(argc - 1, args.data());
} else if (std::string(argv[1]) == "quasiindex") {
if (std::string(argv[1]) == "-v" or
std::string(argv[1]) == "--version") {
std::cout << "rapmap " << rapmap::version << "\n";
std::exit(0);
}

if (std::string(argv[1]) == "quasiindex") {
return rapMapSAIndex(argc - 1, args.data());
} else if (std::string(argv[1]) == "pseudomap") {
std::cerr << "This mode not enabled in this branch\n";
return 1;//rapMapMap(argc - 1, args.data());
} else if (std::string(argv[1]) == "quasimap") {
return rapMapSAMap(argc - 1, args.data());
} else {
Expand Down

0 comments on commit 113ef3d

Please sign in to comment.