meson: add Boost wrap

This commit is contained in:
Myaamori 2020-10-27 17:13:11 +00:00 committed by Ryan Lucia
parent d6ee06eb54
commit ce791773f6
10 changed files with 271 additions and 4 deletions

View File

@ -61,10 +61,23 @@ deps += iconv_dep
deps += dependency('libass', version: '>=0.9.7',
fallback: ['libass', 'libass_dep'])
deps += dependency('boost', version: '>=1.50.0',
modules: ['chrono', 'filesystem', 'locale', 'regex',
'system', 'thread'],
static: get_option('default_library') == 'static')
boost_modules = ['chrono', 'filesystem', 'thread', 'locale', 'regex']
if not get_option('local_boost')
boost_dep = dependency('boost', version: '>=1.50.0',
modules: boost_modules,
required: cxx.get_id() != 'msvc',
static: get_option('default_library') == 'static')
endif
if get_option('local_boost') or not boost_dep.found()
boost_dep = []
boost = subproject('boost')
foreach module: boost_modules
boost_dep += boost.get_variable('boost_' + module + '_dep')
endforeach
endif
deps += boost_dep
if host_machine.system() == 'windows'
conf.set('BOOST_USE_WINDOWS_H', '1')
endif

View File

@ -12,6 +12,7 @@ option('hunspell', type: 'feature', description: 'Hunspell spell checker')
option('uchardet', type: 'feature', description: 'uchardet character encoding detection')
option('system_luajit', type: 'boolean', value: false, description: 'Force using system luajit')
option('local_boost', type: 'boolean', value: false, description: 'Force using locally compiled Boost')
option('icu_path', type: 'string', value: '', description: 'Path to ICU libraries on Windows')
option('wx_path', type: 'string', value: '', description: 'Path to wxWidgets libraries on Windows')

6
subprojects/boost.wrap Normal file
View File

@ -0,0 +1,6 @@
[wrap-file]
directory = boost_1_74_0
source_url = https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.tar.gz
source_filename = boost_1_74_0.tar.gz
source_hash = afff36d392885120bcac079148c177d1f6f7730ec3d47233aa51b0afa4db94a5
patch_directory = boost

View File

@ -0,0 +1,15 @@
chrono_sources = files([
'src/chrono.cpp',
'src/thread_clock.cpp',
'src/process_cpu_clocks.cpp',
])
boost_chrono = library('boost_chrono', chrono_sources,
include_directories: inc,
cpp_args: is_static ? '-DBOOST_All_STATIC_LINK=1' : '-DBOOST_All_DYN_LINK=1',
dependencies: thread_dep)
boost_chrono_dep = declare_dependency(link_with: boost_chrono, include_directories: inc,
compile_args: [is_static ? '-DBOOST_CHRONO_STATIC_LINK=1'
: '-DBOOST_CHRONO_DYN_LINK=1',
'-DBOOST_ALL_NO_LIB=1'])

View File

@ -0,0 +1,37 @@
filesystem_sources = files([
'src/codecvt_error_category.cpp',
'src/exception.cpp',
'src/directory.cpp',
'src/operations.cpp',
'src/path.cpp',
'src/path_traits.cpp',
'src/portability.cpp',
'src/unique_path.cpp',
'src/utf8_codecvt_facet.cpp',
'src/windows_file_codecvt.cpp',
])
filesystem_args = ['-DBOOST_FILESYSTEM_SOURCE',
is_static ? '-DBOOST_FILESYSTEM_STATIC_LINK=1' : '-DBOOST_FILESYSTEM_DYN_LINK=1']
filesystem_deps = []
if host_machine.system() == 'windows'
bcrypt_dep = dependency('bcrypt', required: false)
if bcrypt_dep.found()
filesystem_deps += bcrypt_dep
filesystem_args += '-DBOOST_FILESYSTEM_HAS_BCRYPT'
else
filesystem_deps += cpp.find_library('advapi32')
filesystem_args += '-DBOOST_FILESYSTEM_HAS_WINCRYPT'
endif
endif
boost_filesystem = library('boost_filesystem', filesystem_sources,
include_directories: inc,
cpp_args: filesystem_args,
dependencies: [thread_dep, filesystem_deps])
boost_filesystem_dep = declare_dependency(link_with: boost_filesystem, include_directories: inc,
compile_args: [is_static ? '-DBOOST_FILESYSTEM_STATIC_LINK=1'
: '-DBOOST_FILESYSTEM_DYN_LINK=1',
'-DBOOST_ALL_NO_LIB=1'])

View File

@ -0,0 +1,78 @@
locale_sources = files([
'src/encoding/codepage.cpp',
'src/shared/date_time.cpp',
'src/shared/format.cpp',
'src/shared/formatting.cpp',
'src/shared/generator.cpp',
'src/shared/ids.cpp',
'src/shared/localization_backend.cpp',
'src/shared/message.cpp',
'src/shared/mo_lambda.cpp',
'src/util/codecvt_converter.cpp',
'src/util/default_locale.cpp',
'src/util/info.cpp',
'src/util/locale_data.cpp',
# icu
'src/icu/boundary.cpp',
'src/icu/codecvt.cpp',
'src/icu/collator.cpp',
'src/icu/conversion.cpp',
'src/icu/date_time.cpp',
'src/icu/formatter.cpp',
'src/icu/icu_backend.cpp',
'src/icu/numeric.cpp',
'src/icu/time_zone.cpp',
# std - docs say disabled by default on windows and solaris,
# but jamfile seemingly only disables on solaris
'src/std/codecvt.cpp',
'src/std/collate.cpp',
'src/std/converter.cpp',
'src/std/numeric.cpp',
'src/std/std_backend.cpp',
# included if using posix, win32 or std backend (ie always)
'src/util/gregorian.cpp',
])
locale_args = ['-DBOOST_THREAD_NO_LIB=1']
locale_deps = []
if not is_static
locale_args += '-DBOOST_LOCALE_DYN_LINK=1'
endif
if host_machine.system() == 'windows'
locale_sources += files([
'src/win32/collate.cpp',
'src/win32/converter.cpp',
'src/win32/numeric.cpp',
'src/win32/win_backend.cpp',
# included on windows/cygwin if std *or* win32 included
'src/win32/lcid.cpp',
])
locale_args += '-DBOOST_LOCALE_NO_POSIX_BACKEND=1'
else
locale_sources += files([
'src/posix/collate.cpp',
'src/posix/converter.cpp',
'src/posix/numeric.cpp',
'src/posix/codecvt.cpp',
'src/posix/posix_backend.cpp',
])
locale_args += '-DBOOST_LOCALE_NO_WINAPI_BACKEND=1'
endif
if not cpp.check_header('iconv.h')
locale_deps += dependency('iconv')
endif
locale_args += '-DBOOST_LOCALE_WITH_ICONV=1'
locale_deps += icu_deps
locale_args += '-DBOOST_LOCALE_WITH_ICU=1'
boost_locale = library('boost_locale', locale_sources,
include_directories: inc,
cpp_args: locale_args,
dependencies: [thread_dep, locale_deps, boost_thread_dep])
boost_locale_dep = declare_dependency(link_with: boost_locale, include_directories: inc,
compile_args: '-DBOOST_ALL_NO_LIB=1')

View File

@ -0,0 +1,28 @@
program_options_sources = files([
'src/cmdline.cpp',
'src/config_file.cpp',
'src/options_description.cpp',
'src/parsers.cpp',
'src/variables_map.cpp',
'src/value_semantic.cpp',
'src/positional_options.cpp',
'src/utf8_codecvt_facet.cpp',
'src/convert.cpp',
'src/winmain.cpp',
'src/split.cpp',
])
program_options_args = []
if not is_static
program_options_args += '-DBOOST_PROGRAM_OPTIONS_DYN_LINK=1'
endif
boost_program_options = library('boost_program_options', program_options_sources,
cpp_args: program_options_args,
include_directories: inc,
dependencies: thread_dep)
boost_program_options_dep = declare_dependency(link_with: boost_program_options,
include_directories: inc,
compile_args: program_options_args +
['-DBOOST_ALL_NO_LIB=1'])

View File

@ -0,0 +1,33 @@
regex_sources = files([
'src/c_regex_traits.cpp',
'src/cpp_regex_traits.cpp',
'src/cregex.cpp',
'src/fileiter.cpp',
'src/icu.cpp',
'src/instances.cpp',
'src/posix_api.cpp',
'src/regex.cpp',
'src/regex_debug.cpp',
'src/regex_raw_buffer.cpp',
'src/regex_traits_defaults.cpp',
'src/static_mutex.cpp',
'src/w32_regex_traits.cpp',
'src/wc_regex_traits.cpp',
'src/wide_posix_api.cpp',
'src/winstances.cpp',
'src/usinstances.cpp',
])
regex_args = ['-DBOOST_HAS_ICU=1']
if not is_static
regex_args += '-DBOOST_REGEX_DYN_LINK=1'
endif
boost_regex = library('boost_regex', regex_sources,
include_directories: inc,
cpp_args: regex_args,
dependencies: [thread_dep, icu_deps])
boost_regex_dep = declare_dependency(link_with: boost_regex, include_directories: inc,
compile_args: '-DBOOST_ALL_NO_LIB=1')

View File

@ -0,0 +1,30 @@
thread_args = [is_static ? '-DBOOST_THREAD_BUILD_LIB=1' : '-DBOOST_THREAD_BUILD_DLL=1']
if host_machine.system() == 'windows'
thread_sources = files([
'src/win32/thread.cpp',
'src/win32/tss_dll.cpp',
'src/win32/tss_pe.cpp',
'src/win32/thread_primitives.cpp',
'src/future.cpp',
])
thread_args += ['-DWIN32_LEAN_AND_MEAN', '-DBOOST_USE_WINDOWS_H', '-DBOOST_THREAD_WIN32',
'-DBOOST_THREAD_USES_CHRONO']
else
thread_sources = files([
'src/pthread/thread.cpp',
'src/pthread/once.cpp',
'src/future.cpp',
])
thread_args += ['-DBOOST_THREAD_POSIX', '-DBOOST_THREAD_DONT_USE_CHRONO']
endif
boost_thread = library('boost_thread', thread_sources,
include_directories: inc,
cpp_args: thread_args,
dependencies: [thread_dep, boost_chrono_dep])
boost_thread_dep = declare_dependency(link_with: boost_thread, include_directories: inc,
compile_args: [is_static ? '-DBOOST_THREAD_BUILD_LIB=1'
: '-DBOOST_THREAD_BUILD_DLL=1',
'-DBOOST_ALL_NO_LIB=1'])

View File

@ -0,0 +1,26 @@
project('boost', 'cpp',
version: '1.74.0',
meson_version: '>=0.55.0')
cpp = meson.get_compiler('cpp')
thread_dep = dependency('threads')
inc = include_directories('.')
is_static = get_option('default_library') == 'static'
add_project_arguments('-DBOOST_ALL_NO_LIB=1', language: 'cpp')
if get_option('buildtype').startswith('release')
add_project_arguments('-DNDEBUG', language: 'cpp')
endif
if host_machine.system() == 'windows'
add_project_arguments('-DWIN32', language: 'cpp')
endif
icu_deps = [dependency('icu-uc'),
dependency('icu-i18n')]
modules = ['chrono', 'thread', 'filesystem', 'locale', 'regex', 'program_options']
foreach module: modules
subdir('libs/' + module)
endforeach