コード例 #1
0
ファイル: run_msvc_wine.py プロジェクト: Gmacem/catboost
def process_free_args(args, wine, bld_root, mode):
    short_names = {}
    winepath = os.path.join(os.path.dirname(wine), 'winepath')
    short_names[bld_root] = trim_path(bld_root, winepath)
    # Slow for no benefit.
    # arc_root = args.arcadia_root
    # short_names[arc_root] = trim_path(arc_root, winepath)

    free_args, wa_peers, wa_libs = pwa.get_whole_archive_peers_and_libs(
        pcf.skip_markers(args))

    process_link = lambda x: make_full_path_arg(x, bld_root, short_names[
        bld_root]) if mode in ('link', 'lib') else x

    def process_arg(arg):
        return fix_path(process_link(downsize_path(arg, short_names)))

    result = []
    for arg in free_args:
        if pcf.is_cmdfile_arg(arg):
            cmd_file_path = pcf.cmdfile_path(arg)
            cf_args = pcf.read_from_command_file(cmd_file_path)
            with open(cmd_file_path, 'w') as afile:
                for cf_arg in cf_args:
                    afile.write(process_arg(cf_arg) + "\n")
            result.append(arg)
        else:
            result.append(process_arg(arg))
    return pwa.ProcessWholeArchiveOption('WINDOWS', wa_peers,
                                         wa_libs).construct_cmd(result)
コード例 #2
0
        def add_whole_archive_prefix(arg, need_check_peers_and_libs):
            if not pcf.is_cmdfile_arg(arg):
                return add_prefix(arg, need_check_peers_and_libs)

            cmd_file_path = pcf.cmdfile_path(arg)
            cf_args = pcf.read_from_command_file(cmd_file_path)
            with open(cmd_file_path, 'w') as afile:
                for cf_arg in cf_args:
                    afile.write(add_prefix(cf_arg, need_check_peers_and_libs) + "\n")
            return arg
コード例 #3
0
def process_whole_archive(args):
    cmd = []
    prefix = '/WHOLEARCHIVE:'
    start_wa = '--start-wa'
    end_wa = '--end-wa'
    is_inside_wa = False
    for arg in args:
        if arg == start_wa:
            is_inside_wa = True
        elif arg == end_wa:
            is_inside_wa = False
        elif is_inside_wa:
            if not pcf.is_cmdfile_arg(arg):
                cmd.append(prefix + arg)
                continue
            cmd_file_path = pcf.cmdfile_path(arg)
            cf_args = pcf.read_from_command_file(cmd_file_path)
            with open(cmd_file_path, 'w') as afile:
                for cf_arg in cf_args:
                    afile.write(prefix + cf_arg + "\n")
            cmd.append(arg)
        else:
            cmd.append(arg)
    return cmd
コード例 #4
0
import os
import platform
import sys
import shutil

import process_command_files as pcf


if __name__ == '__main__':
    # Support @response-file notation for windows to reduce cmd length
    if pcf.is_cmdfile_arg(sys.argv[1]):
        args = pcf.read_from_command_file(pcf.cmdfile_path(sys.argv[1]))
        sys.argv[:] = [sys.argv[0]] + args + sys.argv[2:]

    mode = sys.argv[1]
    args = list(pcf.iter_args(sys.argv[2:]))

    if mode == 'copy':
        shutil.copy(args[0], args[1])
    elif mode == 'copy_tree_no_link':
        dst = args[1]
        shutil.copytree(args[0], dst, ignore=lambda dirname, names: [n for n in names if os.path.islink(os.path.join(dirname, n))])
    elif mode == 'copy_files':
        src = args[0]
        dst = args[1]
        files = open(args[2]).read().strip().split()
        for f in files:
            s = os.path.join(src, f)
            d = os.path.join(dst, f)
            if os.path.exists(d):
                continue