| 1 |
# SPDX-License-Identifier: GPL-2.0-or-later |
| 2 |
# Copyright (C) 2019 - 2021 IƱigo Martinez <[email protected]> |
| 3 |
|
| 4 |
generated_inc = include_directories('.') |
| 5 |
|
| 6 |
gen_sources = [] |
| 7 |
gen_headers = [] |
| 8 |
private_gen_sources = [] |
| 9 |
private_gen_headers = [] |
| 10 |
gen_sections = [] |
| 11 |
gen_sections_deps = [] |
| 12 |
|
| 13 |
# Error types |
| 14 |
enum_types = 'qmi-error-types' |
| 15 |
|
| 16 |
gen_headers += custom_target( |
| 17 |
enum_types + '.h', |
| 18 |
input: qmi_errors_header, |
| 19 |
output: enum_types + '.h', |
| 20 |
command: [ |
| 21 |
python, |
| 22 |
qmi_mkenums, |
| 23 |
'--fhead', '#ifndef __LIBQMI_GLIB_ERROR_TYPES_H__\n#define __LIBQMI_GLIB_ERROR_TYPES_H__\n#include "qmi-errors.h"\n', |
| 24 |
'--template', files(templates_dir / enum_types + '.h.template'), |
| 25 |
'--ftail', '#endif /* __LIBQMI_GLIB_ERROR_TYPES_H__ */\n', |
| 26 |
'@INPUT@'], |
| 27 |
capture: true, |
| 28 |
install: true, |
| 29 |
install_dir: qmi_glib_pkgincludedir, |
| 30 |
) |
| 31 |
|
| 32 |
gen_sources += custom_target( |
| 33 |
enum_types + '.c', |
| 34 |
input: qmi_errors_header, |
| 35 |
output: enum_types + '.c', |
| 36 |
command: [ |
| 37 |
python, |
| 38 |
qmi_mkenums, |
| 39 |
'--fhead', '#include "qmi-errors.h"\n#include "qmi-error-types.h"\n', |
| 40 |
'--template', files(templates_dir / enum_types + '.c.template'), |
| 41 |
'@INPUT@'], |
| 42 |
capture: true, |
| 43 |
) |
| 44 |
|
| 45 |
enum_types = 'qmi-error-quarks' |
| 46 |
|
| 47 |
gen_sources += custom_target( |
| 48 |
enum_types + '.c', |
| 49 |
input: qmi_errors_header, |
| 50 |
output: enum_types + '.c', |
| 51 |
command: [ |
| 52 |
python, |
| 53 |
qmi_mkenums, |
| 54 |
'--fhead', '#include "qmi-errors.h"\n#include "qmi-error-types.h"\n', |
| 55 |
'--template', files(templates_dir / enum_types + '.c.template'), |
| 56 |
'@INPUT@'], |
| 57 |
capture: true, |
| 58 |
) |
| 59 |
|
| 60 |
# Enum types |
| 61 |
enum_types = 'qmi-enum-types' |
| 62 |
|
| 63 |
gen_headers += custom_target( |
| 64 |
enum_types + '.h', |
| 65 |
input: qmi_enums_headers, |
| 66 |
output: enum_types + '.h', |
| 67 |
command: [ |
| 68 |
python, |
| 69 |
qmi_mkenums, |
| 70 |
'--enums-only', |
| 71 |
'--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-enums-fox.h"\n#include "qmi-enums-ims.h"\n#include "qmi-enums-imsp.h"\n#include "qmi-enums-imsa.h"\n#include "qmi-enums-imsdcm.h"\n#include "qmi-enums-ssc.h"\n#include "qmi-device.h"\n', |
| 72 |
'--template', files(templates_dir / enum_types + '.h.template'), |
| 73 |
'--ftail', '#endif /* __LIBQMI_GLIB_ENUM_TYPES_H__ */\n', |
| 74 |
'@INPUT@'], |
| 75 |
capture: true, |
| 76 |
install: true, |
| 77 |
install_dir: qmi_glib_pkgincludedir, |
| 78 |
) |
| 79 |
|
| 80 |
gen_sources += custom_target( |
| 81 |
enum_types + '.c', |
| 82 |
input: qmi_enums_headers, |
| 83 |
output: enum_types + '.c', |
| 84 |
command: [ |
| 85 |
python, |
| 86 |
qmi_mkenums, |
| 87 |
'--enums-only', |
| 88 |
'--fhead', '#include "qmi-enum-types.h"\n', |
| 89 |
'--template', files(templates_dir / enum_types + '.c.template'), |
| 90 |
'@INPUT@'], |
| 91 |
capture: true, |
| 92 |
) |
| 93 |
|
| 94 |
# Flag types |
| 95 |
enum_types = 'qmi-flag-types' |
| 96 |
|
| 97 |
gen_headers += custom_target( |
| 98 |
enum_types + '.h', |
| 99 |
input: qmi_enums_headers, |
| 100 |
output: enum_types + '.h', |
| 101 |
command: [ |
| 102 |
python, |
| 103 |
qmi_mkenums, |
| 104 |
'--flags-only', |
| 105 |
'--fhead', '#ifndef __LIBQMI_GLIB_FLAG_TYPES_H__\n#define __LIBQMI_GLIB_FLAG_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-enums-fox.h"\n#include "qmi-enums-ssc.h"\n#include "qmi-device.h"\n', |
| 106 |
'--template', files(templates_dir / enum_types + '.h.template'), |
| 107 |
'--ftail', '#endif /* __LIBQMI_GLIB_FLAG_TYPES_H__ */\n', |
| 108 |
'@INPUT@'], |
| 109 |
capture: true, |
| 110 |
install: true, |
| 111 |
install_dir: qmi_glib_pkgincludedir, |
| 112 |
) |
| 113 |
|
| 114 |
gen_sources += custom_target( |
| 115 |
enum_types + '.c', |
| 116 |
input: qmi_enums_headers, |
| 117 |
output: enum_types + '.c', |
| 118 |
command: [ |
| 119 |
python, |
| 120 |
qmi_mkenums, |
| 121 |
'--flags-only', |
| 122 |
'--fhead', '#include "qmi-flag-types.h"\n', |
| 123 |
'--template', files(templates_dir / enum_types + '.c.template'), |
| 124 |
'@INPUT@'], |
| 125 |
capture: true, |
| 126 |
) |
| 127 |
|
| 128 |
# Private Enum types |
| 129 |
enum_types = 'qmi-enum-types-private' |
| 130 |
|
| 131 |
private_gen_headers += custom_target( |
| 132 |
enum_types + '.h', |
| 133 |
input: qmi_enums_private_header, |
| 134 |
output: enum_types + '.h', |
| 135 |
command: [ |
| 136 |
python, |
| 137 |
qmi_mkenums, |
| 138 |
'--enums-only', |
| 139 |
'--fhead', '#ifndef __LIBQMI_GLIB_ENUM_TYPES_PRIVATE_H__\n#define __LIBQMI_GLIB_ENUM_TYPES_PRIVATE_H__\n#include "qmi-enums-private.h"\n', |
| 140 |
'--template', files(templates_dir / enum_types + '.h.template'), |
| 141 |
'--ftail', '#endif /* __LIBQMI_GLIB_ENUM_TYPES_PRIVATE_H__ */\n', |
| 142 |
'@INPUT@'], |
| 143 |
capture: true, |
| 144 |
) |
| 145 |
|
| 146 |
private_gen_sources += custom_target( |
| 147 |
enum_types + '.c', |
| 148 |
input: qmi_enums_private_header, |
| 149 |
output: enum_types + '.c', |
| 150 |
command: [ |
| 151 |
python, |
| 152 |
qmi_mkenums, |
| 153 |
'--enums-only', |
| 154 |
'--fhead', '#include "qmi-enum-types-private.h"\n', |
| 155 |
'--template', files(templates_dir / enum_types + '.c.template'), |
| 156 |
'@INPUT@'], |
| 157 |
capture: true, |
| 158 |
) |
| 159 |
|
| 160 |
# Private Flag types |
| 161 |
enum_types = 'qmi-flag-types-private' |
| 162 |
|
| 163 |
private_gen_headers += custom_target( |
| 164 |
enum_types + '.h', |
| 165 |
input: qmi_enums_private_header, |
| 166 |
output: enum_types + '.h', |
| 167 |
command: [ |
| 168 |
python, |
| 169 |
qmi_mkenums, |
| 170 |
'--flags-only', |
| 171 |
'--fhead', '#ifndef __LIBQMI_GLIB_FLAG_TYPES_PRIVATE_H__\n#define __LIBQMI_GLIB_FLAG_TYPES_PRIVATE_H__\n#include "qmi-enums-private.h"\n', |
| 172 |
'--template', files(templates_dir / enum_types + '.h.template'), |
| 173 |
'--ftail', '#endif /* __LIBQMI_GLIB_FLAG_TYPES_PRIVATE_H__ */\n', |
| 174 |
'@INPUT@'], |
| 175 |
capture: true, |
| 176 |
) |
| 177 |
|
| 178 |
private_gen_sources += custom_target( |
| 179 |
enum_types + '.c', |
| 180 |
input: qmi_enums_private_header, |
| 181 |
output: enum_types + '.c', |
| 182 |
command: [ |
| 183 |
python, |
| 184 |
qmi_mkenums, |
| 185 |
'--flags-only', |
| 186 |
'--fhead', '#include "qmi-flag-types-private.h"\n', |
| 187 |
'--template', files(templates_dir / enum_types + '.c.template'), |
| 188 |
'@INPUT@'], |
| 189 |
capture: true, |
| 190 |
) |
| 191 |
|
| 192 |
# 64bit flag types |
| 193 |
enum_types = 'qmi-flags64-types' |
| 194 |
|
| 195 |
gen_headers += custom_target( |
| 196 |
enum_types + '.h', |
| 197 |
input: qmi_flags64_headers, |
| 198 |
output: enum_types + '.h', |
| 199 |
command: [ |
| 200 |
python, |
| 201 |
qmi_mkenums, |
| 202 |
'--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', |
| 203 |
'--template', files(templates_dir / enum_types + '.h.template'), |
| 204 |
'--ftail', '#endif /* __LIBQMI_GLIB_FLAGS64_TYPES_H__ */\n', |
| 205 |
'@INPUT@'], |
| 206 |
capture: true, |
| 207 |
install: true, |
| 208 |
install_dir: qmi_glib_pkgincludedir, |
| 209 |
) |
| 210 |
|
| 211 |
gen_sources += custom_target( |
| 212 |
enum_types + '.c', |
| 213 |
input: qmi_flags64_headers, |
| 214 |
output: enum_types + '.c', |
| 215 |
command: [ |
| 216 |
python, |
| 217 |
qmi_mkenums, |
| 218 |
'--fhead', '#include "qmi-flags64-types.h"\n', |
| 219 |
'--template', files(templates_dir / enum_types + '.c.template'), |
| 220 |
'@INPUT@'], |
| 221 |
capture: true, |
| 222 |
) |
| 223 |
|
| 224 |
qmi_common = data_dir / 'qmi-common.json' |
| 225 |
|
| 226 |
service = 'ctl' |
| 227 |
name = 'qmi-' + service |
| 228 |
|
| 229 |
generated = custom_target( |
| 230 |
name, |
| 231 |
input: data_dir / 'qmi-service-@[email protected]'.format(service), |
| 232 |
output: [name + '.c', name + '.h', name + '.sections'], |
| 233 |
command: [qmi_codegen, '--input', '@INPUT@', '--include', qmi_common, '--output', '@OUTDIR@' / name], |
| 234 |
) |
| 235 |
|
| 236 |
private_gen_sources += [generated[0], generated[1]] |
| 237 |
|
| 238 |
services = [ |
| 239 |
'atr', |
| 240 |
'dms', |
| 241 |
'dpm', |
| 242 |
'dsd', |
| 243 |
'ims', |
| 244 |
'imsa', |
| 245 |
'imsp', |
| 246 |
'imsdcm', |
| 247 |
'fox', |
| 248 |
'gas', |
| 249 |
'gms', |
| 250 |
'loc', |
| 251 |
'nas', |
| 252 |
'oma', |
| 253 |
'pbm', |
| 254 |
'pdc', |
| 255 |
'pds', |
| 256 |
'qos', |
| 257 |
'sar', |
| 258 |
'ssc', |
| 259 |
'uim', |
| 260 |
'voice', |
| 261 |
'wda', |
| 262 |
'wds', |
| 263 |
'wms', |
| 264 |
] |
| 265 |
|
| 266 |
command = [ |
| 267 |
qmi_codegen, |
| 268 |
'--input', '@INPUT@', |
| 269 |
'--include', qmi_common, |
| 270 |
] |
| 271 |
|
| 272 |
if qmi_collection_name != 'full' |
| 273 |
command += ['--collection', data_dir / 'qmi-collection-@[email protected]'.format(qmi_collection_name)] |
| 274 |
endif |
| 275 |
|
| 276 |
foreach service: services |
| 277 |
name = 'qmi-' + service |
| 278 |
|
| 279 |
generated = custom_target( |
| 280 |
name, |
| 281 |
input: data_dir / 'qmi-service-@[email protected]'.format(service), |
| 282 |
output: [name + '.c', name + '.h', name + '.sections'], |
| 283 |
command: command + ['--output', '@OUTDIR@' / name], |
| 284 |
install: true, |
| 285 |
install_dir: [false, qmi_glib_pkgincludedir, false], |
| 286 |
) |
| 287 |
|
| 288 |
gen_sources += generated[0] |
| 289 |
gen_headers += generated[1] |
| 290 |
# FIXME: the third target generated by custom target can't by used because is not a known |
| 291 |
# source file, to the path has to be used. the first workaround is to use the |
| 292 |
# build paths to point to the files, and the second workaround is to use |
| 293 |
# custom target objects to force its building. |
| 294 |
gen_sections += [meson.current_build_dir() / name + '.md'] |
| 295 |
gen_sections_deps += [generated] |
| 296 |
endforeach |
| 297 |
|
| 298 |
incs = [ |
| 299 |
top_inc, |
| 300 |
libqmi_glib_inc, |
| 301 |
] |
| 302 |
|
| 303 |
c_flags = [ |
| 304 |
'-DLIBQMI_GLIB_COMPILATION', |
| 305 |
'-DG_LOG_DOMAIN="Qmi"', |
| 306 |
'-Wno-unused-function', |
| 307 |
] |
| 308 |
|
| 309 |
deps = [ |
| 310 |
glib_deps, |
| 311 |
libqmi_common_dep, |
| 312 |
] |
| 313 |
|
| 314 |
if enable_qrtr |
| 315 |
deps += qrtr_glib_dep |
| 316 |
endif |
| 317 |
|
| 318 |
libqmi_glib_generated = static_library( |
| 319 |
'qmi-glib-generated', |
| 320 |
sources: private_gen_sources + private_gen_headers + gen_sources + gen_headers + [version_header], |
| 321 |
include_directories: incs, |
| 322 |
dependencies: deps, |
| 323 |
c_args: c_flags, |
| 324 |
) |
| 325 |
|
| 326 |
# FIXME: in older versions of meson, if libqmi-glib-generated is linked as shared |
| 327 |
# it will also try to link it in documentation generation |
| 328 |
generated_dep = declare_dependency( |
| 329 |
sources: private_gen_headers + gen_headers + [version_header], |
| 330 |
include_directories: [libqmi_glib_inc, generated_inc], |
| 331 |
dependencies: deps, |
| 332 |
) |