From 9592fe090fd8fcdbbee91ddc60e26330de219781 Mon Sep 17 00:00:00 2001 From: Peter Eszlari Date: Tue, 5 May 2020 10:47:09 +0200 Subject: [PATCH] add meson build system --- meson.build | 21 +++++++++++++++++++++ meson_options.txt | 1 + src/meson.build | 15 +++++++++++++++ tests/meson.build | 18 ++++++++++++++++++ tests/test.sh | 17 +++++++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 src/meson.build create mode 100644 tests/meson.build create mode 100755 tests/test.sh diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..8d6fbc3 --- /dev/null +++ b/meson.build @@ -0,0 +1,21 @@ +project('libltc', 'c', + version : '1.3.1', + license : 'LGPL3') + +cc = meson.get_compiler('c') +m_dep = cc.find_library('m', required : false) + +inc = include_directories('src') + +subdir('src') + +if get_option('tests') + subdir('tests') +endif + +pkg_mod = import('pkgconfig') +pkg_mod.generate(libraries : ltc_lib, + version : meson.project_version(), + name : 'libltc', + filebase : 'ltc', + description : 'linear/longitudinal timecode library') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..e293fb0 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('tests', type : 'boolean', value : false, description : 'Build tests') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..753e950 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,15 @@ +install_headers('ltc.h') + +ltc_src = files([ + 'decoder.c', + 'encoder.c', + 'ltc.c', + 'timecode.c' +]) + +ltc_lib = library('ltc', + ltc_src, + include_directories : inc, + dependencies : m_dep, + version : '11.1.0', + install : true) diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..28e116b --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,18 @@ +ltcencode_exe = executable('ltcencode', + 'ltcencode.c', + include_directories : inc, + link_with : ltc_lib) + +ltcdecode_exe = executable('ltcdecode', + 'ltcdecode.c', + include_directories : inc, + link_with : ltc_lib) + +test_sh = find_program('test.sh') + +test('All tests', + test_sh, + env: ['BLD=' + meson.current_build_dir(), + 'SRC=' + meson.current_source_dir(), + 'PRJ=' + meson.project_name(), + 'VER=' + meson.project_version()]) diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000..35a0110 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e + +date +uname -a +echo "-----------------------------------------------------------------" +"$BLD/ltcencode" "$BLD/output.raw" +"$BLD/ltcdecode" "$BLD/output.raw" | diff -q "$SRC/expect_48k_2sec.txt" - +echo "-----------------------------------------------------------------" +"$BLD/ltcencode" "$BLD/output.raw" 192000 +"$BLD/ltcdecode" "$BLD/output.raw" 7680 | diff -q "$SRC/expect_96k_2sec.txt" - +echo "-----------------------------------------------------------------" +"$BLD/ltcdecode" "$SRC/timecode.raw" 882 | diff -q "$SRC/timecode.txt" - +echo "-----------------------------------------------------------------" +echo " $PRJ-$VER passed all tests." +echo "-----------------------------------------------------------------"