diff --git a/releases.json b/releases.json index b27a635ac..01323334b 100644 --- a/releases.json +++ b/releases.json @@ -1381,6 +1381,14 @@ "1.83.1-1" ] }, + "lexy": { + "dependency_names": [ + "lexy" + ], + "versions": [ + "2022.12.1-1" + ] + }, "libarchive": { "dependency_names": [ "libarchive" diff --git a/subprojects/lexy.wrap b/subprojects/lexy.wrap new file mode 100644 index 000000000..c6ac01012 --- /dev/null +++ b/subprojects/lexy.wrap @@ -0,0 +1,9 @@ +[wrap-file] +directory = lexy-2022.12.1 +source_url = https://github.com/foonathan/lexy/archive/refs/tags/v2022.12.1.tar.gz +source_filename = lexy-2022.12.1.tar.gz +source_hash = 97de4324254ad235296a9161d6332200387981671411a6443aadd2b3265122f9 +patch_directory = lexy + +[provide] +lexy = lexy_dep diff --git a/subprojects/packagefiles/lexy/benchmarks/file/meson.build b/subprojects/packagefiles/lexy/benchmarks/file/meson.build new file mode 100644 index 000000000..5c3a66ffb --- /dev/null +++ b/subprojects/packagefiles/lexy/benchmarks/file/meson.build @@ -0,0 +1,2 @@ +file_benchmark = executable('file', files('main.cpp'), dependencies: benchmarks_deps) +benchmark('file_benchmark', file_benchmark) diff --git a/subprojects/packagefiles/lexy/benchmarks/json/meson.build b/subprojects/packagefiles/lexy/benchmarks/json/meson.build new file mode 100644 index 000000000..6a8e837fc --- /dev/null +++ b/subprojects/packagefiles/lexy/benchmarks/json/meson.build @@ -0,0 +1,74 @@ + + + +fetch_targets = [] + +data = [ + ['canada.json', 'https://github.com/miloyip/nativejson-benchmark/raw/master/data/canada.json'], + [ + 'citm_catalog.json', + 'https://github.com/miloyip/nativejson-benchmark/raw/master/data/citm_catalog.json', + ], + [ + 'twitter.json', + 'https://raw.githubusercontent.com/miloyip/nativejson-benchmark/master/data/twitter.json', + ], +] + +foreach d : data + + name = d[0] + url = d[1] + + curl = find_program('curl', required: false) + + if curl.found() + + fetch_targets += custom_target( + 'fetch_' + name, + output: name, + command: [curl, url, '-o', '@OUTPUT@'], + ) + + else + wget = find_program('wget') + + fetch_targets += custom_target( + 'fetch_' + name, + output: name, + command: [wget, url, '-O', '@OUTPUT@'], + ) + + endif + + +endforeach + + + +benchmark_files = files('baseline.cpp', 'lexy.cpp', 'main.cpp') + +pegtl_dep = dependency('PEGTL', required: false) +if pegtl_dep.found() + benchmark_files += files('pegtl.cpp') +endif + +json_dep = dependency('nlohmann_json', required: false) +if json_dep.found() + benchmark_files += files('nlohmann.cpp') +endif + +rapidjson_dep = dependency('rapidjson', required: false) +if rapidjson_dep.found() + benchmark_files += files('rapidjson.cpp') +endif + +# in the original also Boost.JSON is downloaded an used to compare it, that isn't done here + +json_benchmark = executable( + 'json', + benchmark_files, + dependencies: [benchmarks_deps, fetch_targets], + cpp_args: ['-DLEXY_BENCHMARK_DATA=' + meson.current_build_dir()], +) +benchmark('json_benchmark', json_benchmark) diff --git a/subprojects/packagefiles/lexy/benchmarks/meson.build b/subprojects/packagefiles/lexy/benchmarks/meson.build new file mode 100644 index 000000000..7fb8c3f62 --- /dev/null +++ b/subprojects/packagefiles/lexy/benchmarks/meson.build @@ -0,0 +1,8 @@ + +benchmarks_deps = [lexy_dep] +benchmarks_deps += dependency('nanobench') + + +subdir('file') +subdir('json') +subdir('swar') diff --git a/subprojects/packagefiles/lexy/benchmarks/swar/meson.build b/subprojects/packagefiles/lexy/benchmarks/swar/meson.build new file mode 100644 index 000000000..a82602626 --- /dev/null +++ b/subprojects/packagefiles/lexy/benchmarks/swar/meson.build @@ -0,0 +1,15 @@ +swar_benchmark = executable( + 'swar', + files( + 'any.cpp', + 'delimited.cpp', + 'digits.cpp', + 'identifier.cpp', + 'literal.cpp', + 'main.cpp', + 'swar.hpp', + 'until.cpp', + ), + dependencies: benchmarks_deps, +) +benchmark('swar_benchmark', swar_benchmark) diff --git a/subprojects/packagefiles/lexy/include/lexy/meson.build b/subprojects/packagefiles/lexy/include/lexy/meson.build new file mode 100644 index 000000000..f455c3fa1 --- /dev/null +++ b/subprojects/packagefiles/lexy/include/lexy/meson.build @@ -0,0 +1,113 @@ + +header_files += files( + '_detail/any_ref.hpp', + '_detail/assert.hpp', + '_detail/buffer_builder.hpp', + '_detail/code_point.hpp', + '_detail/config.hpp', + '_detail/detect.hpp', + '_detail/integer_sequence.hpp', + '_detail/invoke.hpp', + '_detail/iterator.hpp', + '_detail/lazy_init.hpp', + '_detail/memory_resource.hpp', + '_detail/nttp_string.hpp', + '_detail/stateless_lambda.hpp', + '_detail/std.hpp', + '_detail/string_view.hpp', + '_detail/swar.hpp', + '_detail/tuple.hpp', + '_detail/type_name.hpp', + 'action/base.hpp', + 'action/match.hpp', + 'action/parse.hpp', + 'action/parse_as_tree.hpp', + 'action/scan.hpp', + 'action/validate.hpp', + 'callback/adapter.hpp', + 'callback/aggregate.hpp', + 'callback/base.hpp', + 'callback/bind.hpp', + 'callback/bit_cast.hpp', + 'callback/composition.hpp', + 'callback/constant.hpp', + 'callback/container.hpp', + 'callback/fold.hpp', + 'callback/forward.hpp', + 'callback/integer.hpp', + 'callback/noop.hpp', + 'callback/object.hpp', + 'callback/string.hpp', + 'dsl/any.hpp', + 'dsl/ascii.hpp', + 'dsl/base.hpp', + 'dsl/bits.hpp', + 'dsl/bom.hpp', + 'dsl/brackets.hpp', + 'dsl/branch.hpp', + 'dsl/byte.hpp', + 'dsl/capture.hpp', + 'dsl/case_folding.hpp', + 'dsl/char_class.hpp', + 'dsl/choice.hpp', + 'dsl/code_point.hpp', + 'dsl/combination.hpp', + 'dsl/context_counter.hpp', + 'dsl/context_flag.hpp', + 'dsl/context_identifier.hpp', + 'dsl/delimited.hpp', + 'dsl/digit.hpp', + 'dsl/effect.hpp', + 'dsl/eof.hpp', + 'dsl/error.hpp', + 'dsl/expression.hpp', + 'dsl/flags.hpp', + 'dsl/follow.hpp', + 'dsl/identifier.hpp', + 'dsl/if.hpp', + 'dsl/integer.hpp', + 'dsl/lookahead.hpp', + 'dsl/loop.hpp', + 'dsl/member.hpp', + 'dsl/newline.hpp', + 'dsl/operator.hpp', + 'dsl/option.hpp', + 'dsl/parse_as.hpp', + 'dsl/peek.hpp', + 'dsl/position.hpp', + 'dsl/production.hpp', + 'dsl/punctuator.hpp', + 'dsl/recover.hpp', + 'dsl/repeat.hpp', + 'dsl/return.hpp', + 'dsl/scan.hpp', + 'dsl/separator.hpp', + 'dsl/sequence.hpp', + 'dsl/sign.hpp', + 'dsl/subgrammar.hpp', + 'dsl/symbol.hpp', + 'dsl/terminator.hpp', + 'dsl/times.hpp', + 'dsl/token.hpp', + 'dsl/unicode.hpp', + 'dsl/until.hpp', + 'dsl/whitespace.hpp', + 'input/argv_input.hpp', + 'input/base.hpp', + 'input/buffer.hpp', + 'input/file.hpp', + 'input/lexeme_input.hpp', + 'input/range_input.hpp', + 'input/string_input.hpp', + 'callback.hpp', + 'code_point.hpp', + 'dsl.hpp', + 'encoding.hpp', + 'error.hpp', + 'grammar.hpp', + 'input_location.hpp', + 'lexeme.hpp', + 'parse_tree.hpp', + 'token.hpp', + 'visualize.hpp', +) diff --git a/subprojects/packagefiles/lexy/include/lexy_ext/meson.build b/subprojects/packagefiles/lexy/include/lexy_ext/meson.build new file mode 100644 index 000000000..92f22e7b1 --- /dev/null +++ b/subprojects/packagefiles/lexy/include/lexy_ext/meson.build @@ -0,0 +1,7 @@ +ext_header_files += files( + 'compiler_explorer.hpp', + 'parse_tree_algorithm.hpp', + 'parse_tree_doctest.hpp', + 'report_error.hpp', + 'shell.hpp', +) diff --git a/subprojects/packagefiles/lexy/include/meson.build b/subprojects/packagefiles/lexy/include/meson.build new file mode 100644 index 000000000..fa3968285 --- /dev/null +++ b/subprojects/packagefiles/lexy/include/meson.build @@ -0,0 +1,21 @@ +inc_dirs += include_directories('.') + + +header_files = [] +subdir('lexy') + +ext_header_files = [] +subdir('lexy_ext') + +if install + install_headers( + header_files, + subdir: 'lexy', + preserve_path: true, + ) + install_headers( + ext_header_files, + subdir: 'lexy_ext', + preserve_path: true, + ) +endif diff --git a/subprojects/packagefiles/lexy/meson.build b/subprojects/packagefiles/lexy/meson.build new file mode 100644 index 000000000..4cc9aeff3 --- /dev/null +++ b/subprojects/packagefiles/lexy/meson.build @@ -0,0 +1,81 @@ +project( + 'lexy', + 'cpp', + default_options: {'default_library': 'static'}, + version: '2022.12.1', + license: 'BSL-1.0', + meson_version: '>=1.2.0', +) + +inc_dirs = [] +compile_args = [] +override_options = [] + +install = get_option('install') + +cpp = meson.get_compiler('cpp') +is_in_cpp20_mode = cpp.compiles( + ''' +#if defined(__cplusplus) && (__cplusplus >= 202002L || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)) +#else +#error is not in cpp 20 mode +#endif +''', +) +is_in_cpp17_mode = cpp.compiles( + ''' +#if defined(__cplusplus) && (__cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) +#else +#error is not in cpp 17 mode +#endif +''', +) + +if not is_in_cpp17_mode + error('at least c++17 is required to build this package') +endif + +if get_option('use_cpp17').enabled() + + override_options += 'cpp_std=c++17' + +elif get_option('use_cpp17').disabled() + + if not is_in_cpp20_mode + error( + 'at least c++20 is required to build this package, you explicitely disabled c++17 support', + ) + endif + + override_options += 'cpp_std=c++20' + +else + if not is_in_cpp20_mode + override_options += 'cpp_std=c++17' + else + override_options += 'cpp_std=c++20' + endif +endif + +subdir('include') +subdir('src') + + +lexy_dep = declare_dependency( + include_directories: inc_dirs, + version: meson.project_version(), + link_with: lexy_lib, + compile_args: compile_args, +) + +if get_option('build_examples') + subdir('examples') +endif + +if get_option('build_benchmarks') + subdir('benchmarks') +endif + +if get_option('tests') + subdir('tests') +endif diff --git a/subprojects/packagefiles/lexy/meson_options.txt b/subprojects/packagefiles/lexy/meson_options.txt new file mode 100644 index 000000000..be2e86cf6 --- /dev/null +++ b/subprojects/packagefiles/lexy/meson_options.txt @@ -0,0 +1,37 @@ + +option( + 'build_examples', + type: 'boolean', + value: false, + description: 'whether or not examples should be built', +) +option( + 'build_benchmarks', + type: 'boolean', + value: false, + description: 'whether or not benchmarks should be built', +) +option( + 'tests', + type: 'boolean', + value: true, + description: 'whether or not tests should be built', +) +option( + 'user_config_header', + type: 'string', + value: '', + description: 'set the name of the user config header', +) +option( + 'use_cpp17', + type: 'feature', + value: 'auto', + description: 'use c++17 standard instead of c++20', +) +option( + 'install', + type: 'boolean', + value: false, + description: 'Create installation target', +) diff --git a/subprojects/packagefiles/lexy/src/meson.build b/subprojects/packagefiles/lexy/src/meson.build new file mode 100644 index 000000000..455d76d12 --- /dev/null +++ b/subprojects/packagefiles/lexy/src/meson.build @@ -0,0 +1,25 @@ + + +if get_option('user_config_header') != '' + compile_args += ('-DLEXY_USER_CONFIG_HEADER=' + get_option('user_config_header')) +endif + + +# Link to have FILE I/O. this is only designed to be a static library, since it's very small by design! +lexy_file_lib = static_library( + 'lexy_file', + files('input' / 'file.cpp'), + include_directories: inc_dirs, +) + +compile_args += '-DLEXY_HAS_UNICODE_DATABASE=1' + +lexy_lib = library( + 'lexy', + header_files, + ext_header_files, + install: install, + cpp_args: compile_args, + link_with: [lexy_file_lib], + override_options: override_options, +) diff --git a/subprojects/packagefiles/lexy/tests/examples/meson.build b/subprojects/packagefiles/lexy/tests/examples/meson.build new file mode 100644 index 000000000..d168c191f --- /dev/null +++ b/subprojects/packagefiles/lexy/tests/examples/meson.build @@ -0,0 +1,12 @@ + +tests += [ + ## note: this test is not inlcuded in the upstream repo Cmake defintions, therefore it wasn't maintained and fails + # ['calculator', files('calculator.cpp')], + ['email', files('email.cpp')], + ['ip_address', files('ip_address.cpp')], + ['json', files('json.cpp')], + ['protobuf', files('protobuf.cpp')], + ['shell', files('shell.cpp')], + ['xml', files('xml.cpp')], + ['turing', files('turing.cpp')], +] diff --git a/subprojects/packagefiles/lexy/tests/lexy/meson.build b/subprojects/packagefiles/lexy/tests/lexy/meson.build new file mode 100644 index 000000000..74b3bf87d --- /dev/null +++ b/subprojects/packagefiles/lexy/tests/lexy/meson.build @@ -0,0 +1,119 @@ + +tests += [ + [ + 'all', + files( + 'action/base.cpp', + 'action/match.cpp', + 'action/parse.cpp', + 'action/parse_as_tree.cpp', + 'action/scan.cpp', + 'action/trace.cpp', + 'action/validate.cpp', + 'callback/adapter.cpp', + 'callback/aggregate.cpp', + 'callback/base.cpp', + 'callback/bind.cpp', + 'callback/bit_cast.cpp', + 'callback/composition.cpp', + 'callback/constant.cpp', + 'callback/container.cpp', + 'callback/fold.cpp', + 'callback/forward.cpp', + 'callback/integer.cpp', + 'callback/noop.cpp', + 'callback/object.cpp', + 'callback/string.cpp', + 'detail/any_ref.cpp', + 'detail/buffer_builder.cpp', + 'detail/integer_sequence.cpp', + 'detail/invoke.cpp', + 'detail/lazy_init.cpp', + 'detail/nttp_string.cpp', + 'detail/stateless_lambda.cpp', + 'detail/std.cpp', + 'detail/string_view.cpp', + 'detail/swar.cpp', + 'detail/tuple.cpp', + 'detail/type_name.cpp', + 'dsl/any.cpp', + 'dsl/argv_input.cpp', + 'dsl/ascii.cpp', + 'dsl/base.cpp', + 'dsl/bits.cpp', + 'dsl/bom.cpp', + 'dsl/brackets.cpp', + 'dsl/branch.cpp', + 'dsl/byte.cpp', + 'dsl/capture.cpp', + 'dsl/case_folding.cpp', + 'dsl/char_class.cpp', + 'dsl/choice.cpp', + 'dsl/code_point.cpp', + 'dsl/combination.cpp', + 'dsl/context_counter.cpp', + 'dsl/context_flag.cpp', + 'dsl/context_identifier.cpp', + 'dsl/delimited.cpp', + 'dsl/digit.cpp', + 'dsl/effect.cpp', + 'dsl/eof.cpp', + 'dsl/error.cpp', + 'dsl/expression.cpp', + 'dsl/flags.cpp', + 'dsl/follow.cpp', + 'dsl/identifier.cpp', + 'dsl/if.cpp', + 'dsl/integer.cpp', + 'dsl/list.cpp', + 'dsl/literal.cpp', + 'dsl/lookahead.cpp', + 'dsl/loop.cpp', + 'dsl/member.cpp', + 'dsl/newline.cpp', + 'dsl/operator.cpp', + 'dsl/option.cpp', + 'dsl/parse_as.cpp', + 'dsl/peek.cpp', + 'dsl/position.cpp', + 'dsl/production.cpp', + 'dsl/punctuator.cpp', + 'dsl/recover.cpp', + 'dsl/repeat.cpp', + 'dsl/return.cpp', + 'dsl/scan.cpp', + 'dsl/separator.cpp', + 'dsl/sequence.cpp', + 'dsl/sign.cpp', + 'dsl/subgrammar.cpp', + 'dsl/subgrammar_other.cpp', + 'dsl/symbol.cpp', + 'dsl/terminator.cpp', + 'dsl/times.cpp', + 'dsl/token.cpp', + 'dsl/trace.cpp', + 'dsl/unicode.cpp', + 'dsl/until.cpp', + 'dsl/verify.hpp', + 'dsl/whitespace.cpp', + 'input/argv_input.cpp', + 'input/base.cpp', + 'input/buffer.cpp', + 'input/file.cpp', + 'input/lexeme_input.cpp', + 'input/range_input.cpp', + 'input/string_input.cpp', + 'callback.cpp', + 'code_point.cpp', + 'encoding.cpp', + 'error.cpp', + 'grammar.cpp', + 'input_location.cpp', + 'lexeme.cpp', + 'parse_tree.cpp', + 'token.cpp', + 'visualize.cpp', + + ), + ], +] diff --git a/subprojects/packagefiles/lexy/tests/lexy_ext/meson.build b/subprojects/packagefiles/lexy/tests/lexy_ext/meson.build new file mode 100644 index 000000000..87a2dce2a --- /dev/null +++ b/subprojects/packagefiles/lexy/tests/lexy_ext/meson.build @@ -0,0 +1,13 @@ + +tests += [ + [ + 'ext', + files( + 'compiler_explorer.cpp', + 'parse_tree_algorithm.cpp', + 'parse_tree_doctest.cpp', + 'report_error.cpp', + 'shell.cpp', + ), + ], +] diff --git a/subprojects/packagefiles/lexy/tests/meson.build b/subprojects/packagefiles/lexy/tests/meson.build new file mode 100644 index 000000000..4e8d12a26 --- /dev/null +++ b/subprojects/packagefiles/lexy/tests/meson.build @@ -0,0 +1,45 @@ + + +test_dependencies = [dependency('doctest')] + + +test_src = files('doctest_main.cpp') + +test_dependencies += lexy_dep + +test_flags = ['-DLEXY_TEST'] + + +if (cpp.get_id() == 'msvc') + test_flags += ['/Zc:preprocessor', '/utf-8', '/bigobj'] +endif + +tests = [] + +# Add the individual tests. +subdir('lexy') +subdir('lexy_ext') +subdir('examples') +# note: not inlcuded, since heavy cmake (dark) magic is invloved here and this generates many files! +# subdir('playground') + +foreach test : tests + name = test[0] + files = test[1] + + text_exe = executable( + 'lexy_test_' + name, + files, + test_src, + dependencies: test_dependencies, + override_options: override_options, + cpp_args: test_flags, + ) + + test('lexy_test_' + name, text_exe, is_parallel: true) +endforeach + + + + +