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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
add_project_arguments([
'-DGWEATHER_COMPILATION',
'-D_XOPEN_SOURCE=700',
'-D_DEFAULT_SOURCE',
], language: 'c')
c_compiler = meson.get_compiler('c')
add_project_arguments(c_compiler.get_supported_arguments([
# Warnings we care about
'-Wimplicit-fallthrough',
'-Wmisleading-indentation',
'-Wstrict-prototypes',
'-Wunused',
# We have legacy code and callbacks
'-Wno-unused-parameter',
'-Werror=format=2',
'-Werror=implicit-function-declaration',
'-Werror=init-self',
'-Werror=missing-include-dirs',
]), language: 'c')
header_subdir = 'libgweather-3.0/libgweather'
# convert to soname
current = libgweather_lt_c - libgweather_lt_a
interface_age = libgweather_lt_r
libgweather_so_version = '@0@.@1@.@2@'.format(
current,
libgweather_lt_a,
interface_age,
)
libgweather_darwin_versions = [
current + 1,
'@0@.@1@'.format(current + 1, interface_age),
]
config_h = configuration_data()
config_h.set_quoted('GETTEXT_PACKAGE', GETTEXT_PACKAGE)
config_h.set_quoted('LOCALEDIR', datadir / 'locale')
config_h.set_quoted('GNOMELOCALEDIR', datadir / 'locale')
config_h.set_quoted('G_LOG_DOMAIN', 'GWeather')
config_h.set_quoted('GWEATHER_BIN_LOCATION_DIR', pkglibdir)
config_h.set_quoted('LIBGWEATHER_VERSION', meson.project_version())
if c_compiler.has_member('struct tm', 'tm_gmtoff', prefix: '#include <time.h>')
config_h.set('HAVE_TM_TM_GMOFF', 1)
endif
if c_compiler.has_header_symbol('time.h', 'timezone')
config_h.set('HAVE_TIMEZONE', 1)
endif
if c_compiler.has_header_symbol('langinfo.h', '_NL_MEASUREMENT_MEASUREMENT')
config_h.set('HAVE__NL_MEASUREMENT_MEASUREMENT', 1)
endif
config_h.set_quoted('ZONEINFO_DIR', get_option('zoneinfo_dir'))
config_h.set_quoted('OWM_APIKEY', get_option('owm_apikey'))
if host_machine.system() == 'windows'
visibility_define = '__declspec(dllexport) extern'
else
visibility_define = '__attribute__((visibility("default"))) extern'
endif
if get_option('default_library') != 'static'
config_h.set('_GWEATHER_EXTERN', visibility_define)
if host_machine.system() == 'windows'
config_h.set('DLL_EXPORT', true)
endif
endif
configure_file(
output: 'config.h',
configuration: config_h,
)
versionconf = configuration_data()
versionconf.set('GWEATHER_MAJOR_VERSION', libgweather_version[0])
versionconf.set('GWEATHER_MINOR_VERSION', libgweather_version[1])
versionconf.set('GWEATHER_MICRO_VERSION', libgweather_version[2])
versionconf.set_quoted('GWEATHER_VERSION', meson.project_version())
configure_file(
input: 'gweather-version.h.in',
output: 'gweather-version.h',
configuration: versionconf,
install: true,
install_dir: includedir / header_subdir,
)
deps_libgweather = [
dependency('gio-2.0', version: glib_req_version),
dependency('gtk+-3.0', version: gtk_req_version),
dependency('libsoup-2.4', version: libsoup_req_version),
dependency('libxml-2.0', version: libxml_req_version),
dependency('geocode-glib-1.0'),
c_compiler.find_library('m', required: false),
]
gweather_headers = [
'gweather-location.h',
'gweather-location-entry.h',
'gweather-timezone.h',
'gweather-timezone-menu.h',
'gweather-weather.h',
'gweather-enums.h'
]
gweather_enum_types = gnome.mkenums('gweather-enum-types',
sources: gweather_headers,
c_template: 'gweather-enum-types.c.tmpl',
h_template: 'gweather-enum-types.h.tmpl',
install_header: true,
install_dir: includedir / header_subdir,
)
install_headers(gweather_headers + ['gweather.h'], subdir: header_subdir)
gweather_c_sources = [
gweather_enum_types,
'gweather.c',
'gweather-weather.c',
'gweather-location.c',
'gweather-timezone.c',
'gweather-location-entry.c',
'gweather-timezone-menu.c',
]
gweather_priv_sources = [
'gweather-private.c',
'weather-metar.c',
'weather-iwin.c',
'weather-metno.c',
'weather-owm.c',
'weather-sun.c',
'weather-moon.c',
]
introspection_sources = gweather_c_sources + gweather_headers
libgweather_static = static_library('gweather',
sources: [
gweather_c_sources,
gweather_priv_sources,
],
dependencies: deps_libgweather,
include_directories: [
include_directories('.'),
include_directories('..'),
],
)
libgweather_static_dep = declare_dependency(sources: gweather_c_sources,
include_directories: [
include_directories('.'),
include_directories('..'),
],
dependencies: deps_libgweather,
link_with: libgweather_static,
)
lib_libgweather = shared_library('gweather-3',
dependencies: deps_libgweather,
link_whole: libgweather_static,
version: libgweather_so_version,
gnu_symbol_visibility: 'hidden',
darwin_versions: libgweather_darwin_versions,
include_directories: [
include_directories('..'),
],
install: true,
)
g_ir_scanner = find_program('g-ir-scanner', required: get_option('introspection'))
build_gir = get_option('introspection') and g_ir_scanner.found() and not meson.is_cross_build()
enable_vala = get_option('enable_vala')
vapigen = find_program('vapigen', required: enable_vala == 'true')
if enable_vala == 'auto' or enable_vala == 'true'
build_vapi = vapigen.found() and get_option('introspection')
else
build_vapi = false
endif
if build_gir
gweather_gir = gnome.generate_gir(lib_libgweather,
sources: introspection_sources,
dependencies: deps_libgweather,
nsversion: '3.0',
namespace: 'GWeather',
includes: ['GObject-2.0', 'Gtk-3.0'],
symbol_prefix: 'gweather',
identifier_prefix: 'GWeather',
export_packages: 'gweather-3.0',
header: 'libgweather/gweather.h',
extra_args: [
'--warn-all',
'--quiet',
'-DGWEATHER_COMPILATION',
],
fatal_warnings: get_option('werror'),
install: true,
)
else
gweather_gir = []
endif
libgweather_dep = declare_dependency(
sources: [gweather_enum_types[1], gweather_gir],
dependencies: deps_libgweather,
link_with: lib_libgweather,
include_directories: [
include_directories('..'),
],
)
if build_vapi and build_gir
gnome.generate_vapi('gweather-3.0',
sources: gweather_gir[0],
packages: ['gobject-2.0', 'gtk+-3.0'],
metadata_dirs: '.',
install: true,
)
endif
subdir('tests')
subdir('tools')
|