<commit_before>cmake_minimum_required( VERSION 2.6 )
project( Goo )

set( GOO_VERSION_MAJOR 0 )
set( GOO_VERSION_MINOR 1 )

# This script builds Goo library with all dependent
# utilities. The out-of-source build is mandatory way. Some code
# features are determined by build directory name: 'debug'
# dir enables some debugging features, while 'release'
# (default state) means that code should be optimized
# for performance.
# Right below are some build options that can be enabled or
# disabled by -D<option_name>=<ON|OFF> option given to CMake.


option( PRINTF_SOURCE_INFO  "Supplement printing lines with source file info."  OFF)
option( EXCEPTION_BACTRACE  "C++ exception throw produce a stack unwinding."    ON )
option( PRINTING_ANSI_ESC   "Terminal messages coloring."                       ON )
# The lines below is a development features, basically located at other
# git branches:
option( ENABLE_GDS          "Goo Declarative Semantics."                        OFF)
option( ENABLE_ALLOCATORS   "Goo's own allocators subsystem."                   OFF)
option( ENABLE_TENSORS      "Tensorial algebra support template classes."       OFF)
option( ENABLE_DATASTREAMS  "Goo's serialization template classes."             OFF)
option( ENABLE_PTREE        "Goo's getopt()-like mechanism."                    OFF)
option( HASKELL_MODULE      "Haskell extensions."                               OFF)
#
# Find third-party packages
# 

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/contrib/cmake")
find_package( ZLIB  )
find_package( Lzo   )
find_package( BZip2 )
find_package( Git   )
if( EXCEPTION_BACTRACE )
    find_package( BFD   )
endif( EXCEPTION_BACTRACE )
if( GIT_FOUND )
    # obtain current commit hash
    EXECUTE_PROCESS(COMMAND git rev-parse HEAD OUTPUT_VARIABLE COMMIT_HASH
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE )
    EXECUTE_PROCESS(COMMAND git show -s
        --format="gitInfo:{\\%nCommit:{\\%nhash:%h,\\%ndate:'%ci',\\%ncomment:'%s',\\%n},\\%nbranch:'`git rev-parse --abbrev-ref HEAD`'\\%n}" ${COMMIT_HASH}
                 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
                 OUTPUT_VARIABLE GIT_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
else( GIT_FOUND )
    SET( COMMIT_HASH "<unknown>" )
    SET( GIT_STRING "gitInfo:'unavailable';" )
endif( GIT_FOUND )

#
# Disables Haskell module. Some Goo routines are written on Haskell.
# It is supposed to build it with Glasgow compiler (other compilers are
# untested). Some obscure reasons stop me from linking all object into one
# library, so Haskell modules are linked into libgooHs.so dynamic library and
# libgoo.so linked against it in order.
# see: http://stackoverflow.com/questions/20538087/how-does-one-integrate-haskell-code-into-a-c-program/21378585#21378585
# Probably it can be solved. Actual reasons seems be deep in implementation
# details -- object code generated by GHC seems to be incompatible with
# default GCC linker settings.

#
# Add custom uninstall target (CMake by default does not provide it)
CONFIGURE_FILE(
  "${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake/cmake_uninstall.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") 

#
# Switch installation prefix, if provided (otherwise, set to /usr/local)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
    set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "default install path" FORCE )
endif()

SITE_NAME( BUILDER_HOSTNAME )

include(contrib/cmake/OutOfSource.cmake)

AssureOutOfSourceBuilds()

#
# Obtain versioning parameters
    EXECUTE_PROCESS(COMMAND date +"%x %x"
                    OUTPUT_VARIABLE BUILD_TIMESTAMP
                    OUTPUT_STRIP_TRAILING_WHITESPACE )


#
# Attain configuration depending on current build dir.
string(REPLACE "/" ";" SPLITTED_PATH ${CMAKE_BINARY_DIR})
list(REVERSE SPLITTED_PATH)
list(GET SPLITTED_PATH 0 buildDir)
message( STATUS "Building in directory ${buildDir}" )
if( buildDir STREQUAL "debug" )
    message( STATUS "NOTE: debug build" )
    set( CMAKE_BUILD_TYPE "Debug" )
    set( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -g -fno-omit-frame-pointer" )  # -Wfatal-errors -fprofile-use? -fprofile-correction
    set( CMAKE_CXX_FLAGS   "${CMAKE_CXX_FLAGS} -g -fno-omit-frame-pointer" )
elseif( buildDir STREQUAL "release" )
    message( STATUS "NOTE: release build" )
    set( CMAKE_BUILD_TYPE "Release" )
    set( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -DNDEBUG -O3" )
    set( CMAKE_CXX_FLAGS   "${CMAKE_CXX_FLAGS} -DNDEBUG -O3" )
else()
    message( STATUS "NOTE: custom build" )
    set( CMAKE_BUILD_TYPE "Release" )
    set( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -DNDEBUG -O3" )
    set( CMAKE_CXX_FLAGS   "${CMAKE_CXX_FLAGS} -DNDEBUG -O3" )
endif()

set( GOO_LIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/inc/" )

#
# Configure compiler
set( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   -Wall -std=c99     -D_GNU_SOURCE -fexceptions -pthread -D_FILE_OFFSET_BITS=64 -rdynamic -DHAVE_INLINE -I${GOO_LIB_INCLUDE_DIR}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++11 -D_GNU_SOURCE -fexceptions -pthread -D_FILE_OFFSET_BITS=64 -rdynamic -I${GOO_LIB_INCLUDE_DIR}" )
set( CMAKE_Haskell_FLAGS "-fPIC -no-hs-main" )

#
# Configure source
file(GLOB_RECURSE GOO_LIB_SOURCES src/*.c*)
configure_file (
    "${GOO_LIB_INCLUDE_DIR}/goo_config.h.in"
    "${GOO_LIB_INCLUDE_DIR}/goo_config.h"
)
<commit_msg>Testing build system connection with git by adding dependencies.<commit_after>cmake_minimum_required( VERSION 2.6 )
project( Goo )

set( GOO_VERSION_MAJOR 0 )
set( GOO_VERSION_MINOR 1 )

# This script builds Goo library with all dependent
# utilities. The out-of-source build is mandatory way. Some code
# features are determined by build directory name: 'debug'
# dir enables some debugging features, while 'release'
# (default state) means that code should be optimized
# for performance.
# Right below are some build options that can be enabled or
# disabled by -D<option_name>=<ON|OFF> option given to CMake.


option( PRINTF_SOURCE_INFO  "Supplement printing lines with source file info."  OFF)
option( EXCEPTION_BACTRACE  "C++ exception throw produce a stack unwinding."    ON )
option( PRINTING_ANSI_ESC   "Terminal messages coloring."                       ON )
# The lines below is a development features, basically located at other
# git branches:
option( ENABLE_GDS          "Goo Declarative Semantics."                        OFF)
option( ENABLE_ALLOCATORS   "Goo's own allocators subsystem."                   OFF)
option( ENABLE_TENSORS      "Tensorial algebra support template classes."       OFF)
option( ENABLE_DATASTREAMS  "Goo's serialization template classes."             OFF)
option( ENABLE_PTREE        "Goo's getopt()-like mechanism."                    OFF)
option( HASKELL_MODULE      "Haskell extensions."                               OFF)
#
# Find third-party packages
# 

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/contrib/cmake")
find_package( ZLIB  )
find_package( Lzo   )
find_package( BZip2 )
find_package( Git   )
if( EXCEPTION_BACTRACE )
    find_package( BFD   )
endif( EXCEPTION_BACTRACE )
if( GIT_FOUND )
    # obtain current commit hash
    EXECUTE_PROCESS(COMMAND git rev-parse HEAD OUTPUT_VARIABLE COMMIT_HASH
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE )
    EXECUTE_PROCESS(COMMAND git rev-parse --abbrev-ref HEAD
                    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
                    OUTPUT_VARIABLE GIT_BRANCH_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
    EXECUTE_PROCESS(COMMAND git show -s
        --format="gitInfo:{\\%nCommit:{\\%nhash:%h,\\%ndate:'%ci',\\%ncomment:'%s',\\%n},\\%nbranch:'${GIT_BRANCH_NAME}'}" ${COMMIT_HASH}
                 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
                 OUTPUT_VARIABLE GIT_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
else( GIT_FOUND )
    SET( COMMIT_HASH "<unknown>" )
    SET( GIT_STRING "gitInfo:'unavailable';" )
endif( GIT_FOUND )

#
# Disables Haskell module. Some Goo routines are written on Haskell.
# It is supposed to build it with Glasgow compiler (other compilers are
# untested). Some obscure reasons stop me from linking all object into one
# library, so Haskell modules are linked into libgooHs.so dynamic library and
# libgoo.so linked against it in order.
# see: http://stackoverflow.com/questions/20538087/how-does-one-integrate-haskell-code-into-a-c-program/21378585#21378585
# Probably it can be solved. Actual reasons seems be deep in implementation
# details -- object code generated by GHC seems to be incompatible with
# default GCC linker settings.

#
# Add custom uninstall target (CMake by default does not provide it)
CONFIGURE_FILE(
  "${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake/cmake_uninstall.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") 

#
# Switch installation prefix, if provided (otherwise, set to /usr/local)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
    set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "default install path" FORCE )
endif()

SITE_NAME( BUILDER_HOSTNAME )

include(contrib/cmake/OutOfSource.cmake)

AssureOutOfSourceBuilds()

#
# Obtain versioning parameters
    EXECUTE_PROCESS(COMMAND date +"%x %x"
                    OUTPUT_VARIABLE BUILD_TIMESTAMP
                    OUTPUT_STRIP_TRAILING_WHITESPACE )


#
# Attain configuration depending on current build dir.
string(REPLACE "/" ";" SPLITTED_PATH ${CMAKE_BINARY_DIR})
list(REVERSE SPLITTED_PATH)
list(GET SPLITTED_PATH 0 buildDir)
message( STATUS "Building in directory ${buildDir}" )
if( buildDir STREQUAL "debug" )
    message( STATUS "NOTE: debug build" )
    set( CMAKE_BUILD_TYPE "Debug" )
    set( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -g -fno-omit-frame-pointer" )  # -Wfatal-errors -fprofile-use? -fprofile-correction
    set( CMAKE_CXX_FLAGS   "${CMAKE_CXX_FLAGS} -g -fno-omit-frame-pointer" )
elseif( buildDir STREQUAL "release" )
    message( STATUS "NOTE: release build" )
    set( CMAKE_BUILD_TYPE "Release" )
    set( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -DNDEBUG -O3" )
    set( CMAKE_CXX_FLAGS   "${CMAKE_CXX_FLAGS} -DNDEBUG -O3" )
else()
    message( STATUS "NOTE: custom build" )
    set( CMAKE_BUILD_TYPE "Release" )
    set( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -DNDEBUG -O3" )
    set( CMAKE_CXX_FLAGS   "${CMAKE_CXX_FLAGS} -DNDEBUG -O3" )
endif()

set( GOO_LIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/inc/" )

#
# Configure compiler
set( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   -Wall -std=c99     -D_GNU_SOURCE -fexceptions -pthread -D_FILE_OFFSET_BITS=64 -rdynamic -DHAVE_INLINE -I${GOO_LIB_INCLUDE_DIR}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++11 -D_GNU_SOURCE -fexceptions -pthread -D_FILE_OFFSET_BITS=64 -rdynamic -I${GOO_LIB_INCLUDE_DIR}" )
set( CMAKE_Haskell_FLAGS "-fPIC -no-hs-main" )

#
# Configure source
file(GLOB_RECURSE GOO_LIB_SOURCES src/*.c*)
configure_file (
    "${GOO_LIB_INCLUDE_DIR}/goo_config.h.in"
    "${GOO_LIB_INCLUDE_DIR}/goo_config.h"
)
if( GIT_FOUND )
    configure_file( ${CMAKE_SOURCE_DIR}/.git/ORIG_HEAD
                    ${CMAKE_CURRENT_BINARY_DIR}/ORIG_HEAD )
endif( GIT_FOUND )


{'fraction_non_alphanumeric': 0.10023866348448687, 'fraction_numerical': 0.007425086184036065, 'mean_word_length': 3.94493006993007, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6045967', 'n_tokens_mistral': 4095, 'n_tokens_neox': 3842, 'n_words': 962}