From 669e7c32a2cbc87b2818490beae0a2e25e799845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 29 Dec 2020 00:18:47 +0100 Subject: [PATCH] classic: Pre-generate stylesheet We follow the rule of not putting generated files under version control, but that means drawing in additional build-time dependencies. We can reduce those when building from a released tarball by generating the stylesheets at dist time though, so do that. Part-of: --- data/meson.build | 23 ++++++++++++++--------- meson.build | 4 +++- meson/generate-stylesheets.py | 13 +++++++++++++ 3 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 meson/generate-stylesheets.py diff --git a/data/meson.build b/data/meson.build index 4a029316..27f42872 100644 --- a/data/meson.build +++ b/data/meson.build @@ -76,15 +76,20 @@ theme_data = [ 'gnome-classic-high-contrast.css' ] -style = 'gnome-classic' -custom_target(style + '.css', - input: style + '.scss', - output: style + '.css', - depend_files: theme_sources, - command: [sassc, '-a', '@INPUT@', '@OUTPUT@'], - install: true, - install_dir: themedir -) +stylesheet = 'gnome-classic.css' +if fs.exists(stylesheet) + install_data(stylesheet, install_dir: themedir) +else + sassc = find_program('sassc', required: true) + custom_target(stylesheet, + input: fs.replace_suffix(stylesheet, '.scss'), + output: stylesheet, + depend_files: theme_sources, + command: [sassc, '-a', '@INPUT@', '@OUTPUT@'], + install: true, + install_dir: themedir + ) +endif install_data(theme_data, install_dir: themedir) diff --git a/meson.build b/meson.build index 9e99d745..f1a41081 100644 --- a/meson.build +++ b/meson.build @@ -6,6 +6,7 @@ project('gnome-shell-extensions', gettext_domain = meson.project_name() +fs = import('fs') gnome = import('gnome') i18n = import('i18n') @@ -86,9 +87,10 @@ foreach e : enabled_extensions endforeach if classic_mode_enabled - sassc = find_program('sassc', required: true) subdir('data') endif subdir('extensions') subdir('po') + +meson.add_dist_script('meson/generate-stylesheets.py') diff --git a/meson/generate-stylesheets.py b/meson/generate-stylesheets.py new file mode 100644 index 00000000..6e402b61 --- /dev/null +++ b/meson/generate-stylesheets.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import os +from pathlib import PurePath +import subprocess + +sourceroot = os.environ.get('MESON_SOURCE_ROOT') +distroot = os.environ.get('MESON_DIST_ROOT') + +stylesheet_path = PurePath('data/gnome-classic.css') +src = PurePath(sourceroot, stylesheet_path.with_suffix('.scss')) +dst = PurePath(distroot, stylesheet_path) +subprocess.call(['sassc', '-a', src, dst])