This commit is contained in:
parent
9bd12660eb
commit
d98738fe68
4 changed files with 88 additions and 146 deletions
|
|
@ -67,14 +67,7 @@ namespace Crafter {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_linux_gnu
|
||||
result += RunClang(std::format("{} {}.cppm --precompile -o {}.pcm", clang, path.string(), (pcmDir/path.filename()).string()));
|
||||
#endif
|
||||
#if defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_windows_msvc) || defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32)
|
||||
result += RunClang(std::format("cd {} && {} {}.cppm --precompile -o {}.pcm", pcmDir.string(), clang, path.string(), path.filename().string()));
|
||||
#endif
|
||||
|
||||
result += RunClang(std::format("{} -Wno-unused-command-line-argument {}.pcm -c -o {}.o", clang, (pcmDir/path.filename()).string(), (buildDir/path.filename()).string()));
|
||||
if(result.empty()) {
|
||||
compiled.store(CRAFTER_COMPILE_STATUS_COMPLETED);
|
||||
compiled.notify_all();
|
||||
|
|
@ -84,6 +77,13 @@ namespace Crafter {
|
|||
}
|
||||
}
|
||||
|
||||
void ModulePartition::CompileSource(const std::string_view clang, const fs::path& pcmDir, const fs::path& buildDir, std::string& result) {
|
||||
this->compiled.wait(CRAFTER_COMPILE_STATUS_WAITING);
|
||||
if(this->compiled.load() != CRAFTER_COMPILE_STATUS_ERROR) {
|
||||
result += RunClang(std::format("{} -Wno-unused-command-line-argument {}.pcm -c -o {}.o", clang, (pcmDir/path.filename()).string(), (buildDir/path.filename()).string()));
|
||||
}
|
||||
}
|
||||
|
||||
Module::Module(std::string&& name, fs::path&& path, std::vector<std::unique_ptr<ModulePartition>>&& partitions) : name(std::move(name)), path(std::move(path)), partitions(std::move(partitions)), compiled(CRAFTER_COMPILE_STATUS_WAITING), checked(false) {}
|
||||
|
||||
Module::Module(std::string&& name, fs::path&& path) : name(std::move(name)), path(std::move(path)), compiled(CRAFTER_COMPILE_STATUS_WAITING), checked(false) {}
|
||||
|
|
@ -151,13 +151,7 @@ namespace Crafter {
|
|||
}
|
||||
|
||||
if(result.empty()) {
|
||||
#ifdef CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_linux_gnu
|
||||
result += RunClang(std::format("{} {}.cppm --precompile -o {}.pcm", clang, path.string(), (pcmDir/path.filename()).string()));
|
||||
#endif
|
||||
#if defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_windows_msvc) || defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32)
|
||||
result += RunClang(std::format("cd {} && {} {}.cppm --precompile -o {}.pcm", pcmDir.string(), clang, path.string(), path.filename().string()));
|
||||
#endif
|
||||
result += RunClang(std::format("{} -Wno-unused-command-line-argument {}.pcm -c -o {}.o", clang, (pcmDir/path.filename()).string(), (buildDir/path.filename()).string()));
|
||||
if(result.empty()) {
|
||||
compiled.store(CRAFTER_COMPILE_STATUS_COMPLETED);
|
||||
compiled.notify_all();
|
||||
|
|
@ -170,4 +164,26 @@ namespace Crafter {
|
|||
compiled.notify_all();
|
||||
}
|
||||
}
|
||||
|
||||
void Module::CompileSource(const std::string_view clang, const fs::path& pcmDir, const fs::path& buildDir, std::string& result) {
|
||||
this->compiled.wait(CRAFTER_COMPILE_STATUS_WAITING);
|
||||
if(this->compiled.load() != CRAFTER_COMPILE_STATUS_ERROR) {
|
||||
result += RunClang(std::format("{} -Wno-unused-command-line-argument {}.pcm -c -o {}.o", clang, (pcmDir/path.filename()).string(), (buildDir/path.filename()).string()));
|
||||
std::vector<std::thread> threads;
|
||||
std::vector<std::string> results(partitions.size());
|
||||
for(std::uint_fast32_t i = 0; i < partitions.size(); i++) {
|
||||
if( partitions[i]->needsRecompiling) {
|
||||
threads.emplace_back(&ModulePartition::CompileSource, partitions[i].get(), clang, pcmDir, buildDir, std::ref(results[i]));
|
||||
}
|
||||
}
|
||||
|
||||
for(std::thread& thread : threads){
|
||||
thread.join();
|
||||
}
|
||||
|
||||
for(const std::string& result2 : results) {
|
||||
result += result2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue