forked from F-i-f/tweaks-system-menu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
197 lines (170 loc) · 7.59 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
# -*- meson -*-
# AUTOGENERATED FILE - DO NOT EDIT
# This file has been generated from meson-gse/meson.build.m4 and meson-gse.build
# Tweaks-system-menu - Put Gnome Tweaks in the system menu.
# Copyright (C) 2019-2024 Philippe Troin (F-i-f on Github)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# meson-gse - Library for gnome-shell extensions
# Copyright (C) 2019-2024 Philippe Troin (F-i-f on Github)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Boilerplate
project('tweaks-system-menu',
version: '23',
meson_version: '>= 1.4.0',
license: 'GPL3' )
gnome = import('gnome')
i18n = import('i18n')
gse_lib_convenience = files('meson-gse/lib/convenience.js')
gse_lib_logger = files('meson-gse/lib/logger.js')
gse_gettext_domain = meson.project_name()
gse_sources = files('src/extension.js')
gse_libs = []
gse_data = []
gse_schemas = []
gse_dbus_interfaces = []
gse_run_command_obj = run_command('test', '-f', 'src/prefs.js', check : false)
if gse_run_command_obj.returncode() == 0
gse_sources += files('src/prefs.js')
endif
gse_run_command_obj = run_command('test', '-f', 'src/stylesheet.css', check : false)
if gse_run_command_obj.returncode() == 0
gse_data += files('src/stylesheet.css')
endif
gse_schema_main = 'schemas/org.gnome.shell.extensions.'+ meson.project_name() + '.gschema.xml'
gse_run_command_obj = run_command('test', '-f', gse_schema_main, check : false)
if gse_run_command_obj.returncode() == 0
gse_schemas += files(gse_schema_main)
endif
gse_npm_command_obj = find_program('npm', required:false)
# Include extension-specific settings
gse_sources += []
gse_libs += gse_lib_logger
gse_data += []
gse_schemas += []
gse_dbus_interfaces += []
# End of extension-specific settings
# Boilerplate
gse_run_command_obj = run_command('sh', '-c', 'echo $HOME', check : false)
if gse_run_command_obj.returncode() != 0
error('HOME not found, exit=@0@'.format(gse_run_command_obj.returncode()))
endif
home = gse_run_command_obj.stdout().strip()
gse_uuid = meson.project_name() + '@extensions.gnome-shell.fifi.org'
gse_target_dir = home + '/.local/share/gnome-shell/extensions/' + gse_uuid
gse_target_dir_schemas = join_paths(gse_target_dir, 'schemas')
gse_target_locale_dir = join_paths(gse_target_dir, 'locale')
gse_target_dir_dbus_intf = join_paths(gse_target_dir, 'dbus-interfaces')
meson_extra_scripts = 'meson-gse/meson-scripts'
gse_metadata_conf = configuration_data()
git_rev_cmd = run_command('git', 'describe', '--tags', '--long', '--always', check : false)
if git_rev_cmd.returncode() != 0
warning('git rev-parse exit=@0@'.format(git_rev_cmd.returncode()))
gse_metadata_conf.set('VCS_TAG', 'unknown')
else
gse_metadata_conf.set('VCS_TAG', git_rev_cmd.stdout().strip())
endif
gse_metadata_conf.set('uuid', gse_uuid)
gse_metadata_conf.set('version', meson.project_version())
gse_metadata_conf.set('gettext_domain', gse_gettext_domain)
gse_data += configure_file(input: 'src/metadata.json.in',
output: 'metadata.json',
configuration: gse_metadata_conf)
# This should work but doesn't:
#gse_metadata = vcs_tag(command: ['git', 'rev-parse', 'HEAD'],
# input: files('metadata.json.in'),
# output: 'metadata.json',
# fallback: 'unknown')
#gse_data += gse_metadata
if gse_schemas != []
custom_target(build_by_default: true,
command: ['sh', '-c', 'glib-compile-schemas --targetdir . $(dirname @INPUT0@)'],
input: gse_schemas,
output: 'gschemas.compiled',
install: true,
install_dir: gse_target_dir_schemas)
install_data(gse_schemas,
install_dir: gse_target_dir_schemas)
endif
gse_cleaner_targets = []
gse_cleaner_targets += custom_target(build_by_default: false,
install: false,
build_always_stale: true,
command: ['find', meson.current_source_dir(), '-name', '*~', '-exec', 'rm', '{}', ';'],
output: ['cleaner-backup-files'])
if gse_npm_command_obj.found()
gse_meson_gse_dir = join_paths(meson.current_source_dir(), 'meson-gse')
gse_npm_install_target = custom_target(build_by_default: false,
install: false,
depend_files: [join_paths(gse_meson_gse_dir, 'package.json'), join_paths(gse_meson_gse_dir, 'package-lock.json')],
command: ['sh', '-c', 'pushd "@0@" && "@1@" --fund false install && popd && touch npm-install'.format(gse_meson_gse_dir, gse_npm_command_obj.full_path())],
output: ['npm-install'])
foreach gse_source : gse_sources + gse_libs
test('Linting @0@...'.format(gse_source.full_path()),
gse_npm_command_obj,
args: ['run-script', '--', 'eslint', '--config', join_paths(gse_meson_gse_dir, 'eslint.config.js'), gse_source],
depends: gse_npm_install_target,
workdir: gse_meson_gse_dir)
endforeach
gse_npm_prettier_targets = []
foreach gse_source : gse_sources + gse_libs
gse_npm_prettier_targets += custom_target(build_always_stale: true,
build_by_default: false,
install: false,
depends: gse_npm_install_target,
command: ['sh', '-c', 'cd "@0@" && "@1@" run-script -- prettier --config "@2@" "@3@"'. format(gse_meson_gse_dir, gse_npm_command_obj.full_path(), join_paths(gse_meson_gse_dir, 'prettier.config.js'), gse_source.full_path())],
output: 'prettier-@0@'.format(gse_source.full_path().replace('/', '_')))
endforeach
gse_npm_install_target = custom_target(build_always_stale: true,
build_by_default: false,
install: false,
depends: gse_npm_prettier_targets,
command: ['sh', '-c', 'exit 0'],
output: ['prettier'])
gse_cleaner_targets += custom_target(build_always_stale: true,
build_by_default: false,
install: false,
command: ['rm', '-fr', join_paths(gse_meson_gse_dir, 'node_modules')],
output: ['cleaner-node-modules'])
endif
custom_target(build_by_default: false,
install: false,
build_always_stale: true,
depends: gse_cleaner_targets,
command: ['sh', '-c', 'true'],
output: ['cleaner'])
install_data(gse_sources + gse_data + gse_libs,
install_dir: gse_target_dir)
install_data(gse_dbus_interfaces,
install_dir: gse_target_dir_dbus_intf)
custom_target(build_by_default: false,
install: false,
command: [files(join_paths(meson_extra_scripts, 'make-extension')), gse_target_dir, '@OUTDIR@', '@OUTPUT@'],
output: 'extension.zip')
gse_run_command_obj = run_command('test', '-d', 'po', check : false)
if gse_run_command_obj.returncode() == 0
subdir('po')
endif