示例#1
0
def onresource(unit, *args):
    unit.onpeerdir(['library/resource'])

    outs = []

    for part_args in split(args, 8000):
        srcs_gen = []
        raw_gen = []
        raw_inputs = []
        compressed = []
        compressed_input = []
        compressed_output = []
        for p, n in iterpair(part_args):
            if unit.enabled('ARCH_AARCH64') or unit.enabled(
                    'ARCH_ARM') or unit.enabled('ARCH_PPC64LE'):
                raw_gen += [p, n]
                if p != '-':
                    raw_inputs.append(p)
                continue
            lid = '_' + pathid(p + n + unit.path())
            output = lid + '.rodata'
            if p == '-':
                n, p = n.split('=', 1)
                compressed += ['-', p, output]
            else:
                compressed += [p, output]
                compressed_input.append(p)
                compressed_output.append(output)
            srcs_gen.append('{}={}'.format(lid, n))

        if compressed:
            lid = listid(part_args)
            fake_yasm = '_' + lid + '.yasm'
            cmd = ['tools/rescompressor', fake_yasm
                   ] + gen_ro_flags(unit) + compressed
            if compressed_input:
                cmd += ['IN'] + compressed_input
            cmd += ['OUT_NOAUTO', fake_yasm] + compressed_output
            unit.onrun_program(cmd)
            unit.onsrcs(['GLOBAL', tobuilddir(unit.path() + '/' + fake_yasm)])

        if srcs_gen:
            output = listid(part_args) + '.cpp'
            unit.onrun_program(['tools/rorescompiler', output] + srcs_gen +
                               ['OUT_NOAUTO', output])
            outs.append(output)

        if raw_gen:
            output = listid(part_args) + '_raw.cpp'
            if raw_inputs:
                raw_inputs = ['IN'] + raw_inputs
            unit.onrun_program(['tools/rescompiler', output] + raw_gen +
                               raw_inputs + ['OUT_NOAUTO', output])
            unit.onsrcs(['GLOBAL', output])

    if outs:
        if len(outs) > 1:
            unit.onjoin_srcs_global(['join_' + listid(outs) + '.cpp'] + outs)
        else:
            unit.onsrcs(['GLOBAL'] + outs)
示例#2
0
def onro_resource(unit, *args):
    unit.onpeerdir(['library/resource'])

    for part_args in split(args, 8000):
        srcs_gen = []
        raw_gen = []
        raw_inputs = []
        ro_gen = []
        for p, n in iterpair(part_args):
            if p == '-':
                raw_gen += [p, n]
                continue
            if unit.enabled('ARCH_AARCH64') or unit.enabled(
                    'ARCH_ARM') or unit.enabled('ARCH_PPC64LE'):
                raw_gen += [p, n]
                raw_inputs.append(p)
                continue
            lid = '_' + pathid(p + n + unit.path())
            srcs_gen.append('{}={}'.format(n, lid))
            output = lid + '.roresource'
            unit.onrun_program([
                'tools/rescompressor', p, output, 'IN', p, 'OUT_NOAUTO', output
            ])
            ro_gen.append(output)
        if ro_gen:
            output = listid(part_args) + '.asm'
            unit.onbuiltin_python([
                'build/scripts/gen_rodata.py', '--out-file', output, '--yasm',
                '${tool:"contrib/tools/yasm"}'
            ] + gen_ro_flags(unit) + ro_gen + ['IN'] + ro_gen +
                                  ['OUTPUT_INCLUDES'] + ro_gen +
                                  ['OUT_NOAUTO', output])
            unit.onsrcs(['GLOBAL', tobuilddir(unit.path() + '/' + output)])
        if srcs_gen:
            output = listid(part_args) + '.cpp'
            unit.onrun_program(['tools/rorescompiler', output] + srcs_gen +
                               ['OUT_NOAUTO', output])
            unit.onsrcs(['GLOBAL', output])
        if raw_gen:
            output = listid(part_args) + '_raw.cpp'
            if raw_inputs:
                raw_inputs = ['IN'] + raw_inputs
            unit.onrun_program(['tools/rescompiler', output] + raw_gen +
                               raw_inputs + ['OUT_NOAUTO', output])
            unit.onsrcs(['GLOBAL', output])
示例#3
0
def onro_resource(unit, *args):
    unit.onpeerdir(['library/resource'])

    for part_args in split(args, 8000):
        srcs_gen = []
        for p, n in iterpair(part_args):
            if p == '-':
                continue
            lid = '_' + pathid(p)
            compressed_out = lid + '.rodata'
            unit.onrun_program([
                'tools/rescompressor', p, compressed_out, 'IN', p, 'OUT',
                compressed_out
            ])
            srcs_gen.append('{}={}'.format(n, lid))
        output = listid(part_args) + '.cpp'
        unit.onrun_program(['tools/rorescompiler', output] + srcs_gen +
                           ['OUT_NOAUTO', output])
        unit.onsrcs(['GLOBAL', output])
示例#4
0
def on_register_no_check_imports(unit):
    s = unit.get('NO_CHECK_IMPORTS_FOR_VALUE')
    if s not in ('', 'None'):
        unit.onresource(['-', 'py/no_check_imports/{}="{}"'.format(_common.pathid(s), s)])
示例#5
0
def uniq_suffix(path, unit):
    upath = unit.path()
    if '/' not in path:
        return ''
    return '.{}'.format(pathid(path)[:4])
示例#6
0
def onresource(unit, *args):
    """
    @usage: RESOURCE(file name file name...)
        Add data (resources, random files) to the program)

        This is a simpler but less flexible option than ARCHIVE(), because in the case of ARCHIVE(), you have to use the data explicitly, and in the case of RESOURCE(), the data falls through SRCS(GLOBAL).
        Therefore, there is no static data library from RESOURCE(), they are added only at the program linking stage.

    @example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a2ispolzujjtekomanduresource
    @example:
        LIBRARY()

        OWNER(user1)

        RESOURCE(
        path/to/file1 /key/in/program/1
        path/to/file2 /key2
        )

        END()
    """
    unit.onpeerdir(['library/resource'])

    outs = []
    # https://st.yandex-team.ru/DEVTOOLS-4037
    # compressed_outs = []

    for part_args in split(args, 8000):
        srcs_gen = []
        raw_gen = []
        raw_inputs = []
        compressed = []
        compressed_input = []
        compressed_output = []
        for p, n in iterpair(part_args):
            if unit.enabled('ARCH_AARCH64') or unit.enabled(
                    'ARCH_ARM') or unit.enabled('ARCH_PPC64LE'):
                raw_gen += [p, n]
                if p != '-':
                    raw_inputs.append(p)
                continue
            lid = '_' + pathid(p + n + unit.path())
            output = lid + '.rodata'
            if p == '-':
                n, p = n.split('=', 1)
                compressed += ['-', p, output]
            else:
                compressed += [p, output]
                compressed_input.append(p)
                compressed_output.append(output)
            srcs_gen.append('{}={}'.format(lid, n))

        if compressed:
            lid = listid(part_args)
            fake_yasm = '_' + lid + '.yasm'
            cmd = ['tools/rescompressor', fake_yasm
                   ] + gen_ro_flags(unit) + compressed
            if compressed_input:
                cmd += ['IN'] + compressed_input
            cmd += ['OUT_NOAUTO', fake_yasm] + compressed_output
            unit.onrun_program(cmd)
            # https://st.yandex-team.ru/DEVTOOLS-4037
            # compressed_outs.append(fake_yasm)
            unit.onsrcs(['GLOBAL', tobuilddir(unit.path() + '/' + fake_yasm)])

        if srcs_gen:
            output = listid(part_args) + '.cpp'
            unit.onrun_program(['tools/rorescompiler', output] + srcs_gen +
                               ['OUT_NOAUTO', output])
            outs.append(output)

        if raw_gen:
            output = listid(part_args) + '_raw.cpp'
            if raw_inputs:
                raw_inputs = ['IN'] + raw_inputs
            unit.onrun_program(['tools/rescompiler', output] + raw_gen +
                               raw_inputs + ['OUT_NOAUTO', output])
            unit.onsrcs(['GLOBAL', output])

    if outs:
        if len(outs) > 1:
            unit.onjoin_srcs_global(['join_' + listid(outs) + '.cpp'] + outs)
        else:
            unit.onsrcs(['GLOBAL'] + outs)
示例#7
0
文件: res.py 项目: iamnik13/catboost
def onresource(unit, *args):
    unit.onpeerdir(['library/resource'])

    outs = []

    for part_args in split(args, 8000):
        srcs_gen = []
        raw_gen = []
        raw_inputs = []
        compressed = []
        compressed_input = []
        compressed_output = []
        for p, n in iterpair(part_args):
            if unit.enabled('ARCH_AARCH64') or unit.enabled('ARCH_ARM') or unit.enabled('ARCH_PPC64LE'):
                raw_gen += [p, n]
                if p != '-':
                    raw_inputs.append(p)
                continue
            lid = '_' + pathid(p + n + unit.path())
            output = lid + '.rodata'
            if p == '-':
                n, p = n.split('=', 1)
                compressed += ['-', p, output]
            else:
                compressed += [p, output]
                compressed_input.append(p)
                compressed_output.append(output)
            srcs_gen.append('{}={}'.format(lid, n))

        if compressed:
            lid = listid(part_args)
            fake_yasm = '_' + lid + '.yasm'
            cmd = ['tools/rescompressor', fake_yasm] + gen_ro_flags(unit) + compressed
            if compressed_input:
                cmd += ['IN'] + compressed_input
            cmd += ['OUT_NOAUTO', fake_yasm] + compressed_output
            unit.onrun_program(cmd)
            if compressed_output:
                fake_out = lid + '.yasm'
                cmd = ['build/scripts/fs_tools.py', 'link_or_copy', fake_yasm, fake_out] + ['IN', fake_yasm]
                cmd += ['OUTPUT_INCLUDES'] + compressed_output
                cmd += ['OUT_NOAUTO', fake_out]
                unit.onbuiltin_python(cmd)
            else:
                fake_out = fake_yasm
            unit.onsrcs(['GLOBAL', tobuilddir(unit.path() + '/' + fake_out)])

        if srcs_gen:
            output = listid(part_args) + '.cpp'
            unit.onrun_program(['tools/rorescompiler', output] + srcs_gen + ['OUT_NOAUTO', output])
            outs.append(output)

        if raw_gen:
            output = listid(part_args) + '_raw.cpp'
            if raw_inputs:
                raw_inputs = ['IN'] + raw_inputs
            unit.onrun_program(['tools/rescompiler', output] + raw_gen + raw_inputs + ['OUT_NOAUTO', output])
            unit.onsrcs(['GLOBAL', output])

    if outs:
        if len(outs) > 1:
            unit.onjoin_srcs_global(['join_' + listid(outs) + '.cpp'] + outs)
        else:
            unit.onsrcs(['GLOBAL'] + outs)