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