summaryrefslogtreecommitdiff
path: root/buildtools/wafadmin/Tools/cs.py
blob: 43544856f34045ede3b6c3f4680d87b0d5c94794 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2006 (ita)

"C# support"

import TaskGen, Utils, Task, Options
from Logs import error
from TaskGen import before, after, taskgen, feature

flag_vars= ['FLAGS', 'ASSEMBLIES']

@feature('cs')
def init_cs(self):
	Utils.def_attrs(self,
		flags = '',
		assemblies = '',
		resources = '',
		uselib = '')

@feature('cs')
@after('init_cs')
def apply_uselib_cs(self):
	if not self.uselib:
		return
	global flag_vars
	for var in self.to_list(self.uselib):
		for v in self.flag_vars:
			val = self.env[v+'_'+var]
			if val: self.env.append_value(v, val)

@feature('cs')
@after('apply_uselib_cs')
@before('apply_core')
def apply_cs(self):
	try: self.meths.remove('apply_core')
	except ValueError: pass

	# process the flags for the assemblies
	for i in self.to_list(self.assemblies) + self.env['ASSEMBLIES']:
		self.env.append_unique('_ASSEMBLIES', '/r:'+i)

	# process the flags for the resources
	for i in self.to_list(self.resources):
		self.env.append_unique('_RESOURCES', '/resource:'+i)

	# what kind of assembly are we generating?
	self.env['_TYPE'] = getattr(self, 'type', 'exe')

	# additional flags
	self.env.append_unique('_FLAGS', self.to_list(self.flags))
	self.env.append_unique('_FLAGS', self.env.FLAGS)

	# process the sources
	nodes = [self.path.find_resource(i) for i in self.to_list(self.source)]
	self.create_task('mcs', nodes, self.path.find_or_declare(self.target))

Task.simple_task_type('mcs', '${MCS} ${SRC} /target:${_TYPE} /out:${TGT} ${_FLAGS} ${_ASSEMBLIES} ${_RESOURCES}', color='YELLOW')

def detect(conf):
	csc = getattr(Options.options, 'cscbinary', None)
	if csc:
		conf.env.MCS = csc
	conf.find_program(['gmcs', 'mcs'], var='MCS')

def set_options(opt):
	opt.add_option('--with-csc-binary', type='string', dest='cscbinary')