Skip to content

Commit

Permalink
Update indexlr and btllib (#67)
Browse files Browse the repository at this point in the history
* Update indexlr

* Remove -fopenmp flag
  • Loading branch information
vlad0x00 authored Jun 21, 2021
1 parent e27b430 commit 4d7f958
Show file tree
Hide file tree
Showing 853 changed files with 246,556 additions and 14,588 deletions.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CXXFLAGS=-O3 -Wall -Werror -Wno-unknown-pragmas -std=c++11 -pthread -Ibtllib/include
CXXFLAGS=-O3 -Wall -Wextra -Werror -Wno-unknown-pragmas -std=c++11 -pthread -Ibtllib/include

all: indexlr

Expand Down
33 changes: 22 additions & 11 deletions src/btllib/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[Bioinformatics Technology Lab](http://www.birollab.ca/) common code library in C++ with Python and Java wrappers.

[![Build Status](https://dev.azure.com/bcgsc/btl_public/_apis/build/status/bcgsc.btllib)](https://dev.azure.com/bcgsc/btl_public/_build/latest?definitionId=1)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/bcgsc/btllib.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/bcgsc/btllib/context:cpp)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/bcgsc/btllib.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/bcgsc/btllib/alerts/)

Platforms
---
- Linux
Expand All @@ -9,22 +13,27 @@ Documentation
---
[Docs page](https://bcgsc.github.io/btllib/)

Download
---
The recommended way is to download the [latest release](https://github.com/bcgsc/btllib/releases/latest).

C++
---
- Dependencies
* GCC 4.8.1+ or Clang 3.3.0+ with OpenMP
* GCC 5+ or Clang 4+ with OpenMP
- Copy the root `btllib` directory into your project
- Use any header from the `btllib/include` directory
- Use any header from the `btllib/include` directory (pass `-I btllib/include` flag to the compiler)
- `btllib` uses `C++11` features, so that standard should be enabled at a minimum.

Python and Java
---
- Dependencies
* GCC 4.8.1+ or Clang 3.3.0+ with OpenMP
* GCC 5+ or Clang 4+ with OpenMP
* Python 3.5+
* Meson and Ninja Python3 packages (optional - if they are missing, they will be automatically downloaded to a temporary directory)
* Meson and Ninja Python3 packages, and CMake (optional -- if they are missing, they will be automatically downloaded to a temporary directory)
- Copy the root `btllib` directory into your project
- Run `btllib/compile`
- The wrappers correspond one-to-one with C++ code so any functions and classes can be used under the same name.
- Run `btllib/compile-wrappers`
- The wrappers correspond one-to-one with C++ code so any functions and classes can be used under the same name. The only exception are nested classes which are prefixed with outer class name (e.g. `btllib::SeqReader::Flag` in C++ versus `btllib.SeqReaderFlag` in Python).
- Python
* Use Python's `sys.path.append()` to include `btllib/python` directory
* Include the library with `import btllib`
Expand All @@ -34,24 +43,26 @@ Python and Java

Contributing
---
If you want to contribute code to this repo, before making a pull request, make sure to:
- Create a build directory by running `meson build` in `btllib` directory
- Run `ninja complete` in the `build` directory to generate wrappers, docs, format the code, check for any errors, etc.
If you want to make changes to the btllib code, first create a build directory by running `meson build` in `btllib` directory. `cd` to `build` directory and run `ninja build-sdsl` once to build the `sdsl` dependency. After that, every time you want to build the tests and wrappers, run `ninja` in `build` directory. To run the tests, run `ninja test`.

`ninja complete` does the following steps, in order:
The following are the available `ninja` commands which can be run within `build` directory:
- `ninja build-sdsl` builds the sdsl-lite dependency library
- `ninja format` formats the whitespace in code (requires clang-format 8+)
- `ninja wrap` wraps C++ code for Python and Java (requires SWIG 4.0+)
- `ninja tidycheck` runs clang-tidy on C++ code and makes sure it passes (requires clang-tidy 8+)
- `ninja cppcheck` runs cppcheck on C++ code and makes sure it passes (requires cppcheck)
- `ninja` builds the tests and wrapper libraries / makes sure they compile
- `ninja test` runs the tests
- `ninja docs` generates code documentation from comments (requires Doxygen)
- `ninja complete` runs all of the above commands in the listed order

Any of these can be run individually within `build` directory.
Before making a pull request, make sure to run `ninja complete` to make sure the code passes the CI test.

Credits
---
- Author: [Vladimir Nikolic](https://github.com/schutzekatze)
- Components:
- [Hamid Mohamadi](https://github.com/mohamadi) for [ntHash](https://github.com/bcgsc/ntHash)
- [Justin Chu](https://github.com/JustinChu) for [MIBloomFilter](https://github.com/bcgsc/btl_bloomfilter)
- [Chase Geigle](https://github.com/skystrife) for [cpptoml](https://github.com/skystrife/cpptoml)
- Simon Gog, Timo Beller, Alistair Moffat, and Matthias Petri for [sdsl-lite](https://github.com/simongog/sdsl-lite)
130 changes: 0 additions & 130 deletions src/btllib/compile

This file was deleted.

141 changes: 141 additions & 0 deletions src/btllib/compile-wrappers
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#!/bin/bash

get_major_minor_version() {
echo "$1" | awk '{print $2}' | awk -F '.' '{print $1 "." $2}'
}

get_lib_paths() {
local lib_paths=()
for flag in $1; do
if [[ $flag == "-L"* ]]; then
lib_paths+=($flag)
fi
done
echo "${lib_paths[@]}"
}

get_config_vars() {
local prefix="py${1}"
local config_var="${prefix}_config"
local path_var="${prefix}_path"
local version_var="${prefix}_version"
local version_num_var="${prefix}_version_num"
local cflags_var="${prefix}_cflags"
local ldflags_var="${prefix}_ldflags"
local lib_paths_var="${prefix}_lib_paths"

export declare ${config_var}="python${1}-config"
command -v ${!config_var} >/dev/null
if [[ $? -eq 0 ]]; then
export declare ${path_var}="$(${!config_var} --exec-prefix)/bin/python${1}"
export declare ${version_var}="$(${!path_var} --version 2>&1)"
export declare ${version_num_var}="$(get_major_minor_version "${!version_var}")"
export declare ${cflags_var}="$(${!config_var} --cflags)"
export declare ${ldflags_var}="$(${!config_var} --ldflags)"
export declare ${lib_paths_var}="$(get_lib_paths "${!ldflags_var}")"
else
export declare ${version}=""
export declare ${version_num}=-1
fi
}

are_lists_diff() {
local list1=()
local list2=()
for e in $1; do
list1+=($e)
done
for e in $2; do
list2+=($e)
done
old_IFS="$IFS"
IFS=$'\n'
local list1_sorted=($(sort <<< "${list1[*]}"))
local list2_sorted=($(sort <<< "${list2[*]}"))
IFS="$old_IFS"
[[ ${list1_sorted[@]} == ${list2_sorted[@]} ]]
echo $?
}

get_config_vars
get_config_vars 3

set -e

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

# Check if in interactive prompt
if [[ -n ${PS1+x} ]]; then
if [[ ! "$py_version_num" < "3.0" && "$py_version_num" < "4.0" ]]; then
lib_paths_diff=$(are_lists_diff "$py_lib_paths" "$py3_lib_paths")
if [[ ("$py_version" != "$py3_version") || ($lib_paths_diff -eq 1) ]]; then
option1="$py_version"
option2="$py3_version"
if [[ -n "${py_lib_paths}" ]]; then
option1+=" ($py_lib_paths)"
fi
if [[ -n "${py3_lib_paths}" ]]; then
option2+=" ($py3_lib_paths)"
fi

echo "Multiple Pythons found"
PS3="Select which one to build with: "
options=("${option1}" "${option2}")
select opt in "${options[@]}"; do
case $opt in
"${option1}")
echo "Using ${option1}";
export BTLLIB_PYTHON_CFLAGS="$py_cflags"
export BTLLIB_PYTHON_LDFLAGS="$py_ldflags"
export BTLLIB_PYTHON_VERSION="$py_version_num"
break;;
"${option2}")
echo "Using ${option2}";
export BTLLIB_PYTHON_CFLAGS="$py3_cflags"
export BTLLIB_PYTHON_LDFLAGS="$py3_ldflags"
export BTLLIB_PYTHON_VERSION="$py3_version_num"
break;;
*) echo "Invalid option $REPLY";;
esac
done
fi
fi
fi

deps=( 'meson' 'ninja' 'cmake' )
missing_dep=0
pip_to_install=""
for dep in ${deps[@]}; do
set +e
command -v $dep >/dev/null
if [[ $? -eq 1 ]]; then
missing_dep=1
pip_to_install+=" $dep"
fi
set -e
done

in_venv=false
if [[ $missing_dep -eq 1 ]]; then
if [[ ! -f venv ]]; then
python3 -m venv venv
fi
source venv/bin/activate
pip3 install $pip_to_install
in_venv=true
fi

rm -rf build python java
meson setup --buildtype release --prefix=$SCRIPTPATH build
if [[ $? -eq 0 ]]; then
cd build
ninja build-sdsl
ninja install
cd ..
fi

cd $SCRIPTPATH
if [[ $in_venv == true ]]; then
deactivate
fi
6 changes: 6 additions & 0 deletions src/btllib/external/sdsl-lite/.gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "external/googletest"]
path = external/googletest
url = https://github.com/google/googletest.git
[submodule "external/libdivsufsort"]
path = external/libdivsufsort
url = https://github.com/simongog/libdivsufsort.git
Loading

0 comments on commit 4d7f958

Please sign in to comment.