diff options
l--------- | build-aux/templates/qfu-enum-types.c.template | 1 | ||||
l--------- | build-aux/templates/qfu-enum-types.h.template | 1 | ||||
l--------- | build-aux/templates/qmi-enum-types-private.c.template | 1 | ||||
l--------- | build-aux/templates/qmi-enum-types-private.h.template | 1 | ||||
-rw-r--r-- | docs/man/meson.build | 18 | ||||
-rw-r--r-- | docs/reference/libqmi-glib/meson.build | 78 | ||||
-rw-r--r-- | docs/reference/libqmi-glib/xml/gtkdocentities.ent.in | 7 | ||||
-rw-r--r-- | docs/reference/libqmi-glib/xml/meson.build | 17 | ||||
-rw-r--r-- | meson.build | 247 | ||||
-rw-r--r-- | meson_options.txt | 14 | ||||
-rw-r--r-- | meson_post_install.py | 14 | ||||
-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 | ||||
-rw-r--r-- | utils/meson.build | 21 |
21 files changed, 1118 insertions, 0 deletions
diff --git a/build-aux/templates/qfu-enum-types.c.template b/build-aux/templates/qfu-enum-types.c.template new file mode 120000 index 00000000..840a6260 --- /dev/null +++ b/build-aux/templates/qfu-enum-types.c.template @@ -0,0 +1 @@ +qmi-enum-types.c.template
\ No newline at end of file diff --git a/build-aux/templates/qfu-enum-types.h.template b/build-aux/templates/qfu-enum-types.h.template new file mode 120000 index 00000000..e126ec71 --- /dev/null +++ b/build-aux/templates/qfu-enum-types.h.template @@ -0,0 +1 @@ +qmi-enum-types.h.template
\ No newline at end of file diff --git a/build-aux/templates/qmi-enum-types-private.c.template b/build-aux/templates/qmi-enum-types-private.c.template new file mode 120000 index 00000000..840a6260 --- /dev/null +++ b/build-aux/templates/qmi-enum-types-private.c.template @@ -0,0 +1 @@ +qmi-enum-types.c.template
\ No newline at end of file diff --git a/build-aux/templates/qmi-enum-types-private.h.template b/build-aux/templates/qmi-enum-types-private.h.template new file mode 120000 index 00000000..e126ec71 --- /dev/null +++ b/build-aux/templates/qmi-enum-types-private.h.template @@ -0,0 +1 @@ +qmi-enum-types.h.template
\ No newline at end of file diff --git a/docs/man/meson.build b/docs/man/meson.build new file mode 100644 index 00000000..42aca7d9 --- /dev/null +++ b/docs/man/meson.build @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +mans = [ + ['qmicli', [help2man, '--output=@OUTPUT@', '--name=Control QMI devices', '--help-option="--help-all"', qmicli]], + ['qmi-network', [help2man, '--output=@OUTPUT@', '--name=Simple network management of QMI devices', qmi_network]], + ['qmi-firmware-update', [help2man, '--output=@OUTPUT@', '--name=Update firmware in QMI devices', qmi_firmware_update]], +] + +foreach man: mans + custom_target( + man[0], + output: man[0] + '.1', + command: man[1], + install: true, + install_dir: join_paths(qmi_mandir, 'man1'), + ) +endforeach diff --git a/docs/reference/libqmi-glib/meson.build b/docs/reference/libqmi-glib/meson.build new file mode 100644 index 00000000..4a5dfcc0 --- /dev/null +++ b/docs/reference/libqmi-glib/meson.build @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +subdir('xml') + +doc_module = 'libqmi-glib' + +src_dirs = [ + generated_inc, + libqmi_glib_inc, +] + +private_headers = [ + 'qmi-ctl.h', + 'qmi-endpoint.h', + 'qmi-endpoint-mbim.h', + 'qmi-endpoint-qmux.h', + 'qmi-endpoint-qrtr.h', + 'qmi-enums-private.h', + 'qmi-enum-types-private.h', + 'qmi-file.h', + 'qmi-helpers.h', + 'qmi-net-port-manager.h', + 'qmi-net-port-manager-rmnet.h', + 'qmi-net-port-manager-qmiwwan.h', + 'test-fixture.h', + 'test-port-context.h', +] + +scan_args = [ + '--rebuild-types', + '--deprecated-guards="QMI_DISABLE_DEPRECATED"', +] + +glib_prefix = glib_dep.get_pkgconfig_variable('prefix') + +fixxref_args = [ + '--html-dir=' + join_paths(qmi_prefix, gnome.gtkdoc_html_dir(doc_module)), + '--extra-dir=' + join_paths(glib_prefix, gnome.gtkdoc_html_dir('glib')), + '--extra-dir=' + join_paths(glib_prefix, gnome.gtkdoc_html_dir('gio')), +] + +name = doc_module + '-sections.txt' + +''' +FIXME: gen_sections should be used in the `input` field but it would add + a dependency over file paths that are not yet created, so + the `depends` section is used to generate alternate dependency. + This is fixed in newer meson versions. +''' +sections_txt = custom_target( + name, + input: 'libqmi-glib-common.sections', + output: name, + capture: true, + command: [find_program('cat'), '@INPUT@'] + gen_sections, + depends: gen_sections_deps, +) + +version_xml = configure_file( + input: 'version.xml.in', + output: '@BASENAME@', + configuration: version_conf, +) + +gnome.gtkdoc( + doc_module, + main_xml: doc_module + '-docs.xml', + src_dir: src_dirs, + ignore_headers: private_headers, + include_directories: top_inc, + gobject_typesfile: doc_module + '.types', + dependencies: libqmi_glib_dep, + namespace: 'qmi', + scan_args: scan_args, + fixxref_args: fixxref_args, + install: true, +) diff --git a/docs/reference/libqmi-glib/xml/gtkdocentities.ent.in b/docs/reference/libqmi-glib/xml/gtkdocentities.ent.in new file mode 100644 index 00000000..fd86c165 --- /dev/null +++ b/docs/reference/libqmi-glib/xml/gtkdocentities.ent.in @@ -0,0 +1,7 @@ +<!ENTITY package "@PACKAGE@"> +<!ENTITY package_bugreport "@PACKAGE_BUGREPORT@"> +<!ENTITY package_name "@PACKAGE_NAME@"> +<!ENTITY package_string "@PACKAGE_STRING@"> +<!ENTITY package_tarname "@PACKAGE_TARNAME@"> +<!ENTITY package_url "@PACKAGE_URL@"> +<!ENTITY package_version "@PACKAGE_VERSION@"> diff --git a/docs/reference/libqmi-glib/xml/meson.build b/docs/reference/libqmi-glib/xml/meson.build new file mode 100644 index 00000000..29473fe7 --- /dev/null +++ b/docs/reference/libqmi-glib/xml/meson.build @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +ent_conf = configuration_data() +ent_conf.set('PACKAGE', meson.project_name()) +ent_conf.set('PACKAGE_BUGREPORT', meson.project_name() + '-devel@lists.freedesktop.org') +ent_conf.set('PACKAGE_NAME', meson.project_name()) +ent_conf.set('PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), qmi_version)) +ent_conf.set('PACKAGE_TARNAME', meson.project_name()) +ent_conf.set('PACKAGE_URL', '') +ent_conf.set('PACKAGE_VERSION', qmi_version) + +gtkdocentities_ent = configure_file( + input: 'gtkdocentities.ent.in', + output: '@BASENAME@', + configuration: ent_conf, +) diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..5faaca00 --- /dev/null +++ b/meson.build @@ -0,0 +1,247 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +project( + 'libqmi', 'c', + version: '1.29.5', + license: 'GPL2', + default_options: [ + 'buildtype=debugoptimized', + 'c_std=gnu89', + 'warning_level=2', + ], + meson_version: '>= 0.45.1', +) + +qmi_version = meson.project_version() +version_array = qmi_version.split('.') +qmi_major_version = version_array[0].to_int() +qmi_minor_version = version_array[1].to_int() +qmi_micro_version = version_array[2].to_int() + +qmi_prefix = get_option('prefix') +qmi_bindir = get_option('bindir') +qmi_datadir = get_option('datadir') +qmi_includedir = get_option('includedir') +qmi_libexecdir = get_option('libexecdir') +qmi_mandir = get_option('mandir') + +qmi_glib_include_subdir = meson.project_name() + '-glib' +qmi_glib_pkgincludedir = join_paths(qmi_includedir, qmi_glib_include_subdir) + +# libtool versioning for libqmi-glib (-version-info c:r:a) +# - If the interface is unchanged, but the implementation has changed or been fixed, then increment r +# - Otherwise, increment c and zero r. +# - If the interface has grown (that is, the new library is compatible with old code), increment a. +# - If the interface has changed in an incompatible way (that is, functions have changed or been removed), then zero a. +current = 12 +revision = 0 +age = 7 +qmi_glib_version = '@0@.@1@.@2@'.format(current - age, age, revision) + +qmi_gir_version = '1.0' + +gnome = import('gnome') +i18n = import('i18n') +pkg = import('pkgconfig') +python = import('python3').find_python() + +source_root = meson.current_source_dir() + +data_dir = join_paths(source_root, 'data') +templates_dir = join_paths(source_root, 'build-aux/templates') + +qmi_codegen = find_program(join_paths(source_root, 'build-aux/qmi-codegen/qmi-codegen')) +qmi_mkenums = find_program(join_paths(source_root, 'build-aux/qmi-mkenums')) + +top_inc = include_directories('.') + +cc = meson.get_compiler('c') + +config_h = configuration_data() +config_h.set_quoted('PACKAGE_VERSION', qmi_version) + +# compiler flags +common_flags = ['-DHAVE_CONFIG_H'] + +# compiler flags that are always enabled, even in release builds +cc_flags = cc.get_supported_arguments([ + # warning on unused parameters is overkill, never do that + '-Wno-unused-parameter', + # function type cast disabled: used throughout the code especially to + # cast GAsyncReadyCallbacks with the real object type instead of GObject + '-Wno-cast-function-type', + # all message protocol structs are packed, never complain about it + '-Wno-packed', +]) + +# strict flags to use in debug builds +if get_option('buildtype').contains('debug') + cc_flags += cc.get_supported_arguments([ + '-fno-strict-aliasing', + '-Waggregate-return', + '-Wcast-align', + '-Wdeclaration-after-statement', + '-Wdouble-promotion', + '-Wduplicated-branches', + '-Wduplicated-cond', + '-Wfloat-equal', + '-Wformat=2', + '-Wformat-nonliteral', + '-Wformat-security', + '-Winit-self', + '-Winline', + '-Wjump-misses-init', + '-Wlogical-op', + '-Wnested-externs', + '-Wmissing-declarations', + '-Wmissing-format-attribute', + '-Wmissing-include-dirs', + '-Wmissing-noreturn', + '-Wmissing-prototypes', + '-Wnull-dereference', + '-Wpointer-arith', + '-Wredundant-decls', + '-Wrestrict', + '-Wreturn-type', + '-Wshadow', + '-Wstrict-prototypes', + '-Wsuggest-attribute=format', + '-Wswitch-default', + '-Wswitch-enum', + '-Wundef', + '-Wunused-but-set-variable', + '-Wwrite-strings', + ]) +endif + +add_project_arguments(common_flags + cc_flags, language: 'c') + +no_deprecated_declarations_flags = cc.get_supported_arguments('-Wno-deprecated-declarations') + +glib_version = '2.56' + +glib_dep = dependency('glib-2.0', version: '>= ' + glib_version) +gio_unix_dep = dependency('gio-unix-2.0') + +deps = [ + glib_dep, + dependency('gio-2.0'), + dependency('gobject-2.0'), +] + +c_flags = [ + '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_' + glib_version.underscorify(), + '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_' + glib_version.underscorify(), + '-DGLIB_DISABLE_DEPRECATION_WARNINGS', +] + +glib_deps = declare_dependency( + dependencies: deps, + compile_args: c_flags, +) + +# message collection (existing file in data/qmi-collection-${COLLECTION}.json) +# dnl custom collections may be added as files in data/ +qmi_collection_name = get_option('collection') + +# qmi-firmware-update is optional, enabled by default +enable_firmware_update = get_option('firmware_update') +assert(not enable_firmware_update or qmi_collection_name != 'minimal', 'Cannot build qmi-firmware-update when \'minimal\' collection enabled, use at least the \'basic\' collection instead.') + +# udev support is optional, enabled by default +enable_udev = get_option('udev') + +gudev_dep = dependency('gudev-1.0', version: '>= 232', required: enable_udev and enable_firmware_update) +config_h.set('WITH_UDEV', gudev_dep.found()) + +bash_completion_completionsdir = dependency('bash-completion').get_pkgconfig_variable('completionsdir', define_variable: ['datadir', qmi_datadir]) + +have_rmnet = cc.has_type('struct ifla_rmnet_flags', prefix: '#include<linux/if_link.h>') +config_h.set('RMNET_SUPPORT_ENABLED', have_rmnet) + +# runtime MM check is optional, enabled by default +enable_mm_runtime_check = get_option('mm_runtime_check') +config_h.set('MM_RUNTIME_CHECK_ENABLED', enable_mm_runtime_check) + +# QMI username +qmi_username = get_option('qmi_username') +enable_qmi_username = (qmi_username != '') +if enable_qmi_username + config_h.set_quoted('QMI_USERNAME', qmi_username) + + # FIXME: udev base directory, prefix can't be overrided + udev_udevdir = get_option('udevdir') + if udev_udevdir == '' + udev_udevdir = dependency('udev').get_pkgconfig_variable('udevdir') + endif +else + qmi_username = 'no (root)' +endif +config_h.set('QMI_USERNAME_ENABLED', enable_qmi_username) + +# MBIM QMUX service support +enable_mbim_qmux = get_option('mbim_qmux') +if enable_mbim_qmux + mbim_glib_dep = dependency('mbim-glib', version: '>= 1.18.0') +endif +config_h.set('MBIM_QMUX_ENABLED', enable_mbim_qmux) + +# QRTR support +enable_qrtr = get_option('qrtr') +if enable_qrtr + qrtr_glib_dep = dependency('qrtr-glib', version: '>= 1.0.0') +endif +config_h.set10('QMI_QRTR_SUPPORTED', enable_qrtr) + +version_conf = configuration_data() +version_conf.set('VERSION', qmi_version) +version_conf.set('QMI_MAJOR_VERSION', qmi_major_version) +version_conf.set('QMI_MINOR_VERSION', qmi_minor_version) +version_conf.set('QMI_MICRO_VERSION', qmi_micro_version) +version_conf.set10('QMI_MBIM_QMUX_SUPPORTED', enable_mbim_qmux) +version_conf.set10('QMI_QRTR_SUPPORTED', enable_qrtr) + +# introspection support +enable_gir = dependency('gobject-introspection-1.0', version: '>= 0.9.6', required: get_option('introspection')).found() + +random_number = qmi_minor_version + meson.version().split('.').get(1).to_int() + +test_env = environment() +test_env.set('G_DEBUG', 'gc-friendly') +test_env.set('MALLOC_CHECK_', '2') +test_env.set('MALLOC_PERTURB_', (random_number % 256).to_string()) + +subdir('src') +subdir('utils') + +enable_gtk_doc = get_option('gtk_doc') +if enable_gtk_doc + subdir('docs/reference/libqmi-glib') +endif + +help2man = find_program('help2man', required: false) +if help2man.found() + subdir('docs/man') +endif + +configure_file( + output: 'config.h', + configuration: config_h, +) + +output = '\n' + meson.project_name() + ' ' + meson.project_version() + '\n\n' +output += ' Build\n' +output += ' compiler: ' + cc.get_id() + '\n' +output += ' cflags: ' + ' '.join(cc_flags) + '\n' +output += ' Documentation: ' + enable_gtk_doc.to_string() + '\n' +output += ' gobject introspection: ' + enable_gir.to_string() + '\n\n' +output += ' System paths\n' +output += ' prefix: ' + qmi_prefix + '\n' +output += ' udev base directory: ' + qmi_username + '\n\n' +output += ' Features\n' +output += ' QMI over MBIM: ' + enable_mbim_qmux.to_string() + '\n' +output += ' QMI over QRTR: ' + enable_qrtr.to_string() + '\n' +output += ' QMI username: ' + qmi_username + '\n' +output += ' rmnet support: ' + have_rmnet.to_string() +message(output) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..71e4c5ec --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,14 @@ +option('collection', type: 'combo', choices: ['minimal', 'basic', 'full'], value: 'full', description: 'message collection to build') + +option('firmware_update', type: 'boolean', value: true, description: 'enable compilation of `qmi-firmware-update') + +option('mbim_qmux', type: 'boolean', value: false, description: 'enable support for QMI over MBIM QMUX service') +option('mm_runtime_check', type: 'boolean', value: true, description: 'build ModemManager runtime check support') +option('qmi_username', type: 'string', value: '', description: 'user allowed to access QMI devices') +option('qrtr', type: 'boolean', value: false, description: 'enable support for QRTR protocol') + +option('udev', type: 'boolean', value: true, description: 'build udev support') +option('udevdir', type: 'string', value: '', description: 'where udev base directory is') + +option('introspection', type: 'boolean', value: 'true', description: 'build introspection support') +option('gtk_doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation') diff --git a/meson_post_install.py b/meson_post_install.py new file mode 100644 index 00000000..cf8e2056 --- /dev/null +++ b/meson_post_install.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +import os +import subprocess +import sys + +prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX'] + +bindir = os.path.join(prefix, sys.argv[1]) +subprocess.check_call(['chmod', '755', os.path.join(bindir, 'qmi-network')]) + +bash_completion_completionsdir = os.path.join(prefix, sys.argv[2]) +os.rename(os.path.join(bash_completion_completionsdir, 'qmicli-completion'), + os.path.join(bash_completion_completionsdir, 'qmicli')) diff --git a/src/libqmi-glib/generated/meson.build b/src/libqmi-glib/generated/meson.build new file mode 100644 index 00000000..b2df39cf --- /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 00000000..d03734ee --- /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 00000000..dcb7a1ff --- /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 00000000..3285b43d --- /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 00000000..b720b309 --- /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 00000000..a8020dfd --- /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 00000000..7b9cbae7 --- /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 00000000..b60bb1cc --- /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 00000000..0dabed4c --- /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, +) diff --git a/utils/meson.build b/utils/meson.build new file mode 100644 index 00000000..41faa60a --- /dev/null +++ b/utils/meson.build @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2 +# Copyright (C) 2019 - 2021 Iñigo Martinez <inigomartinez@gmail.com> + +cflags = cc.get_supported_arguments([ + '-Wno-empty-body', + '-Wno-sign-compare', + '-Wno-switch-default', +]) + +executable( + 'swi-update', + sources: 'swi-update.c', + c_args: cflags, +) + +qmi_network = configure_file( + input: 'qmi-network.in', + output: '@BASENAME@', + configuration: version_conf, + install_dir: qmi_bindir, +) |