[gnome-shell] theme: Pre-generate stylesheets as well



commit eafbfdfa077f13bb07fe837bc27ad53b2fd19af5
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Dec 29 00:01:03 2020 +0100

    theme: Pre-generate stylesheets as well
    
    Since commit 9ef9a5ff8a, man pages are generated at dist time to reduce
    build dependencies when building from a released tarball.
    
    Do the same for the stylesheets to also remove the sassc dependency.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1555>

 data/meson.build              |  1 +
 data/theme/meson.build        | 27 ++++++++++++++-------------
 meson.build                   |  2 +-
 meson/generate-stylesheets.py | 19 +++++++++++++++++++
 4 files changed, 35 insertions(+), 14 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 25a81422f8..4a1e16d467 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -41,6 +41,7 @@ foreach service_file : service_files
   )
 endforeach
 
+theme_deps = []
 
 subdir('dbus-interfaces')
 subdir('icons')
diff --git a/data/theme/meson.build b/data/theme/meson.build
index b0e08128e1..87112c358d 100644
--- a/data/theme/meson.build
+++ b/data/theme/meson.build
@@ -42,20 +42,21 @@ theme_sources = files([
   'gnome-shell-sass/widgets/_workspace-thumbnails.scss'
 ])
 
-styles = [
-  'gnome-shell-high-contrast',
-  'gnome-shell'
+stylesheets = [
+  'gnome-shell-high-contrast.css',
+  'gnome-shell.css'
 ]
 
-theme_deps = []
-
-foreach style: styles
-  theme_deps += custom_target('style-' + style,
-                              input: '@0@.scss'.format(style),
-                              output: '@0@.css'.format(style),
-                              command: [
-                                sassc, '-a', '@INPUT@', '@OUTPUT@'
-                              ],
-                              depend_files: theme_sources)
+foreach stylesheet: stylesheets
+  if not fs.exists(stylesheet)
+    sassc = find_program('sassc')
+    theme_deps += custom_target(stylesheet,
+                                input: fs.replace_suffix(stylesheet, '.scss'),
+                                output: stylesheet,
+                                command: [
+                                  sassc, '-a', '@INPUT@', '@OUTPUT@'
+                                ],
+                                depend_files: theme_sources)
+  endif
 endforeach
 
diff --git a/meson.build b/meson.build
index 4c913ff863..b08c8dad50 100644
--- a/meson.build
+++ b/meson.build
@@ -137,7 +137,6 @@ endif
 
 mutter_typelibdir = mutter_dep.get_pkgconfig_variable('typelibdir')
 python = find_program('python3')
-sassc = find_program('sassc')
 gjs = find_program('gjs')
 
 cc = meson.get_compiler('c')
@@ -293,6 +292,7 @@ endif
 
 meson.add_install_script('meson/postinstall.py')
 meson.add_dist_script('meson/generate-manpages.py')
+meson.add_dist_script('meson/generate-stylesheets.py')
 
 summary_options = {
   'networkmanager': get_option('networkmanager'),
diff --git a/meson/generate-stylesheets.py b/meson/generate-stylesheets.py
new file mode 100644
index 0000000000..35242c68fc
--- /dev/null
+++ b/meson/generate-stylesheets.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+
+import os
+from pathlib import PurePath
+import subprocess
+
+stylesheets = [
+    'data/theme/gnome-shell-high-contrast.css',
+    'data/theme/gnome-shell.css'
+]
+
+sourceroot = os.environ.get('MESON_SOURCE_ROOT')
+distroot = os.environ.get('MESON_DIST_ROOT')
+
+for stylesheet in stylesheets:
+    stylesheet_path = PurePath(stylesheet)
+    src = PurePath(sourceroot, stylesheet_path.with_suffix('.scss'))
+    dst = PurePath(distroot, stylesheet_path)
+    subprocess.call(['sassc', '-a', src, dst])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]