Skip to content

Commit

Permalink
divsufsort included as header-only and removed all linking
Browse files Browse the repository at this point in the history
  • Loading branch information
cpockrandt committed Jul 14, 2018
1 parent 6eb434e commit 63292ef
Show file tree
Hide file tree
Showing 10 changed files with 1,978 additions and 34 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "external/googletest"]
path = external/googletest
url = https://chromium.googlesource.com/external/googletest
[submodule "external/libdivsufsort"]
path = external/libdivsufsort
url = https://github.com/simongog/libdivsufsort.git
3 changes: 0 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ file(GLOB example_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

include_directories(
${CMAKE_CURRENT_BINARY_DIR}/../include
${CMAKE_CURRENT_BINARY_DIR}/../external/libdivsufsort/include
)

link_libraries(divsufsort divsufsort64)

foreach(example_source ${example_sources})
get_filename_component(example_name ${example_source} NAME_WE)
add_executable(${example_name} EXCLUDE_FROM_ALL ${example_name}.cpp)
Expand Down
16 changes: 0 additions & 16 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@ if(NOT GIT_FOUND)
message(WARNING "git not found. Cloning of submodules will not work.")
endif()


## Add libdivsufsort
set(divsufsort_cmake_file ${CMAKE_CURRENT_LIST_DIR}/libdivsufsort/CMakeLists.txt)
if(NOT EXISTS ${divsufsort_cmake_file})
EXECUTE_PROCESS(COMMAND git submodule update --init external/libdivsufsort
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/..
OUTPUT_QUIET
)
endif(NOT EXISTS ${divsufsort_cmake_file})

set(BUILD_SHARED_LIBS OFF CACHE BOOL "Do not build a shared library for libdivsufsort")
set(BUILD_EXAMPLES OFF CACHE BOOL "Do not build libdivsufsort example")
set(BUILD_DIVSUFSORT64 ON CACHE BOOL "Build libdivsufsort in 64-bits mode")

add_subdirectory(libdivsufsort)

## Add gtest
set(gtest_dir ${CMAKE_CURRENT_LIST_DIR}/googletest)
set(gtest_file ${gtest_dir}/CMakeLists.txt)
Expand Down
1 change: 0 additions & 1 deletion external/libdivsufsort
Submodule libdivsufsort deleted from 22e6b2
7 changes: 3 additions & 4 deletions include/sdsl/construct_sa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#include "config.hpp"
#include "int_vector.hpp"

#include "divsufsort.h"
#include "divsufsort64.h"
#include "divsufsort.hpp"

#include "qsufsort.hpp"

Expand Down Expand Up @@ -94,7 +93,7 @@ void calculate_sa(const unsigned char* c, typename t_int_vec::size_type len, t_i
if (32 == t_width or (0 == t_width and 32 >= sa_width)) {
sa.width(32);
sa.resize(len);
divsufsort(c, (int32_t*)sa.data(), len);
divsufsort(c, (int32_t*)sa.data(), (int32_t)len);
// copy integers back to the right positions
if (sa_width != 32) {
for (size_type i = 0, p = 0; i < len; ++i, p += sa_width) {
Expand All @@ -108,7 +107,7 @@ void calculate_sa(const unsigned char* c, typename t_int_vec::size_type len, t_i
throw std::logic_error("width of int_vector is to small for the text!!!");
}
int_vector<> sufarray(len, 0, 32);
divsufsort(c, (int32_t*)sufarray.data(), len);
divsufsort(c, (int32_t*)sufarray.data(), (int32_t)len);
sa.resize(len);
for (size_type i = 0; i < len; ++i) {
sa[i] = sufarray[i];
Expand Down
Loading

0 comments on commit 63292ef

Please sign in to comment.