Skip to content

Commit a1f18d5

Browse files
committed
aws-c-compression: add 0.3.1
1 parent d4c1f59 commit a1f18d5

File tree

9 files changed

+199
-0
lines changed

9 files changed

+199
-0
lines changed

releases.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,17 @@
252252
"0.12.4-1"
253253
]
254254
},
255+
"aws-c-compression": {
256+
"dependency_names": [
257+
"aws-c-compression"
258+
],
259+
"program_names": [
260+
"aws-c-common-huffman-generator"
261+
],
262+
"versions": [
263+
"0.3.1-1"
264+
]
265+
},
255266
"backward-cpp": {
256267
"dependency_names": [
257268
"backward-cpp",

subprojects/aws-c-compression.wrap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[wrap-file]
2+
directory = aws-c-compression-0.3.1
3+
source_url = https://github.com/awslabs/aws-c-compression/archive/refs/tags/v0.3.1.tar.gz
4+
source_filename = aws-c-compression-0.3.1.tar.gz
5+
source_hash = d89fca17a37de762dc34f332d2da402343078da8dbd2224c46a11a88adddf754
6+
patch_directory = aws-c-compression
7+
8+
[provide]
9+
dependency_names = aws-c-compression
10+
program_names = aws-c-common-huffman-generator
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
5+
# Usage: generate_tests.py <input test names file> <output C file>
6+
if __name__ == '__main__':
7+
with open(sys.argv[1], 'r') as test_names:
8+
tests = [line.strip() for line in test_names if line.strip()]
9+
with open(sys.argv[2], 'w') as out:
10+
out.write('/* Auto-generated file, do not edit */\n\n#include <string.h>\n\n')
11+
for name in tests:
12+
out.write(f'extern int {name}(int argc, char **argv);\n')
13+
out.write('\n')
14+
out.write('int main(int argc, char **argv) {\n')
15+
for name in tests:
16+
out.write(f' if (strcmp(argv[1], "{name}") == 0) return {name}(argc, argv);\n')
17+
out.write(' return 0;\n')
18+
out.write('}\n')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
install_headers(
2+
'aws/compression/compression.h',
3+
'aws/compression/exports.h',
4+
'aws/compression/huffman.h',
5+
preserve_path: true,
6+
)
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
project(
2+
'aws-c-compression',
3+
'c',
4+
version: '0.3.1',
5+
meson_version: '>=0.63.0',
6+
license: 'Apache-2.0',
7+
)
8+
9+
pkg = import('pkgconfig')
10+
fs = import('fs')
11+
12+
tests_opt = get_option('tests').disable_auto_if(meson.is_subproject())
13+
14+
public_c_args = ['-DAWS_COMPRESSION_USE_IMPORT_EXPORT=1']
15+
c_args = ['-DAWS_COMPRESSION_EXPORTS=1']
16+
17+
if host_machine.system() == 'windows'
18+
public_c_args += ['-DUSE_WINDOWS_DLL_SEMANTICS=1']
19+
endif
20+
21+
aws_c_common_dep = dependency('aws-c-common')
22+
23+
src = files('source/compression.c', 'source/huffman.c')
24+
25+
inc = include_directories('include')
26+
27+
libaws_c_compression = library(
28+
'aws-c-compression',
29+
src,
30+
c_args: c_args + public_c_args,
31+
dependencies: aws_c_common_dep,
32+
include_directories: inc,
33+
install: true,
34+
gnu_symbol_visibility: 'hidden',
35+
)
36+
37+
aws_c_compression_dep = declare_dependency(
38+
link_with: libaws_c_compression,
39+
dependencies: aws_c_common_dep,
40+
include_directories: inc,
41+
compile_args: public_c_args,
42+
)
43+
44+
meson.override_dependency('aws-c-compression', aws_c_compression_dep)
45+
46+
pkg.generate(
47+
libaws_c_compression,
48+
extra_cflags: public_c_args,
49+
description: 'C99 implementation of huffman encoding/decoding',
50+
)
51+
52+
subdir('include')
53+
54+
huffman_generator_src = files('source/huffman_generator/generator.c')
55+
56+
huffman_generator = executable(
57+
'aws-c-common-huffman-generator',
58+
huffman_generator_src,
59+
install: true,
60+
)
61+
62+
meson.override_find_program('aws-c-common-huffman-generator', huffman_generator)
63+
64+
generate_tests = find_program(
65+
'generate_tests.py',
66+
required: tests_opt,
67+
)
68+
run_test = find_program(
69+
'run_test.py',
70+
required: tests_opt,
71+
)
72+
if generate_tests.found() and run_test.found()
73+
test_src = files(
74+
'source/huffman_testing.c',
75+
'tests/huffman_test.c',
76+
'tests/library_test.c',
77+
'tests/test_huffman_static.c',
78+
)
79+
80+
libtestcases = static_library(
81+
'aws_c_compression_testcases',
82+
test_src,
83+
dependencies: [aws_c_compression_dep],
84+
include_directories: inc,
85+
build_by_default: false,
86+
)
87+
88+
test_harness_src = custom_target(
89+
'generate_test_harness',
90+
input: 'tests.txt',
91+
output: 'test_harness.c',
92+
command: [generate_tests, '@INPUT@', '@OUTPUT@'],
93+
)
94+
95+
test_harness = executable(
96+
'aws-c-compression-tests',
97+
test_harness_src,
98+
dependencies: [aws_c_compression_dep],
99+
link_with: [libtestcases],
100+
include_directories: inc,
101+
build_by_default: false,
102+
)
103+
104+
names = fs.read('tests.txt').split('\n')
105+
106+
foreach name : names
107+
test(
108+
name,
109+
run_test,
110+
args: [test_harness, name],
111+
timeout: 600,
112+
)
113+
endforeach
114+
endif
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
option(
2+
'tests',
3+
type: 'feature',
4+
description: 'Build tests',
5+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
5+
# Usage: run_test.py <test exe> [args...]
6+
if __name__ == '__main__':
7+
test_exe = sys.argv[1]
8+
test_args = sys.argv[2:]
9+
import subprocess
10+
result = subprocess.run([test_exe] + test_args)
11+
exitcode = result.returncode
12+
if exitcode == 103:
13+
exitcode = 77 # Skip code for meson
14+
sys.exit(exitcode)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
library_init
2+
huffman_symbol_encoder
3+
huffman_encoder
4+
huffman_encoder_all_code_points
5+
huffman_encoder_partial_output
6+
huffman_encoder_exact_output
7+
huffman_symbol_decoder
8+
huffman_decoder
9+
huffman_decoder_all_code_points
10+
huffman_decoder_partial_input
11+
huffman_decoder_partial_output
12+
huffman_decoder_allow_growth
13+
huffman_transitive
14+
huffman_transitive_even_bytes
15+
huffman_transitive_all_code_points
16+
huffman_transitive_chunked

tools/sanity_checks.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
'generate_tests.py',
4040
'run_test.py',
4141
},
42+
'aws-c-compression': {
43+
'tests.txt',
44+
'generate_tests.py',
45+
'run_test.py',
46+
},
4247
'box2d': {
4348
'doctest.h'
4449
},

0 commit comments

Comments
 (0)