waf

FORK: waf with some random patches
git clone https://git.neptards.moe/neptards/waf.git
Log | Files | Refs | README

fsc.py (1909B)


      1 #!/usr/bin/env python
      2 # encoding: utf-8
      3 # Thomas Nagy, 2011 (ita)
      4 
      5 """
      6 Experimental F# stuff
      7 
      8 FSC="mono /path/to/fsc.exe" waf configure build
      9 """
     10 
     11 from waflib import Utils, Task
     12 from waflib.TaskGen import before_method, after_method, feature
     13 from waflib.Tools import ccroot, cs
     14 
     15 ccroot.USELIB_VARS['fsc'] = set(['CSFLAGS', 'ASSEMBLIES', 'RESOURCES'])
     16 
     17 @feature('fs')
     18 @before_method('process_source')
     19 def apply_fsc(self):
     20 	cs_nodes = []
     21 	no_nodes = []
     22 	for x in self.to_nodes(self.source):
     23 		if x.name.endswith('.fs'):
     24 			cs_nodes.append(x)
     25 		else:
     26 			no_nodes.append(x)
     27 	self.source = no_nodes
     28 
     29 	bintype = getattr(self, 'type', self.gen.endswith('.dll') and 'library' or 'exe')
     30 	self.cs_task = tsk = self.create_task('fsc', cs_nodes, self.path.find_or_declare(self.gen))
     31 	tsk.env.CSTYPE = '/target:%s' % bintype
     32 	tsk.env.OUT    = '/out:%s' % tsk.outputs[0].abspath()
     33 
     34 	inst_to = getattr(self, 'install_path', bintype=='exe' and '${BINDIR}' or '${LIBDIR}')
     35 	if inst_to:
     36 		# note: we are making a copy, so the files added to cs_task.outputs won't be installed automatically
     37 		mod = getattr(self, 'chmod', bintype=='exe' and Utils.O755 or Utils.O644)
     38 		self.install_task = self.add_install_files(install_to=inst_to, install_from=self.cs_task.outputs[:], chmod=mod)
     39 
     40 feature('fs')(cs.use_cs)
     41 after_method('apply_fsc')(cs.use_cs)
     42 
     43 feature('fs')(cs.debug_cs)
     44 after_method('apply_fsc', 'use_cs')(cs.debug_cs)
     45 
     46 class fsc(Task.Task):
     47 	"""
     48 	Compile F# files
     49 	"""
     50 	color   = 'YELLOW'
     51 	run_str = '${FSC} ${CSTYPE} ${CSFLAGS} ${ASS_ST:ASSEMBLIES} ${RES_ST:RESOURCES} ${OUT} ${SRC}'
     52 
     53 def configure(conf):
     54 	"""
     55 	Find a F# compiler, set the variable FSC for the compiler and FS_NAME (mono or fsc)
     56 	"""
     57 	conf.find_program(['fsc.exe', 'fsharpc'], var='FSC')
     58 	conf.env.ASS_ST = '/r:%s'
     59 	conf.env.RES_ST = '/resource:%s'
     60 
     61 	conf.env.FS_NAME = 'fsc'
     62 	if str(conf.env.FSC).lower().find('fsharpc') > -1:
     63 		conf.env.FS_NAME = 'mono'
     64