2008-06-30 14:24:29 +00:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
"Ragel: '.rl' files are converted into .c files using 'ragel': {.rl -> .c -> .o}"
|
|
|
|
|
2008-07-15 20:12:33 +00:00
|
|
|
import TaskGen, Task, Runner
|
2008-06-30 14:24:29 +00:00
|
|
|
|
2008-07-15 20:12:33 +00:00
|
|
|
|
|
|
|
def rageltaskfun(task):
|
|
|
|
env = task.env
|
|
|
|
ragelbin = env.get_flat('RAGEL')
|
|
|
|
if ragelbin:
|
2009-09-05 14:44:25 +00:00
|
|
|
if task.inputs[0].srcpath(env) == '../src/main/config_parser.rl':
|
2008-09-24 19:58:53 +00:00
|
|
|
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))
|
2008-07-15 20:12:33 +00:00
|
|
|
else:
|
|
|
|
src = task.inputs[0].srcpath(env)
|
|
|
|
src = src[:src.rfind('.')] + '.c'
|
|
|
|
cmd = 'cp %s %s' % (src, task.outputs[0].bldpath(env))
|
2008-11-20 23:31:44 +00:00
|
|
|
return task.generator.bld.exec_command(cmd)
|
2008-07-15 20:12:33 +00:00
|
|
|
|
|
|
|
rageltask = Task.task_type_from_func('ragel', rageltaskfun, vars = ['RAGEL'], color = 'BLUE', ext_in = '.rl', ext_out = '.c', before = 'c')
|
|
|
|
|
|
|
|
@TaskGen.extension('.rl')
|
2008-11-20 23:31:44 +00:00
|
|
|
@TaskGen.before('apply_core')
|
2008-07-15 20:12:33 +00:00
|
|
|
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)
|
2008-06-30 14:24:29 +00:00
|
|
|
|
|
|
|
def detect(conf):
|
2009-09-14 17:12:15 +00:00
|
|
|
dang = conf.find_program('ragel', var='RAGEL', mandatory=True)
|