Optionally depend on sassc to generate the theme CSS
authorEmmanuele Bassi <ebassi@gnome.org>
Tue, 14 Mar 2017 16:35:58 +0000 (16:35 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Mon, 3 Apr 2017 11:02:11 +0000 (12:02 +0100)
Instead of using Ruby/Sass to generate the CSS from SCSS files, we can
use the faster and more lightweight libsass/sassc binary.

We can keep the CSS files in Git to make it easier to dist GTK+, but we
can add rules to ensure they get rebuilt if the source SCSS changes.

https://bugzilla.gnome.org/show_bug.cgi?id=780041

configure.ac
gtk/Makefile.am

index f038b48550c497c80a2c561e8d0414e7e3db883f..262bb9676f347d4eb93636dccb9f866f0242595f 100644 (file)
@@ -1815,6 +1815,14 @@ case "$host" in
 esac
 AC_SUBST(GDK_HIDDEN_VISIBILITY_CFLAGS)
 
+##################################################
+# Theming
+##################################################
+
+AC_PATH_PROG([SASSC], [sassc])
+AC_ARG_VAR(SASSC)
+AM_CONDITIONAL([REBUILD_SCSS], [test "xSASSC" != x])
+
 ##################################################
 # Output commands
 ##################################################
index 3b76b82db674f7612e0aa9f0d033d35c68e0df79..c601ad2ededd00d01ae0a0dff1f3b33625fb1119 100644 (file)
@@ -1323,36 +1323,61 @@ gesture_sources =                               \
        gesture/gesture-two-finger-swipe-left-symbolic.svg      \
        gesture/gesture-two-finger-swipe-right-symbolic.svg
 
-theme_sources =                                \
-       theme/win32/gtk.css                     \
-       theme/win32/gtk-win32-base.css          \
-       theme/Adwaita/assets.txt                \
-       theme/Adwaita/assets.svg                \
+adwaita_theme_scss = \
        theme/Adwaita/_colors-public.scss       \
        theme/Adwaita/_colors.scss              \
        theme/Adwaita/_common.scss              \
        theme/Adwaita/_drawing.scss             \
        theme/Adwaita/gtk-contained-dark.scss   \
        theme/Adwaita/gtk-contained.scss        \
-       theme/Adwaita/parse-sass.sh             \
-       theme/Adwaita/render-assets.sh          \
-       theme/Adwaita/Gemfile                   \
-       theme/Adwaita/README                    \
-       theme/Adwaita/gtk-contained.css         \
-       theme/Adwaita/gtk-contained-dark.css    \
-       theme/Adwaita/gtk.css                   \
-       theme/Adwaita/gtk-dark.css              \
+       $()
+
+highcontrast_theme_scss = \
        theme/HighContrast/_colors.scss         \
        theme/HighContrast/_common.scss         \
        theme/HighContrast/_drawing.scss        \
        theme/HighContrast/gtk-contained-inverse.scss \
        theme/HighContrast/gtk-contained.scss   \
-       theme/HighContrast/Gemfile              \
+       $()
+
+if REBUILD_SCSS
+# If we have sassc then we can rebuild the theme CSS as soon as the SCSS
+# files have been changed
+
+scss_verbose = $(scss_verbose_@AM_V@)
+scss_verbose_ = $(scss_verbose_@AM_DEFAULT_V@)
+scss_verbose_0 = @echo "  SCSS     $@";
+
+theme/Adwaita/gtk-contained.css: $(top_srcdir)/gtk/theme/Adwaita/gtk-contained.scss
+       $(scss_verbose) $(MKDIR_P) $(dir $@) && $(SASSC) -a $< $@ || rm -f $@
+
+theme/Adwaita/gtk-contained-dark.css: $(top_srcdir)/gtk/theme/Adwaita/gtk-contained-dark.scss
+       $(scss_verbose) $(MKDIR_P) $(dir $@) && $(SASSC) -a $< $@ || rm -f $@
+
+theme/HighContrast/gtk-contained.css: $(top_srcdir)/gtk/theme/HighContrast/gtk-contained.scss
+       $(scss_verbose) $(MKDIR_P) $(dir $@) && $(SASSC) -a $< $@ || rm -f $@
+
+theme/HighContrast/gtk-contained-inverse.css: $(top_srcdir)/gtk/theme/HighContrast/gtk-contained-inverse.scss
+       $(scss_verbose) $(MKDIR_P) $(dir $@) && $(SASSC) -a $< $@ || rm -f $@
+
+endif # REBUILD_SCSS
+
+theme_sources =                                \
+       theme/win32/gtk.css                     \
+       theme/win32/gtk-win32-base.css          \
+       $(adwaita_theme_scss)                   \
+       theme/Adwaita/assets.txt                \
+       theme/Adwaita/assets.svg                \
+       theme/Adwaita/README                    \
+       theme/Adwaita/gtk-contained.css         \
+       theme/Adwaita/gtk-contained-dark.css    \
+       theme/Adwaita/gtk.css                   \
+       theme/Adwaita/gtk-dark.css              \
+       $(highcontrast_theme_scss)              \
        theme/HighContrast/gtk-contained.css    \
        theme/HighContrast/gtk-contained-inverse.css \
        theme/HighContrast/gtk.css              \
        theme/HighContrast/gtk-inverse.css      \
-       theme/HighContrast/parse-sass.sh        \
        theme/Raleigh/gtk-default.css
 
 resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(builddir)/gtk.gresource.xml)