| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
import os |
| 7 |
from pathlib import Path |
| 8 |
import subprocess |
| 9 |
|
| 10 |
dist_root = os.environ.get('MESON_DIST_ROOT') |
| 11 |
source_root = os.environ.get('MESON_SOURCE_ROOT') |
| 12 |
|
| 13 |
asset_arrays = [ |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
['common/gtk-2.0/assets-dark/assets.svg', |
| 20 |
'common/gtk-2.0/assets.txt', |
| 21 |
'common/gtk-2.0/assets-dark/', |
| 22 |
'96', |
| 23 |
'.png'], |
| 24 |
['common/gtk-2.0/assets-light/assets.svg', |
| 25 |
'common/gtk-2.0/assets.txt', |
| 26 |
'common/gtk-2.0/assets-light/', |
| 27 |
'96', |
| 28 |
'.png'], |
| 29 |
['common/gtk-3.0/assets/assets.svg', |
| 30 |
'common/gtk-3.0/assets/assets.txt', |
| 31 |
'common/gtk-3.0/assets/', |
| 32 |
'96', |
| 33 |
'.png'], |
| 34 |
['common/gtk-3.0/assets/assets.svg', |
| 35 |
'common/gtk-3.0/assets/assets.txt', |
| 36 |
'common/gtk-3.0/assets/', |
| 37 |
'192', |
| 38 |
'@2.png'], |
| 39 |
['common/gtk-4.0/assets/assets.svg', |
| 40 |
'common/gtk-4.0/assets/assets.txt', |
| 41 |
'common/gtk-4.0/assets/', |
| 42 |
'96', |
| 43 |
'.png'], |
| 44 |
['common/gtk-4.0/assets/assets.svg', |
| 45 |
'common/gtk-4.0/assets/assets.txt', |
| 46 |
'common/gtk-4.0/assets/', |
| 47 |
'192', |
| 48 |
'@2.png'], |
| 49 |
['common/xfwm4/dark/assets.svg', |
| 50 |
'common/xfwm4/assets.txt', |
| 51 |
'common/xfwm4/dark/', |
| 52 |
'96', |
| 53 |
'.png'], |
| 54 |
['common/xfwm4/light/assets.svg', |
| 55 |
'common/xfwm4/assets.txt', |
| 56 |
'common/xfwm4/light/', |
| 57 |
'96', |
| 58 |
'.png'] |
| 59 |
] |
| 60 |
|
| 61 |
for asset_array in asset_arrays: |
| 62 |
|
| 63 |
source_file = Path(source_root, asset_array[0]) |
| 64 |
asset_list = Path(source_root, asset_array[1]) |
| 65 |
output_dir = Path(dist_root, asset_array[2]) |
| 66 |
dpi = asset_array[3] |
| 67 |
suffix = asset_array[4] |
| 68 |
|
| 69 |
asset_names = asset_list.read_text().splitlines() |
| 70 |
asset_files = [] |
| 71 |
inkscape_actions = ['export-id-only', 'export-dpi:' + dpi,] |
| 72 |
|
| 73 |
for asset in asset_names: |
| 74 |
asset_file = output_dir / (asset + suffix) |
| 75 |
|
| 76 |
asset_files.append(asset_file) |
| 77 |
|
| 78 |
inkscape_actions.append('export-id:' + asset) |
| 79 |
inkscape_actions.append('export-filename:' + str(asset_file)) |
| 80 |
inkscape_actions.append('export-do') |
| 81 |
|
| 82 |
subprocess.run([ |
| 83 |
'inkscape', |
| 84 |
'--actions=' + '; '.join(inkscape_actions), |
| 85 |
source_file], |
| 86 |
check=True) |
| 87 |
|
| 88 |
subprocess.run([ |
| 89 |
'oxipng', |
| 90 |
'-o', 'max', |
| 91 |
'--strip', 'safe', |
| 92 |
'--libdeflater', |
| 93 |
] + asset_files, |
| 94 |
check=True) |