3 # vim: tabstop=4 noexpandtab
6 Create a satellite assembly from "*.??.txt" files. ?? stands for a language code.
8 The projects Resources subfolder contains resources.??.txt string files for several languages.
9 The build folder will hold the satellite assemblies as ./??/ExeName.resources.dll
11 #gen becomes template (It is called gen because it also uses resx.py).
12 bld(source='Resources/resources.de.txt',gen=ExeName)
16 from waflib import Task
17 from waflib.TaskGen import feature,before_method
20 run_str = '${AL} ${ALFLAGS}'
22 @feature('satellite_assembly')
23 @before_method('process_source')
24 def satellite_assembly(self):
25 if not getattr(self, 'gen', None):
26 self.bld.fatal('satellite_assembly needs a template assembly provided with the "gen" parameter')
27 res_lang = re.compile(r'(.*)\.(\w\w)\.(?:resx|txt)',flags=re.I)
29 # self.source can contain node objects, so this will break in one way or another
30 self.source = self.to_list(self.source)
31 for i, x in enumerate(self.source):
32 #x = 'resources/resources.de.resx'
33 #x = 'resources/resources.de.txt'
34 mo = res_lang.match(x)
36 template = os.path.splitext(self.gen)[0]
37 templatedir, templatename = os.path.split(template)
40 #./Resources/resources.de.resources
41 resources = self.path.find_or_declare(res+ '.' + lang + '.resources')
42 self.create_task('resgen', self.to_nodes(x), [resources])
43 #./de/Exename.resources.dll
44 satellite = self.path.find_or_declare(os.path.join(templatedir,lang,templatename) + '.resources.dll')
45 tsk = self.create_task('al',[resources],[satellite])
46 tsk.env.append_value('ALFLAGS','/template:'+os.path.join(self.path.relpath(),self.gen))
47 tsk.env.append_value('ALFLAGS','/embed:'+resources.relpath())
48 tsk.env.append_value('ALFLAGS','/culture:'+lang)
49 tsk.env.append_value('ALFLAGS','/out:'+satellite.relpath())
51 # remove the None elements that we just substituted
52 self.source = list(filter(lambda x:x, self.source))
55 ctx.find_program('al', var='AL', mandatory=True)