2020-01-04 14:21:38 +00:00
|
|
|
test_sources = [
|
2020-07-05 15:08:28 +00:00
|
|
|
'conformance_burntsushi_invalid.cpp',
|
|
|
|
'conformance_burntsushi_valid.cpp',
|
|
|
|
'conformance_iarna_invalid.cpp',
|
|
|
|
'conformance_iarna_valid.cpp',
|
2020-04-02 21:39:21 +00:00
|
|
|
'impl_toml.cpp',
|
|
|
|
'impl_catch2.cpp',
|
2020-04-06 12:57:49 +00:00
|
|
|
'tests.cpp',
|
|
|
|
'parsing_floats.cpp',
|
2020-01-04 14:21:38 +00:00
|
|
|
'parsing_arrays.cpp',
|
|
|
|
'parsing_booleans.cpp',
|
|
|
|
'parsing_comments.cpp',
|
|
|
|
'parsing_dates_and_times.cpp',
|
|
|
|
'parsing_integers.cpp',
|
|
|
|
'parsing_key_value_pairs.cpp',
|
|
|
|
'parsing_spec_example.cpp',
|
|
|
|
'parsing_strings.cpp',
|
2020-02-03 09:12:43 +00:00
|
|
|
'parsing_tables.cpp',
|
|
|
|
'manipulating_arrays.cpp',
|
2020-03-03 08:10:07 +00:00
|
|
|
'manipulating_tables.cpp',
|
2020-04-06 12:57:49 +00:00
|
|
|
'manipulating_values.cpp',
|
2020-04-18 13:14:07 +00:00
|
|
|
'unicode.cpp',
|
|
|
|
'unicode_generated.cpp',
|
2020-07-13 18:18:04 +00:00
|
|
|
'windows_compat.cpp'
|
2020-01-04 14:21:38 +00:00
|
|
|
]
|
|
|
|
|
2020-07-17 13:33:56 +00:00
|
|
|
compiler_supports_cpp20 = compiler.links('''
|
|
|
|
#include <version>
|
2020-03-18 13:28:00 +00:00
|
|
|
#include <string>
|
2020-07-17 13:33:56 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
int main()
|
2020-03-18 13:28:00 +00:00
|
|
|
{
|
2020-07-17 13:33:56 +00:00
|
|
|
std::string s = "kek";
|
|
|
|
std::cout << s << std::endl;
|
|
|
|
return 0;
|
2020-03-18 13:28:00 +00:00
|
|
|
}
|
|
|
|
''',
|
2020-07-25 17:37:30 +00:00
|
|
|
name : 'supports c++20',
|
2020-03-18 13:28:00 +00:00
|
|
|
args : [ '-std=c++2a' ]
|
|
|
|
)
|
2020-03-03 21:28:24 +00:00
|
|
|
|
2020-07-17 13:33:56 +00:00
|
|
|
compiler_supports_char8 = compiler_supports_cpp20 and compiler.links('''
|
|
|
|
#include <version>
|
|
|
|
#include <string_view>
|
|
|
|
#include <string>
|
|
|
|
#include <type_traits>
|
|
|
|
using namespace std::string_view_literals;
|
2020-04-06 12:57:49 +00:00
|
|
|
|
2020-07-17 13:33:56 +00:00
|
|
|
#ifndef __cpp_lib_char8_t
|
|
|
|
#error oh noes
|
|
|
|
#endif
|
2020-04-06 12:57:49 +00:00
|
|
|
|
2020-07-17 13:33:56 +00:00
|
|
|
static_assert(!std::is_same_v<char, char8_t>);
|
|
|
|
static_assert(!std::is_same_v<std::string, std::u8string>);
|
2020-04-06 12:57:49 +00:00
|
|
|
|
2020-07-17 13:33:56 +00:00
|
|
|
std::u8string func()
|
|
|
|
{
|
|
|
|
return std::u8string{ u8"this is a test."sv };
|
|
|
|
}
|
2020-04-06 12:57:49 +00:00
|
|
|
|
2020-07-17 13:33:56 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
''',
|
|
|
|
name : 'supports char8_t',
|
|
|
|
args : [ '-std=c++2a', '-fchar8_t' ]
|
|
|
|
)
|
2020-06-24 18:05:23 +00:00
|
|
|
|
2020-07-18 12:10:19 +00:00
|
|
|
compiler_supports_consteval = compiler_supports_cpp20 and compiler.compiles('''
|
|
|
|
|
|
|
|
consteval int kek() noexcept
|
|
|
|
{
|
|
|
|
return 42;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
return kek();
|
|
|
|
}
|
|
|
|
''',
|
|
|
|
name : 'supports consteval',
|
|
|
|
args : [ '-std=c++2a' ]
|
|
|
|
)
|
|
|
|
|
2020-07-25 17:37:30 +00:00
|
|
|
float_16_preprocessor_single_check_template = '''
|
|
|
|
#ifndef @0@
|
|
|
|
#error @0@ wasn't defined!
|
|
|
|
#else
|
|
|
|
#pragma message("@0@: " MAKE_STRING(@0@))
|
|
|
|
#endif
|
|
|
|
#if @0@ != @1@
|
|
|
|
#error @0@ was not @1@!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
'''
|
|
|
|
float_16_preprocessor_checks = '''
|
|
|
|
#define MAKE_STRING(s) MAKE_STRING_1(s)
|
|
|
|
#define MAKE_STRING_1(s) #s
|
|
|
|
''' + float_16_preprocessor_single_check_template.format('__FLT_RADIX__', '2') \
|
|
|
|
+ float_16_preprocessor_single_check_template.format('__FLT16_MANT_DIG__', '11') \
|
|
|
|
+ float_16_preprocessor_single_check_template.format('__FLT16_DIG__', '3') \
|
|
|
|
+ float_16_preprocessor_single_check_template.format('__FLT16_MIN_EXP__', '-13') \
|
|
|
|
+ float_16_preprocessor_single_check_template.format('__FLT16_MIN_10_EXP__', '-4') \
|
|
|
|
+ float_16_preprocessor_single_check_template.format('__FLT16_MAX_EXP__', '16') \
|
|
|
|
+ float_16_preprocessor_single_check_template.format('__FLT16_MAX_10_EXP__', '4')
|
|
|
|
|
|
|
|
compiler_supports_float16_args = [ '-O0' ]
|
2020-07-18 12:10:19 +00:00
|
|
|
if compiler.get_id() == 'gcc'
|
|
|
|
compiler_supports_float16_args += '-mfp16-format=ieee'
|
2020-07-25 17:37:30 +00:00
|
|
|
compiler_supports_float16_args += '-fmax-errors=1'
|
|
|
|
elif compiler.get_id() == 'clang'
|
|
|
|
compiler_supports_float16_args += '-ferror-limit=1'
|
2020-07-18 12:10:19 +00:00
|
|
|
endif
|
2020-07-25 17:37:30 +00:00
|
|
|
compiler_supports_fp16 = compiler.links('''
|
|
|
|
@0@
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
static_assert(sizeof(__fp16) == 2);
|
|
|
|
__fp16 f = static_cast<__fp16>(1);
|
|
|
|
const auto f2 = static_cast<float>(f);
|
|
|
|
const auto f3 = static_cast<__fp16>(0.2L);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
'''.format(float_16_preprocessor_checks),
|
|
|
|
name : 'supports __fp16',
|
|
|
|
args : compiler_supports_float16_args
|
|
|
|
)
|
2020-07-17 13:33:56 +00:00
|
|
|
compiler_supports_float16 = compiler.links('''
|
2020-07-25 17:37:30 +00:00
|
|
|
@0@
|
|
|
|
|
2020-07-17 13:33:56 +00:00
|
|
|
int main()
|
|
|
|
{
|
2020-07-18 12:10:19 +00:00
|
|
|
static_assert(sizeof(_Float16) == 2);
|
2020-07-17 13:33:56 +00:00
|
|
|
_Float16 f = static_cast<_Float16>(1);
|
2020-07-25 17:37:30 +00:00
|
|
|
const auto f2 = static_cast<float>(f);
|
|
|
|
const auto f3 = static_cast<_Float16>(0.2L);
|
2020-07-17 13:33:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2020-07-25 17:37:30 +00:00
|
|
|
'''.format(float_16_preprocessor_checks),
|
|
|
|
name : 'supports _Float16',
|
2020-07-18 12:10:19 +00:00
|
|
|
args : compiler_supports_float16_args
|
2020-07-17 13:33:56 +00:00
|
|
|
)
|
2020-06-24 18:05:23 +00:00
|
|
|
|
2020-07-25 17:37:30 +00:00
|
|
|
compiler_supports_int128 = compiler.links('''
|
|
|
|
#ifndef __SIZEOF_INT128__
|
|
|
|
#error __SIZEOF_INT128__ wasn't defined!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
static_assert(__SIZEOF_INT128__ == 16);
|
|
|
|
static_assert(sizeof(__int128_t) == 16);
|
|
|
|
static_assert(sizeof(__uint128_t) == 16);
|
|
|
|
__int128_t i = static_cast<__int128_t>(1);
|
|
|
|
const auto i2 = static_cast<int64_t>(i);
|
|
|
|
const auto i3 = static_cast<int32_t>(i);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
''',
|
|
|
|
name : 'supports __int128_t',
|
|
|
|
args : [ '-O0' ]
|
|
|
|
)
|
|
|
|
|
|
|
|
compiler_supports_float128 = compiler.links('''
|
|
|
|
#ifndef __SIZEOF_FLOAT128__
|
|
|
|
#error __SIZEOF_FLOAT128__ wasn't defined!
|
|
|
|
#endif
|
|
|
|
#ifndef __FLT128_MANT_DIG__
|
|
|
|
#error __FLT128_MANT_DIG__ wasn't defined!
|
|
|
|
#endif
|
|
|
|
#ifndef __LDBL_MANT_DIG__
|
|
|
|
#error __LDBL_MANT_DIG__ wasn't defined!
|
|
|
|
#endif
|
|
|
|
#if __FLT128_MANT_DIG__ <= __LDBL_MANT_DIG__
|
|
|
|
#error __FLT128_MANT_DIG__ was <= __LDBL_MANT_DIG__
|
|
|
|
#endif
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
static_assert(__SIZEOF_FLOAT128__ == 16);
|
|
|
|
static_assert(sizeof(__float128) == 16);
|
|
|
|
__float128 f = static_cast<__float128>(1);
|
|
|
|
const auto f2 = static_cast<long double>(f);
|
|
|
|
const auto f3 = static_cast<double>(f);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
''',
|
|
|
|
name : 'supports __float128',
|
|
|
|
args : [ '-O0' ]
|
|
|
|
)
|
|
|
|
|
2020-07-17 13:33:56 +00:00
|
|
|
compiler_supports_fast_math = compiler.links('''
|
|
|
|
#include <cmath>
|
|
|
|
#include <iostream>
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
std::cout << std::exp2(2.0) << std::pow(2.0, 3.0) << std::endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
''',
|
|
|
|
name : 'supports fast-math',
|
|
|
|
args : [ '-ffast-math', '-ffp-contract=fast' ]
|
|
|
|
)
|
2020-06-24 18:05:23 +00:00
|
|
|
|
2020-07-17 13:33:56 +00:00
|
|
|
fast_math_modes = [ false, true ]
|
|
|
|
exception_modes = [ true, false ]
|
2020-07-21 13:11:32 +00:00
|
|
|
unreleased_feature_modes = [ false, true ]
|
2020-07-17 13:33:56 +00:00
|
|
|
cpp20_modes = [ false, true ]
|
|
|
|
executables = []
|
|
|
|
counter = 0
|
2020-07-25 17:37:30 +00:00
|
|
|
|
2020-07-17 13:33:56 +00:00
|
|
|
foreach cpp20 : cpp20_modes
|
2020-07-21 13:11:32 +00:00
|
|
|
if cpp20 and not compiler_supports_cpp20
|
|
|
|
continue
|
|
|
|
endif
|
|
|
|
foreach unrel : unreleased_feature_modes
|
2020-07-18 12:10:19 +00:00
|
|
|
foreach fast_math : fast_math_modes
|
|
|
|
if fast_math and not compiler_supports_fast_math
|
2020-07-17 13:33:56 +00:00
|
|
|
continue
|
|
|
|
endif
|
2020-07-18 12:10:19 +00:00
|
|
|
foreach exceptions : exception_modes
|
2020-07-17 13:33:56 +00:00
|
|
|
|
2020-07-18 12:10:19 +00:00
|
|
|
name = ''
|
|
|
|
overrides = []
|
|
|
|
args = []
|
2020-07-17 13:33:56 +00:00
|
|
|
|
2020-07-18 12:10:19 +00:00
|
|
|
if cpp20
|
|
|
|
name = 'cpp20'
|
|
|
|
overrides += 'cpp_std=none'
|
|
|
|
args += '-std=c++2a'
|
2020-07-17 13:33:56 +00:00
|
|
|
|
2020-07-18 12:10:19 +00:00
|
|
|
if compiler_supports_char8
|
|
|
|
args += '-fchar8_t'
|
2020-07-17 13:33:56 +00:00
|
|
|
endif
|
2020-07-18 12:10:19 +00:00
|
|
|
else
|
|
|
|
name = 'cpp17'
|
|
|
|
endif
|
|
|
|
|
2020-07-25 17:37:30 +00:00
|
|
|
if exceptions
|
|
|
|
args += '-DSHOULD_HAVE_EXCEPTIONS=1'
|
|
|
|
else
|
2020-07-18 12:10:19 +00:00
|
|
|
name = name + '_noexcept'
|
|
|
|
overrides += 'cpp_eh=none'
|
2020-07-25 17:37:30 +00:00
|
|
|
args += '-DSHOULD_HAVE_EXCEPTIONS=0'
|
2020-07-18 12:10:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
if fast_math
|
|
|
|
name = name + '_fastmath'
|
|
|
|
if compiler.get_id() == 'gcc' or compiler.get_id() == 'clang'
|
|
|
|
args += '-ffast-math'
|
|
|
|
args += '-ffp-contract=fast'
|
2020-07-17 13:33:56 +00:00
|
|
|
endif
|
2020-07-18 12:10:19 +00:00
|
|
|
endif
|
|
|
|
|
2020-07-25 17:37:30 +00:00
|
|
|
if compiler_supports_float16 or compiler_supports_fp16
|
|
|
|
if compiler.get_id() == 'gcc'
|
|
|
|
args += '-mfp16-format=ieee'
|
|
|
|
endif
|
|
|
|
if compiler_supports_fp16
|
|
|
|
args += '-DSHOULD_HAVE_FP16=1'
|
|
|
|
endif
|
|
|
|
if compiler_supports_float16
|
|
|
|
args += '-DSHOULD_HAVE_FLOAT16=1'
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if compiler_supports_int128
|
|
|
|
args += '-DSHOULD_HAVE_INT128=1'
|
|
|
|
endif
|
|
|
|
|
|
|
|
if compiler_supports_float128
|
|
|
|
args += '-DSHOULD_HAVE_FLOAT128=1'
|
|
|
|
endif
|
|
|
|
|
|
|
|
if compiler_supports_float16 or compiler_supports_int128 or compiler_supports_float128
|
|
|
|
if compiler.get_id() == 'gcc'
|
|
|
|
args += '-fext-numeric-literals'
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2020-07-21 13:11:32 +00:00
|
|
|
if unrel
|
|
|
|
name = name + '_unrel'
|
|
|
|
args += '-DTOML_UNRELEASED_FEATURES=1'
|
|
|
|
else
|
|
|
|
args += '-DTOML_UNRELEASED_FEATURES=0'
|
|
|
|
endif
|
|
|
|
|
2020-07-18 12:10:19 +00:00
|
|
|
if counter % 6 == 3
|
2020-07-25 17:37:30 +00:00
|
|
|
args += '-DTOML_HEADER_ONLY=1'
|
2020-07-18 12:10:19 +00:00
|
|
|
endif
|
|
|
|
if counter % 2 == 1
|
|
|
|
args += '-DUSE_SINGLE_HEADER=1'
|
|
|
|
endif
|
|
|
|
if counter % 4 == 2 and exceptions
|
|
|
|
args += '-DUSE_TARTANLLAMA_OPTIONAL=1'
|
|
|
|
name = name + '_tlopt'
|
|
|
|
endif
|
2020-07-21 13:11:32 +00:00
|
|
|
|
|
|
|
if compiler_supports_float16
|
|
|
|
if compiler.get_id() == 'gcc'
|
|
|
|
args += '-mfp16-format=ieee'
|
|
|
|
endif
|
2020-07-18 12:10:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
executables += [[
|
|
|
|
name,
|
|
|
|
executable(
|
|
|
|
name,
|
|
|
|
test_sources,
|
|
|
|
include_directories : inc,
|
|
|
|
cpp_args : args,
|
|
|
|
override_options : overrides
|
|
|
|
)
|
|
|
|
]]
|
2020-07-17 13:33:56 +00:00
|
|
|
|
2020-07-18 12:10:19 +00:00
|
|
|
counter = counter + 1
|
2020-07-17 13:33:56 +00:00
|
|
|
|
2020-07-18 12:10:19 +00:00
|
|
|
endforeach # exceptions
|
|
|
|
endforeach # fast_math
|
2020-07-17 13:33:56 +00:00
|
|
|
endforeach # strict
|
|
|
|
endforeach # cpp20
|
2020-04-06 12:57:49 +00:00
|
|
|
|
|
|
|
locales = [
|
|
|
|
'C',
|
|
|
|
'en_US.utf8',
|
|
|
|
'ja_JP.utf8',
|
|
|
|
'it_IT.utf8',
|
|
|
|
'tr_TR.utf8',
|
|
|
|
'fi_FI.utf8',
|
|
|
|
'fr_FR.utf8',
|
|
|
|
'zh_CN.utf8',
|
|
|
|
'de_DE.utf8'
|
|
|
|
]
|
2020-03-03 21:28:24 +00:00
|
|
|
|
2020-07-17 13:33:56 +00:00
|
|
|
foreach executable : executables
|
|
|
|
foreach locale : locales
|
|
|
|
test(executable[0] + ' (' + locale + ')', executable[1], env : ['LC_ALL=' + locale])
|
2020-04-06 12:57:49 +00:00
|
|
|
endforeach
|
|
|
|
endforeach
|