2017-03-26 21:40:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <optional.h>
|
2017-04-20 05:46:10 +00:00
|
|
|
#include <sparsepp/spp.h>
|
|
|
|
|
|
|
|
#include <mutex>
|
2017-03-31 04:21:52 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2017-03-26 21:40:34 +00:00
|
|
|
|
|
|
|
using std::experimental::optional;
|
|
|
|
using std::experimental::nullopt;
|
|
|
|
|
|
|
|
struct Project {
|
2017-04-20 05:01:36 +00:00
|
|
|
struct Entry {
|
|
|
|
std::string filename;
|
|
|
|
std::vector<std::string> args;
|
2017-04-20 07:25:38 +00:00
|
|
|
|
|
|
|
std::string import_file;
|
2017-04-20 07:53:33 +00:00
|
|
|
std::vector<std::string> import_dependencies;
|
2017-04-20 05:46:10 +00:00
|
|
|
optional<uint64_t> last_modification_time;
|
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_;
|
|
|
|
std::mutex entries_modification_mutex_;
|
2017-03-26 21:40:34 +00:00
|
|
|
|
2017-03-31 04:21:52 +00:00
|
|
|
// Loads a project for the given |directory|.
|
|
|
|
//
|
|
|
|
// If |directory| contains a compile_commands.json file, that will be used to
|
|
|
|
// discover all files and args. Otherwise, a recursive directory listing of
|
|
|
|
// all *.cpp, *.cc, *.h, and *.hpp files will be used. clang arguments can be
|
|
|
|
// specified in a clang_args file located inside of |directory|.
|
|
|
|
void Load(const std::string& directory);
|
|
|
|
|
|
|
|
// Lookup the CompilationEntry for |filename|.
|
2017-04-20 05:01:36 +00:00
|
|
|
optional<Entry> FindCompilationEntryForFile(const std::string& filename);
|
2017-04-20 05:46:10 +00:00
|
|
|
|
|
|
|
// Update the modification time for the given filename. This is thread-safe.
|
2017-04-20 07:53:33 +00:00
|
|
|
void UpdateFileState(const std::string& filename, const std::string& import_file, const std::vector<std::string>& import_dependencies, uint64_t modification_time);
|
2017-03-31 04:21:52 +00:00
|
|
|
};
|
|
|
|
|