2013-07-16 11:28:28 +00:00
|
|
|
from waflib.Build import BuildContext
|
2016-12-17 16:12:56 +00:00
|
|
|
from waflib import TaskGen
|
|
|
|
from io import StringIO
|
|
|
|
from TOOLS.matroska import generate_C_header, generate_C_definitions
|
|
|
|
from TOOLS.file2string import file2string
|
2013-07-16 11:28:28 +00:00
|
|
|
import os
|
|
|
|
|
2014-06-08 14:00:43 +00:00
|
|
|
def __zshcomp_cmd__(ctx, argument):
|
2015-03-30 03:20:00 +00:00
|
|
|
return '"${{BIN_PERL}}" "{0}/TOOLS/zsh.pl" "{1}" > "${{TGT}}"' \
|
2014-06-08 14:00:43 +00:00
|
|
|
.format(ctx.srcnode.abspath(), argument)
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
def __file2string__(ctx, **kwargs):
|
|
|
|
ctx(
|
|
|
|
rule = __file2string_cmd__(ctx),
|
|
|
|
before = ("c",),
|
|
|
|
name = os.path.basename(kwargs['target']),
|
|
|
|
**kwargs
|
|
|
|
)
|
|
|
|
|
2016-12-17 16:12:56 +00:00
|
|
|
def execf(self, fn):
|
2017-01-07 13:59:30 +00:00
|
|
|
setattr(self, 'before', ['c'])
|
2016-12-17 16:12:56 +00:00
|
|
|
setattr(self, 'rule', ' ') # waf doesn't print the task with no rule
|
|
|
|
target = getattr(self, 'target', None)
|
|
|
|
out = self.path.find_or_declare(target)
|
|
|
|
tmp = StringIO()
|
|
|
|
fn(tmp)
|
|
|
|
out.write(tmp.getvalue())
|
|
|
|
tmp.close()
|
|
|
|
|
|
|
|
@TaskGen.feature('file2string')
|
|
|
|
def f2s(self):
|
|
|
|
def fn(out):
|
|
|
|
source = getattr(self, 'source', None)
|
|
|
|
src = self.path.find_resource(source)
|
2017-01-05 15:48:27 +00:00
|
|
|
file2string(source, iter(src.read().splitlines(True)), out)
|
2016-12-17 16:12:56 +00:00
|
|
|
execf(self, fn)
|
|
|
|
|
|
|
|
@TaskGen.feature('ebml_header')
|
|
|
|
def ebml_header(self):
|
|
|
|
execf(self, generate_C_header)
|
|
|
|
|
|
|
|
@TaskGen.feature('ebml_definitions')
|
|
|
|
def ebml_definitions(self):
|
|
|
|
execf(self, generate_C_definitions)
|
2013-07-16 11:28:28 +00:00
|
|
|
|
2014-06-08 14:00:43 +00:00
|
|
|
def __zshcomp__(ctx, **kwargs):
|
|
|
|
ctx(
|
2014-06-09 13:43:47 +00:00
|
|
|
rule = __zshcomp_cmd__(ctx, ctx.bldnode.abspath() + '/mpv'),
|
|
|
|
after = ("c", "cprogram",),
|
2014-06-08 14:00:43 +00:00
|
|
|
name = os.path.basename(kwargs['target']),
|
|
|
|
**kwargs
|
|
|
|
)
|
|
|
|
|
2016-12-17 16:12:56 +00:00
|
|
|
BuildContext.file2string = __file2string__
|
|
|
|
BuildContext.zshcomp = __zshcomp__
|