diff --git a/.gitattributes b/.gitattributes index 5675f86..7dedafb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ /version-info ident +*/meson.build ident diff --git a/.github/scripts/build-and-test.sh b/.github/scripts/build-and-test.sh index 64bfb66..11f1604 100755 --- a/.github/scripts/build-and-test.sh +++ b/.github/scripts/build-and-test.sh @@ -2,16 +2,13 @@ # Run the build and tests set -e -./autogen.sh -mkdir build +meson setup -Dprefix=/usr -Dsysconfdir=/etc -Dlocalstatedir=/var -Dnls=enabled build cd build -../configure -make -j V=0 -make -j check V=0 -make -j distcheck +ninja +ninja test # Print bugreport output -./x52bugreport +./bugreport/x52bugreport # Make sure that there are no changes to the source code # This may happen if the source have changed with differences to the diff --git a/.github/scripts/build-doxygen.sh b/.github/scripts/build-doxygen.sh index 458578a..414981a 100755 --- a/.github/scripts/build-doxygen.sh +++ b/.github/scripts/build-doxygen.sh @@ -2,8 +2,6 @@ # Generate Doxygen documentation set -e -./autogen.sh -mkdir build +meson setup -Dprefix=/usr -Dsysconfdir=/etc -Dlocalstatedir=/var -Dnls=enabled build cd build -../configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var -make docs/.stamp +ninja docs diff --git a/.github/scripts/install-dependencies-macos.sh b/.github/scripts/install-dependencies-macos.sh index 0b622e5..b197265 100755 --- a/.github/scripts/install-dependencies-macos.sh +++ b/.github/scripts/install-dependencies-macos.sh @@ -11,6 +11,9 @@ brew install \ hidapi \ inih \ doxygen \ - cmocka + cmocka \ + meson \ + ninja \ + inih exit 0 diff --git a/.github/scripts/install-dependencies-ubuntu.sh b/.github/scripts/install-dependencies-ubuntu.sh index 01ccc33..ad83cc9 100755 --- a/.github/scripts/install-dependencies-ubuntu.sh +++ b/.github/scripts/install-dependencies-ubuntu.sh @@ -15,6 +15,9 @@ sudo apt-get install -y \ libinih-dev \ doxygen \ libcmocka-dev \ - faketime + faketime \ + meson \ + ninja-build \ + libinih-dev exit 0 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3880611..4de4d11 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -40,13 +40,7 @@ jobs: # languages: go, javascript, csharp, python, cpp, java - name: Build - run: | - ./autogen.sh - mkdir -p build - cd build - ../configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var - make -j V=0 - make -j V=0 check + run: ./.github/scripts/build-and-test.sh - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v4 diff --git a/Makefile.am b/Makefile.am index ea7ef22..53f9e85 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,7 +7,7 @@ ACLOCAL_AMFLAGS = -I m4 # Build any support libraries first -SUBDIRS = lib +SUBDIRS = subprojects if USE_NLS SUBDIRS += po diff --git a/bugreport/bugreport.c b/bugreport/bugreport.c index 62c9c06..3606c33 100644 --- a/bugreport/bugreport.c +++ b/bugreport/bugreport.c @@ -76,6 +76,7 @@ int main(int argc, char **argv) printf("Build host kernel: %s\n", BUILD_KERNEL); printf("Build host architecture: %s\n", BUILD_ARCH); printf("Build host version: %s\n", BUILD_OS_VERSION); + printf("Build target: %s\n", BUILD_TARGET); printf("Compiler: %s\n", BUILD_COMPILER); printf("Build date: %s\n", BUILD_DATE); printf("version-info %s\n", BUILD_VERSION_INFO_IDENT); diff --git a/bugreport/meson.build b/bugreport/meson.build new file mode 100644 index 0000000..01d5778 --- /dev/null +++ b/bugreport/meson.build @@ -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') diff --git a/bugreport/version-info.h.meson b/bugreport/version-info.h.meson new file mode 100644 index 0000000..3f333fd --- /dev/null +++ b/bugreport/version-info.h.meson @@ -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 diff --git a/cli/meson.build b/cli/meson.build new file mode 100644 index 0000000..e5c263f --- /dev/null +++ b/cli/meson.build @@ -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') + + diff --git a/cli/x52_cli.c b/cli/x52_cli.c index 79c9b73..d44365a 100644 --- a/cli/x52_cli.c +++ b/cli/x52_cli.c @@ -462,12 +462,12 @@ static void do_help(const struct command_handler *cmd) if (cmd) { fprintf(stderr, "Command usage: %s\n", cmd->help); } else { - printf("\nCommands:\n"); + fprintf(stderr, "\nCommands:\n"); 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"); } } diff --git a/config.h.meson b/config.h.meson new file mode 100644 index 0000000..2f7f7ab --- /dev/null +++ b/config.h.meson @@ -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" diff --git a/configure.ac b/configure.ac index f5ed691..e9d1fb2 100644 --- a/configure.ac +++ b/configure.ac @@ -138,11 +138,11 @@ AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([ po/Makefile.in Makefile - lib/Makefile + subprojects/Makefile libx52/libx52.pc libx52io/libx52io.pc libx52util/libx52util.pc - lib/pinelog/Makefile + subprojects/pinelog/Makefile udev/60-saitek-x52-x52pro.rules ]) AC_OUTPUT diff --git a/daemon/Makefile.am b/daemon/Makefile.am index b391bed..2e0449a 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -26,7 +26,7 @@ x52d_CFLAGS = \ -I $(top_srcdir)/libx52io \ -I $(top_srcdir)/libx52 \ -I $(top_srcdir)/libx52util \ - -I $(top_srcdir)/lib/pinelog \ + -I $(top_srcdir)/subprojects/pinelog \ -DSYSCONFDIR=\"$(sysconfdir)\" \ -DLOCALEDIR=\"$(localedir)\" \ -DLOGDIR=\"$(localstatedir)/log\" \ @@ -35,7 +35,7 @@ x52d_CFLAGS = \ x52d_LDFLAGS = @INIH_LIBS@ @PTHREAD_LIBS@ $(WARN_LDFLAGS) x52d_LDADD = \ - lib/pinelog/libpinelog.la \ + subprojects/pinelog/libpinelog.la \ libx52.la \ @LTLIBINTL@ @@ -123,11 +123,11 @@ x52d_mouse_test_CFLAGS = \ -I $(top_srcdir) \ -I $(top_srcdir)/libx52 \ -I $(top_srcdir)/libx52io \ - -I $(top_srcdir)/lib/pinelog \ + -I $(top_srcdir)/subprojects/pinelog \ $(WARN_CFLAGS) @CMOCKA_CFLAGS@ x52d_mouse_test_LDFLAGS = @CMOCKA_LIBS@ $(WARN_LDFLAGS) x52d_mouse_test_LDADD = \ - lib/pinelog/libpinelog.la \ + subprojects/pinelog/libpinelog.la \ @LTLIBINTL@ TESTS += x52d-mouse-test diff --git a/daemon/meson.build b/daemon/meson.build new file mode 100644 index 0000000..88cd27e --- /dev/null +++ b/daemon/meson.build @@ -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') + diff --git a/evtest/meson.build b/evtest/meson.build new file mode 100644 index 0000000..435b9be --- /dev/null +++ b/evtest/meson.build @@ -0,0 +1,6 @@ +# x52evtest +executable('x52evtest', 'ev_test.c', + install: true, + include_directories: includes, + dependencies: [dep_intl], + link_with: [lib_libx52io]) diff --git a/joytest/meson.build b/joytest/meson.build new file mode 100644 index 0000000..99688fd --- /dev/null +++ b/joytest/meson.build @@ -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]) diff --git a/libx52/libx52.h b/libx52/libx52.h index 94e4b4a..c92c48d 100644 --- a/libx52/libx52.h +++ b/libx52/libx52.h @@ -285,7 +285,6 @@ int libx52_init(libx52_device ** dev); * cause errors. * * @param[in] dev Pointer to the device context - * @returns None */ void libx52_exit(libx52_device *dev); diff --git a/libx52/meson.build b/libx52/meson.build new file mode 100644 index 0000000..4ca9cb9 --- /dev/null +++ b/libx52/meson.build @@ -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') diff --git a/libx52io/libx52io.h b/libx52io/libx52io.h index dff593b..2357ad9 100644 --- a/libx52io/libx52io.h +++ b/libx52io/libx52io.h @@ -303,7 +303,6 @@ int libx52io_init(libx52io_context **ctx); * cause errors. * * @param[in] ctx Pointer to the device context - * @returns None */ void libx52io_exit(libx52io_context *ctx); diff --git a/libx52io/meson.build b/libx52io/meson.build new file mode 100644 index 0000000..85c5aa6 --- /dev/null +++ b/libx52io/meson.build @@ -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') + + diff --git a/libx52util/meson.build b/libx52util/meson.build new file mode 100644 index 0000000..f371fd4 --- /dev/null +++ b/libx52util/meson.build @@ -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') diff --git a/libx52util/x52_map_test_gen.py b/libx52util/x52_map_test_gen.py index 97c879b..60567d6 100755 --- a/libx52util/x52_map_test_gen.py +++ b/libx52util/x52_map_test_gen.py @@ -48,7 +48,7 @@ static void test_map_{in_char}(void **state) {{ rc = libx52util_convert_utf8_string(input_array, output, &out_len); assert_int_equal(rc, 0); assert_int_equal(out_len, 1); - assert_string_equal(output, expected_output); + assert_memory_equal(output, expected_output, 2); }} """ diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..f20515f --- /dev/null +++ b/meson.build @@ -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 ')) + +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 diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..fe747e1 --- /dev/null +++ b/meson_options.txt @@ -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') diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..3872d60 --- /dev/null +++ b/po/meson.build @@ -0,0 +1,3 @@ +i18n.gettext(meson.project_name(), + args: '--directory=' + meson.source_root(), +) diff --git a/lib/Makefile.am b/subprojects/Makefile.am similarity index 100% rename from lib/Makefile.am rename to subprojects/Makefile.am diff --git a/lib/pinelog/.gitignore b/subprojects/pinelog/.gitignore similarity index 100% rename from lib/pinelog/.gitignore rename to subprojects/pinelog/.gitignore diff --git a/lib/pinelog/LICENSE b/subprojects/pinelog/LICENSE similarity index 100% rename from lib/pinelog/LICENSE rename to subprojects/pinelog/LICENSE diff --git a/lib/pinelog/Makefile.am b/subprojects/pinelog/Makefile.am similarity index 100% rename from lib/pinelog/Makefile.am rename to subprojects/pinelog/Makefile.am diff --git a/lib/pinelog/README.md b/subprojects/pinelog/README.md similarity index 100% rename from lib/pinelog/README.md rename to subprojects/pinelog/README.md diff --git a/lib/pinelog/autogen.sh b/subprojects/pinelog/autogen.sh similarity index 100% rename from lib/pinelog/autogen.sh rename to subprojects/pinelog/autogen.sh diff --git a/lib/pinelog/bench_pinelog.c b/subprojects/pinelog/bench_pinelog.c similarity index 100% rename from lib/pinelog/bench_pinelog.c rename to subprojects/pinelog/bench_pinelog.c diff --git a/lib/pinelog/configure.ac b/subprojects/pinelog/configure.ac similarity index 100% rename from lib/pinelog/configure.ac rename to subprojects/pinelog/configure.ac diff --git a/lib/pinelog/m4/ax_append_compile_flags.m4 b/subprojects/pinelog/m4/ax_append_compile_flags.m4 similarity index 100% rename from lib/pinelog/m4/ax_append_compile_flags.m4 rename to subprojects/pinelog/m4/ax_append_compile_flags.m4 diff --git a/lib/pinelog/m4/ax_append_flag.m4 b/subprojects/pinelog/m4/ax_append_flag.m4 similarity index 100% rename from lib/pinelog/m4/ax_append_flag.m4 rename to subprojects/pinelog/m4/ax_append_flag.m4 diff --git a/lib/pinelog/m4/ax_append_link_flags.m4 b/subprojects/pinelog/m4/ax_append_link_flags.m4 similarity index 100% rename from lib/pinelog/m4/ax_append_link_flags.m4 rename to subprojects/pinelog/m4/ax_append_link_flags.m4 diff --git a/lib/pinelog/m4/ax_check_compile_flag.m4 b/subprojects/pinelog/m4/ax_check_compile_flag.m4 similarity index 100% rename from lib/pinelog/m4/ax_check_compile_flag.m4 rename to subprojects/pinelog/m4/ax_check_compile_flag.m4 diff --git a/lib/pinelog/m4/ax_check_link_flag.m4 b/subprojects/pinelog/m4/ax_check_link_flag.m4 similarity index 100% rename from lib/pinelog/m4/ax_check_link_flag.m4 rename to subprojects/pinelog/m4/ax_check_link_flag.m4 diff --git a/lib/pinelog/m4/ax_compiler_flags.m4 b/subprojects/pinelog/m4/ax_compiler_flags.m4 similarity index 100% rename from lib/pinelog/m4/ax_compiler_flags.m4 rename to subprojects/pinelog/m4/ax_compiler_flags.m4 diff --git a/lib/pinelog/m4/ax_compiler_flags_cflags.m4 b/subprojects/pinelog/m4/ax_compiler_flags_cflags.m4 similarity index 100% rename from lib/pinelog/m4/ax_compiler_flags_cflags.m4 rename to subprojects/pinelog/m4/ax_compiler_flags_cflags.m4 diff --git a/lib/pinelog/m4/ax_compiler_flags_gir.m4 b/subprojects/pinelog/m4/ax_compiler_flags_gir.m4 similarity index 100% rename from lib/pinelog/m4/ax_compiler_flags_gir.m4 rename to subprojects/pinelog/m4/ax_compiler_flags_gir.m4 diff --git a/lib/pinelog/m4/ax_compiler_flags_ldflags.m4 b/subprojects/pinelog/m4/ax_compiler_flags_ldflags.m4 similarity index 100% rename from lib/pinelog/m4/ax_compiler_flags_ldflags.m4 rename to subprojects/pinelog/m4/ax_compiler_flags_ldflags.m4 diff --git a/lib/pinelog/m4/ax_gcc_func_attribute.m4 b/subprojects/pinelog/m4/ax_gcc_func_attribute.m4 similarity index 100% rename from lib/pinelog/m4/ax_gcc_func_attribute.m4 rename to subprojects/pinelog/m4/ax_gcc_func_attribute.m4 diff --git a/lib/pinelog/m4/ax_require_defined.m4 b/subprojects/pinelog/m4/ax_require_defined.m4 similarity index 100% rename from lib/pinelog/m4/ax_require_defined.m4 rename to subprojects/pinelog/m4/ax_require_defined.m4 diff --git a/subprojects/pinelog/meson.build b/subprojects/pinelog/meson.build new file mode 100644 index 0000000..7b1fb79 --- /dev/null +++ b/subprojects/pinelog/meson.build @@ -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 diff --git a/subprojects/pinelog/meson_options.txt b/subprojects/pinelog/meson_options.txt new file mode 100644 index 0000000..20273c6 --- /dev/null +++ b/subprojects/pinelog/meson_options.txt @@ -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') diff --git a/lib/pinelog/pinelog.c b/subprojects/pinelog/pinelog.c similarity index 100% rename from lib/pinelog/pinelog.c rename to subprojects/pinelog/pinelog.c diff --git a/lib/pinelog/pinelog.h b/subprojects/pinelog/pinelog.h similarity index 100% rename from lib/pinelog/pinelog.h rename to subprojects/pinelog/pinelog.h diff --git a/lib/pinelog/test_pinelog.c b/subprojects/pinelog/test_pinelog.c similarity index 100% rename from lib/pinelog/test_pinelog.c rename to subprojects/pinelog/test_pinelog.c diff --git a/udev/install-hook.sh b/udev/install-hook.sh new file mode 100755 index 0000000..138dad8 --- /dev/null +++ b/udev/install-hook.sh @@ -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 diff --git a/udev/meson.build b/udev/meson.build new file mode 100644 index 0000000..e951f41 --- /dev/null +++ b/udev/meson.build @@ -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 diff --git a/version-info b/version-info index edc67a3..0310c02 100755 --- a/version-info +++ b/version-info @@ -31,12 +31,30 @@ 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 <