forked from lighttpd/lighttpd2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ragel.py
35 lines (28 loc) · 1.12 KB
/
ragel.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
#! /usr/bin/env python
# encoding: utf-8
"Ragel: '.rl' files are converted into .c files using 'ragel': {.rl -> .c -> .o}"
import TaskGen, Task, Runner
def rageltaskfun(task):
env = task.env
ragelbin = env.get_flat('RAGEL')
if ragelbin:
if task.inputs[0].srcpath(env) == '../src/main/config_parser.rl':
cmd = '%s -o %s -C -T0 %s' % (ragelbin, task.outputs[0].bldpath(env), task.inputs[0].srcpath(env))
else:
cmd = '%s -o %s -C -T1 %s' % (ragelbin, task.outputs[0].bldpath(env), task.inputs[0].srcpath(env))
else:
src = task.inputs[0].srcpath(env)
src = src[:src.rfind('.')] + '.c'
cmd = 'cp %s %s' % (src, task.outputs[0].bldpath(env))
return task.generator.bld.exec_command(cmd)
rageltask = Task.task_type_from_func('ragel', rageltaskfun, vars = ['RAGEL'], color = 'BLUE', ext_in = '.rl', ext_out = '.c', before = 'c')
@TaskGen.extension('.rl')
@TaskGen.before('apply_core')
def ragel(self, node):
out = node.change_ext('.c')
self.allnodes.append(out)
tsk = self.create_task('ragel')
tsk.set_inputs(node)
tsk.set_outputs(out)
def detect(conf):
dang = conf.find_program('ragel', var='RAGEL', mandatory=True)