Debian Codegraph @

common/gtk-3.0/meson.build

raw
1 # render PNG assets
2
3 gtk3_asset_names = run_command(
4 'cat', 'assets' / 'assets.txt',
5 check : true
6 ).stdout().split()
7
8 subdir('assets')
9
10 # compile CSS
11
12 sass_path = meson.current_source_dir() / 'sass'
13 sass_depend_files = run_command(
14 'find',
15 sass_path,
16 '-name', '_*.scss',
17 check : true
18 ).stdout().split()
19
20 # always compile the dark CSS
21 input_scss_dark = configure_file(
22 input: meson.current_source_dir() / 'sass' / 'gtk.scss.in',
23 output : 'gtk-dark.scss',
24 configuration : {
25 'variant' : 'dark',
26 'transparency' : get_option('transparency').to_string(),
27 'sass_path' : meson.current_source_dir() / 'sass',
28 }
29 )
30
31 output_css_dark = 'gtk-main-dark.css'
32 gtk3_stylesheets = []
33
34 gtk3_stylesheets += custom_target(
35 output_css_dark,
36 input : input_scss_dark,
37 output : output_css_dark,
38 command : [sassc, sassc_options, '@INPUT@', '@OUTPUT@'],
39 build_by_default : true,
40 depend_files : sass_depend_files
41 )
42
43 foreach variant : get_option('variants')
44 output_css = (variant == 'light' ? 'gtk-main.css' : 'gtk-main-' + variant + '.css')
45
46 if variant != 'dark'
47 input_scss = configure_file(
48 input: meson.current_source_dir() / 'sass' / 'gtk.scss.in',
49 output : 'gtk-' + variant + '.scss',
50 configuration : {
51 'variant' : variant,
52 'transparency' : get_option('transparency').to_string(),
53 'sass_path' : meson.current_source_dir() / 'sass',
54 }
55 )
56
57 gtk3_stylesheets += custom_target(
58 output_css,
59 input : input_scss,
60 output : output_css,
61 command : [sassc, sassc_options, '@INPUT@', '@OUTPUT@'],
62 build_by_default : true,
63 depend_files : sass_depend_files
64 )
65 endif
66
67 # generate the gresource XML
68
69 gresource_xml_array = [
70 '<?xml version="1.0" encoding="UTF-8"?>',
71 '<gresources>',
72 '<gresource prefix="/org/gnome/arc-theme">'
73 ]
74
75 foreach asset : gtk3_asset_names
76 gresource_xml_array += [
77 '<file>assets/' + asset + '.png</file>',
78 '<file>assets/' + asset + '@2.png</file>'
79 ]
80 endforeach
81
82 gresource_xml_array += ['<file>' + output_css + '</file>']
83
84 if variant != 'dark'
85 gresource_xml_array += ['<file>' + output_css_dark + '</file>']
86 endif
87
88 gresource_xml_array += [
89 '</gresource>',
90 '</gresources>'
91 ]
92
93 # compile the gresource
94
95 gresource_xml = configure_file(
96 capture : true,
97 command : ['echo', gresource_xml_array],
98 output : 'gtk-' + variant + '.gresource.xml'
99 )
100
101 #TODO use gnome.compile_resources()???
102 gresource = custom_target(
103 'gresource-' + variant,
104 input : gresource_xml,
105 output : 'gtk-' + variant + '.gresource',
106 command : [
107 glib_compile_resources,
108 '--sourcedir=@OUTDIR@',
109 '--sourcedir=@CURRENT_SOURCE_DIR@',
110 '--target=@OUTPUT@',
111 '@INPUT@'
112 ],
113 depends : [gtk3_assets, gtk3_hidpi_assets, gtk3_stylesheets],
114 depend_files : [gtk3_asset_files, gtk3_hidpi_asset_files],
115 build_by_default : true
116 )
117
118 # install gresource
119 meson.add_install_script(
120 install_file,
121 gresource.full_path(),
122 '$MESON_INSTALL_DESTDIR_PREFIX' / install_dir.get(variant) / common_dirs.get('gtk3') / 'gtk.gresource'
123 )
124
125 # install gtk.css files
126
127 gtk3_css = configure_file(
128 capture : true,
129 command : ['echo', '@import url("resource:///org/gnome/arc-theme/' + output_css + '");'],
130 output : 'gtk-' + variant + '.css'
131 )
132
133 install_data(
134 gtk3_css,
135 install_dir : prefix / install_dir.get(variant) / common_dirs.get('gtk3'),
136 rename : ['gtk.css']
137 )
138
139 #FIXME gtk-dark.css gets overwritten for subsequent variants, resulting in build warnings
140 gtk3_dark_css = configure_file(
141 capture : true,
142 command : ['echo', '@import url("resource:///org/gnome/arc-theme/' + output_css_dark + '");'],
143 output : 'gtk-dark.css',
144 install : true,
145 install_dir : prefix / install_dir.get(variant) / common_dirs.get('gtk3')
146 )
147
148 # install thumbnail
149 install_data(
150 variant != 'dark' ? 'thumbnail/light.png' : 'thumbnail/dark.png',
151 install_dir : prefix / install_dir.get(variant) / common_dirs.get('gtk3'),
152 rename : ['thumbnail.png']
153 )
154 endforeach