diff options
author | Iñigo Martínez <inigomartinez@gmail.com> | 2020-11-08 20:12:04 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-05-05 08:52:51 +0000 |
commit | 89c619ec1c5355353e03e7ae5ccc8264e4e5cfb2 (patch) | |
tree | 53d0a8adeda8de53028900a1a7b63c8e27cfe738 /src | |
parent | 29fab8a1d4496ca5a1d32bb486013b1868a718ba (diff) |
build: Port to meson build system
meson is a build system focused on speed an ease of use, which
helps speeding up the software development. This patch adds meson
support along autotools.
Diffstat (limited to 'src')
-rw-r--r-- | src/libqmi-glib/generated/meson.build | 243 | ||||
-rw-r--r-- | src/libqmi-glib/meson.build | 175 | ||||
-rw-r--r-- | src/libqmi-glib/test/meson.build | 40 | ||||
-rw-r--r-- | src/meson.build | 10 | ||||
-rw-r--r-- | src/qmi-firmware-update/meson.build | 104 | ||||
-rw-r--r-- | src/qmi-firmware-update/test/meson.build | 27 | ||||
-rw-r--r-- | src/qmi-proxy/meson.build | 22 | ||||
-rw-r--r-- | src/qmicli/meson.build | 57 | ||||
-rw-r--r-- | src/qmicli/test/meson.build | 20 |
9 files changed, 698 insertions, 0 deletions
diff --git a/src/libqmi-glib/generated/meson.build b/src/libqmi-glib/generated/meson.build new file mode 100644 index 0000000..b2df39c --- /dev/null +++ b/src/libqmi-glib/generated/meson.build @@ -0,0 +1,243 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +generated_inc = include_directories('.') + +gen_sources = [] +gen_headers = [] +gen_sections = [] +gen_sections_deps = [] + +# Error types +enum_types = 'qmi-error-types' + +gen_headers += custom_target( + enum_types + '.h', + input: qmi_errors_header, + output: enum_types + '.h', + command: [ + python, + qmi_mkenums, + '--fhead', '#ifndef __LIBQMI_GLIB_ERROR_TYPES_H__\n#define __LIBQMI_GLIB_ERROR_TYPES_H__\n#include "qmi-errors.h"\n', + '--template', files(join_paths(templates_dir, enum_types + '.h.template')), + '--ftail', '#endif /* __LIBQMI_GLIB_ERROR_TYPES_H__ */\n', + '@INPUT@'], + capture: true, + install: true, + install_dir: qmi_glib_pkgincludedir, +) + +gen_sources += custom_target( + enum_types + '.c', + input: qmi_errors_header, + output: enum_types + '.c', + command: [ + python, + qmi_mkenums, + '--fhead', '#include "qmi-errors.h"\n#include "qmi-error-types.h"\n', + '--template', files(join_paths(templates_dir, enum_types + '.c.template')), + '@INPUT@'], + capture: true, +) + +enum_types = 'qmi-error-quarks' + +gen_sources += custom_target( + enum_types + '.c', + input: qmi_errors_header, + output: enum_types + '.c', + command: [ + python, + qmi_mkenums, + '--fhead', '#include "qmi-errors.h"\n#include "qmi-error-types.h"\n', + '--template', files(join_paths(templates_dir, enum_types + '.c.template')), + '@INPUT@'], + capture: true, +) + +# Enum/Flag types +enum_types = 'qmi-enum-types' + +gen_headers += custom_target( + enum_types + '.h', + input: qmi_enums_headers, + output: enum_types + '.h', + command: [ + python, + qmi_mkenums, + '--fhead', '#ifndef __LIBQMI_GLIB_ENUM_TYPES_H__\n#define __LIBQMI_GLIB_ENUM_TYPES_H__\n#include "qmi-enums.h"\n#include "qmi-enums-wds.h"\n#include "qmi-enums-dms.h"\n#include "qmi-enums-nas.h"\n#include "qmi-enums-wms.h"\n#include "qmi-enums-pds.h"\n#include "qmi-enums-pdc.h"\n#include "qmi-enums-pbm.h"\n#include "qmi-enums-uim.h"\n#include "qmi-enums-sar.h"\n#include "qmi-enums-oma.h"\n#include "qmi-enums-wda.h"\n#include "qmi-enums-voice.h"\n#include "qmi-enums-loc.h"\n#include "qmi-enums-qos.h"\n#include "qmi-enums-gas.h"\n#include "qmi-enums-dsd.h"\n#include "qmi-device.h"\n', + '--template', files(join_paths(templates_dir, enum_types + '.h.template')), + '--ftail', '#endif /* __LIBQMI_GLIB_ENUM_TYPES_H__ */\n', + '@INPUT@'], + capture: true, + install: true, + install_dir: qmi_glib_pkgincludedir, +) + +gen_sources += custom_target( + enum_types + '.c', + input: qmi_enums_headers, + output: enum_types + '.c', + command: [ + python, + qmi_mkenums, + '--fhead', '#include "qmi-enum-types.h"\n', + '--template', files(join_paths(templates_dir, enum_types + '.c.template')), + '@INPUT@'], + capture: true, +) + +# Private Enum/Flag types +enum_types = 'qmi-enum-types-private' + +gen_headers += custom_target( + enum_types + '.h', + input: qmi_enums_private_header, + output: enum_types + '.h', + command: [ + python, + qmi_mkenums, + '--fhead', '#ifndef __LIBQMI_GLIB_ENUM_TYPES_PRIVATE_H__\n#define __LIBQMI_GLIB_ENUM_TYPES_PRIVATE_H__\n#include "qmi-enums-private.h"\n', + '--template', files(join_paths(templates_dir, enum_types + '.h.template')), + '--ftail', '#endif /* __LIBQMI_GLIB_ENUM_TYPES_PRIVATE_H__ */\n', + '@INPUT@'], + capture: true, +) + +gen_sources += custom_target( + enum_types + '.c', + input: qmi_enums_private_header, + output: enum_types + '.c', + command: [ + python, + qmi_mkenums, + '--fhead', '#include "qmi-enum-types-private.h"\n', + '--template', files(join_paths(templates_dir, enum_types + '.c.template')), + '@INPUT@'], + capture: true, +) + +# 64bit flag types +enum_types = 'qmi-flags64-types' + +gen_headers += custom_target( + enum_types + '.h', + input: qmi_flags64_headers, + output: enum_types + '.h', + command: [ + python, + qmi_mkenums, + '--fhead', '#ifndef __LIBQMI_GLIB_FLAGS64_TYPES_H__\n#define __LIBQMI_GLIB_FLAGS64_TYPES_H__\n#include "qmi-flags64-dms.h"\n#include "qmi-flags64-nas.h"\n#include "qmi-flags64-loc.h"\n#include "qmi-flags64-dsd.h"\n#include "qmi-flags64-wds.h"\n', + '--template', files(join_paths(templates_dir, enum_types + '.h.template')), + '--ftail', '#endif /* __LIBQMI_GLIB_FLAGS64_TYPES_H__ */\n', + '@INPUT@'], + capture: true, + install: true, + install_dir: qmi_glib_pkgincludedir, +) + +gen_sources += custom_target( + enum_types + '.c', + input: qmi_flags64_headers, + output: enum_types + '.c', + command: [ + python, + qmi_mkenums, + '--fhead', '#include "qmi-flags64-types.h"\n', + '--template', files(join_paths(templates_dir, enum_types + '.c.template')), + '@INPUT@'], + capture: true, +) + +qmi_common = join_paths(data_dir, 'qmi-common.json') + +service = 'ctl' +name = 'qmi-' + service + +generated = custom_target( + name, + input: join_paths(data_dir, 'qmi-service-@0@.json'.format(service)), + output: [name + '.c', name + '.h', name + '.sections'], + command: [qmi_codegen, '--input', '@INPUT@', '--include', qmi_common, '--output', join_paths('@OUTDIR@', name)], +) + +gen_sources += [generated[0], generated[1]] + +services = [ + 'dms', + 'dpm', + 'dsd', + 'gas', + 'gms', + 'loc', + 'nas', + 'oma', + 'pbm', + 'pdc', + 'pds', + 'qos', + 'sar', + 'uim', + 'voice', + 'wda', + 'wds', + 'wms', +] + +command = [ + qmi_codegen, + '--input', '@INPUT@', + '--include', qmi_common, +] + +if qmi_collection_name != 'full' + command += ['--collection', join_paths(data_dir, 'qmi-collection-@0@.json'.format(qmi_collection_name))] +endif + +foreach service: services + name = 'qmi-' + service + + generated = custom_target( + name, + input: join_paths(data_dir, 'qmi-service-@0@.json'.format(service)), + output: [name + '.c', name + '.h', name + '.sections'], + command: command + ['--output', join_paths('@OUTDIR@', name)], + install: true, + install_dir: [false, qmi_glib_pkgincludedir, false], + ) + + gen_sources += generated[0] + gen_headers += generated[1] + # FIXME: the third target generated by custom target can't by used because is not a known + # source file, to the path has to be used. the first workaround is to use the + # build paths to point to the files, and the second workaround is to use + # custom target objects to force its building. + gen_sections += [join_paths(meson.current_build_dir(), name + '.sections')] + gen_sections_deps += [generated] +endforeach + +incs = [ + top_inc, + libqmi_glib_inc, +] + +c_flags = [ + '-DLIBQMI_GLIB_COMPILATION', + '-DG_LOG_DOMAIN="Qmi"', + '-Wno-unused-function', +] + +libqmi_glib_generated = static_library( + 'qmi-glib-generated', + sources: gen_sources + gen_headers, + include_directories: incs, + dependencies: glib_deps, + c_args: c_flags, +) + +libqmi_glib_generated_dep = declare_dependency( + sources: gen_headers, + include_directories: [libqmi_glib_inc, generated_inc], + dependencies: glib_deps, + link_with: libqmi_glib_generated, +) diff --git a/src/libqmi-glib/meson.build b/src/libqmi-glib/meson.build new file mode 100644 index 0000000..d03734e --- /dev/null +++ b/src/libqmi-glib/meson.build @@ -0,0 +1,175 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +libqmi_glib_inc = include_directories('.') + +qmi_errors_header = files('qmi-errors.h') + +qmi_enums_headers = files( + 'qmi-device.h', + 'qmi-enums.h', + 'qmi-enums-dms.h', + 'qmi-enums-dsd.h', + 'qmi-enums-gas.h', + 'qmi-enums-loc.h', + 'qmi-enums-nas.h', + 'qmi-enums-oma.h', + 'qmi-enums-pbm.h', + 'qmi-enums-pdc.h', + 'qmi-enums-pds.h', + 'qmi-enums-qos.h', + 'qmi-enums-sar.h', + 'qmi-enums-uim.h', + 'qmi-enums-voice.h', + 'qmi-enums-wda.h', + 'qmi-enums-wds.h', + 'qmi-enums-wms.h', +) + +qmi_enums_private_header = files('qmi-enums-private.h') + +qmi_flags64_headers = files( + 'qmi-flags64-dms.h', + 'qmi-flags64-dsd.h', + 'qmi-flags64-loc.h', + 'qmi-flags64-nas.h', + 'qmi-flags64-wds.h', +) + +headers = qmi_errors_header + qmi_enums_headers + qmi_enums_private_header + qmi_flags64_headers + files( + 'libqmi-glib.h', + 'qmi-client.h', + 'qmi-message-context.h', + 'qmi-message.h', + 'qmi-proxy.h', + 'qmi-utils.h', +) + +install_headers( + headers + files('qmi-compat.h'), + subdir: qmi_glib_include_subdir, +) + +version_header = configure_file( + input: 'qmi-version.h.in', + output: '@BASENAME@', + configuration: version_conf, + install_dir: qmi_glib_pkgincludedir, +) + +subdir('generated') + +common_c_flags = [ + '-DLIBQMI_GLIB_COMPILATION', + '-DG_LOG_DOMAIN="Qmi"', +] + +libqmi_glib_compat = static_library( + 'qmi-glib-compat', + sources: 'qmi-compat.c', + include_directories: top_inc, + dependencies: libqmi_glib_generated_dep, + c_args: common_c_flags + no_deprecated_declarations_flags, +) + +libname = 'qmi-glib' + +sources = files( + 'qmi-client.c', + 'qmi-device.c', + 'qmi-endpoint.c', + 'qmi-endpoint-qmux.c', + 'qmi-enums-dms.c', + 'qmi-enums-nas.c', + 'qmi-enums-wds.c', + 'qmi-file.c', + 'qmi-helpers.c', + 'qmi-message.c', + 'qmi-message-context.c', + 'qmi-net-port-manager.c', + 'qmi-net-port-manager-qmiwwan.c', + 'qmi-proxy.c', + 'qmi-utils.c', +) + +deps = [ + gio_unix_dep, + libqmi_glib_generated_dep, +] + +if enable_mbim_qmux + sources += files('qmi-endpoint-mbim.c') + deps += mbim_glib_dep +endif + +if enable_qrtr + sources += files('qmi-endpoint-qrtr.c') + deps += qrtr_glib_dep +endif + +if have_rmnet + sources += files('qmi-net-port-manager-rmnet.c') +endif + +libqmi_glib = shared_library( + libname, + version: qmi_glib_version, + sources: sources + [version_header], + include_directories: top_inc, + dependencies: deps, + c_args: common_c_flags + ['-DLIBEXEC_PATH="@0@"'.format(join_paths(qmi_prefix, qmi_libexecdir))], + link_whole: libqmi_glib_compat, + install: true, +) + +libqmi_glib_dep = declare_dependency( + sources: [gen_headers, version_header], + include_directories: [libqmi_glib_inc, generated_inc], + dependencies: glib_deps, + link_with: libqmi_glib, +) + +pkg.generate( + libraries: libqmi_glib, + version: qmi_version, + name: libname, + description: 'Library to communicate with QMI-powered modems', + subdirs: qmi_glib_include_subdir, + # FIXME: produced by the inhability of meson to use internal dependencies + requires: ['glib-2.0', 'gobject-2.0', 'gio-2.0'], + variables: [ + 'exec_prefix=${prefix}', + 'qmi_qrtr_supported=' + enable_qrtr.to_int().to_string(), + 'qmi_mbim_qmux_supported=' + enable_mbim_qmux.to_int().to_string(), + ], +) + +if enable_gir + incs = [ + 'Gio-2.0', + 'GLib-2.0', + 'GObject-2.0', + ] + + if enable_qrtr + incs += ['Qrtr-1.0'] + endif + + ns = 'Qmi' + + libqmi_glib_gir = gnome.generate_gir( + libqmi_glib, + sources: sources + headers + gen_sources + gen_headers, + includes: incs, + namespace: ns, + nsversion: qmi_gir_version, + identifier_prefix: ns, + symbol_prefix: ns.to_lower() + '_', + extra_args: common_c_flags + ['--identifier-prefix=' + ns.to_upper()], + header: 'libqmi-glib.h', + export_packages: 'libqmi-glib', + install: true, + ) +endif + +subdir('test') diff --git a/src/libqmi-glib/test/meson.build b/src/libqmi-glib/test/meson.build new file mode 100644 index 0000000..dcb7a1f --- /dev/null +++ b/src/libqmi-glib/test/meson.build @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +test_units = [ + ['test-compat-utils', files('test-compat-utils.c'), [libqmi_glib_dep]], + ['test-message', files('test-message.c'), [libqmi_glib_dep]], + ['test-utils', files('test-utils.c'), [libqmi_glib_dep]], +] + +sources = files( + 'test-fixture.c', + 'test-generated.c', + 'test-port-context.c', +) + +deps = [ + gio_unix_dep, + libqmi_glib_dep, +] + +test_units += [['test-generated', sources, deps]] + +test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) +test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) + +foreach test_unit: test_units + exe = executable( + test_unit[0], + sources: test_unit[1], + include_directories: top_inc, + dependencies: test_unit[2], + c_args: ['-DLIBQMI_GLIB_COMPILATION'] + no_deprecated_declarations_flags, + ) + + test( + test_unit[0], + exe, + env: test_env, + ) +endforeach diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..3285b43 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +subdir('libqmi-glib') +subdir('qmicli') +subdir('qmi-proxy') + +if enable_firmware_update + subdir('qmi-firmware-update') +endif diff --git a/src/qmi-firmware-update/meson.build b/src/qmi-firmware-update/meson.build new file mode 100644 index 0000000..b720b30 --- /dev/null +++ b/src/qmi-firmware-update/meson.build @@ -0,0 +1,104 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +libutils = static_library( + 'utils', + sources: 'qfu-utils.c', + include_directories: top_inc, + dependencies: libqmi_glib_dep, +) + +libutils_dep = declare_dependency( + include_directories: include_directories('.'), + dependencies: libqmi_glib_dep, + link_with: libutils, +) + +libfirehose = static_library( + 'firehose', + sources: 'qfu-firehose-message.c', + dependencies: glib_deps, +) + +libfirehose_dep = declare_dependency( + include_directories: include_directories('.'), + dependencies: glib_deps, + link_with: libfirehose, +) + +enum_headers = files( + 'qfu-dload-message.h', + 'qfu-image.h', + 'qfu-qdl-message.h', + 'qfu-sahara-message.h', +) + +sources = files( + 'qfu-at-device.c', + 'qfu-device-selection.c', + 'qfu-dload-message.c', + 'qfu-image.c', + 'qfu-image-cwe.c', + 'qfu-image-factory.c', + 'qfu-log.c', + 'qfu-main.c', + 'qfu-operation-reset.c', + 'qfu-operation-update.c', + 'qfu-operation-verify.c', + 'qfu-qdl-device.c', + 'qfu-qdl-message.c', + 'qfu-reseter.c', + 'qfu-sahara-device.c', + 'qfu-sahara-message.c', + 'qfu-udev-helpers.c', + 'qfu-updater.c', +) + +enum_types = 'qfu-enum-types' + +sources += custom_target( + enum_types + '.h', + input: enum_headers, + output: enum_types + '.h', + command: [ + python, + qmi_mkenums, + '--fhead', '#ifndef QFU_ENUM_TYPES_H\n#define QFU_ENUM_TYPES_H\n#include "qfu-image.h"\n#include "qfu-qdl-message.h"\n#include "qfu-dload-message.h"\n#include "qfu-sahara-message.h"\n', + '--template', files(join_paths(templates_dir, enum_types + '.h.template')), + '--ftail', '#endif /* __QFUENUM_TYPES_H__ */\n', + '@INPUT@'], + capture: true, +) + +sources += custom_target( + enum_types + '.c', + input: enum_headers, + output: enum_types + '.c', + command: [ + python, + qmi_mkenums, + '--fhead', '#include "qfu-enum-types.h"\n', + '--template', files(join_paths(templates_dir, enum_types + '.c.template')), + '@INPUT@'], + capture: true, +) + +deps = [ + gudev_dep, + libfirehose_dep, + libutils_dep, +] + +if enable_mbim_qmux + deps += mbim_glib_dep +endif + +qmi_firmware_update = executable( + 'qmi-firmware-update', + sources: sources, + include_directories: top_inc, + dependencies: deps, + install: true, +) + +subdir('test') diff --git a/src/qmi-firmware-update/test/meson.build b/src/qmi-firmware-update/test/meson.build new file mode 100644 index 0000000..a8020df --- /dev/null +++ b/src/qmi-firmware-update/test/meson.build @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +test_units = [ + ['test-utils', libutils_dep], + ['test-firehose', libfirehose_dep], +] + +test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) +test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) + +foreach test_unit: test_units + exe = executable( + # FIXME: added `firm` prefix to avoid target name collision + 'firm-' + test_unit[0], + sources: test_unit[0] + '.c', + include_directories: top_inc, + dependencies: test_unit[1], + c_args: '-DLIBQMI_GLIB_COMPILATION', + ) + + test( + test_unit[0], + exe, + env: test_env, + ) +endforeach diff --git a/src/qmi-proxy/meson.build b/src/qmi-proxy/meson.build new file mode 100644 index 0000000..7b9cbae --- /dev/null +++ b/src/qmi-proxy/meson.build @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +name = 'qmi-proxy' + +executable( + name, + sources: name + '.c', + include_directories: top_inc, + dependencies: libqmi_glib_dep, + install: true, + install_dir: qmi_libexecdir, +) + +if enable_qmi_username + configure_file( + input: '76-qmi-proxy-device-ownership.rules.in', + output: '@BASENAME@', + configuration: config_h, + install_dir: join_paths(udev_udevdir, 'rules.d'), + ) +endif diff --git a/src/qmicli/meson.build b/src/qmicli/meson.build new file mode 100644 index 0000000..b60bb1c --- /dev/null +++ b/src/qmicli/meson.build @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +libhelpers = static_library( + 'helpers', + sources: 'qmicli-helpers.c', + dependencies: libqmi_glib_dep, +) + +libhelpers_dep = declare_dependency( + include_directories: include_directories('.'), + dependencies: libqmi_glib_dep, + link_with: libhelpers, +) + +sources = files( + 'qmicli.c', + 'qmicli-dms.c', + 'qmicli-dpm.c', + 'qmicli-dsd.c', + 'qmicli-gas.c', + 'qmicli-gms.c', + 'qmicli-link-management.c', + 'qmicli-loc.c', + 'qmicli-nas.c', + 'qmicli-pbm.c', + 'qmicli-pdc.c', + 'qmicli-qmiwwan.c', + 'qmicli-qos.c', + 'qmicli-sar.c', + 'qmicli-uim.c', + 'qmicli-voice.c', + 'qmicli-wda.c', + 'qmicli-wds.c', + 'qmicli-wms.c', +) + +deps = [libhelpers_dep] + +if enable_mbim_qmux + deps += mbim_glib_dep +endif + +qmicli = executable( + 'qmicli', + sources: sources, + include_directories: top_inc, + dependencies: deps, + install: true, +) + +install_data( + 'qmicli-completion', + install_dir: bash_completion_completionsdir, +) + +subdir('test') diff --git a/src/qmicli/test/meson.build b/src/qmicli/test/meson.build new file mode 100644 index 0000000..0dabed4 --- /dev/null +++ b/src/qmicli/test/meson.build @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +test_unit = 'test-helpers' + +exe = executable( + test_unit, + sources: test_unit + '.c', + include_directories: top_inc, + dependencies: libhelpers_dep, +) + +test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) +test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) + +test( + test_unit, + exe, + env: test_env, +) |