summaryrefslogtreecommitdiff
path: root/src/libmbim-glib/generated/meson.build
blob: 2ec85ea848f7a63738b2e9c91cb3dae85a9bb833 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2021 IƱigo Martinez <inigomartinez@gmail.com>

generated_inc = include_directories('.')

gen_sources = []
gen_headers = []
gen_sections = []
gen_sections_deps = []

# Error types
enum_types = 'mbim-error-types'

gen_headers += custom_target(
  enum_types + '.h',
  input: mbim_errors_header,
  output: enum_types + '.h',
  command: [
    python,
    mbim_mkenums,
    '--fhead', '#ifndef __LIBMBIM_GLIB_ERROR_TYPES_H__\n#define __LIBMBIM_GLIB_ERROR_TYPES_H__\n#include "mbim-errors.h"\n',
    '--template', files(templates_dir / enum_types + '.h.template'),
    '--ftail', '#endif /* __LIBMBIM_GLIB_ERROR_TYPES_H__ */\n',
    '@INPUT@'],
  capture: true,
  install: true,
  install_dir: mbim_glib_pkgincludedir,
)

gen_sources += custom_target(
  enum_types + '.c',
  input: mbim_errors_header,
  output: enum_types + '.c',
  command: [
    python,
    mbim_mkenums,
    '--fhead', '#include "mbim-errors.h"\n#include "mbim-error-types.h"\n',
    '--template', files(templates_dir / enum_types + '.c.template'),
    '@INPUT@'],
  capture: true,
)

enum_types = 'mbim-error-quarks'

gen_sources += custom_target(
  enum_types + '.c',
  input: mbim_errors_header,
  output: enum_types + '.c',
  command: [
    python,
    mbim_mkenums,
    '--fhead', '#include "mbim-errors.h"\n#include "mbim-error-types.h"\n',
    '--template', files(templates_dir / enum_types + '.c.template'),
    '@INPUT@'],
  capture: true,
)

# Enum/Flag types
enum_types = 'mbim-enum-types'

gen_headers += custom_target(
  enum_types + '.h',
  input: mbim_enums_headers,
  output: enum_types + '.h',
  command: [
    python,
    mbim_mkenums,
    '--fhead', '#ifndef __LIBMBIM_GLIB_ENUM_TYPES_H__\n#define __LIBMBIM_GLIB_ENUM_TYPES_H__\n#include "mbim-uuid.h"\n#include "mbim-cid.h"\n#include "mbim-message.h"\n#include "mbim-enums.h"\n#include "mbim-tlv.h"\n',
    '--template', files(templates_dir / enum_types + '.h.template'),
    '--ftail', '#endif /* __LIBMBIM_GLIB_ENUM_TYPES_H__ */\n',
    '@INPUT@'],
  capture: true,
  install: true,
  install_dir: mbim_glib_pkgincludedir,
)

gen_sources += custom_target(
  enum_types + '.c',
  input: mbim_enums_headers,
  output: enum_types + '.c',
  command: [
    python,
    mbim_mkenums,
    '--fhead', '#include "mbim-enum-types.h"\n',
    '--template', files(templates_dir / enum_types + '.c.template'),
    '@INPUT@'],
  capture: true,
)

services_data = [
  ['atds'],
  ['auth'],
  ['basic-connect', 'ms-basic-connect-v2', 'ms-basic-connect-v3'],
  ['dss'],
  ['intel-firmware-update', 'intel-firmware-update-v2'],
  ['intel-thermal-rf'],
  ['ms-basic-connect-extensions', 'ms-basic-connect-extensions-v2', 'ms-basic-connect-extensions-v3'],
  ['ms-uicc-low-level-access'],
  ['ms-firmware-id'],
  ['ms-host-shutdown'],
  ['ms-sar'],
  ['ms-voice-extensions'],
  ['phonebook'],
  ['proxy-control'],
  ['qdu'],
  ['quectel'],
  ['qmi'],
  ['sms'],
  ['stk'],
  ['ussd'],
]

foreach service_data: services_data
  service = service_data[0]
  name = 'mbim-' + service

  input = []
  foreach service_file: service_data
    input += data_dir / 'mbim-service-@0@.json'.format(service_file)
  endforeach

  generated = custom_target(
    name,
    input: input,
    output: [name + '.c', name + '.h', name + '.sections'],
    command: [mbim_codegen, '--output', '@OUTDIR@' / name, '@INPUT@'],
    install: true,
    install_dir: [false, mbim_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 += [meson.current_build_dir() / name + '.sections']
  gen_sections_deps += [generated]
endforeach

c_flags = [
  '-DLIBMBIM_GLIB_COMPILATION',
  '-DG_LOG_DOMAIN="Mbim"',
  '-Wno-unused-function',
]

libmbim_glib_generated = static_library(
  'mbim-glib-generated',
  sources: gen_sources + gen_headers,
  include_directories: libmbim_glib_inc,
  dependencies: glib_deps,
  c_args: c_flags,
)

generated_dep = declare_dependency(
  sources: gen_headers,
  include_directories: [libmbim_glib_inc, generated_inc],
  dependencies: glib_deps,
)