Commit db778361 authored by Simon de Givry's avatar Simon de Givry Committed by Thomas Schiex
Browse files

[code] compilation with lzma depending on Boost version

parent 41a73562
#INCLUDE(CTest)
file ( GLOB_RECURSE validation_file
validation/*.wcsp
validation/*.cfn
validation/*.cfn.gz )
SET (Boost_rev "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
MESSAGE(STATUS "Boost " ${Boost_rev} " detected")
IF (${Boost_rev} VERSION_GREATER "1.65.0")
SET (BenchMatchString ".(wcsp.gz|wcsp.xz|cfn.gz|cfn.xz|wcsp|cfn)$")
file ( GLOB_RECURSE validation_file
validation/*.wcsp
validation/*.wcsp.gz
validation/*.wcsp.xz
validation/*.cfn
validation/*.cfn.gz
validation/*.cfn.xz
)
MESSAGE(STATUS "xz compressed file testing activated.")
ELSE (${Boost_rev} VERSION_GREATER "1.65.0")
SET (BenchMatchString ".(wcsp.gz|cfn.gz|wcsp|cfn)$")
file ( GLOB_RECURSE validation_file
validation/*.wcsp
validation/*.wcsp.gz
validation/*.cfn
validation/*.cfn.gz
)
ENDIF (${Boost_rev} VERSION_GREATER "1.65.0")
################
# test unitaire
################
SET(FOPT "test-opt.cmake") #cmake name where local value for timeout,regexp and command line option are declared
SET (Boost_rev "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
MESSAGE(STATUS "Boost " ${Boost_rev} " detected")
IF (${Boost_rev} VERSION_GREATER "1.65.0")
SET (BenchMatchString ".(wcsp.gz|wcsp.xz|cfn.gz|cfn.xz|wcsp|cfn)$")
MESSAGE(STATUS "xz compressed file testing activated.")
ELSE (${Boost_rev} VERSION_GREATER "1.65.0")
SET (BenchMatchString ".(wcsp.gz|cfn.gz|wcsp|cfn)$")
ENDIF (${Boost_rev} VERSION_GREATER "1.65.0")
MESSAGE(STATUS "##############TEST liste building #############")
FOREACH (UTEST ${validation_file})
......@@ -17,23 +43,22 @@ FOREACH (UTEST ${validation_file})
UNSET(UB)
UNSET(ENUM)
STRING(REGEX REPLACE ".(wcsp|cfn.gz|cfn)$" ".ub" UBF ${UTEST})
STRING(REGEX REPLACE ".(wcsp|cfn.gz|cfn)$" ".lb" LBF ${UTEST})
STRING(REGEX REPLACE ".(wcsp|cfn.gz|cfn)$" ".enum" ENUM_file ${UTEST})
STRING(REGEX REPLACE ${BenchMatchString} ".ub" UBF ${UTEST})
STRING(REGEX REPLACE ${BenchMatchString} ".lb" LBF ${UTEST})
STRING(REGEX REPLACE ${BenchMatchString} ".enum" ENUM_file ${UTEST})
GET_FILENAME_COMPONENT(TPATH ${UTEST} PATH)
IF (EXISTS ${UBF})
FILE(READ ${UBF} UB)
STRING(REPLACE "\n" "" TUB ${UB})
SET (UB ${TUB})
FILE(READ ${UBF} UB)
STRING(REPLACE "\n" "" TUB ${UB})
SET (UB ${TUB})
EXECUTE_PROCESS(COMMAND echo "1+(${TUB})" COMMAND bc OUTPUT_VARIABLE UBP)
SET (OpTub "-ub" )
SET (UBP "${OpTub}=${UBP}" )
SET (OpTub "-ub" )
SET (UBP "${OpTub}=${UBP}" )
MESSAGE(STATUS "UB found ==> ${UB} " )
ELSE()
UNSET(UBP)
UNSET(UBP)
MESSAGE(STATUS "${UBF} does not exist")
ENDIF()
......@@ -59,28 +84,30 @@ FOREACH (UTEST ${validation_file})
set(ENUM)
ENDIF()
IF (EXISTS ${ENUM_file})
FILE(READ ${ENUM_file} TENUM)
STRING(REPLACE "\n" "" ENUM ${TENUM})
MESSAGE(STATUS "ENUM file: ${TPATH}/${ENUM_file} found ENUM variable loaded ")
ELSE()
set(ENUM)
ENDIF()
IF (EXISTS ${TPATH}/${FOPT})
include (${TPATH}/${FOPT})
MESSAGE(STATUS "file: ${TPATH}/${FOPT} found.")
include (${TPATH}/${FOPT})
MESSAGE(STATUS "file: ${TPATH}/${FOPT} found.")
ELSE()
# init default value :
set (command_line_option ${Default_test_option} )
set (test_timeout ${Default_test_timeout})
set (test_regexp ${Default_test_regexp})
MESSAGE(STATUS "file: ${TPATH}/${FOPT} not found ==>
# init default value :
set (command_line_option ${Default_test_option} )
set (test_timeout ${Default_test_timeout})
set (test_regexp ${Default_test_regexp})
MESSAGE(STATUS "file: ${TPATH}/${FOPT} not found ==>
default option used: command line : ${command_line_option} timeout=${test_timeout};regexp=${test_regexp} ")
ENDIF()
ENDIF()
MESSAGE(STATUS "file: ${UTEST} used opt = ${command_line_option}")
STRING(REPLACE "${PROJECT_SOURCE_DIR}/validation/" "" TMP ${UTEST})
STRING(REGEX REPLACE ".(wcsp|cfn.gz|cfn)$" "" TNAME ${TMP})
STRING(REGEX REPLACE ${BenchMatchString} "" TNAME ${TMP})
if($verbose)
MESSAGE(STATUS "UBF: ${UBF}")
......@@ -90,10 +117,10 @@ FOREACH (UTEST ${validation_file})
endif($verbose)
IF (EXISTS ${UBF}) # if ub file exist
add_test(Phase1_Toulbar_${TNAME} ${EXECUTABLE_OUTPUT_PATH}/toulbar2${EXE} ${UTEST} ${UBP} ${command_line_option})
add_test(Phase1_Toulbar_${TNAME} ${EXECUTABLE_OUTPUT_PATH}/toulbar2${EXE} ${UTEST} ${UBP} ${command_line_option})
set_tests_properties (Phase1_Toulbar_${TNAME} PROPERTIES PASS_REGULAR_EXPRESSION "${test_regexp}" TIMEOUT "${test_timeout}")
ELSE()
add_test(Phase1_Toulbar_${TNAME} ${EXECUTABLE_OUTPUT_PATH}/toulbar2${EXE} ${UTEST} ${command_line_option})
add_test(Phase1_Toulbar_${TNAME} ${EXECUTABLE_OUTPUT_PATH}/toulbar2${EXE} ${UTEST} ${command_line_option})
set_tests_properties (Phase1_Toulbar_${TNAME} PROPERTIES PASS_REGULAR_EXPRESSION "${test_regexp}" TIMEOUT "${test_timeout}")
ENDIF()
......
// Cmake generated version
#define Toulbar_VERSION "1.0.1-3-gc7f044d-master-tainted (1544265320)"
#define Toulbar_VERSION "1.0.1-master-tainted (1544738028)"
// (C) Copyright Milan Svoboda 2008.
// Originally developed under the fusecompress project.
// Based on bzip2.cpp by:
// (C) Copyright Jonathan Turkanis 2003.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
// See http://www.boost.org/libs/iostreams for documentation.
// Define BOOST_IOSTREAMS_SOURCE so that <boost/iostreams/detail/config.hpp>
// knows that we are building the library (possibly exporting code), rather
// than using it (possibly importing code).
#define BOOST_IOSTREAMS_SOURCE
#include <lzma.h>
#include <boost/throw_exception.hpp>
#include <boost/iostreams/detail/config/dyn_link.hpp>
#include <boost/iostreams/filter/lzma.hpp>
namespace boost { namespace iostreams {
namespace lzma {
// Compression levels
const uint32_t no_compression = 0;
const uint32_t best_speed = 1;
const uint32_t best_compression = 9;
const uint32_t default_compression = 2;
// Status codes
const int okay = LZMA_OK;
const int stream_end = LZMA_STREAM_END;
const int unsupported_check = LZMA_UNSUPPORTED_CHECK;
const int mem_error = LZMA_MEM_ERROR;
const int options_error = LZMA_OPTIONS_ERROR;
const int data_error = LZMA_DATA_ERROR;
const int buf_error = LZMA_BUF_ERROR;
const int prog_error = LZMA_PROG_ERROR;
// Flush codes
const int finish = LZMA_FINISH;
const int full_flush = LZMA_FULL_FLUSH;
const int sync_flush = LZMA_SYNC_FLUSH;
const int run = LZMA_RUN;
// Code for current OS
} // End namespace lzma.
//------------------Implementation of lzma_error------------------------------//
lzma_error::lzma_error(int error)
: BOOST_IOSTREAMS_FAILURE("lzma error"), error_(error)
{ }
void lzma_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(int error)
{
switch (error) {
case LZMA_OK:
case LZMA_STREAM_END:
return;
case LZMA_MEM_ERROR:
boost::throw_exception(std::bad_alloc());
default:
boost::throw_exception(lzma_error(error));
}
}
//------------------Implementation of lzma_base-------------------------------//
namespace detail {
lzma_base::lzma_base()
: stream_(new lzma_stream)
{ }
lzma_base::~lzma_base() { delete static_cast<lzma_stream*>(stream_); }
void lzma_base::before( const char*& src_begin, const char* src_end,
char*& dest_begin, char* dest_end )
{
lzma_stream* s = static_cast<lzma_stream*>(stream_);
s->next_in = reinterpret_cast<uint8_t*>(const_cast<char*>(src_begin));
s->avail_in = static_cast<size_t>(src_end - src_begin);
s->next_out = reinterpret_cast<uint8_t*>(dest_begin);
s->avail_out= static_cast<size_t>(dest_end - dest_begin);
}
void lzma_base::after(const char*& src_begin, char*& dest_begin, bool)
{
lzma_stream* s = static_cast<lzma_stream*>(stream_);
src_begin = const_cast<const char*>(reinterpret_cast<const char*>(s->next_in));
dest_begin = reinterpret_cast<char*>(s->next_out);
}
int lzma_base::deflate(int action)
{
return lzma_code(static_cast<lzma_stream*>(stream_), static_cast<lzma_action>(action));
}
int lzma_base::inflate(int action)
{
return lzma_code(static_cast<lzma_stream*>(stream_), static_cast<lzma_action>(action));
}
void lzma_base::reset(bool compress, bool realloc)
{
lzma_stream* s = static_cast<lzma_stream*>(stream_);
lzma_end(s);
if (realloc)
{
memset(s, 0, sizeof(*s));
lzma_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(
compress ?
lzma_easy_encoder(s, level, LZMA_CHECK_CRC32) :
lzma_stream_decoder(s, 100 * 1024 * 1024, LZMA_CONCATENATED)
);
}
}
void lzma_base::do_init
( const lzma_params& p, bool compress,
lzma::alloc_func, lzma::free_func,
void* )
{
lzma_stream* s = static_cast<lzma_stream*>(stream_);
memset(s, 0, sizeof(*s));
level = p.level;
lzma_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(
compress ?
lzma_easy_encoder(s, p.level, LZMA_CHECK_CRC32) :
lzma_stream_decoder(s, 100 * 1024 * 1024, LZMA_CONCATENATED)
);
}
} // End namespace detail.
//----------------------------------------------------------------------------//
} } // End namespaces iostreams, boost.
......@@ -14,6 +14,7 @@
#include "core/tb2clqcover.hpp"
#ifdef BOOST
#define BOOST_IOSTREAMS_NO_LIB
#include <boost/version.hpp>
#include <boost/tokenizer.hpp>
#include <boost/iostreams/filtering_streambuf.hpp>
......@@ -21,6 +22,7 @@
#include <boost/iostreams/filter/gzip.hpp>
#if (BOOST_VERSION >= 106500)
#include <boost/iostreams/filter/lzma.hpp>
#include "lzma-cpp.inc"
#endif
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
......
......@@ -151,6 +151,6 @@ List of optional arguments (use symbol ":" after an option to remove a default o
</ul>
<p id="footer"><br/><br/>Last modification : May 11, 2018</p>
<p id="footer"><br/><br/>Last modification : December 11, 2018</p>
</body>
</html>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment