"Build" a local copy of the icons to be used from sources
authorEmanuele Aina <emanuele.aina@collabora.com>
Mon, 19 Apr 2010 10:59:16 +0000 (12:59 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 8 Mar 2012 12:09:06 +0000 (13:09 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=616159

data/.gitignore
data/icons/Makefile.am
data/icons/utils.mk [new file with mode: 0644]

index 2c0f33226f8585a81aff05c9e8f815d2796c293b..2d4a96f0ca671a9b04aa170060c1ebf4638b657d 100644 (file)
@@ -10,3 +10,4 @@ empathy-accounts.desktop
 empathy-accounts.desktop.in
 org.freedesktop.Telepathy.Client.Empathy.Auth.service
 org.freedesktop.Telepathy.Client.Empathy.FileTransfer.service
+icons/local-copy/*
index 56ad3312f0ac0fe5fd19b92a68d907ab27fc4076..4bac794d6cd371554458dd23d1d9d980c3daf7c8 100644 (file)
@@ -192,6 +192,8 @@ EXTRA_DIST = \
        local-xmpp.svg          \
        $(NULL)
 
+include $(srcdir)/utils.mk
+
 ###############################################################################
 
 gtk_update_icon_cache = gtk-update-icon-cache -f -t
@@ -252,3 +254,31 @@ uninstall-icons:
 install-data-local: install-icons update-icon-cache
 
 uninstall-local: uninstall-icons update-icon-cache
+
+# Local copy of the "installed" icon. This is used to be able to run empathy
+# from source (see bgo #616159)
+local_icons_dir = local-copy
+
+# Generate the lists of destination paths
+public_icons_local_install_paths = $(foreach obj, $(public_icons), $(local_icons_dir)/$(subst _,/,$(call reorder,_,1 3 2 4,$(obj))))
+private_icons_local_install_paths = $(foreach obj, $(private_icons), $(local_icons_dir)/$(subst _,/,$(call reorder,_,1 3 2 4,$(obj))))
+
+# For each destination path we'll need to compute back the original icon
+# and create a rule that will ensure that the destination directory exists
+# and then copy the original file
+define icon_local_install_rule_template
+$(local_icons_dir)/$$(subst _,/,$$(call reorder,_,1 3 2 4,$1)): $1
+       $$(AM_V_GEN)mkdir -p $$(@D)
+       $$(AM_V_GEN)cp $$^ $$@
+endef
+
+# Instantiate the template above for each icon
+$(foreach icon,$(public_icons),$(eval $(call icon_local_install_rule_template,$(icon))))
+$(foreach icon,$(private_icons),$(eval $(call icon_local_install_rule_template,$(icon))))
+
+install-icons-src: $(public_icons_local_install_paths) $(private_icons_local_install_paths)
+
+all: install-icons-src
+
+clean-local:
+       -rm -rf $(local_icons_dir)
diff --git a/data/icons/utils.mk b/data/icons/utils.mk
new file mode 100644 (file)
index 0000000..84b1c82
--- /dev/null
@@ -0,0 +1,11 @@
+# define a variable containing a single space
+blank :=
+space := $(blank) $(blank)
+# split string $3 with $1 as separator and return the token in position $2
+define token
+$(word $2, $(subst $1, ,$3))
+endef
+# split string $3 with $1 as separator and reassemble it using the indexes in $2
+define reorder
+$(subst $(space),$1,$(foreach i,$2,$(call token,$1,$i,$3)))
+endef