Skip to content
Open

Meson #108

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Compiled Object files
build
subprojects
!subprojects/*.wrap

16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:

Expand Down
118 changes: 118 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meson supports has a GTest wrapDB?

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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tried vcs_tag?

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'],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

files(['src/main.cpp']) (does an implicit check whether the file exists)

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
4 changes: 3 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include "sequence.hpp"
#include "polisher.hpp"

static const char* version = "v1.3.3";
#include <version.hpp>

static const char* version = RACON_VERSION_STRING.c_str();

static struct option options[] = {
{"include-unpolished", no_argument, 0, 'u'},
Expand Down
21 changes: 21 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -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])
22 changes: 22 additions & 0 deletions src/version.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*!
* @file version.hpp
*
* @brief Version information for the entire project.
*/

#pragma once

#include <string>

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__));
10 changes: 10 additions & 0 deletions subprojects/gtest.wrap
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions subprojects/zlib.wrap
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions test/meson.build
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 6 additions & 6 deletions test/racon_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* @brief Racon unit test source file
*/

#include "racon_test_config.h"
#include <racon_test_config.h>

#include "sequence.hpp"
#include "polisher.hpp"
#include <sequence.hpp>
#include <polisher.hpp>

#include "edlib.h"
#include "bioparser/bioparser.hpp"
#include "gtest/gtest.h"
#include <edlib.h>
#include <bioparser/bioparser.hpp>
#include <gtest/gtest.h>

uint32_t calculateEditDistance(const std::string& query, const std::string& target) {

Expand Down
35 changes: 35 additions & 0 deletions vendor/meson.build
Original file line number Diff line number Diff line change
@@ -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])