Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add meson build system #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
21 changes: 21 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about declaring our own dependency? This would allow using the library as a meson subproject:

Suggested change
description : 'linear/longitudinal timecode library')
description : 'linear/longitudinal timecode library')
ltc_dep = declare_dependency(link_with : ltc_lib,
include_directories : inc)

1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('tests', type : 'boolean', value : false, description : 'Build tests')
15 changes: 15 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -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',
Copy link

@jmaibaum jmaibaum Jun 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be '1.3.1' or rather:

Suggested change
version : '11.1.0',
version : meson.project_version(),

install : true)
18 changes: 18 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -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()])
17 changes: 17 additions & 0 deletions tests/test.sh
Original file line number Diff line number Diff line change
@@ -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 "-----------------------------------------------------------------"