diff --git a/.gitignore b/.gitignore index 075e9096..9f430d3d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,9 @@ examples/ArmTimerCallbacks/Objects examples/ArmTimerCallbacks/DebugConfig build-test-Desktop_x86_windows_msvc2017_pe_32bit-Debug/unittest++/src buildresults/ +build +subprojects/* +!subprojects/*.wrap ################# ## Eclipse diff --git a/meson.build b/meson.build index a69ff468..0b52026d 100644 --- a/meson.build +++ b/meson.build @@ -1,209 +1,30 @@ -project('PROJECT_NAME', - ['cpp'], - default_options : [ - 'warning_level=2', - 'werror=false', - # `build.*` options affect `native: true targets` - # plain options affect `native: false` targets. - 'cpp_std=c++17', 'build.cpp_std=c++17', - ], - meson_version: '>=0.54.0', - version: '20.19.0' +project('etl', + ['cpp'], + default_options : [ + 'warning_level=2', + 'werror=false', + # `build.*` options affect `native: true targets` + # plain options affect `native: false` targets. + 'cpp_std=c++17', 'build.cpp_std=c++17', + ], + meson_version: '>=0.54.0', + version: '20.18.1' ) -###################### -# Library Dependency # -###################### - -etl_dep = declare_dependency( - include_directories: include_directories('include', is_system: true), -) - -######### -# Tests # -######### - -# Disabled 'test/tests below fail to compile in our configuration, often due to iostream use -etl_test_sources = files( - 'test/main.cpp', - 'test/murmurhash3.cpp', - 'test/test_algorithm.cpp', - 'test/test_alignment.cpp', - 'test/test_array.cpp', - 'test/test_array_view.cpp', - 'test/test_array_wrapper.cpp', - 'test/test_binary.cpp', - 'test/test_bitset.cpp', - 'test/test_bloom_filter.cpp', - 'test/test_bsd_checksum.cpp', - 'test/test_buffer_descriptors.cpp', - 'test/test_callback_timer.cpp', - 'test/test_checksum.cpp', - 'test/test_compare.cpp', - 'test/test_compiler_settings.cpp', - 'test/test_constant.cpp', - 'test/test_container.cpp', - 'test/test_crc.cpp', - 'test/test_cyclic_value.cpp', - 'test/test_debounce.cpp', - 'test/test_endian.cpp', - 'test/test_enum_type.cpp', - 'test/test_error_handler.cpp', - 'test/test_exception.cpp', - 'test/test_fixed_iterator.cpp', - 'test/test_fnv_1.cpp', - 'test/test_forward_list.cpp', - 'test/test_fsm.cpp', - 'test/test_hfsm.cpp', - 'test/test_functional.cpp', - 'test/test_function.cpp', - 'test/test_hash.cpp', - 'test/test_instance_count.cpp', - 'test/test_integral_limits.cpp', - 'test/test_intrusive_forward_list.cpp', - 'test/test_intrusive_links.cpp', - 'test/test_intrusive_list.cpp', - 'test/test_intrusive_queue.cpp', - 'test/test_intrusive_stack.cpp', - 'test/test_io_port.cpp', - 'test/test_iterator.cpp', - 'test/test_jenkins.cpp', - 'test/test_largest.cpp', - 'test/test_list.cpp', - 'test/test_maths.cpp', - 'test/test_mem_cast.cpp', - 'test/test_mem_cast_ptr.cpp', - 'test/test_memory.cpp', - 'test/test_message_bus.cpp', - 'test/test_message_router.cpp', - 'test/test_message_timer.cpp', - 'test/test_murmur3.cpp', - 'test/test_numeric.cpp', - 'test/test_observer.cpp', - 'test/test_optional.cpp', - 'test/test_packet.cpp', - 'test/test_parameter_type.cpp', - 'test/test_parity_checksum.cpp', - 'test/test_pool.cpp', - 'test/test_pool_external_buffer.cpp', - 'test/test_priority_queue.cpp', - 'test/test_queue.cpp', - 'test/test_queue_memory_model_small.cpp', - 'test/test_queue_mpmc_mutex.cpp', - 'test/test_queue_mpmc_mutex_small.cpp', - 'test/test_queue_spsc_isr.cpp', - 'test/test_queue_spsc_isr_small.cpp', - 'test/test_queue_spsc_atomic.cpp', - 'test/test_queue_spsc_atomic_small.cpp', - 'test/test_queue_spsc_isr.cpp', - 'test/test_queue_spsc_isr_small.cpp', - 'test/test_queue_spsc_locked.cpp', - 'test/test_queue_spsc_locked_small.cpp', - 'test/test_random.cpp', - 'test/test_smallest.cpp', - 'test/test_stack.cpp', - 'test/test_string_char.cpp', - 'test/test_string_u16.cpp', - 'test/test_string_u32.cpp', - 'test/test_string_wchar_t.cpp', - 'test/test_task_scheduler.cpp', - 'test/test_type_def.cpp', - 'test/test_type_lookup.cpp', - 'test/test_type_traits.cpp', - 'test/test_user_type.cpp', - 'test/test_utility.cpp', - 'test/test_variant_legacy.cpp', - 'test/test_variant_variadic.cpp', - 'test/test_variant_pool.cpp', - 'test/test_variant_pool_external_buffer.cpp', - 'test/test_variant_variadic.cpp', - 'test/test_vector.cpp', - 'test/test_vector_non_trivial.cpp', - 'test/test_vector_pointer.cpp', - 'test/test_visitor.cpp', - 'test/test_xor_checksum.cpp', - 'test/test_xor_rotate_checksum.cpp', - 'test/test_atomic_std.cpp', - 'test/test_callback_service.cpp', - 'test/test_cumulative_moving_average.cpp', - 'test/test_delegate.cpp', - 'test/test_delegate_service.cpp', - 'test/test_forward_list_shared_pool.cpp', - 'test/test_list_shared_pool.cpp', - 'test/test_multi_array.cpp', - 'test/test_queue_memory_model_small.cpp', - 'test/test_queue_mpmc_mutex.cpp', - 'test/test_queue_mpmc_mutex_small.cpp', - 'test/test_queue_spsc_atomic.cpp', - 'test/test_queue_spsc_atomic_small.cpp', - 'test/test_queue_spsc_isr.cpp', - 'test/test_queue_spsc_isr_small.cpp', - 'test/test_queue_spsc_locked.cpp', - 'test/test_queue_spsc_locked_small.cpp', - 'test/test_scaled_rounding.cpp', - 'test/test_state_chart.cpp', - 'test/test_type_select.cpp', - 'test/test_vector_external_buffer.cpp', - 'test/test_vector_pointer_external_buffer.cpp', - 'test/test_deque.cpp', - 'test/test_flat_map.cpp', - 'test/test_flat_multimap.cpp', - 'test/test_flat_multiset.cpp', - 'test/test_flat_set.cpp', - 'test/test_map.cpp', - 'test/test_multimap.cpp', - 'test/test_multiset.cpp', - 'test/test_reference_flat_map.cpp', - 'test/test_reference_flat_multimap.cpp', - 'test/test_reference_flat_multiset.cpp', - 'test/test_reference_flat_set.cpp', - 'test/test_pearson.cpp', - 'test/test_set.cpp', - 'test/test_string_view.cpp', - 'test/test_to_u16string.cpp', - 'test/test_to_u32string.cpp', - 'test/test_to_string.cpp', - 'test/test_to_wstring.cpp', - 'test/test_unordered_map.cpp', - 'test/test_unordered_multimap.cpp', - 'test/test_unordered_multiset.cpp', - 'test/test_unordered_set.cpp' -) - -if meson.get_compiler('cpp').get_id() == 'gcc' - etl_test_sources += files('test/test_atomic_gcc_sync.cpp') +compile_args = [] +if get_option('use_stl') + compile_args += '-DETL_NO_STL=0' +elif + compile_args += '-DETL_NO_STL=1' endif -unittestcpp_dep = dependency('UnitTest++', - native: true, - required: false, - not_found_message: 'UnitTest++ not found, ETL unit tests will be disabled', - disabler: true, -) - -threads_dep = dependency('threads') - -etl_unit_tests = executable('etl_unit_tests', - include_directories: [ - include_directories('test'), - # Included here instead of with the dependency so we can see - # header-induced warnings when building the tests - include_directories('include') - ], - sources: etl_test_sources, - dependencies: [unittestcpp_dep, threads_dep], - cpp_args: [ - '-fexceptions', - '-DENABLE_ETL_UNIT_TESTS', - '-DETL_DEBUG', - ], - native: true, - install: false, - # Don't build tests by default if we are a subproject - build_by_default: meson.is_subproject() == false +etl_dep = declare_dependency( + include_directories: include_directories('include'), + extra_files: ['meson.build'], + compile_args: compile_args ) # Only register tests with the test runner when built as a primary project if meson.is_subproject() == false - test('ETL Unit Tests', etl_unit_tests) + subdir('test') endif diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..c664f51c --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('use_stl', type : 'boolean', value : true) diff --git a/subprojects/unittest-cpp.wrap b/subprojects/unittest-cpp.wrap new file mode 100644 index 00000000..dfdc9d8f --- /dev/null +++ b/subprojects/unittest-cpp.wrap @@ -0,0 +1,9 @@ +[wrap-file] +directory = unittest-cpp-2.0.0 +source_url = https://github.com/unittest-cpp/unittest-cpp/archive/v2.0.0.zip +source_filename = unittest-cpp-2.0.0.zip +source_hash = 3ba4f8b6c6e75ca8c79dd6008c78e95fb08554fbf2e0f1195fb78a4bf5a8a805 +patch_url = https://wrapdb.mesonbuild.com/v2/unittest-cpp_2.0.0-1/get_patch +patch_filename = unittest-cpp-2.0.0-1-wrap.zip +patch_hash = a887de2b619c13fc4fd8bff844ca7015a2046dc613ae0765dd4452ff70db12ca + diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 00000000..14daaa36 --- /dev/null +++ b/test/meson.build @@ -0,0 +1,267 @@ + +etl_test_sources = files( + 'main.cpp', + 'murmurhash3.cpp', + 'test_algorithm.cpp', + 'test_alignment.cpp', + 'test_array.cpp', + 'test_array_view.cpp', + 'test_array_wrapper.cpp', + 'test_atomic_clang_sync.cpp', + 'test_atomic_gcc_sync.cpp', + 'test_atomic_std.cpp', + 'test_binary.cpp', + 'test_bip_buffer_spsc_atomic.cpp', + 'test_bitset.cpp', + 'test_bit_stream.cpp', + 'test_bloom_filter.cpp', + 'test_bresenham_line.cpp', + 'test_bsd_checksum.cpp', + 'test_buffer_descriptors.cpp', + 'test_byte_stream.cpp', + 'test_callback_service.cpp', + 'test_callback_timer.cpp', + 'test_checksum.cpp', + 'test_circular_buffer.cpp', + 'test_circular_buffer_external_buffer.cpp', + 'test_compare.cpp', + 'test_compiler_settings.cpp', + 'test_constant.cpp', + 'test_container.cpp', + 'test_correlation.cpp', + 'test_covariance.cpp', + 'test_crc.cpp', + 'test_crc16.cpp', + 'test_crc16_a.cpp', + 'test_crc16_arc.cpp', + 'test_crc16_aug_ccitt.cpp', + 'test_crc16_buypass.cpp', + 'test_crc16_ccitt.cpp', + 'test_crc16_cdma2000.cpp', + 'test_crc16_dds110.cpp', + 'test_crc16_dectr.cpp', + 'test_crc16_dectx.cpp', + 'test_crc16_dnp.cpp', + 'test_crc16_en13757.cpp', + 'test_crc16_genibus.cpp', + 'test_crc16_kermit.cpp', + 'test_crc16_maxim.cpp', + 'test_crc16_mcrf4xx.cpp', + 'test_crc16_modbus.cpp', + 'test_crc16_profibus.cpp', + 'test_crc16_riello.cpp', + 'test_crc16_t10dif.cpp', + 'test_crc16_teledisk.cpp', + 'test_crc16_tms37157.cpp', + 'test_crc16_usb.cpp', + 'test_crc16_x25.cpp', + 'test_crc16_xmodem.cpp', + 'test_crc32.cpp', + 'test_crc32_bzip2.cpp', + 'test_crc32_c.cpp', + 'test_crc32_d.cpp', + 'test_crc32_jamcrc.cpp', + 'test_crc32_mpeg2.cpp', + 'test_crc32_posix.cpp', + 'test_crc32_q.cpp', + 'test_crc32_xfer.cpp', + 'test_crc64_ecma.cpp', + 'test_crc8_ccitt.cpp', + 'test_crc8_cdma2000.cpp', + 'test_crc8_darc.cpp', + 'test_crc8_dvbs2.cpp', + 'test_crc8_ebu.cpp', + 'test_crc8_icode.cpp', + 'test_crc8_itu.cpp', + 'test_crc8_maxim.cpp', + 'test_crc8_rohc.cpp', + 'test_crc8_wcdma.cpp', + 'test_cumulative_moving_average.cpp', + 'test_cyclic_value.cpp', + 'test_debounce.cpp', + 'test_delegate.cpp', + 'test_delegate_service.cpp', + 'test_delegate_service_compile_time.cpp', + 'test_deque.cpp', + 'test_endian.cpp', + 'test_enum_type.cpp', + 'test_error_handler.cpp', + 'test_exception.cpp', + 'test_fixed_iterator.cpp', + 'test_fixed_sized_memory_block_allocator.cpp', + 'test_flags.cpp', + 'test_flat_map.cpp', + 'test_flat_multimap.cpp', + 'test_flat_multiset.cpp', + 'test_flat_set.cpp', + 'test_fnv_1.cpp', + 'test_format_spec.cpp', + 'test_forward_list.cpp', + 'test_forward_list_shared_pool.cpp', + 'test_fsm.cpp', + 'test_function.cpp', + 'test_functional.cpp', + 'test_gamma.cpp', + 'test_hash.cpp', + 'test_hfsm.cpp', + 'test_histogram.cpp', + 'test_indirect_vector.cpp', + 'test_indirect_vector_external_buffer.cpp', + 'test_instance_count.cpp', + 'test_integral_limits.cpp', + 'test_intrusive_forward_list.cpp', + 'test_intrusive_links.cpp', + 'test_intrusive_list.cpp', + 'test_intrusive_queue.cpp', + 'test_intrusive_stack.cpp', + 'test_invert.cpp', + 'test_io_port.cpp', + 'test_iterator.cpp', + 'test_jenkins.cpp', + 'test_largest.cpp', + 'test_limiter.cpp', + 'test_limits.cpp', + 'test_list.cpp', + 'test_list_shared_pool.cpp', + 'test_make_string.cpp', + 'test_map.cpp', + 'test_maths.cpp', + 'test_mean.cpp', + 'test_memory.cpp', + 'test_mem_cast.cpp', + 'test_mem_cast_ptr.cpp', + #'test_mem_type.cpp', + 'test_message_bus.cpp', + 'test_message_packet.cpp', + 'test_message_router.cpp', + 'test_message_router_registry.cpp', + 'test_message_timer.cpp', + 'test_multimap.cpp', + 'test_multiset.cpp', + 'test_multi_array.cpp', + 'test_multi_range.cpp', + 'test_multi_span.cpp', + 'test_multi_vector.cpp', + 'test_murmur3.cpp', + 'test_numeric.cpp', + 'test_observer.cpp', + 'test_optional.cpp', + 'test_overload.cpp', + 'test_packet.cpp', + 'test_parameter_pack.cpp', + 'test_parameter_type.cpp', + 'test_parity_checksum.cpp', + 'test_pearson.cpp', + 'test_pool.cpp', + 'test_pool_external_buffer.cpp', + 'test_priority_queue.cpp', + 'test_quantize.cpp', + 'test_queue.cpp', + 'test_queue_lockable.cpp', + 'test_queue_lockable_small.cpp', + 'test_queue_memory_model_small.cpp', + 'test_queue_mpmc_mutex.cpp', + 'test_queue_mpmc_mutex_small.cpp', + 'test_queue_spsc_atomic.cpp', + 'test_queue_spsc_atomic_small.cpp', + 'test_queue_spsc_isr.cpp', + 'test_queue_spsc_isr_small.cpp', + 'test_queue_spsc_locked.cpp', + 'test_queue_spsc_locked_small.cpp', + 'test_random.cpp', + 'test_reference_flat_map.cpp', + 'test_reference_flat_multimap.cpp', + 'test_reference_flat_multiset.cpp', + 'test_reference_flat_set.cpp', + 'test_rescale.cpp', + 'test_result.cpp', + 'test_rms.cpp', + 'test_scaled_rounding.cpp', + 'test_set.cpp', + 'test_shared_message.cpp', + 'test_smallest.cpp', + 'test_span.cpp', + 'test_stack.cpp', + 'test_standard_deviation.cpp', + 'test_state_chart.cpp', + 'test_state_chart_with_data_parameter.cpp', + 'test_state_chart_with_rvalue_data_parameter.cpp', + 'test_string_char.cpp', + 'test_string_char_external_buffer.cpp', + 'test_string_stream.cpp', + 'test_string_stream_u16.cpp', + 'test_string_stream_u32.cpp', + 'test_string_stream_wchar_t.cpp', + 'test_string_u16.cpp', + 'test_string_u16_external_buffer.cpp', + 'test_string_u32.cpp', + 'test_string_u32_external_buffer.cpp', + 'test_string_utilities.cpp', + 'test_string_utilities_std.cpp', + 'test_string_utilities_std_u16.cpp', + 'test_string_utilities_std_u32.cpp', + 'test_string_utilities_std_wchar_t.cpp', + 'test_string_utilities_u16.cpp', + 'test_string_utilities_u32.cpp', + 'test_string_utilities_wchar_t.cpp', + 'test_string_view.cpp', + 'test_string_wchar_t.cpp', + 'test_string_wchar_t_external_buffer.cpp', + 'test_task_scheduler.cpp', + 'test_threshold.cpp', + 'test_to_string.cpp', + 'test_to_u16string.cpp', + 'test_to_u32string.cpp', + 'test_to_wstring.cpp', + 'test_type_def.cpp', + 'test_type_lookup.cpp', + 'test_type_select.cpp', + 'test_type_traits.cpp', + 'test_unordered_map.cpp', + 'test_unordered_multimap.cpp', + 'test_unordered_multiset.cpp', + 'test_unordered_set.cpp', + 'test_user_type.cpp', + 'test_utility.cpp', + 'test_variance.cpp', + 'test_variant_legacy.cpp', + 'test_variant_pool.cpp', + 'test_variant_pool_external_buffer.cpp', + 'test_variant_variadic.cpp', + 'test_vector.cpp', + 'test_vector_external_buffer.cpp', + 'test_vector_non_trivial.cpp', + 'test_vector_pointer.cpp', + 'test_vector_pointer_external_buffer.cpp', + 'test_visitor.cpp', + 'test_xor_checksum.cpp', + 'test_xor_rotate_checksum.cpp', +) + +compile_args = [ + '-DENABLE_ETL_UNIT_TESTS', + '-DETL_DEBUG', +] + +if get_option('use_stl') + compile_args += '-DETL_NO_STL=0' +elif + compile_args += '-DETL_NO_STL=1' +endif + +if meson.get_compiler('cpp').get_id() == 'gcc' + etl_test_sources += files('test/test_atomic_gcc_sync.cpp') + compile_args += '-fexceptions' +endif + +threads_dep = dependency('threads') +unittestcpp_dep = subproject('unittest-cpp').get_variable('unittest_cpp_dep') + +etl_unit_tests = executable('etl_unit_tests', + include_directories: [ + include_directories('.'), + ], + sources: etl_test_sources, + dependencies: [etl_dep, unittestcpp_dep, threads_dep], + cpp_args: compile_args, +)