Пример #1
0
def exec_response_command_clang(self, cmd, **kw):
    try:
        tmp = None
        arg_max = get_command_line_limit()

        if isinstance(cmd, list) and len(' '.join(cmd)) >= arg_max:
            program = cmd[
                0]  # unquoted program name, otherwise exec_command will fail
            if program == 'ar' and sys.platform.startswith('darwin'):
                Logs.error('ar does not support response files on osx')
            else:
                cmd = [self.quote_response_command(x) for x in cmd]
                (fd, tmp) = tempfile.mkstemp(prefix=self.outputs[0].name)
                os.write(fd, '\n'.join(cmd[1:]).encode())
                os.close(fd)
                cmd = [program, '@' + tmp]
        # no return here, that's on purpose
        ret = self.generator.bld.exec_command(cmd, **kw)
    finally:
        if tmp:
            try:
                os.remove(tmp)
            except OSError:
                pass  # anti-virus and indexers can keep the files open -_-
    return ret
Пример #2
0
def exec_response_command_clang(self, cmd, **kw):
    try:
        tmp = None
        arg_max = get_command_line_limit()

        # 1) Join options that carry no space are joined e.g. /Fo FilePath -> /FoFilePath
        # 2) Join options that carry a ':' as last character : e.g. /OUT: FilePath -> /OUT:FilePath
        if isinstance(cmd, list):
            lst = []
            carry = ''
            join_with_next_list_item = ['/Fo', '/doc', '/Fi', '/Fa']
            for a in cmd:
                if a in join_with_next_list_item or a[-1] == ':':
                    carry = a
                else:
                    lst.append(carry + a)
                    carry = ''

            cmd = lst

        if isinstance(cmd, list) and len(' '.join(cmd)) >= arg_max:
            program = cmd[
                0]  # unquoted program name, otherwise exec_command will fail
            if program == 'ar' and sys.platform.startswith('darwin'):
                Logs.error('ar does not support response files on osx')
            else:
                cmd = [self.quote_response_command(x) for x in cmd]
                (fd, tmp) = tempfile.mkstemp(prefix=self.outputs[0].name)
                os.write(fd, '\n'.join(cmd[1:]).encode())
                os.close(fd)
                cmd = [program, '@' + tmp]
        # no return here, that's on purpose
        ret = self.generator.bld.exec_command(cmd, **kw)
    finally:
        if tmp:
            try:
                os.remove(tmp)
            except OSError:
                pass  # anti-virus and indexers can keep the files open -_-
    return ret