Esempio n. 1
0
def _GetFilesFromCompileDB(build_directory):
  """ Gets the list of files mentioned in the compilation database.

  Args:
    build_directory: Directory that contains the compile database.
  """
  return [os.path.join(entry['directory'], entry['file'])
          for entry in compile_db.Read(build_directory)]
Esempio n. 2
0
def main():
    args = ParseArgs()
    os.chdir(args.p)
    if args.generate_compdb:
        compile_db.GenerateWithNinja('.')
    db = compile_db.Read('.')
    for record in db:
        if os.path.normpath(os.path.join(args.p,
                                         record['file'])) == args.target_file:
            return BuildIt(record, args.prefix, args.compiler, args.suffix)
    print 'error: could not find %s in compile DB!' % args.target_file
    return 1
Esempio n. 3
0
def _GetEntriesFromCompileDB(build_directory, source_filenames):
    """ Gets the list of files and args mentioned in the compilation database.

  Args:
    build_directory: Directory that contains the compile database.
    source_filenames: If not None, only include entries for the given list of
      filenames.
  """

    filenames_set = None if source_filenames is None else set(source_filenames)
    return [
        CompDBEntry(entry['directory'], entry['file'], entry['command'])
        for entry in compile_db.Read(build_directory)
        if filenames_set is None or os.path.realpath(
            os.path.join(entry['directory'], entry['file'])) in filenames_set
    ]
Esempio n. 4
0
  def GetCompDBFiles(self, generate_compdb):
    """Gets the list of files.

    Args:
      generate_compdb: if true, generate a new compdb and write it to
                       compile_commands.json.

    Returns:
      A set of absolute filepaths, with all compile-able C++ files (based on the
      compilation database).
    """
    if generate_compdb:
      compile_commands = compile_db.GenerateWithNinja(self.build_path)
      compdb_path = os.path.join(self.build_path, 'compile_commands.json')
      with open(compdb_path, 'w') as f:
        f.write(json.dumps(compile_commands, indent=2))

    compdb = compile_db.Read(self.build_path)
    return set(
        os.path.abspath(os.path.join(self.build_path, e['file']))
        for e in compdb)