diff --git a/.gitignore b/.gitignore index f9d0a24..595c557 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ # Compiled Object files build +subprojects +!subprojects/*.wrap + diff --git a/CMakeLists.txt b/CMakeLists.txt index ee77217..c4d1dfe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,22 @@ cmake_minimum_required(VERSION 3.2) project(racon) +# The version number. +set (RACON_VERSION_MAJOR 1) +set (RACON_VERSION_MINOR 3) +set (RACON_VERSION_PATCH 4) +# Get the commit ID. +execute_process( + COMMAND git log -1 --pretty=%h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE RACON_VERSION_COMMIT + OUTPUT_STRIP_TRAILING_WHITESPACE +) +# Configure the version file. +configure_file("${PROJECT_SOURCE_DIR}/src/version.hpp.in" "${PROJECT_BINARY_DIR}/generated/version.hpp") +# Add the include directory for the generated file. +include_directories(${PROJECT_BINARY_DIR}/generated) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bdae427 --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +.PHONY: all clean meson cmake debug dist modules + +all: meson + +clean: + rm -rf build build-meson + +meson: modules + @echo "[Invoking Meson]" + @mkdir -p build-meson && cd build-meson && meson --buildtype=release -Dc_args=-O3 && ninja + +rebuild: modules + @echo "[Running Ninja only]" + @ninja -C build-meson + +cmake: modules + @echo "[Invoking CMake]" + @mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -Dracon_build_tests=ON .. && make + +debug: modules + @echo "[Invoking Meson]" + @mkdir -p build-debug && cd build-debug && (meson --buildtype=debugoptimized -Db_sanitize=address) && ninja + +dist: release + cd build && ninja-dist + +modules: + @echo "[Fetching submodules]" + @git submodule update --init diff --git a/README.md b/README.md index 1586003..d74b1af 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,15 @@ A **wrapper script** is also available to enable easier usage to the end-user fo ## Dependencies 1. gcc 4.8+ or clang 3.4+ -2. cmake 3.2+ +2. cmake 3.2+ or meson 0.49+ ## Installation -To install Racon run the following commands: +There are two alternative build options which can be used to compile Racon: +1. CMake, and +2. Meson. + +### CMake +To compile Racon using CMake, run the following commands: ```bash git clone --recursive https://github.com/isovic/racon.git racon @@ -43,6 +48,34 @@ To build unit tests add `-Dracon_build_tests=ON` while running `cmake`. After in To build the wrapper script add `-Dracon_build_wrapper=ON` while running `cmake`. After installation, an executable named `racon_wrapper` (python script) will be created in `build/bin`. +### Meson +To compile Racon using Meson, run the following commands: +```bash +git clone --recursive https://github.com/isovic/racon.git racon +cd racon +mkdir build +cd build +meson --buildtype=release -Dc_args=-O3 +ninja +``` + +After successful installation, an executable named `racon` will appear in `build/`. +Tests are built automatically when Meson build is instantiated. + +### Wrapping the builds using a Makefile +Alternatively, to achieve the same, we provide Makefile shorthands. +To run the above commands and build the project using CMake, simply type: +``` +make cmake +``` + +For the Meson build version, analogously write: +``` +make meson +``` + +(Note: CMake build directory will be `build`, and Meson will be built in `build-meson` to make the two build types distinct.) + ## Usage Usage of `racon` is as following: diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..20b2b1e --- /dev/null +++ b/meson.build @@ -0,0 +1,118 @@ +project( + 'Racon', + 'cpp', + version : '1.3.4', + default_options : [ + 'buildtype=release', + 'warning_level=3', + 'cpp_std=c++11'], + license : 'MIT', + meson_version : '>= 0.48') + +cpp = meson.get_compiler('cpp') + +############ +# CXXFLAGS # +############ + +racon_warning_flags = [] +racon_cpp_flags = [] + +################ +# Dependencies # +################ + +# Threads. +racon_thread_dep = dependency('threads', required : true) + +# Zlib. +racon_zlib_dep = dependency('zlib', required: true, version : '>= 1.2.11', fallback : ['zlib', 'zlib_dep']) + +# Google test. +gtest_dep = dependency('gtest', main : true, required : false) +if not gtest_dep.found() + gtest_proj = subproject('gtest') + gtest_inc = gtest_proj.get_variable('gtest_incdir') + gtest_lib = static_library('gtest', gtest_proj.get_variable('gtest_libsources'), + gtest_proj.get_variable('gtest_mainsources'), + include_directories : gtest_inc) + + gtest_dep = declare_dependency(include_directories : gtest_inc, + link_with : gtest_lib, dependencies: racon_thread_dep) +endif + +####################### +# Configuring headers # +####################### +racon_version_commit = 'unknown' +git_command = find_program('git', required: false) +if git_command.found() + git_run = run_command('git', ['log', '-1', '--pretty=%h']) + if git_run.returncode() == 0 + racon_version_commit = git_run.stdout().strip() + endif +endif + +racon_version_h_config = configuration_data() +racon_version = meson.project_version() +racon_version_split = meson.project_version().split('.') +racon_version_h_config.set('RACON_VERSION_MAJOR', racon_version_split[0]) +racon_version_h_config.set('RACON_VERSION_MINOR', racon_version_split[1]) +racon_version_h_config.set('RACON_VERSION_PATCH', racon_version_split[2]) +racon_version_h_config.set('RACON_VERSION_COMMIT', racon_version_commit) + +racon_version_h = configure_file( + input : files('src/version.hpp.in'), + output : 'version.hpp', + configuration : racon_version_h_config) + +########### +# Headers # +########### + +racon_include_directories = [include_directories('src'), include_directories('test')] + +###################### +# Sources + codebase # +###################### + +subdir('vendor') +subdir('src') +subdir('test') + +all_sources = racon_cpp_sources + vendor_cpp_sources + +###################### +# The Racon exe. # +###################### + +racon_dep = declare_dependency( + include_directories: vendor_include_directories + racon_include_directories, + link_with: [racon_lib, vendor_lib], + dependencies: [racon_thread_dep, racon_zlib_dep], + version: meson.project_version(), + compile_args: racon_warning_flags + racon_cpp_flags) + +if not meson.is_subproject() + racon_bin = executable( + 'racon', + ['src/main.cpp'], + install : true, + dependencies : [racon_thread_dep, racon_zlib_dep], + include_directories : vendor_include_directories + racon_include_directories, + link_with : [racon_lib], + cpp_args : [racon_warning_flags, racon_cpp_flags]) + + ###################### + # Tests # + ###################### + if gtest_dep.found() + tests_bin = executable( + 'racon_test', + racon_test_cpp_sources, + dependencies : [racon_thread_dep, racon_zlib_dep, gtest_dep], + include_directories : racon_include_directories + vendor_include_directories + racon_test_include_directories, + link_with : [racon_lib, vendor_lib], + cpp_args : [racon_warning_flags, racon_cpp_flags, racon_test_extra_flags]) + endif +endif diff --git a/src/main.cpp b/src/main.cpp index 1868ba7..cae4d66 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,7 +9,9 @@ #include "sequence.hpp" #include "polisher.hpp" -static const char* version = "v1.3.3"; +#include + +static const char* version = RACON_VERSION_STRING.c_str(); static struct option options[] = { {"include-unpolished", no_argument, 0, 'u'}, diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..121a901 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,21 @@ +racon_cpp_sources = files([ + 'overlap.cpp', + 'polisher.cpp', + 'sequence.cpp', + 'window.cpp' +]) + +racon_extra_flags = [] + +racon_lib_install = (not meson.is_subproject()) or (get_option('default_library') == 'shared') + +racon_lib = library( + 'racon', + racon_cpp_sources, + soversion : 0, + version : meson.project_version(), + install : racon_lib_install, + link_with : vendor_lib, + dependencies : [racon_thread_dep, racon_zlib_dep], + include_directories : racon_include_directories + vendor_include_directories, + cpp_args : [racon_extra_flags, racon_warning_flags, racon_cpp_flags]) diff --git a/src/version.hpp.in b/src/version.hpp.in new file mode 100644 index 0000000..b5fc570 --- /dev/null +++ b/src/version.hpp.in @@ -0,0 +1,22 @@ +/*! + * @file version.hpp + * + * @brief Version information for the entire project. + */ + +#pragma once + +#include + +static const int32_t RACON_VERSION_MAJOR = @RACON_VERSION_MAJOR@; +static const int32_t RACON_VERSION_MINOR = @RACON_VERSION_MINOR@; +static const int32_t RACON_VERSION_PATCH = @RACON_VERSION_PATCH@; +static const std::string RACON_VERSION_COMMIT("@RACON_VERSION_COMMIT@"); + +static const std::string RACON_VERSION_STRING = + std::to_string(RACON_VERSION_MAJOR) + "." + + std::to_string(RACON_VERSION_MINOR) + "." + + std::to_string(RACON_VERSION_PATCH) + "-" + + RACON_VERSION_COMMIT; + +static const std::string COMPILE_DATE = (std::string(__DATE__) + std::string(" at ") + std::string(__TIME__)); diff --git a/subprojects/gtest.wrap b/subprojects/gtest.wrap new file mode 100644 index 0000000..773a713 --- /dev/null +++ b/subprojects/gtest.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory = googletest-release-1.8.0 + +source_url = https://github.com/google/googletest/archive/release-1.8.0.zip +source_filename = gtest-1.8.0.zip +source_hash = f3ed3b58511efd272eb074a3a6d6fb79d7c2e6a0e374323d1e6bcbcc1ef141bf + +patch_url = https://wrapdb.mesonbuild.com/v1/projects/gtest/1.8.0/5/get_zip +patch_filename = gtest-1.8.0-5-wrap.zip +patch_hash = 7eeaede4aa2610a403313b74e04baf91ccfbaef03203d8f56312e22df1834ec5 diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap new file mode 100644 index 0000000..97de00e --- /dev/null +++ b/subprojects/zlib.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory = zlib-1.2.11 + +source_url = http://zlib.net/fossils/zlib-1.2.11.tar.gz +source_filename = zlib-1.2.11.tar.gz +source_hash = c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 + +patch_url = https://wrapdb.mesonbuild.com/v1/projects/zlib/1.2.11/3/get_zip +patch_filename = zlib-1.2.11-3-wrap.zip +patch_hash = f07dc491ab3d05daf00632a0591e2ae61b470615b5b73bcf9b3f061fff65cff0 diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 0000000..86d7c7b --- /dev/null +++ b/test/meson.build @@ -0,0 +1,14 @@ +racon_test_cpp_sources = files([ + 'racon_test.cpp' +]) + +racon_test_include_directories = [include_directories('.')] + +racon_test_extra_flags = [] + +racon_test_config_h_vars = configuration_data() +racon_test_config_h_vars.set('racon_test_data_path', meson.source_root() + '/test/data/') +racon_test_config_h = configure_file( + input : files('racon_test_config.h.in'), + output : 'racon_test_config.h', + configuration : racon_test_config_h_vars) diff --git a/test/racon_test.cpp b/test/racon_test.cpp index 057bfb4..f26efd9 100644 --- a/test/racon_test.cpp +++ b/test/racon_test.cpp @@ -4,14 +4,14 @@ * @brief Racon unit test source file */ -#include "racon_test_config.h" +#include -#include "sequence.hpp" -#include "polisher.hpp" +#include +#include -#include "edlib.h" -#include "bioparser/bioparser.hpp" -#include "gtest/gtest.h" +#include +#include +#include uint32_t calculateEditDistance(const std::string& query, const std::string& target) { diff --git a/vendor/meson.build b/vendor/meson.build new file mode 100644 index 0000000..c639a4c --- /dev/null +++ b/vendor/meson.build @@ -0,0 +1,35 @@ +vendor_cpp_sources = files([ + 'edlib/edlib/src/edlib.cpp', + 'rampler/src/sampler.cpp', + 'rampler/src/sequence.cpp', + 'spoa/src/alignment_engine.cpp', + 'spoa/src/graph.cpp', + 'spoa/src/sequence.cpp', + 'spoa/src/simd_alignment_engine.cpp', + 'spoa/src/sisd_alignment_engine.cpp', + 'thread_pool/src/thread_pool.cpp' +]) + +vendor_include_directories = [ + include_directories('bioparser/include'), + include_directories('edlib/edlib/include'), + include_directories('logger/include'), + include_directories('rampler/src'), + include_directories('spoa/include'), + include_directories('thread_pool/include') + ] + +vendor_extra_flags = [] + +vendor_lib_install = (not meson.is_subproject()) or (get_option('default_library') == 'shared') + +vendor_lib = library( + 'vendor', + vendor_cpp_sources, + soversion : 0, + version : meson.project_version(), + install : vendor_lib_install, + link_with : [], + dependencies : [racon_thread_dep, racon_zlib_dep], + include_directories : vendor_include_directories, + cpp_args : [vendor_extra_flags, racon_warning_flags, racon_cpp_flags])