mirror of https://github.com/nirenjan/libx52.git
refactor: Add additional libraries and programs to meson.build
parent
dcdee29ddb
commit
a684d2e08b
|
@ -1 +1,2 @@
|
|||
/version-info ident
|
||||
/meson.build ident
|
||||
|
|
196
meson.build
196
meson.build
|
@ -4,28 +4,96 @@ project('libx52', 'C',
|
|||
|
||||
# Internationalization
|
||||
i18n = import('i18n')
|
||||
# define GETTEXT_PACKAGE
|
||||
add_project_arguments('-DGETTEXT_PACKAGE="libx52"', language:'C')
|
||||
# # define GETTEXT_PACKAGE
|
||||
# add_project_arguments(
|
||||
# '-DPACKAGE="libx52"',
|
||||
# '-DLOCALEDIR=""',
|
||||
# language:'C')
|
||||
i18n.gettext(meson.project_name())
|
||||
|
||||
dep_systemd = dependency('systemd', required: false)
|
||||
dep_libusb = dependency('libusb-1.0', required: true)
|
||||
dep_evdev = dependency('libevdev', required: false)
|
||||
dep_hidapi = dependency('hidapi-hidraw', required: false)
|
||||
if not dep_hidapi.found()
|
||||
dep_hidapi = dependency('hidapi', required: true)
|
||||
endif
|
||||
|
||||
dep_evdev = dependency('libevdev', required: false)
|
||||
|
||||
dep_systemd = dependency('systemd', required: false)
|
||||
dep_udev = dependency('udev', required: false)
|
||||
|
||||
dep_cmocka = dependency('cmocka', required: false)
|
||||
|
||||
doxygen_program = find_program('doxygen', required: false)
|
||||
|
||||
# pkgconfig module is needed
|
||||
pkgconfig = import('pkgconfig')
|
||||
|
||||
# Python 3.5 or greater is needed
|
||||
pymod = import('python')
|
||||
pyinstall = pymod.find_installation('python3')
|
||||
pyversion = pyinstall.language_version().split('.')
|
||||
python = pymod.find_installation('python3')
|
||||
pyversion = python.language_version().split('.')
|
||||
assert(pyversion[1].to_int() >= 5, 'Require Python >= 3.5')
|
||||
|
||||
cdata = configuration_data()
|
||||
cdata.set_quoted('PACKAGE', meson.project_name())
|
||||
cdata.set_quoted('LOCALEDIR', get_option('localedir'))
|
||||
cdata.set_quoted('VERSION', meson.project_version())
|
||||
|
||||
config_h = configure_file(
|
||||
input: 'config.h.meson',
|
||||
output: 'config.h',
|
||||
configuration: cdata
|
||||
)
|
||||
#
|
||||
#######################################################################
|
||||
# Version information
|
||||
#######################################################################
|
||||
compiler = meson.get_compiler('c')
|
||||
compiler_version = run_command(compiler.cmd_array(), '--version',
|
||||
capture: true,
|
||||
check: true).stdout().split('\n')[0]
|
||||
|
||||
build_date = run_command('date', '+%Y-%m-%dT%H:%M:%S%z',
|
||||
capture: true,
|
||||
check: true).stdout().strip()
|
||||
|
||||
build_host = run_command('uname', '-a',
|
||||
capture: true,
|
||||
check: true).stdout().strip()
|
||||
|
||||
built_for = '@0@ @1@ @2@-endian'.format(
|
||||
host_machine.system(),
|
||||
host_machine.cpu(),
|
||||
host_machine.endian(),
|
||||
)
|
||||
|
||||
git = find_program('git', required: false)
|
||||
if git.found()
|
||||
vcs_describe = run_command(git, 'describe', '--dirty',
|
||||
capture: true,
|
||||
check: false).stdout().strip()
|
||||
if vcs_describe == ''
|
||||
vcs_describe = meson.project_version()
|
||||
endif
|
||||
else
|
||||
vcs_describe = meson.project_version()
|
||||
endif
|
||||
|
||||
version_data = configuration_data()
|
||||
version_data.set_quoted('BUILD_VERSION', vcs_describe)
|
||||
version_data.set_quoted('BUILD_DATE', build_date)
|
||||
version_data.set_quoted('BUILD_HOST', build_host)
|
||||
version_data.set_quoted('BUILD_COMPILER', compiler_version)
|
||||
version_data.set_quoted('BUILD_TARGET', built_for)
|
||||
version_data.set_quoted('BUILD_VERSION_INFO_IDENT', '$Id$')
|
||||
|
||||
version_info_h = configure_file(
|
||||
input: 'version-info.h.meson',
|
||||
output: 'version-info.h',
|
||||
configuration: version_data
|
||||
)
|
||||
|
||||
#######################################################################
|
||||
# Internal dependencies
|
||||
#######################################################################
|
||||
|
@ -41,3 +109,119 @@ if not dep_inih.found()
|
|||
sub_inih = subproject('inih', required: true)
|
||||
dep_inih = sub_inih.get_variable('inih_dep')
|
||||
endif
|
||||
|
||||
#######################################################################
|
||||
# Shared libraries
|
||||
#######################################################################
|
||||
# Includes
|
||||
includes = include_directories('.', 'libx52')
|
||||
|
||||
# libx52
|
||||
libx52_files = files(
|
||||
'libx52/x52_control.c',
|
||||
'libx52/x52_core.c',
|
||||
'libx52/x52_date_time.c',
|
||||
'libx52/x52_mfd_led.c',
|
||||
'libx52/x52_strerror.c',
|
||||
'libx52/x52_stringify.c',
|
||||
)
|
||||
|
||||
lib_libx52 = library('x52', libx52_files,
|
||||
install: true,
|
||||
version: '2.4.1',
|
||||
dependencies: [dep_libusb])
|
||||
|
||||
install_headers('libx52/libx52.h', subdir: meson.project_name())
|
||||
pkgconfig.generate(lib_libx52)
|
||||
|
||||
# Unit tests for libx52
|
||||
if dep_cmocka.found()
|
||||
libx52_string_test = executable('libx52-string-test',
|
||||
'libx52/test_strings.c',
|
||||
'libx52/x52_stringify.c',
|
||||
'libx52/x52_strerror.c',
|
||||
build_by_default: false,
|
||||
dependencies: [dep_cmocka],
|
||||
link_with: [lib_libx52],
|
||||
include_directories: [includes, lib_libx52.private_dir_include()],
|
||||
)
|
||||
|
||||
test('libx52-string-test', libx52_string_test, protocol: 'tap')
|
||||
|
||||
libx52_test_file = custom_target('libx52-test',
|
||||
build_by_default: false,
|
||||
depend_files: ['libx52/x52_test_gen.py', 'libx52/x52_tests.json'],
|
||||
command: [python, '@SOURCE_ROOT@/libx52/x52_test_gen.py', '@INPUT@'],
|
||||
capture: true,
|
||||
input: 'libx52/x52_tests.json',
|
||||
output: 'test_libx52.c'
|
||||
)
|
||||
|
||||
libx52test = executable('libx52test', libx52_test_file, libx52_files,
|
||||
c_args: ['-Dlibusb_control_transfer=__wrap_libusb_control_transfer'],
|
||||
dependencies: [dep_cmocka, dep_libusb],
|
||||
link_with: [lib_libx52],
|
||||
build_by_default: false,
|
||||
include_directories: [includes, lib_libx52.private_dir_include()],
|
||||
)
|
||||
|
||||
test('libx52test', libx52test, protocol: 'tap')
|
||||
endif
|
||||
|
||||
# libx52io
|
||||
libx52io_files = files(
|
||||
'libx52io/io_core.c',
|
||||
'libx52io/io_axis.c',
|
||||
'libx52io/io_parser.c',
|
||||
'libx52io/io_strings.c',
|
||||
'libx52io/io_device.c',
|
||||
)
|
||||
|
||||
lib_libx52io = library('x52io', libx52io_files,
|
||||
install: true,
|
||||
version: '1.0.0',
|
||||
dependencies: [dep_hidapi])
|
||||
|
||||
install_headers('libx52io/libx52io.h', subdir: meson.project_name())
|
||||
pkgconfig.generate(lib_libx52io)
|
||||
|
||||
if dep_cmocka.found()
|
||||
test_axis = executable('test-axis', 'libx52io/test_axis.c', libx52io_files,
|
||||
build_by_default: false,
|
||||
dependencies: [dep_cmocka, dep_hidapi],
|
||||
)
|
||||
test('test-axis', test_axis, protocol: 'tap')
|
||||
|
||||
test_parser = executable('test-parser', 'libx52io/test_parser.c', libx52io_files,
|
||||
build_by_default: false,
|
||||
dependencies: [dep_cmocka, dep_hidapi],
|
||||
)
|
||||
test('test-parser', test_parser, protocol: 'tap')
|
||||
endif
|
||||
|
||||
# libx52util
|
||||
util_char_map = custom_target('util-char-map',
|
||||
build_by_default: false,
|
||||
depend_files: ['libx52util/x52_char_map_gen.py', 'libx52util/x52_char_map.cfg'],
|
||||
command: [python, '@SOURCE_ROOT@/libx52util/x52_char_map_gen.py', '@INPUT@', '@OUTPUT@'],
|
||||
input: 'libx52util/x52_char_map.cfg',
|
||||
output: 'util_char_map.c')
|
||||
|
||||
lib_libx52util = library('x52util', util_char_map, 'libx52util/x52_char_map_lookup.c',
|
||||
include_directories: 'libx52util',
|
||||
install: true,
|
||||
version: '1.0.0',
|
||||
)
|
||||
|
||||
install_headers('libx52util/libx52util.h', subdir: meson.project_name())
|
||||
pkgconfig.generate(lib_libx52util)
|
||||
|
||||
#######################################################################
|
||||
# Programs
|
||||
#######################################################################
|
||||
# x52bugreport
|
||||
executable('x52bugreport', 'bugreport/bugreport.c',
|
||||
extra_files: ['bugreport/bugreport.dox'],
|
||||
include_directories: 'libx52io',
|
||||
dependencies: [dep_libusb, dep_hidapi],
|
||||
link_with: [lib_libx52io])
|
||||
|
|
12
version-info
12
version-info
|
@ -31,10 +31,20 @@ then
|
|||
fi
|
||||
fi
|
||||
|
||||
if test -n "$2"
|
||||
then
|
||||
BUILD_COMPILER="$2"
|
||||
elif test -n "${CC}"
|
||||
then
|
||||
BUILD_COMPILER="$(${CC} --version | head -n1)"
|
||||
else
|
||||
BUILD_COMPILER=unknown
|
||||
fi
|
||||
|
||||
cat <<EOM
|
||||
#define BUILD_VERSION "${DESCRIBE}"
|
||||
#define BUILD_DATE "$(date +%Y-%m-%dT%H:%M:%S%z)"
|
||||
#define BUILD_HOST "$(uname -a)"
|
||||
#define BUILD_COMPILER "$(${CC} --version | head -n1)"
|
||||
#define BUILD_COMPILER "${BUILD_COMPILER}"
|
||||
EOM
|
||||
echo '#define BUILD_VERSION_INFO_IDENT "$Id$"'
|
||||
|
|
Loading…
Reference in New Issue