mirror of https://github.com/nirenjan/libx52.git
build: Migrate to meson build
Meson is a far more robust build framework, compared to autotools. This greatly simplifies adding new features, since it's far easier to maintain a set of meson.build files vs the autotools mishmash. DEPRECATION NOTICE: Autotools based build is deprecated and will be removed in the future.migrate-to-meson
parent
3fb0d72124
commit
b4ec8d4629
|
|
@ -1 +1,2 @@
|
||||||
/version-info ident
|
/version-info ident
|
||||||
|
*/meson.build ident
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,13 @@
|
||||||
# Run the build and tests
|
# Run the build and tests
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
./autogen.sh
|
meson setup -Dprefix=/usr -Dsysconfdir=/etc -Dlocalstatedir=/var -Dnls=enabled build
|
||||||
mkdir build
|
|
||||||
cd build
|
cd build
|
||||||
../configure
|
ninja
|
||||||
make -j V=0
|
ninja test
|
||||||
make -j check V=0
|
|
||||||
make -j distcheck
|
|
||||||
|
|
||||||
# Print bugreport output
|
# Print bugreport output
|
||||||
./x52bugreport
|
./bugreport/x52bugreport
|
||||||
|
|
||||||
# Make sure that there are no changes to the source code
|
# Make sure that there are no changes to the source code
|
||||||
# This may happen if the source have changed with differences to the
|
# This may happen if the source have changed with differences to the
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
# Generate Doxygen documentation
|
# Generate Doxygen documentation
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
./autogen.sh
|
meson setup -Dprefix=/usr -Dsysconfdir=/etc -Dlocalstatedir=/var -Dnls=enabled build
|
||||||
mkdir build
|
|
||||||
cd build
|
cd build
|
||||||
../configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
|
ninja docs
|
||||||
make docs/.stamp
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ brew install \
|
||||||
hidapi \
|
hidapi \
|
||||||
inih \
|
inih \
|
||||||
doxygen \
|
doxygen \
|
||||||
cmocka
|
cmocka \
|
||||||
|
meson \
|
||||||
|
ninja \
|
||||||
|
inih
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@ sudo apt-get install -y \
|
||||||
libinih-dev \
|
libinih-dev \
|
||||||
doxygen \
|
doxygen \
|
||||||
libcmocka-dev \
|
libcmocka-dev \
|
||||||
faketime
|
faketime \
|
||||||
|
meson \
|
||||||
|
ninja-build \
|
||||||
|
libinih-dev
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,7 @@ jobs:
|
||||||
# languages: go, javascript, csharp, python, cpp, java
|
# languages: go, javascript, csharp, python, cpp, java
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: ./.github/scripts/build-and-test.sh
|
||||||
./autogen.sh
|
|
||||||
mkdir -p build
|
|
||||||
cd build
|
|
||||||
../configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
|
|
||||||
make -j V=0
|
|
||||||
make -j V=0 check
|
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v4
|
uses: github/codeql-action/analyze@v4
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
# Build any support libraries first
|
# Build any support libraries first
|
||||||
SUBDIRS = lib
|
SUBDIRS = subprojects
|
||||||
|
|
||||||
if USE_NLS
|
if USE_NLS
|
||||||
SUBDIRS += po
|
SUBDIRS += po
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ int main(int argc, char **argv)
|
||||||
printf("Build host kernel: %s\n", BUILD_KERNEL);
|
printf("Build host kernel: %s\n", BUILD_KERNEL);
|
||||||
printf("Build host architecture: %s\n", BUILD_ARCH);
|
printf("Build host architecture: %s\n", BUILD_ARCH);
|
||||||
printf("Build host version: %s\n", BUILD_OS_VERSION);
|
printf("Build host version: %s\n", BUILD_OS_VERSION);
|
||||||
|
printf("Build target: %s\n", BUILD_TARGET);
|
||||||
printf("Compiler: %s\n", BUILD_COMPILER);
|
printf("Compiler: %s\n", BUILD_COMPILER);
|
||||||
printf("Build date: %s\n", BUILD_DATE);
|
printf("Build date: %s\n", BUILD_DATE);
|
||||||
printf("version-info %s\n", BUILD_VERSION_INFO_IDENT);
|
printf("version-info %s\n", BUILD_VERSION_INFO_IDENT);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
#######################################################################
|
||||||
|
# Version information
|
||||||
|
#######################################################################
|
||||||
|
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_kernel = run_command('uname', '-sr',
|
||||||
|
capture: true,
|
||||||
|
check: true).stdout().strip()
|
||||||
|
|
||||||
|
build_arch = run_command('uname', '-mp',
|
||||||
|
capture: true,
|
||||||
|
check: true).stdout().strip()
|
||||||
|
|
||||||
|
build_os_version = run_command('uname', '-v',
|
||||||
|
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_KERNEL', build_kernel)
|
||||||
|
version_data.set_quoted('BUILD_ARCH', build_arch)
|
||||||
|
version_data.set_quoted('BUILD_OS_VERSION', build_os_version)
|
||||||
|
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
|
||||||
|
)
|
||||||
|
|
||||||
|
# x52bugreport
|
||||||
|
exe_bugreport = executable('x52bugreport', 'bugreport.c',
|
||||||
|
install: true,
|
||||||
|
include_directories: [includes],
|
||||||
|
dependencies: [dep_libusb, dep_hidapi],
|
||||||
|
link_with: [lib_libx52io])
|
||||||
|
|
||||||
|
# Test only to get code coverage
|
||||||
|
test('x52bugreport', exe_bugreport, protocol:'exitcode')
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
#mesondefine BUILD_VERSION
|
||||||
|
#mesondefine BUILD_DATE
|
||||||
|
#mesondefine BUILD_KERNEL
|
||||||
|
#mesondefine BUILD_ARCH
|
||||||
|
#mesondefine BUILD_OS_VERSION
|
||||||
|
#mesondefine BUILD_COMPILER
|
||||||
|
#mesondefine BUILD_TARGET
|
||||||
|
#mesondefine BUILD_VERSION_INFO_IDENT
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# x52cli
|
||||||
|
executable('x52cli', 'x52_cli.c',
|
||||||
|
install: true,
|
||||||
|
include_directories: [includes],
|
||||||
|
link_with: lib_libx52)
|
||||||
|
|
||||||
|
test_cli = executable('test-cli', 'x52_cli.c', 'test_x52_cli.c',
|
||||||
|
build_by_default: false,
|
||||||
|
c_args: ['-DX52_CLI_TESTING'],
|
||||||
|
include_directories: [includes],
|
||||||
|
dependencies: [dep_cmocka],
|
||||||
|
)
|
||||||
|
|
||||||
|
test('test-cli', test_cli, protocol: 'tap')
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -462,12 +462,12 @@ static void do_help(const struct command_handler *cmd)
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
fprintf(stderr, "Command usage: %s\n", cmd->help);
|
fprintf(stderr, "Command usage: %s\n", cmd->help);
|
||||||
} else {
|
} else {
|
||||||
printf("\nCommands:\n");
|
fprintf(stderr, "\nCommands:\n");
|
||||||
for (i = 0; i < X52_CTL_CMD_MAX; i++) {
|
for (i = 0; i < X52_CTL_CMD_MAX; i++) {
|
||||||
printf("\t%s\n", handlers[i].help);
|
fprintf(stderr, "\t%s\n", handlers[i].help);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nWARNING: raw command may damage your device\n\n");
|
fprintf(stderr, "\nWARNING: raw command may damage your device\n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
/* Define to 1 if translation of program messages to the user's native
|
||||||
|
language is requested. */
|
||||||
|
#mesondefine ENABLE_NLS
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the `noreturn' function attribute */
|
||||||
|
#mesondefine HAVE_FUNC_ATTRIBUTE_NORETURN
|
||||||
|
|
||||||
|
/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
|
||||||
|
#mesondefine HAVE_STRUCT_TM_TM_GMTOFF
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#mesondefine PACKAGE
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#mesondefine PACKAGE_BUGREPORT
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#mesondefine PACKAGE_NAME
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#mesondefine PACKAGE_VERSION
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#mesondefine VERSION
|
||||||
|
|
||||||
|
/* Define to the directory where locale files are stored */
|
||||||
|
#mesondefine LOCALEDIR
|
||||||
|
|
||||||
|
/* Define to the location of the configuration directory */
|
||||||
|
#mesondefine SYSCONFDIR
|
||||||
|
|
||||||
|
/* Define to the location of the local state directory */
|
||||||
|
#mesondefine LOCALSTATEDIR
|
||||||
|
|
||||||
|
/* Define to the location of the log directory */
|
||||||
|
#define LOGDIR LOCALSTATEDIR "/log"
|
||||||
|
|
||||||
|
/* Define to the location of the run directory */
|
||||||
|
#define RUNDIR LOCALSTATEDIR "/run"
|
||||||
|
|
@ -138,11 +138,11 @@ AC_CONFIG_HEADERS([config.h])
|
||||||
|
|
||||||
AC_CONFIG_FILES([ po/Makefile.in
|
AC_CONFIG_FILES([ po/Makefile.in
|
||||||
Makefile
|
Makefile
|
||||||
lib/Makefile
|
subprojects/Makefile
|
||||||
libx52/libx52.pc
|
libx52/libx52.pc
|
||||||
libx52io/libx52io.pc
|
libx52io/libx52io.pc
|
||||||
libx52util/libx52util.pc
|
libx52util/libx52util.pc
|
||||||
lib/pinelog/Makefile
|
subprojects/pinelog/Makefile
|
||||||
udev/60-saitek-x52-x52pro.rules
|
udev/60-saitek-x52-x52pro.rules
|
||||||
])
|
])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ x52d_CFLAGS = \
|
||||||
-I $(top_srcdir)/libx52io \
|
-I $(top_srcdir)/libx52io \
|
||||||
-I $(top_srcdir)/libx52 \
|
-I $(top_srcdir)/libx52 \
|
||||||
-I $(top_srcdir)/libx52util \
|
-I $(top_srcdir)/libx52util \
|
||||||
-I $(top_srcdir)/lib/pinelog \
|
-I $(top_srcdir)/subprojects/pinelog \
|
||||||
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||||
-DLOCALEDIR=\"$(localedir)\" \
|
-DLOCALEDIR=\"$(localedir)\" \
|
||||||
-DLOGDIR=\"$(localstatedir)/log\" \
|
-DLOGDIR=\"$(localstatedir)/log\" \
|
||||||
|
|
@ -35,7 +35,7 @@ x52d_CFLAGS = \
|
||||||
|
|
||||||
x52d_LDFLAGS = @INIH_LIBS@ @PTHREAD_LIBS@ $(WARN_LDFLAGS)
|
x52d_LDFLAGS = @INIH_LIBS@ @PTHREAD_LIBS@ $(WARN_LDFLAGS)
|
||||||
x52d_LDADD = \
|
x52d_LDADD = \
|
||||||
lib/pinelog/libpinelog.la \
|
subprojects/pinelog/libpinelog.la \
|
||||||
libx52.la \
|
libx52.la \
|
||||||
@LTLIBINTL@
|
@LTLIBINTL@
|
||||||
|
|
||||||
|
|
@ -123,11 +123,11 @@ x52d_mouse_test_CFLAGS = \
|
||||||
-I $(top_srcdir) \
|
-I $(top_srcdir) \
|
||||||
-I $(top_srcdir)/libx52 \
|
-I $(top_srcdir)/libx52 \
|
||||||
-I $(top_srcdir)/libx52io \
|
-I $(top_srcdir)/libx52io \
|
||||||
-I $(top_srcdir)/lib/pinelog \
|
-I $(top_srcdir)/subprojects/pinelog \
|
||||||
$(WARN_CFLAGS) @CMOCKA_CFLAGS@
|
$(WARN_CFLAGS) @CMOCKA_CFLAGS@
|
||||||
x52d_mouse_test_LDFLAGS = @CMOCKA_LIBS@ $(WARN_LDFLAGS)
|
x52d_mouse_test_LDFLAGS = @CMOCKA_LIBS@ $(WARN_LDFLAGS)
|
||||||
x52d_mouse_test_LDADD = \
|
x52d_mouse_test_LDADD = \
|
||||||
lib/pinelog/libpinelog.la \
|
subprojects/pinelog/libpinelog.la \
|
||||||
@LTLIBINTL@
|
@LTLIBINTL@
|
||||||
|
|
||||||
TESTS += x52d-mouse-test
|
TESTS += x52d-mouse-test
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
# x52d
|
||||||
|
libx52dcomm_sources = [
|
||||||
|
'x52d_comm_client.c',
|
||||||
|
'x52d_comm_internal.c'
|
||||||
|
]
|
||||||
|
|
||||||
|
install_headers('x52dcomm.h', subdir: meson.project_name())
|
||||||
|
|
||||||
|
lib_libx52dcomm = library('x52dcomm', libx52dcomm_sources,
|
||||||
|
dependencies: [dep_intl],
|
||||||
|
include_directories: includes)
|
||||||
|
|
||||||
|
x52d_sources = [
|
||||||
|
'x52d_main.c',
|
||||||
|
'x52d_config_parser.c',
|
||||||
|
'x52d_config_dump.c',
|
||||||
|
'x52d_config.c',
|
||||||
|
'x52d_device.c',
|
||||||
|
'x52d_client.c',
|
||||||
|
'x52d_clock.c',
|
||||||
|
'x52d_mouse.c',
|
||||||
|
'x52d_notify.c',
|
||||||
|
'x52d_led.c',
|
||||||
|
'x52d_command.c',
|
||||||
|
]
|
||||||
|
|
||||||
|
dep_threads = dependency('threads')
|
||||||
|
x52d_linkwith = [lib_libx52, lib_libx52dcomm]
|
||||||
|
x52d_deps = [dep_pinelog, dep_inih, dep_threads, dep_intl]
|
||||||
|
x52d_cflags = []
|
||||||
|
if dep_evdev.found()
|
||||||
|
x52d_sources += 'x52d_io.c'
|
||||||
|
x52d_sources += 'x52d_mouse_evdev.c'
|
||||||
|
x52d_cflags += '-DHAVE_EVDEV'
|
||||||
|
x52d_linkwith += lib_libx52io
|
||||||
|
x52d_deps += dep_evdev
|
||||||
|
endif
|
||||||
|
|
||||||
|
exe_x52d = executable('x52d', x52d_sources,
|
||||||
|
install: true,
|
||||||
|
include_directories: includes,
|
||||||
|
c_args: x52d_cflags,
|
||||||
|
dependencies: x52d_deps,
|
||||||
|
link_with: x52d_linkwith)
|
||||||
|
|
||||||
|
executable('x52ctl', 'x52ctl.c',
|
||||||
|
install: true,
|
||||||
|
dependencies: [dep_intl],
|
||||||
|
include_directories: includes,
|
||||||
|
link_with: lib_libx52dcomm)
|
||||||
|
|
||||||
|
install_data('x52d.conf',
|
||||||
|
install_dir: join_paths(get_option('sysconfdir'), 'x52d'))
|
||||||
|
|
||||||
|
test('daemon-communication', files('test_daemon_comm.py')[0],
|
||||||
|
depends: exe_x52d, protocol: 'tap')
|
||||||
|
|
||||||
|
x52d_mouse_test_sources = ['x52d_mouse_test.c', 'x52d_mouse.c']
|
||||||
|
x52d_mouse_test = executable('x52d-mouse-test', x52d_mouse_test_sources,
|
||||||
|
include_directories: includes,
|
||||||
|
dependencies: [dep_pinelog, dep_cmocka, dep_intl])
|
||||||
|
|
||||||
|
test('x52d-mouse-test', x52d_mouse_test, protocol: 'tap')
|
||||||
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
# x52evtest
|
||||||
|
executable('x52evtest', 'ev_test.c',
|
||||||
|
install: true,
|
||||||
|
include_directories: includes,
|
||||||
|
dependencies: [dep_intl],
|
||||||
|
link_with: [lib_libx52io])
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
# x52test
|
||||||
|
executable('x52test',
|
||||||
|
'x52_test.c',
|
||||||
|
'x52_test_mfd.c',
|
||||||
|
'x52_test_led.c',
|
||||||
|
'x52_test_clock.c',
|
||||||
|
install: true,
|
||||||
|
dependencies: [dep_intl],
|
||||||
|
include_directories: includes,
|
||||||
|
link_with: [lib_libx52])
|
||||||
|
|
@ -285,7 +285,6 @@ int libx52_init(libx52_device ** dev);
|
||||||
* cause errors.
|
* cause errors.
|
||||||
*
|
*
|
||||||
* @param[in] dev Pointer to the device context
|
* @param[in] dev Pointer to the device context
|
||||||
* @returns None
|
|
||||||
*/
|
*/
|
||||||
void libx52_exit(libx52_device *dev);
|
void libx52_exit(libx52_device *dev);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
libx52_files = files(
|
||||||
|
'x52_control.c',
|
||||||
|
'x52_core.c',
|
||||||
|
'x52_date_time.c',
|
||||||
|
'x52_mfd_led.c',
|
||||||
|
'x52_strerror.c',
|
||||||
|
'x52_stringify.c',
|
||||||
|
)
|
||||||
|
|
||||||
|
lib_libx52 = library('x52', libx52_files,
|
||||||
|
install: true,
|
||||||
|
version: '2.4.2',
|
||||||
|
dependencies: [dep_libusb, dep_intl],
|
||||||
|
include_directories: [includes])
|
||||||
|
|
||||||
|
install_headers('libx52.h', subdir: meson.project_name())
|
||||||
|
pkgconfig.generate(lib_libx52)
|
||||||
|
|
||||||
|
# Unit tests for libx52
|
||||||
|
libx52_string_test = executable('libx52-string-test',
|
||||||
|
'test_strings.c',
|
||||||
|
'x52_stringify.c',
|
||||||
|
'x52_strerror.c',
|
||||||
|
build_by_default: false,
|
||||||
|
dependencies: [dep_cmocka, dep_intl],
|
||||||
|
link_with: [lib_libx52],
|
||||||
|
include_directories: [includes, lib_libx52.private_dir_include()],
|
||||||
|
)
|
||||||
|
|
||||||
|
test('libx52-string-test', libx52_string_test, protocol: 'tap')
|
||||||
|
|
||||||
|
test_gen_script = files('x52_test_gen.py')[0]
|
||||||
|
|
||||||
|
libx52_test_file = custom_target('libx52-test',
|
||||||
|
build_by_default: false,
|
||||||
|
depend_files: ['x52_test_gen.py', 'x52_tests.json'],
|
||||||
|
command: [python, test_gen_script, '@INPUT@'],
|
||||||
|
capture: true,
|
||||||
|
input: '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, dep_intl],
|
||||||
|
link_with: [lib_libx52],
|
||||||
|
build_by_default: false,
|
||||||
|
include_directories: [includes, lib_libx52.private_dir_include()],
|
||||||
|
)
|
||||||
|
|
||||||
|
test('libx52test', libx52test, protocol: 'tap')
|
||||||
|
|
@ -303,7 +303,6 @@ int libx52io_init(libx52io_context **ctx);
|
||||||
* cause errors.
|
* cause errors.
|
||||||
*
|
*
|
||||||
* @param[in] ctx Pointer to the device context
|
* @param[in] ctx Pointer to the device context
|
||||||
* @returns None
|
|
||||||
*/
|
*/
|
||||||
void libx52io_exit(libx52io_context *ctx);
|
void libx52io_exit(libx52io_context *ctx);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
libx52io_files = files(
|
||||||
|
'io_core.c',
|
||||||
|
'io_axis.c',
|
||||||
|
'io_parser.c',
|
||||||
|
'io_strings.c',
|
||||||
|
'io_device.c',
|
||||||
|
)
|
||||||
|
|
||||||
|
lib_libx52io = library('x52io', libx52io_files,
|
||||||
|
install: true,
|
||||||
|
version: '1.0.0',
|
||||||
|
dependencies: [dep_hidapi, dep_intl],
|
||||||
|
include_directories: [includes])
|
||||||
|
|
||||||
|
install_headers('libx52io.h', subdir: meson.project_name())
|
||||||
|
pkgconfig.generate(lib_libx52io)
|
||||||
|
|
||||||
|
test_axis = executable('test-axis', 'test_axis.c', libx52io_files,
|
||||||
|
build_by_default: false,
|
||||||
|
dependencies: [dep_cmocka, dep_hidapi, dep_intl],
|
||||||
|
include_directories: [includes],
|
||||||
|
)
|
||||||
|
test('test-axis', test_axis, protocol: 'tap')
|
||||||
|
|
||||||
|
test_parser = executable('test-parser', 'test_parser.c', libx52io_files,
|
||||||
|
build_by_default: false,
|
||||||
|
dependencies: [dep_cmocka, dep_hidapi, dep_intl],
|
||||||
|
include_directories: [includes],
|
||||||
|
)
|
||||||
|
test('test-parser', test_parser, protocol: 'tap')
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
# libx52util
|
||||||
|
gen_script = files('x52_char_map_gen.py')[0]
|
||||||
|
|
||||||
|
util_char_map = custom_target('util-char-map',
|
||||||
|
build_by_default: false,
|
||||||
|
depend_files: ['x52_char_map_gen.py', 'x52_char_map.cfg'],
|
||||||
|
command: [python, gen_script, '@INPUT@', '@OUTPUT@'],
|
||||||
|
input: 'x52_char_map.cfg',
|
||||||
|
output: 'util_char_map.c')
|
||||||
|
|
||||||
|
lib_libx52util = library('x52util', util_char_map, 'x52_char_map_lookup.c',
|
||||||
|
install: true,
|
||||||
|
version: '1.0.1',
|
||||||
|
include_directories: [includes],
|
||||||
|
)
|
||||||
|
|
||||||
|
install_headers('libx52util.h', subdir: meson.project_name())
|
||||||
|
pkgconfig.generate(lib_libx52util)
|
||||||
|
|
||||||
|
test_gen_script = files('x52_map_test_gen.py')[0]
|
||||||
|
|
||||||
|
libx52util_map_test_src = custom_target('libx52util-map-test-src',
|
||||||
|
build_by_default: false,
|
||||||
|
depend_files: ['x52_map_test_gen.py', 'x52_char_map.cfg'],
|
||||||
|
command: [python, test_gen_script, '@INPUT@', '@OUTPUT@'],
|
||||||
|
input: 'x52_char_map.cfg',
|
||||||
|
output: 'x52_map_test.c'
|
||||||
|
)
|
||||||
|
|
||||||
|
libx52util_map_test = executable('libx52util-map-test', libx52util_map_test_src,
|
||||||
|
dependencies: [dep_cmocka],
|
||||||
|
link_with: [lib_libx52util],
|
||||||
|
build_by_default: false,
|
||||||
|
include_directories: [includes, lib_libx52util.private_dir_include()],
|
||||||
|
)
|
||||||
|
|
||||||
|
test('libx52util-map-test', libx52util_map_test, protocol: 'tap')
|
||||||
|
|
@ -48,7 +48,7 @@ static void test_map_{in_char}(void **state) {{
|
||||||
rc = libx52util_convert_utf8_string(input_array, output, &out_len);
|
rc = libx52util_convert_utf8_string(input_array, output, &out_len);
|
||||||
assert_int_equal(rc, 0);
|
assert_int_equal(rc, 0);
|
||||||
assert_int_equal(out_len, 1);
|
assert_int_equal(out_len, 1);
|
||||||
assert_string_equal(output, expected_output);
|
assert_memory_equal(output, expected_output, 2);
|
||||||
}}
|
}}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,140 @@
|
||||||
|
project('libx52', 'C',
|
||||||
|
license: 'GPL-2.0-only WITH Classpath-exception-2.0',
|
||||||
|
version: '0.3.2')
|
||||||
|
|
||||||
|
dep_libusb = dependency('libusb-1.0', required: true)
|
||||||
|
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)
|
||||||
|
if not dep_cmocka.found()
|
||||||
|
dep_cmocka = disabler()
|
||||||
|
endif
|
||||||
|
|
||||||
|
doxygen_program = find_program('doxygen', required: false)
|
||||||
|
|
||||||
|
# pkgconfig module is needed
|
||||||
|
pkgconfig = import('pkgconfig')
|
||||||
|
|
||||||
|
# Python 3.5 or greater is needed
|
||||||
|
pymod = import('python')
|
||||||
|
python = pymod.find_installation('python3')
|
||||||
|
pyversion = python.language_version().split('.')
|
||||||
|
assert(pyversion[1].to_int() >= 5, 'Require Python >= 3.5')
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# config.h
|
||||||
|
#######################################################################
|
||||||
|
compiler = meson.get_compiler('c')
|
||||||
|
cdata = configuration_data()
|
||||||
|
cdata.set_quoted('PACKAGE', meson.project_name())
|
||||||
|
cdata.set_quoted('PACKAGE_BUGREPORT', 'https://github.com/nirenjan/libx52/issues')
|
||||||
|
cdata.set_quoted('PACKAGE_NAME', meson.project_name())
|
||||||
|
cdata.set_quoted('LOCALEDIR', get_option('localedir'))
|
||||||
|
cdata.set_quoted('SYSCONFDIR', get_option('sysconfdir'))
|
||||||
|
cdata.set_quoted('LOCALSTATEDIR', get_option('localstatedir'))
|
||||||
|
cdata.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||||
|
cdata.set_quoted('VERSION', meson.project_version())
|
||||||
|
cdata.set10('ENABLE_NLS', get_option('nls').enabled())
|
||||||
|
cdata.set10('HAVE_FUNC_ATTRIBUTE_NORETURN', compiler.has_function_attribute('noreturn'))
|
||||||
|
cdata.set10('HAVE_STRUCT_TM_TM_GMTOFF',
|
||||||
|
compiler.has_member('struct tm', 'tm_gmtoff', prefix:'#include <time.h>'))
|
||||||
|
|
||||||
|
config_h = configure_file(
|
||||||
|
input: 'config.h.meson',
|
||||||
|
output: 'config.h',
|
||||||
|
configuration: cdata
|
||||||
|
)
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Internationalization
|
||||||
|
#######################################################################
|
||||||
|
i18n = import('i18n')
|
||||||
|
dep_intl = dependency('intl', required: false)
|
||||||
|
if not dep_intl.found() and host_machine.system() == 'darwin'
|
||||||
|
brew = find_program('brew', required: false)
|
||||||
|
if brew.found()
|
||||||
|
brew_prefix = run_command(brew, '--prefix', 'gettext',
|
||||||
|
check: true).stdout().strip()
|
||||||
|
|
||||||
|
brew_inc = brew_prefix / 'include'
|
||||||
|
brew_lib_dir = brew_prefix / 'lib'
|
||||||
|
|
||||||
|
dep_intl = compiler.find_library('intl', dirs: brew_lib_dir)
|
||||||
|
dep_intl = declare_dependency(dependencies: dep_intl, include_directories: brew_inc)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# # define GETTEXT_PACKAGE
|
||||||
|
if get_option('nls').enabled()
|
||||||
|
add_project_arguments(
|
||||||
|
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
|
||||||
|
language:'C')
|
||||||
|
|
||||||
|
subdir('po')
|
||||||
|
endif
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Internal dependencies
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
# pinelog
|
||||||
|
pinelog_options = []
|
||||||
|
if dep_systemd.found() and not get_option('systemd-logs').disabled()
|
||||||
|
# If systemd logs is enabled or auto, and systemd is found, then hide
|
||||||
|
# the timestamps in log messages
|
||||||
|
pinelog_options = ['show-date=false']
|
||||||
|
endif
|
||||||
|
|
||||||
|
sub_pinelog = subproject('pinelog', required: true,
|
||||||
|
default_options: pinelog_options)
|
||||||
|
dep_pinelog = sub_pinelog.get_variable('libpinelog_dep')
|
||||||
|
|
||||||
|
# inih
|
||||||
|
# Use system inih
|
||||||
|
dep_inih = dependency('inih')
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Shared libraries and programs
|
||||||
|
#######################################################################
|
||||||
|
# Includes
|
||||||
|
includes = include_directories('.', 'libx52', 'libx52io', 'libx52util')
|
||||||
|
|
||||||
|
subdir('libx52')
|
||||||
|
subdir('libx52io')
|
||||||
|
subdir('libx52util')
|
||||||
|
subdir('bugreport')
|
||||||
|
subdir('cli')
|
||||||
|
subdir('joytest')
|
||||||
|
subdir('evtest')
|
||||||
|
subdir('daemon')
|
||||||
|
subdir('udev')
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Documentation - doxygen
|
||||||
|
#######################################################################
|
||||||
|
if doxygen_program.found()
|
||||||
|
doxyfile = configure_file(
|
||||||
|
input: 'Doxyfile.in',
|
||||||
|
output: 'Doxyfile',
|
||||||
|
configuration: {
|
||||||
|
'PACKAGE_NAME': meson.project_name(),
|
||||||
|
'PACKAGE_VERSION': meson.project_version(),
|
||||||
|
'abs_top_builddir': meson.build_root(),
|
||||||
|
'abs_top_srcdir': meson.source_root(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
docs_tgt = custom_target('docs',
|
||||||
|
depend_files: [doxyfile, 'DoxygenLayout.xml'],
|
||||||
|
command: [doxygen_program],
|
||||||
|
output: 'docs'
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
option('systemd-logs',
|
||||||
|
type: 'feature',
|
||||||
|
description: 'Hide timestamps in log messages, needed for systemd')
|
||||||
|
|
||||||
|
option('nls',
|
||||||
|
type: 'feature',
|
||||||
|
description: 'Enable message translations')
|
||||||
|
|
||||||
|
option('input-group',
|
||||||
|
type: 'string', value: 'plugdev',
|
||||||
|
description: 'Group for input devices')
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
i18n.gettext(meson.project_name(),
|
||||||
|
args: '--directory=' + meson.source_root(),
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
project('pinelog', 'C',
|
||||||
|
default_options: ['show-date=true', 'show-level=true', 'show-backtrace=true'])
|
||||||
|
|
||||||
|
pinelog_cflags = [
|
||||||
|
'-DPINELOG_SHOW_DATE=@0@'.format(get_option('show-date').to_int()),
|
||||||
|
'-DPINELOG_SHOW_LEVEL=@0@'.format(get_option('show-level').to_int()),
|
||||||
|
'-DPINELOG_SHOW_BACKTRACE=@0@'.format(get_option('show-backtrace').to_int()),
|
||||||
|
]
|
||||||
|
|
||||||
|
libpinelog = static_library('pinelog', 'pinelog.c', c_args: pinelog_cflags)
|
||||||
|
|
||||||
|
libpinelog_inc = include_directories('.')
|
||||||
|
libpinelog_dep = declare_dependency(
|
||||||
|
include_directories: libpinelog_inc,
|
||||||
|
link_with: libpinelog
|
||||||
|
)
|
||||||
|
|
||||||
|
prog_class = ['bench', 'test']
|
||||||
|
date_class = ['nots', 'ts']
|
||||||
|
level_class = ['nolvl', 'lvl']
|
||||||
|
backtrace_class = ['notr', 'tr']
|
||||||
|
|
||||||
|
test_files = []
|
||||||
|
test_name_template = '@0@-@1@-@2@-@3@'
|
||||||
|
foreach test_type: ['bench', 'test']
|
||||||
|
test_src = test_type + '_pinelog.c'
|
||||||
|
foreach date_arg: [0, 1]
|
||||||
|
date_def = '-DPINELOG_SHOW_DATE=' + date_arg.to_string()
|
||||||
|
date_name = date_arg == 1 ? 'ts' : 'nots'
|
||||||
|
|
||||||
|
foreach level_arg: [0, 1]
|
||||||
|
level_def = '-DPINELOG_SHOW_LEVEL=' + level_arg.to_string()
|
||||||
|
level_name = level_arg == 1 ? 'lvl' : 'nolvl'
|
||||||
|
|
||||||
|
foreach backtrace_arg: [0, 1]
|
||||||
|
backtrace_def = '-DPINELOG_SHOW_BACKTRACE=' + backtrace_arg.to_string()
|
||||||
|
backtrace_name = backtrace_arg == 1 ? 'tr' : 'notr'
|
||||||
|
|
||||||
|
test_name = test_name_template.format(test_type,
|
||||||
|
date_name, level_name, backtrace_name)
|
||||||
|
test_exe = executable(test_name, test_src, 'pinelog.c',
|
||||||
|
c_args: [
|
||||||
|
'-DPINELOG_FATAL_STR="F"',
|
||||||
|
'-DPINELOG_ERROR_STR="E"',
|
||||||
|
'-DPINELOG_WARNING_STR="W"',
|
||||||
|
'-DPINELOG_INFO_STR="I"',
|
||||||
|
'-DPINELOG_DEBUG_STR="D"',
|
||||||
|
'-DPINELOG_TRACE_STR="T"',
|
||||||
|
'-DPINELOG_DEFAULT_LEVEL=PINELOG_LVL_TRACE',
|
||||||
|
'-DPINELOG_DEFAULT_STREAM=stderr',
|
||||||
|
'-DPINELOG_TEST',
|
||||||
|
date_def, level_def, backtrace_def
|
||||||
|
])
|
||||||
|
|
||||||
|
test(test_name, test_exe, protocol: 'tap')
|
||||||
|
endforeach
|
||||||
|
endforeach
|
||||||
|
endforeach
|
||||||
|
endforeach
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
option('show-date', type: 'boolean',
|
||||||
|
description: 'Show timestamp in log message')
|
||||||
|
|
||||||
|
option('show-level', type: 'boolean',
|
||||||
|
description: 'Show level string in log message')
|
||||||
|
|
||||||
|
option('show-backtrace', type: 'boolean',
|
||||||
|
description: 'Show backtrace information in log message')
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh -x
|
||||||
|
# Run the following command when installing files
|
||||||
|
|
||||||
|
# If DESTDIR is not specified or is not /, quit early
|
||||||
|
if ! test -n "${DESTDIR}" || [ "${DESTDIR}" != "/" ]
|
||||||
|
then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$(id -u)" = "0" ]
|
||||||
|
then
|
||||||
|
udevadm control --reload-rules && \
|
||||||
|
udevadm trigger --subsystem-match=usb --attr-match=idVendor=06a3 --action=add
|
||||||
|
fi
|
||||||
|
|
||||||
|
true
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# udev rules
|
||||||
|
if dep_udev.found()
|
||||||
|
if meson.version().version_compare('>= 0.58.0')
|
||||||
|
udev_dir = dep_udev.get_variable('udevdir', default_value:'/lib/udev')
|
||||||
|
else
|
||||||
|
udev_dir = dep_udev.get_pkgconfig_variable('udevdir', default:'/lib/udev')
|
||||||
|
endif
|
||||||
|
udev_rules_dir = join_paths(udev_dir, 'rules.d')
|
||||||
|
udev_file = configure_file(
|
||||||
|
input: '60-saitek-x52-x52pro.rules.in',
|
||||||
|
output: '60-saitek-x52-x52pro.rules',
|
||||||
|
configuration: {'input_group': get_option('input-group')}
|
||||||
|
)
|
||||||
|
install_data(udev_file, install_dir: udev_rules_dir)
|
||||||
|
meson.add_install_script('install-hook.sh')
|
||||||
|
endif
|
||||||
20
version-info
20
version-info
|
|
@ -31,12 +31,30 @@ then
|
||||||
fi
|
fi
|
||||||
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
|
cat <<EOM
|
||||||
#define BUILD_VERSION "${DESCRIBE}"
|
#define BUILD_VERSION "${DESCRIBE}"
|
||||||
#define BUILD_DATE "$(date -u +%Y-%m-%dT%H:%M:%S%z)"
|
#define BUILD_DATE "$(date -u +%Y-%m-%dT%H:%M:%S%z)"
|
||||||
#define BUILD_ARCH "$(uname -mp)"
|
#define BUILD_ARCH "$(uname -mp)"
|
||||||
#define BUILD_KERNEL "$(uname -sr)"
|
#define BUILD_KERNEL "$(uname -sr)"
|
||||||
#define BUILD_OS_VERSION "$(uname -v)"
|
#define BUILD_OS_VERSION "$(uname -v)"
|
||||||
#define BUILD_COMPILER "$(${CC} --version | head -n1)"
|
#define BUILD_COMPILER "${BUILD_COMPILER}"
|
||||||
EOM
|
EOM
|
||||||
echo '#define BUILD_VERSION_INFO_IDENT "$Id$"'
|
echo '#define BUILD_VERSION_INFO_IDENT "$Id$"'
|
||||||
|
|
||||||
|
if test -n "${CC}"
|
||||||
|
then
|
||||||
|
BUILD_TARGET="$(${CC} -dumpmachine || echo "unknown")"
|
||||||
|
else
|
||||||
|
BUILD_TARGET=unknown
|
||||||
|
fi
|
||||||
|
echo "#define BUILD_TARGET \"${BUILD_TARGET}\""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue