#!/usr/bin/env python
Import('boost_env')
Import('user_options_dict')

lib_dir = user_options_dict['LIB_BUILD_DIR']
#
# Boost.Test
#
butf_env = boost_env.Clone()
# Boost.Test dynamic build is being built without main(),
# static - with main() . I find it stupid (having the difference).
# So, build it like dynamic so external Boost can be used without any modification
# to sources.
butf_env.Append(CPPDEFINES = ['BOOST_TEST_DYN_LINK'])

make_source_files = user_options_dict['make_source_files']

butf_src = 'libs/test/src/'
butf_source_files = make_source_files(butf_src, 
[
    'compiler_log_formatter.cpp',
    'debug.cpp',                #1.44
    'exception_safety.cpp',     #1.44
    'execution_monitor.cpp',
    'framework.cpp',
    'interaction_based.cpp',    #1.44
    'logged_expectations.cpp',  #1.44
    'plain_report_formatter.cpp',
    'progress_monitor.cpp',
    'results_collector.cpp',
    'results_reporter.cpp',
    'test_tools.cpp',
    'unit_test_log.cpp',
    'unit_test_main.cpp',
    'unit_test_monitor.cpp',
    'unit_test_parameters.cpp',
    'unit_test_suite.cpp',
    'xml_log_formatter.cpp',
    'xml_report_formatter.cpp'
])

# libboost_unit_test_framework.a
# Depends('.',
#         butf_env.Library( target = user_options_dict['LIB_BUILD_DIR']+'/boost_unit_test_framework', source = butf_source_files )
#        )
butf_env.Library( target = lib_dir+'/boost_unit_test_framework', source = butf_source_files )

#
# Boost.Filesystem & Boost.System
#
bfs_env = boost_env

bfs_src = 'libs/filesystem/'
bfs_source_files = make_source_files(bfs_src, 
[
    #'convenience.cpp',
    #'exception.cpp',
    #'operations_posix_windows.cpp',
    #'path_posix_windows.cpp'

    #'v2/src/v2_operations.cpp',
    #'v2/src/v2_path.cpp',
    #'v2/src/v2_portability.cpp',

    # v3 is needed because of better arch for win32
    'v3/src/operations.cpp', 
    'v3/src/path.cpp',
    'v3/src/portability.cpp',
    'v3/src/utf8_codecvt_facet.cpp',
    'v3/src/codecvt_error_category.cpp',
    'v3/src/path_traits.cpp',
    'v3/src/unique_path.cpp',
    'v3/src/windows_file_codecvt.cpp'
]) 
# libboost_filesystem.a
bfs_env.Library( target = lib_dir+'/boost_filesystem', source = bfs_source_files )
bfs_env.Library( target = lib_dir+'/boost_system', source = ['libs/system/src/error_code.cpp'] )

#
# Boost.Regex
#
# If there will be need for ICU then add "-DBOOST_HAS_ICU=1" + corresponding lib for linking,
# see libs/regex/build/Jamfile(Jamfile.v2)
brg_env = boost_env

brg_src = 'libs/regex/src/'
brg_source_files = make_source_files(brg_src, 
[
    'c_regex_traits.cpp',
    'cpp_regex_traits.cpp',
    'cregex.cpp',
    'fileiter.cpp',
    'icu.cpp',
    'instances.cpp',
    'posix_api.cpp',
    'regex.cpp',
    'regex_debug.cpp',
    'regex_raw_buffer.cpp',
    'regex_traits_defaults.cpp',
    'static_mutex.cpp',
    'w32_regex_traits.cpp',
    'wc_regex_traits.cpp',
    'wide_posix_api.cpp',
    'winstances.cpp',
    'usinstances.cpp'
])
# libboost_regex.a
brg_env.Library( target = lib_dir+'/boost_regex', source = brg_source_files )

