コード例 #1
0
ファイル: test_shell.py プロジェクト: LegalizeAdulthood/clang
 def test_encode(self):
     self.assertEqual(sut.encode(['clang', "it's me", 'again']),
                      'clang "it\'s me" again')
     self.assertEqual(sut.encode(['clang', "it(s me", 'again)']),
                      'clang "it(s me" "again)"')
     self.assertEqual(sut.encode(['clang', 'redirect > it']),
                      'clang "redirect > it"')
     self.assertEqual(sut.encode(['clang', '-DKEY="VALUE"']),
                      'clang -DKEY=\\"VALUE\\"')
     self.assertEqual(sut.encode(['clang', '-DKEY="value with spaces"']),
                      'clang -DKEY=\\"value with spaces\\"')
コード例 #2
0
ファイル: test_shell.py プロジェクト: M680x0/M680x0-clang
 def test_encode(self):
     self.assertEqual(sut.encode(['clang', "it's me", 'again']),
                      'clang "it\'s me" again')
     self.assertEqual(sut.encode(['clang', "it(s me", 'again)']),
                      'clang "it(s me" "again)"')
     self.assertEqual(sut.encode(['clang', 'redirect > it']),
                      'clang "redirect > it"')
     self.assertEqual(sut.encode(['clang', '-DKEY="VALUE"']),
                      'clang -DKEY=\\"VALUE\\"')
     self.assertEqual(sut.encode(['clang', '-DKEY="value with spaces"']),
                      'clang -DKEY=\\"value with spaces\\"')
コード例 #3
0
ファイル: intercept.py プロジェクト: AlexDenisov/clang
def format_entry(entry):
    """ Generate the desired fields for compilation database entries. """

    def abspath(cwd, name):
        """ Create normalized absolute path from input filename. """
        fullname = name if os.path.isabs(name) else os.path.join(cwd, name)
        return os.path.normpath(fullname)

    logging.debug('format this command: %s', entry['command'])
    atoms = classify_parameters(entry['command'])
    if atoms['action'] <= Action.Compile:
        for source in atoms['files']:
            compiler = 'c++' if atoms['c++'] else 'cc'
            flags = atoms['compile_options']
            flags += ['-o', atoms['output']] if atoms['output'] else []
            flags += ['-x', atoms['language']] if 'language' in atoms else []
            flags += [elem
                      for arch in atoms.get('archs_seen', [])
                      for elem in ['-arch', arch]]
            command = [compiler, '-c'] + flags + [source]
            logging.debug('formated as: %s', command)
            yield {
                'directory': entry['directory'],
                'command': encode(command),
                'file': abspath(entry['directory'], source)
            }
コード例 #4
0
ファイル: intercept.py プロジェクト: zmukwa/swift-clang
def format_entry(entry):
    """ Generate the desired fields for compilation database entries. """
    def abspath(cwd, name):
        """ Create normalized absolute path from input filename. """
        fullname = name if os.path.isabs(name) else os.path.join(cwd, name)
        return os.path.normpath(fullname)

    logging.debug('format this command: %s', entry['command'])
    atoms = classify_parameters(entry['command'])
    if atoms['action'] <= Action.Compile:
        for source in atoms['files']:
            compiler = 'c++' if atoms['c++'] else 'cc'
            flags = atoms['compile_options']
            flags += ['-o', atoms['output']] if atoms['output'] else []
            flags += ['-x', atoms['language']] if 'language' in atoms else []
            flags += [
                elem for arch in atoms.get('archs_seen', [])
                for elem in ['-arch', arch]
            ]
            command = [compiler, '-c'] + flags + [source]
            logging.debug('formated as: %s', command)
            yield {
                'directory': entry['directory'],
                'command': encode(command),
                'file': abspath(entry['directory'], source)
            }
コード例 #5
0
def format_entry(exec_trace):
    """ Generate the desired fields for compilation database entries. """
    def abspath(cwd, name):
        """ Create normalized absolute path from input filename. """
        fullname = name if os.path.isabs(name) else os.path.join(cwd, name)
        return os.path.normpath(fullname)

    logging.debug('format this command: %s', exec_trace['command'])
    compilation = split_command(exec_trace['command'])
    if compilation:
        for source in compilation.files:
            compiler = 'c++' if compilation.compiler == 'c++' else 'cc'
            command = [compiler, '-c'] + compilation.flags + [source]
            logging.debug('formated as: %s', command)
            yield {
                'directory': exec_trace['directory'],
                'command': encode(command),
                'file': abspath(exec_trace['directory'], source)
            }
コード例 #6
0
ファイル: intercept.py プロジェクト: typegrind/clang
def format_entry(exec_trace):
    """ Generate the desired fields for compilation database entries. """

    def abspath(cwd, name):
        """ Create normalized absolute path from input filename. """
        fullname = name if os.path.isabs(name) else os.path.join(cwd, name)
        return os.path.normpath(fullname)

    logging.debug('format this command: %s', exec_trace['command'])
    compilation = split_command(exec_trace['command'])
    if compilation:
        for source in compilation.files:
            compiler = 'c++' if compilation.compiler == 'c++' else 'cc'
            command = [compiler, '-c'] + compilation.flags + [source]
            logging.debug('formated as: %s', command)
            yield {
                'directory': exec_trace['directory'],
                'command': encode(command),
                'file': abspath(exec_trace['directory'], source)
            }
コード例 #7
0
ファイル: test_shell.py プロジェクト: LegalizeAdulthood/clang
 def test(value):
     self.assertEqual(sut.decode(sut.encode(value)), value)
コード例 #8
0
ファイル: test_shell.py プロジェクト: M680x0/M680x0-clang
 def test(value):
     self.assertEqual(sut.decode(sut.encode(value)), value)