2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 22:27:43 +00:00

Add -j argument for hecl cooking

This commit is contained in:
Jack Andersen
2019-02-03 14:01:12 -10:00
parent f35285b076
commit 23a6d66a8c
5 changed files with 52 additions and 5 deletions

View File

@@ -3,6 +3,7 @@
#include "athena/FileReader.hpp"
#include "hecl/Blender/Connection.hpp"
#include "hecl/MultiProgressPrinter.hpp"
#include "boo/IApplication.hpp"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
@@ -18,14 +19,41 @@ static logvisor::Module CP_Log("hecl::ClientProcess");
ThreadLocalPtr<ClientProcess::Worker> ClientProcess::ThreadWorker;
int CpuCountOverride = 0;
void SetCpuCountOverride(int argc, const SystemChar** argv) {
bool threadArg = false;
for (int i = 1; i < argc; ++i) {
if (threadArg) {
if (int count = int(hecl::StrToUl(argv[i], nullptr, 0))) {
CpuCountOverride = count;
return;
}
}
if (!hecl::StrNCmp(argv[i], _SYS_STR("-j"), 2)) {
if (int count = int(hecl::StrToUl(argv[i] + 2, nullptr, 0))) {
CpuCountOverride = count;
return;
}
threadArg = true;
}
}
}
static int GetCPUCount() {
int ret;
#if _WIN32
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors;
ret = sysinfo.dwNumberOfProcessors;
#else
return sysconf(_SC_NPROCESSORS_ONLN);
ret = sysconf(_SC_NPROCESSORS_ONLN);
#endif
if (CpuCountOverride)
return std::min(CpuCountOverride, ret);
return ret;
}
void ClientProcess::BufferTransaction::run(blender::Token& btok) {