|
| 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 |
0 commit comments