-
Notifications
You must be signed in to change notification settings - Fork 8
/
meson.build
205 lines (172 loc) · 5.41 KB
/
meson.build
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
project(
'gtranslator', 'c',
version: '47.0',
license: 'GPL3+',
meson_version: '>= 0.59.0',
)
###########
# Version #
###########
gtr_version = meson.project_version()
version_array = gtr_version.split('.')
gtr_major_version = version_array[0].to_int()
gtr_minor_version = version_array[1]
#################
# Default paths #
#################
gtr_prefix = get_option('prefix')
gtr_datadir = join_paths(gtr_prefix, get_option('datadir'))
gtr_includedir = join_paths(gtr_prefix, get_option('includedir'))
gtr_libdir = join_paths(gtr_prefix, get_option('libdir'))
gtr_localedir = join_paths(gtr_prefix, get_option('localedir'))
gtr_pkgdatadir = join_paths(gtr_datadir, meson.project_name())
###########
# Options #
###########
gtr_namespace = 'org.gnome.Gtranslator'
gtr_debug = get_option('profile') == 'development'
if gtr_debug
profile = 'Devel'
name_suffix = ' (Development)'
vcs_tag = run_command(find_program('git'), 'rev-parse', '--short', 'HEAD', check: false).stdout().strip()
version_suffix = '-' + (vcs_tag == '' ? 'devel' : vcs_tag)
else
profile = ''
name_suffix = ''
version_suffix = ''
endif
gtr_app_id = gtr_namespace + profile
cc = meson.get_compiler('c')
config_h = configuration_data()
set_defines = [
# package
['PACKAGE', meson.project_name()],
['PACKAGE_DATADIR', gtr_datadir],
['PACKAGE_LIBDIR', gtr_libdir],
['PACKAGE_LOCALEDIR', gtr_localedir],
['PACKAGE_URL', 'https://gitlab.gnome.org/GNOME/gtranslator/'],
['PACKAGE_ISSUES_URL', 'https://gitlab.gnome.org/GNOME/gtranslator/-/issues'],
['PACKAGE_VERSION', gtr_version],
['PACKAGE_APPID', gtr_app_id],
['PROFILE', get_option('profile')],
# i18
['GETTEXT_PACKAGE', meson.project_name()],
['DL_SERVER', get_option('dl_server')],
['API_URL', get_option('dl_server') + '/api/v1/'],
]
foreach define: set_defines
config_h.set_quoted(define[0], define[1])
endforeach
assert(cc.has_function('strerror'), '"strerror" not found')
# Compiler flags
common_flags = ['-DHAVE_CONFIG_H']
if gtr_debug
common_flags += ['-DG_DISABLE_CAST_CHECKS']
test_cflags = [
'-fno-strict-aliasing',
'-Wno-c++11-extensions',
'-Wno-missing-include-dirs',
'-Wno-typedef-redefinition',
'-Wno-tautological-constant-out-of-range-compare',
'-Wduplicated-branches',
'-Wduplicated-cond',
'-Wformat=2',
'-Wformat-nonliteral',
'-Wformat-security',
'-Wignored-qualifiers',
'-Wimplicit-function-declaration',
'-Wlogical-op',
'-Wmisleading-indentation',
'-Wmissing-format-attribute',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wnested-externs',
'-Wold-style-definition',
'-Wpointer-arith',
'-Wshadow',
'-Wstrict-prototypes',
'-Wswitch-default',
'-Wswitch-enum',
'-Wundef',
'-Wuninitialized',
'-Wunused',
]
common_flags += cc.get_supported_arguments(test_cflags)
else
common_flags += [
'-DG_DISABLE_ASSERT',
#'-DG_DISABLE_CHECKS',
'-DG_DISABLE_CAST_CHECKS',
]
endif
add_project_arguments(common_flags, language: 'c')
gnome = import('gnome')
i18n = import('i18n')
pkg = import('pkgconfig')
top_inc = include_directories('.')
data_dir = join_paths(meson.project_source_root(), 'data')
po_dir = join_paths(meson.project_source_root(), 'po')
src_dir = join_paths(meson.project_source_root(), 'src')
################
# Dependencies #
################
glib_dep = dependency('glib-2.0', version: '>= 2.71.3')
gtk_dep = dependency('gtk4', version: '>= 4.12.0')
libadwaita_dep = dependency('libadwaita-1', version: '>= 1.6.alpha')
libspell_dep = dependency('libspelling-1', required: false)
# if not libspell, we disable it
if libspell_dep.found()
config_h.set('LIBSPELL', 1)
endif
gtr_deps = [
glib_dep,
gtk_dep,
libadwaita_dep,
libspell_dep,
dependency('libgda-6.0'),
dependency('gio-2.0', version: '>= 2.36.0'),
dependency('gsettings-desktop-schemas'),
dependency('gthread-2.0', version: '>= 2.13.0'),
dependency('gtksourceview-5', version: '>= 5.4.0'),
dependency('libxml-2.0', version: '>= 2.4.12'),
dependency('libsoup-3.0'),
dependency('json-glib-1.0', version: '>= 1.2.0'),
cc.find_library('gettextpo'),
]
gtr_schemasdir = dependency('gio-2.0').get_variable(pkgconfig: 'schemasdir', pkgconfig_define: ['datadir', gtr_datadir])
if gtr_schemasdir == ''
gtr_schemasdir = join_paths(gtr_datadir, 'glib-2.0', 'schemas')
message(gtr_schemasdir)
endif
itstool = find_program ('itstool')
###########
# Subdirs #
###########
subdir('data')
subdir('src')
subdir('po')
subdir('help')
subdir('man')
configure_file(
output: 'config.h',
configuration: config_h,
)
gnome.post_install(
glib_compile_schemas: true,
gtk_update_icon_cache: true,
update_desktop_database: true,
)
output = '\n\n GTranslator ' + gtr_version + '\n'
output += ' =========================\n\n'
output += ' Source ..........................: ' + meson.current_source_dir() + '\n'
output += ' Prefix ..........................: ' + gtr_prefix + '\n'
output += ' Compiler ........................: ' + cc.get_id() + '\n'
if libspell_dep.found()
output += ' libspell ........................: enabled\n\n'
else
output += ' libspell ........................: disabled\n\n'
endif
output += ' Development options\n'
output += ' Enable Debug: ...................: ' + gtr_debug.to_string() + '\n'
output += ' Now type "ninja -C ' + meson.current_build_dir() + '" to build ' + meson.project_name() + '\n\n'
message(output)