The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / ragel.py @ 1a126ed1

History | View | Annotate | Download (1.09 KB)

1
#! /usr/bin/env python
2
# encoding: utf-8
3

    
4
"Ragel: '.rl' files are converted into .c files using 'ragel': {.rl -> .c -> .o}"
5

    
6
import TaskGen, Task, Runner
7

    
8

    
9
def rageltaskfun(task):
10
        env = task.env
11
        ragelbin = env.get_flat('RAGEL')
12
        if ragelbin:
13
                if task.inputs[0].srcpath(env) == '../src/config_parser.rl':
14
                        cmd = '%s -o %s -C -T0 %s' % (ragelbin, task.outputs[0].bldpath(env), task.inputs[0].srcpath(env))
15
                else:
16
                        cmd = '%s -o %s -C -T1 %s' % (ragelbin, task.outputs[0].bldpath(env), task.inputs[0].srcpath(env))
17
        else:
18
                src = task.inputs[0].srcpath(env)
19
                src = src[:src.rfind('.')] + '.c'
20
                cmd = 'cp %s %s' % (src, task.outputs[0].bldpath(env))
21
        return task.generator.bld.exec_command(cmd)
22

    
23
rageltask = Task.task_type_from_func('ragel', rageltaskfun, vars = ['RAGEL'], color = 'BLUE', ext_in = '.rl', ext_out = '.c', before = 'c')
24

    
25
@TaskGen.extension('.rl')
26
@TaskGen.before('apply_core')
27
def ragel(self, node):
28
        out = node.change_ext('.c')
29
        self.allnodes.append(out)
30
        tsk = self.create_task('ragel')
31
        tsk.set_inputs(node)
32
        tsk.set_outputs(out)
33

    
34
def detect(conf):
35
        dang = conf.find_program('ragel', var='RAGEL')