File: resource_template.py

package info (click to toggle)
gpick 0.2.6-1.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,800 kB
  • sloc: cpp: 27,983; python: 738; xml: 70; makefile: 37; sh: 10
file content (22 lines) | stat: -rw-r--r-- 754 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import re
from SCons.Script import Builder
from SCons.Action import Action
def addResourceTemplateBuilder(env):
	def buildResourceFile(target, source, env):
		source_dest = SCons.Util.splitext(str(target[0]))[0] + ".rc"
		wfile = open(source_dest,"w")
		data = open(str(File(source[0]).srcnode())).read()
		for key, var in env['RESOURCE_TEMPLATE_VARS'].iteritems():
			data = re.sub("%" + key + "%", var, data)
		wfile.write(data)
		wfile.close()
		return 0
	def buildResourceFileString(target, source, env):
		return "Preparing resource file %s" % os.path.basename(str(target[0]))
	env.Append(BUILDERS = {
		'ResourceTemplate': Builder(
			action = Action(buildResourceFile, buildResourceFileString),
			suffix = '.rc',
			src_suffix = '.rct',
		),
	})