From a1f18d59570416730a83764a48a7c54e0bfea6b7 Mon Sep 17 00:00:00 2001 From: Elliot Date: Sun, 9 Nov 2025 22:40:34 -0500 Subject: [PATCH] aws-c-compression: add 0.3.1 --- releases.json | 11 ++ subprojects/aws-c-compression.wrap | 10 ++ .../aws-c-compression/generate_tests.py | 18 +++ .../aws-c-compression/include/meson.build | 6 + .../aws-c-compression/meson.build | 114 ++++++++++++++++++ .../aws-c-compression/meson_options.txt | 5 + .../aws-c-compression/run_test.py | 14 +++ .../packagefiles/aws-c-compression/tests.txt | 16 +++ tools/sanity_checks.py | 5 + 9 files changed, 199 insertions(+) create mode 100644 subprojects/aws-c-compression.wrap create mode 100644 subprojects/packagefiles/aws-c-compression/generate_tests.py create mode 100644 subprojects/packagefiles/aws-c-compression/include/meson.build create mode 100644 subprojects/packagefiles/aws-c-compression/meson.build create mode 100644 subprojects/packagefiles/aws-c-compression/meson_options.txt create mode 100644 subprojects/packagefiles/aws-c-compression/run_test.py create mode 100644 subprojects/packagefiles/aws-c-compression/tests.txt diff --git a/releases.json b/releases.json index 9800e512f..482e6e30d 100644 --- a/releases.json +++ b/releases.json @@ -252,6 +252,17 @@ "0.12.4-1" ] }, + "aws-c-compression": { + "dependency_names": [ + "aws-c-compression" + ], + "program_names": [ + "aws-c-common-huffman-generator" + ], + "versions": [ + "0.3.1-1" + ] + }, "backward-cpp": { "dependency_names": [ "backward-cpp", diff --git a/subprojects/aws-c-compression.wrap b/subprojects/aws-c-compression.wrap new file mode 100644 index 000000000..048fa3466 --- /dev/null +++ b/subprojects/aws-c-compression.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory = aws-c-compression-0.3.1 +source_url = https://github.com/awslabs/aws-c-compression/archive/refs/tags/v0.3.1.tar.gz +source_filename = aws-c-compression-0.3.1.tar.gz +source_hash = d89fca17a37de762dc34f332d2da402343078da8dbd2224c46a11a88adddf754 +patch_directory = aws-c-compression + +[provide] +dependency_names = aws-c-compression +program_names = aws-c-common-huffman-generator diff --git a/subprojects/packagefiles/aws-c-compression/generate_tests.py b/subprojects/packagefiles/aws-c-compression/generate_tests.py new file mode 100644 index 000000000..b6816209f --- /dev/null +++ b/subprojects/packagefiles/aws-c-compression/generate_tests.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import sys + +# Usage: generate_tests.py +if __name__ == '__main__': + with open(sys.argv[1], 'r') as test_names: + tests = [line.strip() for line in test_names if line.strip()] + with open(sys.argv[2], 'w') as out: + out.write('/* Auto-generated file, do not edit */\n\n#include \n\n') + for name in tests: + out.write(f'extern int {name}(int argc, char **argv);\n') + out.write('\n') + out.write('int main(int argc, char **argv) {\n') + for name in tests: + out.write(f' if (strcmp(argv[1], "{name}") == 0) return {name}(argc, argv);\n') + out.write(' return 0;\n') + out.write('}\n') diff --git a/subprojects/packagefiles/aws-c-compression/include/meson.build b/subprojects/packagefiles/aws-c-compression/include/meson.build new file mode 100644 index 000000000..3f13c9220 --- /dev/null +++ b/subprojects/packagefiles/aws-c-compression/include/meson.build @@ -0,0 +1,6 @@ +install_headers( + 'aws/compression/compression.h', + 'aws/compression/exports.h', + 'aws/compression/huffman.h', + preserve_path: true, +) diff --git a/subprojects/packagefiles/aws-c-compression/meson.build b/subprojects/packagefiles/aws-c-compression/meson.build new file mode 100644 index 000000000..90520efa8 --- /dev/null +++ b/subprojects/packagefiles/aws-c-compression/meson.build @@ -0,0 +1,114 @@ +project( + 'aws-c-compression', + 'c', + version: '0.3.1', + meson_version: '>=0.63.0', + license: 'Apache-2.0', +) + +pkg = import('pkgconfig') +fs = import('fs') + +tests_opt = get_option('tests').disable_auto_if(meson.is_subproject()) + +public_c_args = ['-DAWS_COMPRESSION_USE_IMPORT_EXPORT=1'] +c_args = ['-DAWS_COMPRESSION_EXPORTS=1'] + +if host_machine.system() == 'windows' + public_c_args += ['-DUSE_WINDOWS_DLL_SEMANTICS=1'] +endif + +aws_c_common_dep = dependency('aws-c-common') + +src = files('source/compression.c', 'source/huffman.c') + +inc = include_directories('include') + +libaws_c_compression = library( + 'aws-c-compression', + src, + c_args: c_args + public_c_args, + dependencies: aws_c_common_dep, + include_directories: inc, + install: true, + gnu_symbol_visibility: 'hidden', +) + +aws_c_compression_dep = declare_dependency( + link_with: libaws_c_compression, + dependencies: aws_c_common_dep, + include_directories: inc, + compile_args: public_c_args, +) + +meson.override_dependency('aws-c-compression', aws_c_compression_dep) + +pkg.generate( + libaws_c_compression, + extra_cflags: public_c_args, + description: 'C99 implementation of huffman encoding/decoding', +) + +subdir('include') + +huffman_generator_src = files('source/huffman_generator/generator.c') + +huffman_generator = executable( + 'aws-c-common-huffman-generator', + huffman_generator_src, + install: true, +) + +meson.override_find_program('aws-c-common-huffman-generator', huffman_generator) + +generate_tests = find_program( + 'generate_tests.py', + required: tests_opt, +) +run_test = find_program( + 'run_test.py', + required: tests_opt, +) +if generate_tests.found() and run_test.found() + test_src = files( + 'source/huffman_testing.c', + 'tests/huffman_test.c', + 'tests/library_test.c', + 'tests/test_huffman_static.c', + ) + + libtestcases = static_library( + 'aws_c_compression_testcases', + test_src, + dependencies: [aws_c_compression_dep], + include_directories: inc, + build_by_default: false, + ) + + test_harness_src = custom_target( + 'generate_test_harness', + input: 'tests.txt', + output: 'test_harness.c', + command: [generate_tests, '@INPUT@', '@OUTPUT@'], + ) + + test_harness = executable( + 'aws-c-compression-tests', + test_harness_src, + dependencies: [aws_c_compression_dep], + link_with: [libtestcases], + include_directories: inc, + build_by_default: false, + ) + + names = fs.read('tests.txt').split('\n') + + foreach name : names + test( + name, + run_test, + args: [test_harness, name], + timeout: 600, + ) + endforeach +endif diff --git a/subprojects/packagefiles/aws-c-compression/meson_options.txt b/subprojects/packagefiles/aws-c-compression/meson_options.txt new file mode 100644 index 000000000..e05afdd26 --- /dev/null +++ b/subprojects/packagefiles/aws-c-compression/meson_options.txt @@ -0,0 +1,5 @@ +option( + 'tests', + type: 'feature', + description: 'Build tests', +) diff --git a/subprojects/packagefiles/aws-c-compression/run_test.py b/subprojects/packagefiles/aws-c-compression/run_test.py new file mode 100644 index 000000000..551506fb0 --- /dev/null +++ b/subprojects/packagefiles/aws-c-compression/run_test.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +import sys + +# Usage: run_test.py [args...] +if __name__ == '__main__': + test_exe = sys.argv[1] + test_args = sys.argv[2:] + import subprocess + result = subprocess.run([test_exe] + test_args) + exitcode = result.returncode + if exitcode == 103: + exitcode = 77 # Skip code for meson + sys.exit(exitcode) diff --git a/subprojects/packagefiles/aws-c-compression/tests.txt b/subprojects/packagefiles/aws-c-compression/tests.txt new file mode 100644 index 000000000..016ecaeb1 --- /dev/null +++ b/subprojects/packagefiles/aws-c-compression/tests.txt @@ -0,0 +1,16 @@ +library_init +huffman_symbol_encoder +huffman_encoder +huffman_encoder_all_code_points +huffman_encoder_partial_output +huffman_encoder_exact_output +huffman_symbol_decoder +huffman_decoder +huffman_decoder_all_code_points +huffman_decoder_partial_input +huffman_decoder_partial_output +huffman_decoder_allow_growth +huffman_transitive +huffman_transitive_even_bytes +huffman_transitive_all_code_points +huffman_transitive_chunked \ No newline at end of file diff --git a/tools/sanity_checks.py b/tools/sanity_checks.py index c5414d63b..b2f34639a 100755 --- a/tools/sanity_checks.py +++ b/tools/sanity_checks.py @@ -39,6 +39,11 @@ 'generate_tests.py', 'run_test.py', }, + 'aws-c-compression': { + 'tests.txt', + 'generate_tests.py', + 'run_test.py', + }, 'box2d': { 'doctest.h' },