2017-03-26 21:40:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-05-21 19:51:15 +00:00
|
|
|
#include "config.h"
|
2017-04-21 04:50:31 +00:00
|
|
|
|
2017-03-26 21:40:34 +00:00
|
|
|
#include <optional.h>
|
2017-04-20 05:46:10 +00:00
|
|
|
#include <sparsepp/spp.h>
|
|
|
|
|
2017-04-21 04:50:31 +00:00
|
|
|
#include <functional>
|
2017-04-20 05:46:10 +00:00
|
|
|
#include <mutex>
|
2017-03-31 04:21:52 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2017-03-26 21:40:34 +00:00
|
|
|
|
|
|
|
struct Project {
|
2017-04-20 05:01:36 +00:00
|
|
|
struct Entry {
|
|
|
|
std::string filename;
|
|
|
|
std::vector<std::string> args;
|
2017-05-07 05:36:29 +00:00
|
|
|
// If true, this entry is inferred and was not read from disk.
|
|
|
|
bool is_inferred = false;
|
2017-04-20 05:01:36 +00:00
|
|
|
};
|
|
|
|
|
2017-05-21 07:37:53 +00:00
|
|
|
// Include directories for "" headers
|
|
|
|
std::vector<std::string> quote_include_directories;
|
|
|
|
// Include directories for <> headers
|
|
|
|
std::vector<std::string> angle_include_directories;
|
|
|
|
|
2017-04-20 05:01:36 +00:00
|
|
|
std::vector<Entry> entries;
|
2017-04-20 05:46:10 +00:00
|
|
|
spp::sparse_hash_map<std::string, int> absolute_path_to_entry_index_;
|
2017-03-26 21:40:34 +00:00
|
|
|
|
2017-03-31 04:21:52 +00:00
|
|
|
// Loads a project for the given |directory|.
|
|
|
|
//
|
2017-11-22 07:24:39 +00:00
|
|
|
// If |opt_compilation_db_dir| is not empty, the compile_commands.json
|
2017-11-21 16:47:28 +00:00
|
|
|
// file in it will be used to discover all files and args. If it's empty and
|
2017-12-01 17:50:39 +00:00
|
|
|
// |root_directory| contains a compile_commands.json file, that one will be
|
|
|
|
// used instead. Otherwise, a recursive directory listing of all *.cpp, *.cc,
|
|
|
|
// *.h, and *.hpp files will be used. clang arguments can be specified in a
|
2017-11-27 06:56:23 +00:00
|
|
|
// .cquery file located inside of |root_directory|.
|
2018-01-09 08:46:37 +00:00
|
|
|
void Load(Config* initOpts,
|
|
|
|
const std::vector<std::string>& extra_flags,
|
2017-11-22 07:24:39 +00:00
|
|
|
const std::string& opt_compilation_db_dir,
|
|
|
|
const std::string& root_directory,
|
2017-10-25 01:02:15 +00:00
|
|
|
const std::string& resource_directory);
|
2017-03-31 04:21:52 +00:00
|
|
|
|
2017-05-07 05:36:29 +00:00
|
|
|
// Lookup the CompilationEntry for |filename|. If no entry was found this
|
|
|
|
// will infer one based on existing project structure.
|
|
|
|
Entry FindCompilationEntryForFile(const std::string& filename);
|
2017-04-21 04:50:31 +00:00
|
|
|
|
2017-09-22 03:02:48 +00:00
|
|
|
// Run |action| on every file in the project.
|
2017-09-22 01:14:57 +00:00
|
|
|
void ForAllFilteredFiles(
|
|
|
|
Config* config,
|
|
|
|
std::function<void(int i, const Entry& entry)> action);
|
2017-03-31 04:21:52 +00:00
|
|
|
};
|