third_party:waf: update to upstream 2.0.4 release
[bbaumbach/samba-autobuild/.git] / third_party / waf / waflib / extras / resx.py
1 #! /usr/bin/env python
2 # encoding: utf-8
3 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
4
5 #! /usr/bin/env python
6 # encoding: utf-8
7
8 import os
9 from waflib import Task
10 from waflib.TaskGen import extension
11
12 def configure(conf):
13         conf.find_program(['resgen'], var='RESGEN')
14         conf.env.RESGENFLAGS = '/useSourcePath'
15
16 @extension('.resx')
17 def resx_file(self, node):
18         """
19         Bind the .resx extension to a resgen task
20         """
21         if not getattr(self, 'cs_task', None):
22                 self.bld.fatal('resx_file has no link task for use %r' % self)
23
24         # Given assembly 'Foo' and file 'Sub/Dir/File.resx', create 'Foo.Sub.Dir.File.resources'
25         assembly = getattr(self, 'namespace', os.path.splitext(self.gen)[0])
26         res = os.path.splitext(node.path_from(self.path))[0].replace('/', '.').replace('\\', '.')
27         out = self.path.find_or_declare(assembly + '.' + res + '.resources')
28
29         tsk = self.create_task('resgen', node, out)
30
31         self.cs_task.dep_nodes.extend(tsk.outputs) # dependency
32         self.env.append_value('RESOURCES', tsk.outputs[0].bldpath())
33
34 class resgen(Task.Task):
35         """
36         Compile C# resource files
37         """
38         color   = 'YELLOW'
39         run_str = '${RESGEN} ${RESGENFLAGS} ${SRC} ${TGT}'