mirror of https://github.com/nirenjan/libx52.git
refactor: Rearrange files to avoid duplicate code issue
Prior to this change, SonarQube complains about duplicated code in the symlinked header files. This change reworks the layout so that the installed headers all reside under the 'includes' directory, and the meson.build files are updated to reflect the new paths.pull/69/head
parent
dbf891f951
commit
3c02fe5ec2
|
|
@ -6,14 +6,14 @@ libx52dcomm_sources = [
|
||||||
'comm_internal.c'
|
'comm_internal.c'
|
||||||
]
|
]
|
||||||
|
|
||||||
install_headers('x52dcomm.h', subdir: meson.project_name())
|
root_includes = include_directories('..')
|
||||||
|
|
||||||
lib_libx52dcomm = library('x52dcomm', libx52dcomm_sources,
|
lib_libx52dcomm = library('x52dcomm', libx52dcomm_sources,
|
||||||
dependencies: [dep_intl, dep_config_h],
|
dependencies: [dep_intl, dep_config_h],
|
||||||
version: libx52dcomm_version,
|
version: libx52dcomm_version,
|
||||||
c_args: sym_hidden_cargs,
|
c_args: sym_hidden_cargs,
|
||||||
install: true,
|
install: true,
|
||||||
include_directories: includes)
|
include_directories: [includes, root_includes])
|
||||||
|
|
||||||
pkgconfig.generate(lib_libx52dcomm,
|
pkgconfig.generate(lib_libx52dcomm,
|
||||||
name: 'x52dcomm',
|
name: 'x52dcomm',
|
||||||
|
|
@ -50,7 +50,7 @@ x52d_cflags = []
|
||||||
|
|
||||||
exe_x52d = executable('x52d', x52d_sources + libx52dcomm_sources,
|
exe_x52d = executable('x52d', x52d_sources + libx52dcomm_sources,
|
||||||
install: true,
|
install: true,
|
||||||
include_directories: includes,
|
include_directories: [includes, root_includes],
|
||||||
c_args: sym_hidden_cargs + x52d_cflags,
|
c_args: sym_hidden_cargs + x52d_cflags,
|
||||||
dependencies: x52d_deps,
|
dependencies: x52d_deps,
|
||||||
link_with: x52d_linkwith)
|
link_with: x52d_linkwith)
|
||||||
|
|
@ -58,7 +58,7 @@ exe_x52d = executable('x52d', x52d_sources + libx52dcomm_sources,
|
||||||
exe_x52ctl = executable('x52ctl', 'daemon_control.c',
|
exe_x52ctl = executable('x52ctl', 'daemon_control.c',
|
||||||
install: true,
|
install: true,
|
||||||
dependencies: [dep_intl, dep_config_h],
|
dependencies: [dep_intl, dep_config_h],
|
||||||
include_directories: includes,
|
include_directories: [includes, root_includes],
|
||||||
link_with: lib_libx52dcomm)
|
link_with: lib_libx52dcomm)
|
||||||
|
|
||||||
install_data('x52d.conf',
|
install_data('x52d.conf',
|
||||||
|
|
@ -82,7 +82,7 @@ test('daemon-communication', files('test_daemon_comm.py')[0],
|
||||||
|
|
||||||
x52d_mouse_test_sources = ['mouse_test.c', 'mouse.c']
|
x52d_mouse_test_sources = ['mouse_test.c', 'mouse.c']
|
||||||
x52d_mouse_test = executable('x52d-mouse-test', x52d_mouse_test_sources,
|
x52d_mouse_test = executable('x52d-mouse-test', x52d_mouse_test_sources,
|
||||||
include_directories: includes,
|
include_directories: [includes, root_includes],
|
||||||
dependencies: [dep_pinelog, dep_cmocka, dep_intl, dep_math, dep_config_h])
|
dependencies: [dep_pinelog, dep_cmocka, dep_intl, dep_math, dep_config_h])
|
||||||
|
|
||||||
test('x52d-mouse-test', x52d_mouse_test, protocol: 'tap')
|
test('x52d-mouse-test', x52d_mouse_test, protocol: 'tap')
|
||||||
|
|
@ -91,14 +91,14 @@ layout_usage_allowlist_test = executable('layout-usage-allowlist-test',
|
||||||
'layout_usage_allowlist_test.c',
|
'layout_usage_allowlist_test.c',
|
||||||
'layout_usage_allowlist.c',
|
'layout_usage_allowlist.c',
|
||||||
build_by_default: false,
|
build_by_default: false,
|
||||||
include_directories: includes,
|
include_directories: [includes, root_includes],
|
||||||
dependencies: [dep_cmocka, dep_config_h])
|
dependencies: [dep_cmocka, dep_config_h])
|
||||||
|
|
||||||
test('layout-usage-allowlist', layout_usage_allowlist_test, protocol: 'tap')
|
test('layout-usage-allowlist', layout_usage_allowlist_test, protocol: 'tap')
|
||||||
|
|
||||||
crc32_test = executable('crc32-test', 'crc32_test.c', 'crc32.c',
|
crc32_test = executable('crc32-test', 'crc32_test.c', 'crc32.c',
|
||||||
build_by_default: false,
|
build_by_default: false,
|
||||||
include_directories: includes,
|
include_directories: [includes, root_includes],
|
||||||
dependencies: [dep_cmocka, dep_config_h])
|
dependencies: [dep_cmocka, dep_config_h])
|
||||||
|
|
||||||
test('crc32', crc32_test, protocol: 'tap')
|
test('crc32', crc32_test, protocol: 'tap')
|
||||||
|
|
@ -109,7 +109,7 @@ layout_load_test = executable('layout-load-test',
|
||||||
'layout_usage_allowlist.c',
|
'layout_usage_allowlist.c',
|
||||||
'crc32.c',
|
'crc32.c',
|
||||||
build_by_default: false,
|
build_by_default: false,
|
||||||
include_directories: includes,
|
include_directories: [includes, root_includes],
|
||||||
dependencies: [dep_cmocka, dep_config_h])
|
dependencies: [dep_cmocka, dep_config_h])
|
||||||
|
|
||||||
test('layout-load', layout_load_test, protocol: 'tap')
|
test('layout-load', layout_load_test, protocol: 'tap')
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
#######################################################################
|
||||||
|
# build-config.h (Meson configuration; template is config.h.meson)
|
||||||
|
#######################################################################
|
||||||
|
sym_hidden_cargs = []
|
||||||
|
if compiler.has_argument('-fvisibility=hidden')
|
||||||
|
sym_hidden_cargs = ['-fvisibility=hidden']
|
||||||
|
endif
|
||||||
|
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('prefix') / get_option('localedir'))
|
||||||
|
cdata.set_quoted('SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
|
||||||
|
cdata.set_quoted('LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
|
||||||
|
cdata.set_quoted('DATADIR', get_option('prefix') / get_option('datadir'))
|
||||||
|
cdata.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||||
|
cdata.set_quoted('VERSION', meson.project_version())
|
||||||
|
cdata.set10('ENABLE_NLS', not get_option('nls').disabled())
|
||||||
|
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: 'build-config.h.meson',
|
||||||
|
output: 'build-config.h',
|
||||||
|
configuration: cdata
|
||||||
|
)
|
||||||
|
|
||||||
|
dep_config_h = declare_dependency(sources: config_h)
|
||||||
|
|
||||||
|
|
||||||
|
install_headers(
|
||||||
|
'libx52/libx52.h',
|
||||||
|
'libx52/libx52io.h',
|
||||||
|
'libx52/libx52util.h',
|
||||||
|
'libx52/x52dcomm.h',
|
||||||
|
subdir: 'libx52'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
../libx52io/libx52io.h
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
../libx52util/libx52util.h
|
|
||||||
|
|
@ -16,7 +16,6 @@ lib_libx52 = library('x52', libx52_files,
|
||||||
dependencies: [dep_libusb, dep_intl],
|
dependencies: [dep_libusb, dep_intl],
|
||||||
include_directories: [includes])
|
include_directories: [includes])
|
||||||
|
|
||||||
install_headers('libx52.h', subdir: meson.project_name())
|
|
||||||
pkgconfig.generate(lib_libx52,
|
pkgconfig.generate(lib_libx52,
|
||||||
name: 'libx52',
|
name: 'libx52',
|
||||||
description: 'Linux/Unix library to control Saitek X52/X52Pro joystick extended functionality.',
|
description: 'Linux/Unix library to control Saitek X52/X52Pro joystick extended functionality.',
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
../daemon/x52dcomm.h
|
|
||||||
|
|
@ -15,7 +15,6 @@ lib_libx52io = library('x52io', libx52io_files,
|
||||||
dependencies: [dep_hidapi, dep_intl],
|
dependencies: [dep_hidapi, dep_intl],
|
||||||
include_directories: [includes])
|
include_directories: [includes])
|
||||||
|
|
||||||
install_headers('libx52io.h', subdir: meson.project_name())
|
|
||||||
pkgconfig.generate(lib_libx52io,
|
pkgconfig.generate(lib_libx52io,
|
||||||
name: 'libx52io',
|
name: 'libx52io',
|
||||||
description: 'Linux/Unix library to read and parse X52 input',
|
description: 'Linux/Unix library to read and parse X52 input',
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ lib_libx52util = library('x52util', util_char_map, 'char_map_lookup.c',
|
||||||
include_directories: [includes],
|
include_directories: [includes],
|
||||||
)
|
)
|
||||||
|
|
||||||
install_headers('libx52util.h', subdir: meson.project_name())
|
|
||||||
pkgconfig.generate(lib_libx52util,
|
pkgconfig.generate(lib_libx52util,
|
||||||
name: 'libx52util',
|
name: 'libx52util',
|
||||||
description: 'Extra utility functions to manage X52 extended functionality',
|
description: 'Extra utility functions to manage X52 extended functionality',
|
||||||
|
|
|
||||||
34
meson.build
34
meson.build
|
|
@ -35,36 +35,7 @@ python = pymod.find_installation('python3')
|
||||||
pyversion = python.language_version().split('.')
|
pyversion = python.language_version().split('.')
|
||||||
assert(pyversion[1].to_int() >= 5, 'Require Python >= 3.5')
|
assert(pyversion[1].to_int() >= 5, 'Require Python >= 3.5')
|
||||||
|
|
||||||
#######################################################################
|
|
||||||
# build-config.h (Meson configuration; template is config.h.meson)
|
|
||||||
#######################################################################
|
|
||||||
compiler = meson.get_compiler('c')
|
compiler = meson.get_compiler('c')
|
||||||
sym_hidden_cargs = []
|
|
||||||
if compiler.has_argument('-fvisibility=hidden')
|
|
||||||
sym_hidden_cargs = ['-fvisibility=hidden']
|
|
||||||
endif
|
|
||||||
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('prefix') / get_option('localedir'))
|
|
||||||
cdata.set_quoted('SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
|
|
||||||
cdata.set_quoted('LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
|
|
||||||
cdata.set_quoted('DATADIR', get_option('prefix') / get_option('datadir'))
|
|
||||||
cdata.set_quoted('PACKAGE_VERSION', meson.project_version())
|
|
||||||
cdata.set_quoted('VERSION', meson.project_version())
|
|
||||||
cdata.set10('ENABLE_NLS', not get_option('nls').disabled())
|
|
||||||
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: 'build-config.h',
|
|
||||||
configuration: cdata
|
|
||||||
)
|
|
||||||
|
|
||||||
dep_config_h = declare_dependency(sources: config_h)
|
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Internationalization
|
# Internationalization
|
||||||
|
|
@ -122,12 +93,15 @@ dep_pinelog = sub_pinelog.get_variable('libpinelog_dep')
|
||||||
# Use system inih
|
# Use system inih
|
||||||
dep_inih = dependency('inih')
|
dep_inih = dependency('inih')
|
||||||
|
|
||||||
|
# Local includes
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Shared libraries and programs
|
# Shared libraries and programs
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Includes
|
# Includes
|
||||||
includes = include_directories('.')
|
includes = include_directories('include')
|
||||||
|
|
||||||
|
subdir('include')
|
||||||
subdir('libx52')
|
subdir('libx52')
|
||||||
subdir('libx52io')
|
subdir('libx52io')
|
||||||
subdir('libx52util')
|
subdir('libx52util')
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
def check_vkm_modifier_symbols():
|
def check_vkm_modifier_symbols():
|
||||||
vkm = (root / "vkm" / "vkm.h").read_text(encoding="utf-8")
|
vkm = (root / "include" / "vkm" / "vkm.h").read_text(encoding="utf-8")
|
||||||
for name in (
|
for name in (
|
||||||
"VKM_KEY_MOD_LCTRL",
|
"VKM_KEY_MOD_LCTRL",
|
||||||
"VKM_KEY_MOD_LSHIFT",
|
"VKM_KEY_MOD_LSHIFT",
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,6 @@ if host_machine.system() == 'linux' and dep_evdev.found()
|
||||||
test('vkm_linux_evdev', vkm_linux_evdev_test)
|
test('vkm_linux_evdev', vkm_linux_evdev_test)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
install_headers('vkm.h', subdir: 'vkm')
|
|
||||||
pkgconfig.generate(lib_vkm,
|
pkgconfig.generate(lib_vkm,
|
||||||
name: 'vkm',
|
name: 'vkm',
|
||||||
description: 'Virtual keyboard/mouse interface library for injecting events into the host OS.',
|
description: 'Virtual keyboard/mouse interface library for injecting events into the host OS.',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue