Implement checking deps logic for building PCH and PCM. (#15)

This commit is contained in:
ykiko
2024-12-14 22:32:32 +08:00
committed by GitHub
parent 5326480cd6
commit c13048b976
9 changed files with 225 additions and 67 deletions

View File

@@ -44,31 +44,56 @@ struct llvm::DenseMapInfo<clice::SourceContext> {
namespace clice {
struct File {
bool isIdle = true;
/// The current ASTInfo.
std::unique_ptr<ASTInfo> info = std::make_unique<ASTInfo>();
/// Coroutine handles that are waiting for the file to be updated.
std::deque<std::coroutine_handle<>> waiters;
};
/// Responsible for manage the files and schedule the tasks.
class Scheduler {
private:
async::promise<> updatePCH(CompilationParams& params, class Synchronizer& sync);
/// Update the PCH for the given source file.
async::promise<> updatePCH(llvm::StringRef srcPath, llvm::StringRef content);
/// Clang requires all direct and indirect dependent modules to be added during module building.
/// This function adds the dependencies of the given module to the compilation parameters.
/// Note: It is assumed that all dependent modules have already been built.
llvm::Error addModuleDeps(CompilationParams& params, const ModuleInfo& moduleInfo) const;
async::promise<> updatePCM(llvm::StringRef name, class Synchronizer& sync);
/// Update the PCM for the given module.
async::promise<> updatePCM(llvm::StringRef moduleName, class Synchronizer& sync);
/// Update the AST for the given source file.
async::promise<> updateAST(llvm::StringRef filename,
llvm::StringRef content,
class Synchronizer& sync);
/// Wait for until the file is idle.
async::promise<> waitForFile(llvm::StringRef filename);
void scheduleNext(llvm::StringRef filename);
public:
/// Update the given file.
async::promise<> update(llvm::StringRef filename,
llvm::StringRef content,
class Synchronizer& sync);
/// Execute the given action on the given file.
async::promise<> execute(llvm::StringRef filename,
llvm::unique_function<void(ASTInfo&)> action);
/// Load all Information about PCHs and PCMs from disk.
void loadFromDisk();
void loadCache();
/// Save all Information about PCHs and PCMs to disk.
/// So that we can reuse them next time.
void saveToDisk() const;
struct File {};
void saveCache() const;
private:
/// [file name] -> [PCHInfo]
@@ -76,6 +101,9 @@ private:
/// [module name] -> [PCMInfo]
llvm::StringMap<PCMInfo> pcms;
/// [file name] -> [File]
llvm::StringMap<File> files;
};
} // namespace clice