From 9e56434c7ec4130098bf374649103bc5c071b50b Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 29 Jan 2011 23:09:02 +0100 Subject: [PATCH] SCons: start concentrating all custom builders into LumieraEnvironment --- SConstruct | 1 - admin/scons/LumieraEnvironment.py | 40 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 3ae0c4fcb..3711f489e 100644 --- a/SConstruct +++ b/SConstruct @@ -86,7 +86,6 @@ def setupBasicEnvironment(): , CCFLAGS='-Wall -Wextra ' , CFLAGS='-std=gnu99' ) - RegisterIcon_Builder(env) handleNoBugSwitches(env) env.Append(CPPDEFINES = '_GNU_SOURCE') diff --git a/admin/scons/LumieraEnvironment.py b/admin/scons/LumieraEnvironment.py index b9a018c08..a1e050156 100644 --- a/admin/scons/LumieraEnvironment.py +++ b/admin/scons/LumieraEnvironment.py @@ -41,6 +41,7 @@ class LumieraEnvironment(Environment): def __init__(self,*args,**kw): Environment.__init__ (self,*args,**kw) self.libInfo = {} + RegisterIcon_Builder(self) def Configure (self, *args, **kw): kw['env'] = self @@ -184,3 +185,42 @@ class LumieraConfigContext(ConfigBase): return self.env.addLibInfo (libID, minVersion, alias) + +###### Lumiera custom tools and builders ######################## + + +def RegisterIcon_Builder(env): + """ Registers Custom Builders for generating and installing Icons. + Additionally you need to build the tool (rsvg-convert.c) + used to generate png from the svg source using librsvg. + """ + + import render_icon as renderer # load Joel's python script for invoking the rsvg-convert (SVG render) + renderer.rsvgPath = env.subst("$TARDIR/rsvg-convert") + + def invokeRenderer(target, source, env): + source = str(source[0]) + targetdir = env.subst("$TARDIR") + renderer.main([source,targetdir]) + return 0 + + def createIconTargets(target,source,env): + """ parse the SVG to get the target file names """ + source = str(source[0]) + targetdir = os.path.basename(str(target[0])) + targetfiles = renderer.getTargetNames(source) # parse SVG + return (["$TARDIR/%s" % name for name in targetfiles], source) + + def IconCopy(env, source): + """Copy icon to corresponding icon dir. """ + subdir = getDirname(source) + return env.Install("$TARDIR/%s" % subdir, source) + + + buildIcon = env.Builder( action = Action(invokeRenderer, "rendering Icon: $SOURCE --> $TARGETS") + , single_source = True + , emitter = createIconTargets + ) + env.Append(BUILDERS = {'IconRender' : buildIcon}) + env.AddMethod(IconCopy) +