forked from algorithm-archivists/algorithm-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoconut.py
40 lines (27 loc) · 805 Bytes
/
coconut.py
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
from SCons.Builder import Builder
import SCons.Util
class ToolCocoWarning(SCons.Warnings.SConsWarning):
pass
class CoconutNotFound(ToolCocoWarning):
pass
SCons.Warnings.enableWarningClass(ToolCocoWarning)
def _detect(env):
try:
return env['coconut']
except KeyError:
pass
coconut = env.WhereIs('coconut')
if coconut:
return coconut
SCons.Warnings.warn(CoconutNotFound, 'Could not find Coconut executable')
def generate(env):
env['COCONUT'] = _detect(env)
env['COCONUTFLAGS'] = []
coconut_compiler = Builder(
action='"$COCONUT" $COCONUTFLAGS $SOURCE $TARGET',
src_suffix='.coco',
suffix='.py',
)
env.Append(BUILDERS={'Coconut': coconut_compiler})
def exists(env):
return env.Detect('coconut')