Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions subprojects/aws-c-compression.wrap
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions subprojects/packagefiles/aws-c-compression/generate_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python3

import sys

# Usage: generate_tests.py <input test names file> <output C file>
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 <string.h>\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')
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
install_headers(
'aws/compression/compression.h',
'aws/compression/exports.h',
'aws/compression/huffman.h',
preserve_path: true,
)
114 changes: 114 additions & 0 deletions subprojects/packagefiles/aws-c-compression/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
project(
'aws-c-compression',
'c',
version: '0.3.1',
meson_version: '>=0.63.0',

Check notice on line 5 in subprojects/packagefiles/aws-c-compression/meson.build

View workflow job for this annotation

GitHub Actions / Ubuntu (x86_64)

Minimum Meson version is 0.63.0

0.42.0: extra_cflags arg in pkgconfig.generate 0.46.0: meson.override_find_program, pkgconfig.generate optional positional argument 0.47.0: User option "feature" 0.48.0: gnu_symbol_visibility arg in library 0.53.0: module fs 0.54.0: meson.override_dependency 0.59.0: feature_option.disable_auto_if() 0.63.0: preserve_path arg in install_headers
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
5 changes: 5 additions & 0 deletions subprojects/packagefiles/aws-c-compression/meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
option(
'tests',
type: 'feature',
description: 'Build tests',
)
14 changes: 14 additions & 0 deletions subprojects/packagefiles/aws-c-compression/run_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python3

import sys

# Usage: run_test.py <test exe> [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)
16 changes: 16 additions & 0 deletions subprojects/packagefiles/aws-c-compression/tests.txt
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions tools/sanity_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
'generate_tests.py',
'run_test.py',
},
'aws-c-compression': {
'tests.txt',
'generate_tests.py',
'run_test.py',
},
'box2d': {
'doctest.h'
},
Expand Down