mirror of
https://github.com/linux-usb-gadgets/libusbgx.git
synced 2025-07-12 23:09:47 +03:00
libusbgx: Add meson build system
This commit is contained in:
parent
2e374d50aa
commit
2a3a4bacfc
6 changed files with 182 additions and 0 deletions
14
examples/meson.build
Normal file
14
examples/meson.build
Normal file
|
@ -0,0 +1,14 @@
|
|||
executable('show-gadgets', 'show-gadgets.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('gadget-acm-ecm', 'gadget-acm-ecm.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('gadget-vid-pid-remove', 'gadget-vid-pid-remove.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('gadget-ffs', 'gadget-ffs.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('gadget-export', 'gadget-export.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('gadget-import', 'gadget-import.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('gadget-rndis-os-desc', 'gadget-rndis-os-desc.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('gadget-printer', 'gadget-printer.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('gadget-ms', 'gadget-ms.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('gadget-midi', 'gadget-midi.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('gadget-hid', 'gadget-hid.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('gadget-uac2', 'gadget-uac2.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('gadget-uvc', 'gadget-uvc.c', dependencies: [ libusbgx_dep ], install: true)
|
||||
executable('show-udcs', 'show-udcs.c', dependencies: [ libusbgx_dep ], install: true)
|
6
install-headers.sh
Executable file
6
install-headers.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
install -d "${DESTDIR}/${MESON_INSTALL_PREFIX}/include/usbg/function"
|
||||
install -m 0644 "${MESON_BUILD_ROOT}/usbg_version.h" "${DESTDIR}/${MESON_INSTALL_PREFIX}/include/usbg"
|
||||
install -m 0644 "${MESON_SOURCE_ROOT}/include/usbg/usbg.h" "${DESTDIR}/${MESON_INSTALL_PREFIX}/include/usbg"
|
||||
install -m 0644 "${MESON_SOURCE_ROOT}/include/usbg/function/"* "${DESTDIR}/${MESON_INSTALL_PREFIX}/include/usbg/function"
|
106
meson.build
Normal file
106
meson.build
Normal file
|
@ -0,0 +1,106 @@
|
|||
project(
|
||||
'libusbgx',
|
||||
[ 'c', 'cpp' ],
|
||||
version: '0.2.0',
|
||||
license: 'LGPL2.1',
|
||||
default_options: [
|
||||
'warning_level=1',
|
||||
'werror=true',
|
||||
]
|
||||
)
|
||||
|
||||
add_project_arguments([ '-D_GNU_SOURCE' ], language: 'c')
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
config = configuration_data()
|
||||
|
||||
version = meson.project_version()
|
||||
version_hex = run_command('sh', '-c', 'printf "0x%02x%02x%04x" $(printf "%s" "@0@" | sed -e "s/\./ /g")'.format(version), check: true).stdout().strip()
|
||||
config.set('USBG_VERSION_HEX', version_hex)
|
||||
|
||||
dependencies = []
|
||||
sources = []
|
||||
c_flags = []
|
||||
|
||||
libconfig = dependency('libconfig', required: get_option('gadget-schemes'))
|
||||
libdl = cc.find_library('dl', required: get_option('tests'))
|
||||
cmocka = dependency('cmocka', required: get_option('tests'))
|
||||
doxygen = find_program('doxygen', required: get_option('doxygen'))
|
||||
|
||||
if libconfig.found()
|
||||
c_flags = ['-DHAS_GADGET_SCHEMES']
|
||||
dependencies += libconfig
|
||||
endif
|
||||
|
||||
inc = include_directories('include', '.')
|
||||
|
||||
subdir('src')
|
||||
|
||||
configure_file(
|
||||
input: 'include/usbg/usbg_version.h.in',
|
||||
output: 'usbg_version.h',
|
||||
configuration: config
|
||||
)
|
||||
meson.add_install_script('install-headers.sh')
|
||||
|
||||
libusbgx = library(
|
||||
'usbgx',
|
||||
sources,
|
||||
version: '2.0.0',
|
||||
dependencies: dependencies,
|
||||
include_directories: inc,
|
||||
c_args: c_flags,
|
||||
install: true,
|
||||
)
|
||||
|
||||
# For subproject:
|
||||
libusbgx_dep = declare_dependency(
|
||||
include_directories: inc,
|
||||
link_with: libusbgx,
|
||||
)
|
||||
|
||||
if get_option('examples')
|
||||
subdir('examples')
|
||||
endif
|
||||
|
||||
if cmocka.found()
|
||||
subdir('tests')
|
||||
endif
|
||||
|
||||
if doxygen.found()
|
||||
cfg = configuration_data()
|
||||
if cmocka.found()
|
||||
cfg.set('BUILD_TESTS_TRUE', '')
|
||||
else
|
||||
cfg.set('BUILD_TESTS_TRUE', 'X')
|
||||
endif
|
||||
configure_file(
|
||||
input: 'doxygen.cfg.in',
|
||||
output: 'doxygen.cfg',
|
||||
configuration: cfg
|
||||
)
|
||||
|
||||
env = environment()
|
||||
env.set('PROJECT', meson.project_name())
|
||||
env.set('VERSION', version)
|
||||
env.set('DOCDIR', meson.current_build_dir() + '/doc')
|
||||
env.set('SRCDIR', meson.current_source_dir())
|
||||
run_command(doxygen,
|
||||
meson.current_build_dir() + '/doxygen.cfg',
|
||||
env: env,
|
||||
check: true,
|
||||
)
|
||||
endif
|
||||
|
||||
pkgconfig = import('pkgconfig')
|
||||
pkgconfig.generate(
|
||||
libraries: libusbgx,
|
||||
version: meson.project_version(),
|
||||
filebase: meson.project_name(),
|
||||
name: meson.project_name(),
|
||||
description: 'USB gadget-configfs library',
|
||||
)
|
||||
|
||||
# TODO: install doxygen?
|
||||
# TODO: install cmake files
|
4
meson_options.txt
Normal file
4
meson_options.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
option('examples', type: 'boolean', value: false, description: 'Build examples')
|
||||
option('tests', type: 'feature', value: 'auto', description: 'Build unit tests')
|
||||
option('gadget-schemes', type: 'feature', value: 'auto', description: 'Enable gadget schemes')
|
||||
option('doxygen', type: 'feature', value: 'auto', description: 'Build documentation')
|
26
src/meson.build
Normal file
26
src/meson.build
Normal file
|
@ -0,0 +1,26 @@
|
|||
sources += files(
|
||||
'usbg.c',
|
||||
'usbg_error.c',
|
||||
'usbg_common.c',
|
||||
'function/ether.c',
|
||||
'function/ffs.c',
|
||||
'function/midi.c',
|
||||
'function/ms.c',
|
||||
'function/phonet.c',
|
||||
'function/serial.c',
|
||||
'function/loopback.c',
|
||||
'function/hid.c',
|
||||
'function/uac2.c',
|
||||
'function/uvc.c',
|
||||
'function/printer.c',
|
||||
'function/9pfs.c',
|
||||
)
|
||||
|
||||
if libconfig.found()
|
||||
sources += files(
|
||||
'usbg_schemes_libconfig.c',
|
||||
'usbg_common_libconfig.c'
|
||||
)
|
||||
else
|
||||
sources += files('usbg_schemes_none.c')
|
||||
endif
|
26
tests/meson.build
Normal file
26
tests/meson.build
Normal file
|
@ -0,0 +1,26 @@
|
|||
test_exe = executable('test_exe',
|
||||
[
|
||||
'test.c',
|
||||
'usbg-test.c',
|
||||
'usbg-io-wrappers.c',
|
||||
],
|
||||
dependencies: [
|
||||
libusbgx_dep,
|
||||
cmocka,
|
||||
],
|
||||
)
|
||||
|
||||
header_checker = executable('header_checker',
|
||||
[
|
||||
'header_checker.cpp',
|
||||
],
|
||||
dependencies: [
|
||||
libusbgx_dep,
|
||||
cmocka,
|
||||
],
|
||||
)
|
||||
|
||||
# TODO: also run with --generate-config or --use-config
|
||||
test('test_exe', test_exe)
|
||||
|
||||
test('header_checker', header_checker)
|
Loading…
Add table
Add a link
Reference in a new issue