diff --git a/hecl/CMakeLists.txt b/hecl/CMakeLists.txt index 64ffbcee3..7ff406a90 100644 --- a/hecl/CMakeLists.txt +++ b/hecl/CMakeLists.txt @@ -40,17 +40,9 @@ foreach(name ${HECL_APPLICATION_PIPELINE_REPS}) set(HECL_APPLICATION_PIPELINE_REPS_NX_LOCAL "${HECL_APPLICATION_PIPELINE_REPS_NX_LOCAL}NX_PIPELINES_${name} \\\n") endforeach() -unset(HECL_APPLICATION_STAGE_REPS_OPENGL_LOCAL) -unset(HECL_APPLICATION_STAGE_REPS_VULKAN_LOCAL) -unset(HECL_APPLICATION_STAGE_REPS_D3D11_LOCAL) -unset(HECL_APPLICATION_STAGE_REPS_METAL_LOCAL) -unset(HECL_APPLICATION_STAGE_REPS_NX_LOCAL) +unset(HECL_APPLICATION_STAGE_REPS_LOCAL) foreach(name ${HECL_APPLICATION_STAGE_REPS}) - set(HECL_APPLICATION_STAGE_REPS_OPENGL_LOCAL "${HECL_APPLICATION_STAGE_REPS_OPENGL_LOCAL}OPENGL_STAGES_${name} \\\n") - set(HECL_APPLICATION_STAGE_REPS_VULKAN_LOCAL "${HECL_APPLICATION_STAGE_REPS_VULKAN_LOCAL}VULKAN_STAGES_${name} \\\n") - set(HECL_APPLICATION_STAGE_REPS_D3D11_LOCAL "${HECL_APPLICATION_STAGE_REPS_D3D11_LOCAL}D3D11_STAGES_${name} \\\n") - set(HECL_APPLICATION_STAGE_REPS_METAL_LOCAL "${HECL_APPLICATION_STAGE_REPS_METAL_LOCAL}METAL_STAGES_${name} \\\n") - set(HECL_APPLICATION_STAGE_REPS_NX_LOCAL "${HECL_APPLICATION_STAGE_REPS_NX_LOCAL}NX_STAGES_${name} \\\n") + set(HECL_APPLICATION_STAGE_REPS_LOCAL "${HECL_APPLICATION_STAGE_REPS_LOCAL}STAGES_${name}(P, S) \\\n") endforeach() configure_file(include/hecl/ApplicationReps.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/include/hecl/ApplicationReps.hpp @ONLY) diff --git a/hecl/driver/ToolBase.hpp b/hecl/driver/ToolBase.hpp index 75f849ccb..b2b0e323a 100644 --- a/hecl/driver/ToolBase.hpp +++ b/hecl/driver/ToolBase.hpp @@ -59,9 +59,9 @@ protected: if (!m_info.yes) { if (XTERM_COLOR) - hecl::Printf(_S("\n" BLUE BOLD "Continue?" NORMAL " (Y/n) ")); + hecl::Printf(_SYS_STR("\n" BLUE BOLD "Continue?" NORMAL " (Y/n) ")); else - hecl::Printf(_S("\nContinue? (Y/n) ")); + hecl::Printf(_SYS_STR("\nContinue? (Y/n) ")); fflush(stdout); int ch; @@ -78,7 +78,7 @@ protected: { if (ch == 'n' || ch == 'N') { - hecl::Printf(_S("\n")); + hecl::Printf(_SYS_STR("\n")); return false; } if (ch == 'y' || ch == 'Y' || ch == '\r' || ch == '\n') @@ -88,7 +88,7 @@ protected: tcsetattr(0, TCSANOW, &tioOld); #endif } - hecl::Printf(_S("\n")); + hecl::Printf(_SYS_STR("\n")); return true; } @@ -130,7 +130,7 @@ private: { if (it >= string.end()) return; - if (*it == _S('\n')) + if (*it == _SYS_STR('\n')) { counter = WRAP_INDENT; ++it; @@ -138,17 +138,17 @@ private: if (counter == WRAP_INDENT) { for (int i=0 ; i= string.end()) return; - if (*it != _S('\n')) + if (*it != _SYS_STR('\n')) ++it; } /* check for whitespace */ if (isspace(*it)) { - *it = _S('\n'); + *it = _SYS_STR('\n'); counter = WRAP_INDENT; ++it; } @@ -161,9 +161,9 @@ private: { counter = WRAP_INDENT; if (k - string.begin() < v) - k = string.insert(it, _S('\n')); + k = string.insert(it, _SYS_STR('\n')); else - *k = _S('\n'); + *k = _SYS_STR('\n'); it = k + 1; break; } @@ -200,31 +200,31 @@ public: void print(const hecl::SystemChar* str) { - hecl::FPrintf(m_sout, _S("%s"), str); + hecl::FPrintf(m_sout, _SYS_STR("%s"), str); } void printBold(const hecl::SystemChar* str) { if (XTERM_COLOR) - hecl::FPrintf(m_sout, _S("" BOLD "%s" NORMAL ""), str); + hecl::FPrintf(m_sout, _SYS_STR("" BOLD "%s" NORMAL ""), str); else - hecl::FPrintf(m_sout, _S("%s"), str); + hecl::FPrintf(m_sout, _SYS_STR("%s"), str); } void secHead(const hecl::SystemChar* headName) { if (XTERM_COLOR) - hecl::FPrintf(m_sout, _S("" BOLD "%s" NORMAL "\n"), headName); + hecl::FPrintf(m_sout, _SYS_STR("" BOLD "%s" NORMAL "\n"), headName); else - hecl::FPrintf(m_sout, _S("%s\n"), headName); + hecl::FPrintf(m_sout, _SYS_STR("%s\n"), headName); } void optionHead(const hecl::SystemChar* flag, const hecl::SystemChar* synopsis) { if (XTERM_COLOR) - hecl::FPrintf(m_sout, _S("" BOLD "%s" NORMAL " (%s)\n"), flag, synopsis); + hecl::FPrintf(m_sout, _SYS_STR("" BOLD "%s" NORMAL " (%s)\n"), flag, synopsis); else - hecl::FPrintf(m_sout, _S("%s (%s)\n"), flag, synopsis); + hecl::FPrintf(m_sout, _SYS_STR("%s (%s)\n"), flag, synopsis); } void beginWrap() @@ -240,17 +240,17 @@ public: void wrapBold(const hecl::SystemChar* str) { if (XTERM_COLOR) - m_wrapBuffer += _S("" BOLD ""); + m_wrapBuffer += _SYS_STR("" BOLD ""); m_wrapBuffer += str; if (XTERM_COLOR) - m_wrapBuffer += _S("" NORMAL ""); + m_wrapBuffer += _SYS_STR("" NORMAL ""); } void endWrap() { _wrapBuf(m_wrapBuffer); - m_wrapBuffer += _S('\n'); - hecl::FPrintf(m_sout, _S("%s"), m_wrapBuffer.c_str()); + m_wrapBuffer += _SYS_STR('\n'); + hecl::FPrintf(m_sout, _SYS_STR("%s"), m_wrapBuffer.c_str()); m_wrapBuffer.clear(); } }; @@ -259,17 +259,17 @@ static hecl::SystemString MakePathArgAbsolute(const hecl::SystemString& arg, const hecl::SystemString& cwd) { #if _WIN32 - if (arg.size() >= 2 && iswalpha(arg[0]) && arg[1] == _S(':')) + if (arg.size() >= 2 && iswalpha(arg[0]) && arg[1] == _SYS_STR(':')) return arg; - if (arg[0] == _S('\\') || arg[0] == _S('/')) + if (arg[0] == _SYS_STR('\\') || arg[0] == _SYS_STR('/')) return arg; - return cwd + _S('\\') + arg; + return cwd + _SYS_STR('\\') + arg; #else - if (arg[0] == _S('/') || arg[0] == _S('\\')) + if (arg[0] == _SYS_STR('/') || arg[0] == _SYS_STR('\\')) return arg; - if (cwd.back() == _S('/') || cwd.back() == _S('\\')) + if (cwd.back() == _SYS_STR('/') || cwd.back() == _SYS_STR('\\')) return cwd + arg; - return cwd + _S('/') + arg; + return cwd + _SYS_STR('/') + arg; #endif } diff --git a/hecl/driver/ToolCook.hpp b/hecl/driver/ToolCook.hpp index cd512d0df..14cb55c7e 100644 --- a/hecl/driver/ToolCook.hpp +++ b/hecl/driver/ToolCook.hpp @@ -18,7 +18,7 @@ public: { /* Check for recursive flag */ for (hecl::SystemChar arg : info.flags) - if (arg == _S('r')) + if (arg == _SYS_STR('r')) m_recursive = true; /* Scan args */ @@ -30,12 +30,12 @@ public: { if (arg.empty()) continue; - else if (!arg.compare(_S("--fast"))) + else if (!arg.compare(_SYS_STR("--fast"))) { m_fast = true; continue; } - else if (arg.size() >= 8 && !arg.compare(0, 7, _S("--spec="))) + else if (arg.size() >= 8 && !arg.compare(0, 7, _SYS_STR("--spec="))) { hecl::SystemString specName(arg.begin() + 7, arg.end()); for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) @@ -50,7 +50,7 @@ public: LogModule.report(logvisor::Fatal, "unable to find data spec '%s'", specName.c_str()); continue; } - else if (arg.size() >= 2 && arg[0] == _S('-') && arg[1] == _S('-')) + else if (arg.size() >= 2 && arg[0] == _SYS_STR('-') && arg[1] == _SYS_STR('-')) continue; hecl::SystemString subPath; @@ -64,8 +64,8 @@ public: } else if (m_fallbackProj->getProjectRootPath() != root) LogModule.report(logvisor::Fatal, - _S("hecl cook can only process multiple items in the same project; ") - _S("'%s' and '%s' are different projects"), + _SYS_STR("hecl cook can only process multiple items in the same project; ") + _SYS_STR("'%s' and '%s' are different projects"), m_fallbackProj->getProjectRootPath().getAbsolutePath().data(), root.getAbsolutePath().data()); m_selectedItems.emplace_back(*m_useProj, subPath); @@ -81,87 +81,87 @@ public: if (m_selectedItems.empty()) { m_selectedItems.reserve(1); - m_selectedItems.push_back({hecl::ProjectPath(*m_useProj, _S(""))}); + m_selectedItems.push_back({hecl::ProjectPath(*m_useProj, _SYS_STR(""))}); m_recursive = true; } } static void Help(HelpOutput& help) { - help.secHead(_S("NAME")); + help.secHead(_SYS_STR("NAME")); help.beginWrap(); - help.wrap(_S("hecl-cook - Cook objects within the project database\n")); + help.wrap(_SYS_STR("hecl-cook - Cook objects within the project database\n")); help.endWrap(); - help.secHead(_S("SYNOPSIS")); + help.secHead(_SYS_STR("SYNOPSIS")); help.beginWrap(); - help.wrap(_S("hecl cook [-rf] [--fast] [--spec=] [...]\n")); + help.wrap(_SYS_STR("hecl cook [-rf] [--fast] [--spec=] [...]\n")); help.endWrap(); - help.secHead(_S("DESCRIPTION")); + help.secHead(_SYS_STR("DESCRIPTION")); help.beginWrap(); - help.wrap(_S("This command initiates a cooking pass on the project database. Cooking ") - _S("is analogous to compiling in software development. The resulting object buffers ") - _S("are cached within the project database. HECL performs the following ") - _S("tasks for each object during the cook process:\n\n")); - help.wrapBold(_S("- Object Gather: ")); - help.wrap(_S("Files added with ")); - help.wrapBold(_S("hecl add")); - help.wrap(_S(" are queried for their dependent files (e.g. ")); - help.wrapBold(_S(".blend")); - help.wrap(_S(" files return any linked ")); - help.wrapBold(_S(".png")); - help.wrap(_S(" images). If the dependent files are unable to be found, the cook process aborts.\n\n")); - help.wrapBold(_S("- Modtime Comparison: ")); - help.wrap(_S("Files that have previously finished a cook pass are inspected for their time of ") - _S("last modification. If the file hasn't changed since its previous cook-pass, the ") - _S("process is skipped. If the file has been moved or deleted, the object is automatically ") - _S("removed from the project database.\n\n")); - help.wrapBold(_S("- Cook: ")); - help.wrap(_S("A type-specific procedure compiles the file's contents into an efficient format ") - _S("for use by the runtime. A data-buffer is provided to HECL.\n\n")); - help.wrapBold(_S("- Hash and Compress: ")); - help.wrap(_S("The data-buffer is hashed and compressed before being cached in the object database.\n\n")); + help.wrap(_SYS_STR("This command initiates a cooking pass on the project database. Cooking ") + _SYS_STR("is analogous to compiling in software development. The resulting object buffers ") + _SYS_STR("are cached within the project database. HECL performs the following ") + _SYS_STR("tasks for each object during the cook process:\n\n")); + help.wrapBold(_SYS_STR("- Object Gather: ")); + help.wrap(_SYS_STR("Files added with ")); + help.wrapBold(_SYS_STR("hecl add")); + help.wrap(_SYS_STR(" are queried for their dependent files (e.g. ")); + help.wrapBold(_SYS_STR(".blend")); + help.wrap(_SYS_STR(" files return any linked ")); + help.wrapBold(_SYS_STR(".png")); + help.wrap(_SYS_STR(" images). If the dependent files are unable to be found, the cook process aborts.\n\n")); + help.wrapBold(_SYS_STR("- Modtime Comparison: ")); + help.wrap(_SYS_STR("Files that have previously finished a cook pass are inspected for their time of ") + _SYS_STR("last modification. If the file hasn't changed since its previous cook-pass, the ") + _SYS_STR("process is skipped. If the file has been moved or deleted, the object is automatically ") + _SYS_STR("removed from the project database.\n\n")); + help.wrapBold(_SYS_STR("- Cook: ")); + help.wrap(_SYS_STR("A type-specific procedure compiles the file's contents into an efficient format ") + _SYS_STR("for use by the runtime. A data-buffer is provided to HECL.\n\n")); + help.wrapBold(_SYS_STR("- Hash and Compress: ")); + help.wrap(_SYS_STR("The data-buffer is hashed and compressed before being cached in the object database.\n\n")); help.endWrap(); - help.secHead(_S("OPTIONS")); - help.optionHead(_S("..."), _S("input file(s)")); + help.secHead(_SYS_STR("OPTIONS")); + help.optionHead(_SYS_STR("..."), _SYS_STR("input file(s)")); help.beginWrap(); - help.wrap(_S("Specifies working file(s) containing production data to be cooked by HECL. ") - _S("Glob-strings may be specified (e.g. ")); - help.wrapBold(_S("*.blend")); - help.wrap(_S(") to automatically cook all matching current-directory files in the project database. ") - _S("If no path specified, all files in the project database are cooked.\n")); + help.wrap(_SYS_STR("Specifies working file(s) containing production data to be cooked by HECL. ") + _SYS_STR("Glob-strings may be specified (e.g. ")); + help.wrapBold(_SYS_STR("*.blend")); + help.wrap(_SYS_STR(") to automatically cook all matching current-directory files in the project database. ") + _SYS_STR("If no path specified, all files in the project database are cooked.\n")); help.endWrap(); - help.optionHead(_S("-r"), _S("recursion")); + help.optionHead(_SYS_STR("-r"), _SYS_STR("recursion")); help.beginWrap(); - help.wrap(_S("Enables recursive file-matching for cooking entire directories of working files.\n")); + help.wrap(_SYS_STR("Enables recursive file-matching for cooking entire directories of working files.\n")); help.endWrap(); - help.optionHead(_S("-f"), _S("force")); + help.optionHead(_SYS_STR("-f"), _SYS_STR("force")); help.beginWrap(); - help.wrap(_S("Forces cooking of all matched files, ignoring timestamp differences.\n")); + help.wrap(_SYS_STR("Forces cooking of all matched files, ignoring timestamp differences.\n")); help.endWrap(); - help.optionHead(_S("--fast"), _S("fast cook")); + help.optionHead(_SYS_STR("--fast"), _SYS_STR("fast cook")); help.beginWrap(); - help.wrap(_S("Performs draft-optimization cooking for supported data types.\n")); + help.wrap(_SYS_STR("Performs draft-optimization cooking for supported data types.\n")); help.endWrap(); - help.optionHead(_S("--spec="), _S("data specification")); + help.optionHead(_SYS_STR("--spec="), _SYS_STR("data specification")); help.beginWrap(); - help.wrap(_S("Specifies a DataSpec to use when cooking. ") - _S("This build of hecl supports the following values of :\n")); + help.wrap(_SYS_STR("Specifies a DataSpec to use when cooking. ") + _SYS_STR("This build of hecl supports the following values of :\n")); for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) { if (!spec->m_factory) continue; - help.wrap(_S(" ")); + help.wrap(_SYS_STR(" ")); help.wrapBold(spec->m_name.data()); - help.wrap(_S("\n")); + help.wrap(_SYS_STR("\n")); } } - hecl::SystemString toolName() const {return _S("cook");} + hecl::SystemString toolName() const {return _SYS_STR("cook");} int run() { diff --git a/hecl/driver/ToolExtract.hpp b/hecl/driver/ToolExtract.hpp index 488b9bbde..8e022dfe6 100644 --- a/hecl/driver/ToolExtract.hpp +++ b/hecl/driver/ToolExtract.hpp @@ -43,12 +43,12 @@ public: { /* Get name from input file and init project there */ hecl::SystemString baseFile = info.args.front(); - size_t slashPos = baseFile.rfind(_S('/')); + size_t slashPos = baseFile.rfind(_SYS_STR('/')); if (slashPos == hecl::SystemString::npos) - slashPos = baseFile.rfind(_S('\\')); + slashPos = baseFile.rfind(_SYS_STR('\\')); if (slashPos != hecl::SystemString::npos) baseFile.assign(baseFile.begin() + slashPos + 1, baseFile.end()); - size_t dotPos = baseFile.rfind(_S('.')); + size_t dotPos = baseFile.rfind(_SYS_STR('.')); if (dotPos != hecl::SystemString::npos) baseFile.assign(baseFile.begin(), baseFile.begin() + dotPos); @@ -71,7 +71,7 @@ public: m_fallbackProj.reset(new hecl::Database::Project(newProjRoot)); if (logvisor::ErrorCount > ErrorRef) LogModule.report(logvisor::Fatal, "unable to init project at '%s'", rootDir.c_str()); - LogModule.report(logvisor::Info, _S("initialized project at '%s/.hecl'"), rootDir.c_str()); + LogModule.report(logvisor::Info, _SYS_STR("initialized project at '%s/.hecl'"), rootDir.c_str()); m_useProj = m_fallbackProj.get(); } else @@ -99,45 +99,45 @@ public: static void Help(HelpOutput& help) { - help.secHead(_S("NAME")); + help.secHead(_SYS_STR("NAME")); help.beginWrap(); - help.wrap(_S("hecl-extract - Extract objects from supported package/image formats\n")); + help.wrap(_SYS_STR("hecl-extract - Extract objects from supported package/image formats\n")); help.endWrap(); - help.secHead(_S("SYNOPSIS")); + help.secHead(_SYS_STR("SYNOPSIS")); help.beginWrap(); - help.wrap(_S("hecl extract [...]\n")); + help.wrap(_SYS_STR("hecl extract [...]\n")); help.endWrap(); - help.secHead(_S("DESCRIPTION")); + help.secHead(_SYS_STR("DESCRIPTION")); help.beginWrap(); - help.wrap(_S("This command recursively extracts all or part of a dataspec-supported ") - _S("package format. Each object is decoded to a working format and added to the project.\n\n")); + help.wrap(_SYS_STR("This command recursively extracts all or part of a dataspec-supported ") + _SYS_STR("package format. Each object is decoded to a working format and added to the project.\n\n")); help.endWrap(); - help.secHead(_S("OPTIONS")); - help.optionHead(_S("[/...]"), _S("input file")); + help.secHead(_SYS_STR("OPTIONS")); + help.optionHead(_SYS_STR("[/...]"), _SYS_STR("input file")); help.beginWrap(); - help.wrap(_S("Specifies the package file or disc image to source data from. ") - _S("An optional subnode specifies a named hierarchical-node specific ") - _S("to the game architecture (levels/areas).")); + help.wrap(_SYS_STR("Specifies the package file or disc image to source data from. ") + _SYS_STR("An optional subnode specifies a named hierarchical-node specific ") + _SYS_STR("to the game architecture (levels/areas).")); help.endWrap(); } - hecl::SystemString toolName() const {return _S("extract");} + hecl::SystemString toolName() const {return _SYS_STR("extract");} static void _recursivePrint(int level, hecl::Database::IDataSpec::ExtractReport& rep) { for (int l=0 ; lm_name.data()); + hecl::Printf(_SYS_STR("" MAGENTA BOLD "Using DataSpec %s:" NORMAL "\n"), ds.m_entry->m_name.data()); else - hecl::Printf(_S("Using DataSpec %s:\n"), ds.m_entry->m_name.data()); + hecl::Printf(_SYS_STR("Using DataSpec %s:\n"), ds.m_entry->m_name.data()); ds.m_instance->doExtract(m_einfo, {true}); - hecl::Printf(_S("\n\n")); + hecl::Printf(_SYS_STR("\n\n")); } } diff --git a/hecl/driver/ToolHelp.hpp b/hecl/driver/ToolHelp.hpp index 97d494118..58efa508d 100644 --- a/hecl/driver/ToolHelp.hpp +++ b/hecl/driver/ToolHelp.hpp @@ -29,51 +29,51 @@ public: static void Help(HelpOutput& help) { help.printBold( - _S(" ___________ \n") - _S(" ,.-'\"...........``~., \n") - _S(" ,.-\".......................\"-., \n") - _S(" ,/..................................\":, \n") - _S(" .,?........................................, \n") - _S(" /...........................................,}\n") - _S(" ./........................................,:`^`..}\n") - _S(" ./.......................................,:\"...../\n") - _S(" ?.....__..................................:`...../\n") - _S(" /__.(...\"~-,_...........................,:`....../\n") - _S(" /(_....\"~,_....\"~,_.....................,:`...._/ \n") - _S(" {.._$;_....\"=,_.....\"-,_......,.-~-,},.~\";/....} \n") - _S(" ((...*~_......\"=-._...\";,,./`........../\"..../ \n") - _S(" ,,,___.`~,......\"~.,....................`......}....../ \n") - _S("............(....`=-,,...`.........................(...;_,,-\" \n") - _S("............/.`~,......`-.................................../ \n") - _S(".............`~.*-,.....................................|,./...,__ \n") - _S(",,_..........}.>-._...................................|.......`=~-, \n") - _S(".....`=~-,__......`,................................. \n") - _S("...................`=~-,,.,........................... \n") - _S(".........................`:,,..........................`\n") - _S("...........................`=-,...............,%%`>--==`` \n") - _S(".................................._.........._,-%%...` \n") - _S("...................................,\n")); + _SYS_STR(" ___________ \n") + _SYS_STR(" ,.-'\"...........``~., \n") + _SYS_STR(" ,.-\".......................\"-., \n") + _SYS_STR(" ,/..................................\":, \n") + _SYS_STR(" .,?........................................, \n") + _SYS_STR(" /...........................................,}\n") + _SYS_STR(" ./........................................,:`^`..}\n") + _SYS_STR(" ./.......................................,:\"...../\n") + _SYS_STR(" ?.....__..................................:`...../\n") + _SYS_STR(" /__.(...\"~-,_...........................,:`....../\n") + _SYS_STR(" /(_....\"~,_....\"~,_.....................,:`...._/ \n") + _SYS_STR(" {.._$;_....\"=,_.....\"-,_......,.-~-,},.~\";/....} \n") + _SYS_STR(" ((...*~_......\"=-._...\";,,./`........../\"..../ \n") + _SYS_STR(" ,,,___.`~,......\"~.,....................`......}....../ \n") + _SYS_STR("............(....`=-,,...`.........................(...;_,,-\" \n") + _SYS_STR("............/.`~,......`-.................................../ \n") + _SYS_STR(".............`~.*-,.....................................|,./...,__ \n") + _SYS_STR(",,_..........}.>-._...................................|.......`=~-, \n") + _SYS_STR(".....`=~-,__......`,................................. \n") + _SYS_STR("...................`=~-,,.,........................... \n") + _SYS_STR(".........................`:,,..........................`\n") + _SYS_STR("...........................`=-,...............,%%`>--==`` \n") + _SYS_STR(".................................._.........._,-%%...` \n") + _SYS_STR("...................................,\n")); } static void ShowHelp(const hecl::SystemString& toolName) { /* Select tool's help-text streamer */ HelpOutput::HelpFunc helpFunc = NULL; - if (toolName == _S("init")) + if (toolName == _SYS_STR("init")) helpFunc = ToolInit::Help; - else if (toolName == _S("spec")) + else if (toolName == _SYS_STR("spec")) helpFunc = ToolSpec::Help; - else if (toolName == _S("extract")) + else if (toolName == _SYS_STR("extract")) helpFunc = ToolExtract::Help; - else if (toolName == _S("cook")) + else if (toolName == _SYS_STR("cook")) helpFunc = ToolCook::Help; - else if (toolName == _S("package") || toolName == _S("pack")) + else if (toolName == _SYS_STR("package") || toolName == _SYS_STR("pack")) helpFunc = ToolPackage::Help; - else if (toolName == _S("help")) + else if (toolName == _SYS_STR("help")) helpFunc = ToolHelp::Help; else { - LogModule.report(logvisor::Error, _S("unrecognized tool '%s' - can't help"), toolName.c_str()); + LogModule.report(logvisor::Error, _SYS_STR("unrecognized tool '%s' - can't help"), toolName.c_str()); return; } @@ -81,7 +81,7 @@ public: ho.go(); } - hecl::SystemString toolName() const {return _S("help");} + hecl::SystemString toolName() const {return _SYS_STR("help");} int run() { diff --git a/hecl/driver/ToolImage.hpp b/hecl/driver/ToolImage.hpp index 15eb97d45..0947c162c 100644 --- a/hecl/driver/ToolImage.hpp +++ b/hecl/driver/ToolImage.hpp @@ -57,69 +57,69 @@ public: static void Help(HelpOutput& help) { - help.secHead(_S("NAME")); + help.secHead(_SYS_STR("NAME")); help.beginWrap(); - help.wrap(_S("hecl-image - Generate GameCube/Wii disc image from packaged files\n")); + help.wrap(_SYS_STR("hecl-image - Generate GameCube/Wii disc image from packaged files\n")); help.endWrap(); - help.secHead(_S("SYNOPSIS")); + help.secHead(_SYS_STR("SYNOPSIS")); help.beginWrap(); - help.wrap(_S("hecl image []\n")); + help.wrap(_SYS_STR("hecl image []\n")); help.endWrap(); - help.secHead(_S("DESCRIPTION")); + help.secHead(_SYS_STR("DESCRIPTION")); help.beginWrap(); - help.wrap(_S("This command uses the current contents of `out` to generate a GameCube or ") - _S("Wii disc image. `hecl package` must have been run previously to be effective.\n")); + help.wrap(_SYS_STR("This command uses the current contents of `out` to generate a GameCube or ") + _SYS_STR("Wii disc image. `hecl package` must have been run previously to be effective.\n")); help.endWrap(); - help.secHead(_S("OPTIONS")); - help.optionHead(_S(""), _S("input directory")); + help.secHead(_SYS_STR("OPTIONS")); + help.optionHead(_SYS_STR(""), _SYS_STR("input directory")); help.beginWrap(); - help.wrap(_S("Specifies a project subdirectory to root the resulting image from. ") - _S("Project must contain an out/sys and out/files directory to succeed.\n")); + help.wrap(_SYS_STR("Specifies a project subdirectory to root the resulting image from. ") + _SYS_STR("Project must contain an out/sys and out/files directory to succeed.\n")); help.endWrap(); } - hecl::SystemString toolName() const {return _S("image");} + hecl::SystemString toolName() const {return _SYS_STR("image");} int run() { if (XTERM_COLOR) - hecl::Printf(_S("" GREEN BOLD "ABOUT TO IMAGE:" NORMAL "\n")); + hecl::Printf(_SYS_STR("" GREEN BOLD "ABOUT TO IMAGE:" NORMAL "\n")); else - hecl::Printf(_S("ABOUT TO IMAGE:\n")); + hecl::Printf(_SYS_STR("ABOUT TO IMAGE:\n")); - hecl::Printf(_S(" %s\n"), m_useProj->getProjectRootPath().getAbsolutePath().data()); + hecl::Printf(_SYS_STR(" %s\n"), m_useProj->getProjectRootPath().getAbsolutePath().data()); fflush(stdout); if (continuePrompt()) { - hecl::ProjectPath outPath(m_useProj->getProjectWorkingPath(), _S("out")); + hecl::ProjectPath outPath(m_useProj->getProjectWorkingPath(), _SYS_STR("out")); if (!outPath.isDirectory()) { - LogModule.report(logvisor::Error, _S("%s is not a directory"), outPath.getAbsolutePath().data()); + LogModule.report(logvisor::Error, _SYS_STR("%s is not a directory"), outPath.getAbsolutePath().data()); return 1; } - hecl::ProjectPath bootBinPath(outPath, _S("sys/boot.bin")); + hecl::ProjectPath bootBinPath(outPath, _SYS_STR("sys/boot.bin")); if (!bootBinPath.isFile()) { - LogModule.report(logvisor::Error, _S("%s is not a file"), bootBinPath.getAbsolutePath().data()); + LogModule.report(logvisor::Error, _SYS_STR("%s is not a file"), bootBinPath.getAbsolutePath().data()); return 1; } athena::io::FileReader r(bootBinPath.getAbsolutePath()); if (r.hasError()) { - LogModule.report(logvisor::Error, _S("unable to open %s"), bootBinPath.getAbsolutePath().data()); + LogModule.report(logvisor::Error, _SYS_STR("unable to open %s"), bootBinPath.getAbsolutePath().data()); return 1; } std::string id = r.readString(6); r.close(); hecl::SystemStringConv idView(id); - hecl::SystemString fileOut = hecl::SystemString(outPath.getAbsolutePath()) + _S('/') + idView.c_str(); + hecl::SystemString fileOut = hecl::SystemString(outPath.getAbsolutePath()) + _SYS_STR('/') + idView.c_str(); hecl::MultiProgressPrinter printer(true); auto progFunc = [&printer](float totalProg, nod::SystemStringView fileName, size_t fileBytesXfered) { @@ -127,22 +127,22 @@ public: }; if (id[0] == 'G') { - fileOut += _S(".gcm"); + fileOut += _SYS_STR(".gcm"); if (nod::DiscBuilderGCN::CalculateTotalSizeRequired(outPath.getAbsolutePath()) == -1) return 1; - LogModule.report(logvisor::Info, _S("Generating %s as GameCube image"), fileOut.c_str()); + LogModule.report(logvisor::Info, _SYS_STR("Generating %s as GameCube image"), fileOut.c_str()); nod::DiscBuilderGCN db(fileOut, progFunc); if (db.buildFromDirectory(outPath.getAbsolutePath()) != nod::EBuildResult::Success) return 1; } else { - fileOut += _S(".iso"); + fileOut += _SYS_STR(".iso"); bool dualLayer; if (nod::DiscBuilderWii::CalculateTotalSizeRequired(outPath.getAbsolutePath(), dualLayer) == -1) return 1; - LogModule.report(logvisor::Info, _S("Generating %s as %s-layer Wii image"), fileOut.c_str(), - dualLayer ? _S("dual") : _S("single")); + LogModule.report(logvisor::Info, _SYS_STR("Generating %s as %s-layer Wii image"), fileOut.c_str(), + dualLayer ? _SYS_STR("dual") : _SYS_STR("single")); nod::DiscBuilderWii db(fileOut, dualLayer, progFunc); if (db.buildFromDirectory(outPath.getAbsolutePath()) != nod::EBuildResult::Success) return 1; diff --git a/hecl/driver/ToolInit.hpp b/hecl/driver/ToolInit.hpp index 9818b06f6..59f1659ab 100644 --- a/hecl/driver/ToolInit.hpp +++ b/hecl/driver/ToolInit.hpp @@ -22,20 +22,20 @@ public: hecl::MakeDir(dir->c_str()); if (hecl::Stat(dir->c_str(), &theStat)) { - LogModule.report(logvisor::Fatal, _S("unable to stat '%s'"), dir->c_str()); + LogModule.report(logvisor::Fatal, _SYS_STR("unable to stat '%s'"), dir->c_str()); return; } } if (!S_ISDIR(theStat.st_mode)) { - LogModule.report(logvisor::Fatal, _S("'%s' is not a directory"), dir->c_str()); + LogModule.report(logvisor::Fatal, _SYS_STR("'%s' is not a directory"), dir->c_str()); return; } - hecl::SystemString testPath = *dir + _S("/.hecl/beacon"); + hecl::SystemString testPath = *dir + _SYS_STR("/.hecl/beacon"); if (!hecl::Stat(testPath.c_str(), &theStat)) { - LogModule.report(logvisor::Fatal, _S("project already exists at '%s'"), dir->c_str()); + LogModule.report(logvisor::Fatal, _SYS_STR("project already exists at '%s'"), dir->c_str()); return; } @@ -50,37 +50,37 @@ public: hecl::Database::Project proj((hecl::ProjectRootPath(*m_dir))); if (logvisor::ErrorCount > ErrorRef) return 1; - LogModule.report(logvisor::Info, _S("initialized project at '%s/.hecl'"), m_dir->c_str()); + LogModule.report(logvisor::Info, _SYS_STR("initialized project at '%s/.hecl'"), m_dir->c_str()); return 0; } static void Help(HelpOutput& help) { - help.secHead(_S("NAME")); + help.secHead(_SYS_STR("NAME")); help.beginWrap(); - help.wrap(_S("hecl-init - Initialize a brand-new project database\n")); + help.wrap(_SYS_STR("hecl-init - Initialize a brand-new project database\n")); help.endWrap(); - help.secHead(_S("SYNOPSIS")); + help.secHead(_SYS_STR("SYNOPSIS")); help.beginWrap(); - help.wrap(_S("hecl init []\n")); + help.wrap(_SYS_STR("hecl init []\n")); help.endWrap(); - help.secHead(_S("DESCRIPTION")); + help.secHead(_SYS_STR("DESCRIPTION")); help.beginWrap(); - help.wrap(_S("Creates a ")); - help.wrapBold(_S(".hecl")); - help.wrap(_S(" directory within the selected directory with an initialized database index. ") - _S("This constitutes an empty HECL project, ready for making stuff!!\n")); + help.wrap(_SYS_STR("Creates a ")); + help.wrapBold(_SYS_STR(".hecl")); + help.wrap(_SYS_STR(" directory within the selected directory with an initialized database index. ") + _SYS_STR("This constitutes an empty HECL project, ready for making stuff!!\n")); help.endWrap(); - help.secHead(_S("OPTIONS")); - help.optionHead(_S(""), _S("group directory path")); + help.secHead(_SYS_STR("OPTIONS")); + help.optionHead(_SYS_STR(""), _SYS_STR("group directory path")); help.beginWrap(); - help.wrap(_S("Directory to create new project database in. If not specified, current directory is used.\n")); + help.wrap(_SYS_STR("Directory to create new project database in. If not specified, current directory is used.\n")); help.endWrap(); } - hecl::SystemString toolName() const {return _S("init");} + hecl::SystemString toolName() const {return _SYS_STR("init");} }; diff --git a/hecl/driver/ToolPackage.hpp b/hecl/driver/ToolPackage.hpp index 46150d0d9..162e66782 100644 --- a/hecl/driver/ToolPackage.hpp +++ b/hecl/driver/ToolPackage.hpp @@ -23,13 +23,13 @@ class ToolPackage final : public ToolBase void CheckFile(const hecl::ProjectPath& path) { - if (!hecl::StrCmp(path.getLastComponent().data(), _S("!world.blend"))) + if (!hecl::StrCmp(path.getLastComponent().data(), _SYS_STR("!world.blend"))) AddSelectedItem(path); #if RUNTIME_ORIGINAL_IDS - else if (!hecl::StrCmp(path.getLastComponent().data(), _S("!original_ids.yaml"))) + else if (!hecl::StrCmp(path.getLastComponent().data(), _SYS_STR("!original_ids.yaml"))) { auto pathComps = path.getPathComponents(); - if (pathComps.size() == 2 && pathComps[0] != _S("out")) + if (pathComps.size() == 2 && pathComps[0] != _SYS_STR("out")) AddSelectedItem(path); } #endif @@ -60,8 +60,8 @@ class ToolPackage final : public ToolBase if (checkGeneral && origSize == m_selectedItems.size()) { auto pathComps = path.getPathComponents(); - if (pathComps.size() == 2 && pathComps[0] != _S("out") && - pathComps[1] != _S("Shared") && pathComps[0].find(_S(".app")) == hecl::SystemString::npos) + if (pathComps.size() == 2 && pathComps[0] != _SYS_STR("out") && + pathComps[1] != _SYS_STR("Shared") && pathComps[0].find(_SYS_STR(".app")) == hecl::SystemString::npos) AddSelectedItem(path); } } @@ -82,12 +82,12 @@ public: { if (arg.empty()) continue; - else if (!arg.compare(_S("--fast"))) + else if (!arg.compare(_SYS_STR("--fast"))) { m_fast = true; continue; } - else if (arg.size() >= 8 && !arg.compare(0, 7, _S("--spec="))) + else if (arg.size() >= 8 && !arg.compare(0, 7, _SYS_STR("--spec="))) { hecl::SystemString specName(arg.begin() + 7, arg.end()); for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) @@ -102,7 +102,7 @@ public: LogModule.report(logvisor::Fatal, "unable to find data spec '%s'", specName.c_str()); continue; } - else if (arg.size() >= 2 && arg[0] == _S('-') && arg[1] == _S('-')) + else if (arg.size() >= 2 && arg[0] == _SYS_STR('-') && arg[1] == _SYS_STR('-')) continue; hecl::SystemString subPath; @@ -117,8 +117,8 @@ public: } else if (m_fallbackProj->getProjectRootPath() != root) LogModule.report(logvisor::Fatal, - _S("hecl package can only process multiple items in the same project; ") - _S("'%s' and '%s' are different projects"), + _SYS_STR("hecl package can only process multiple items in the same project; ") + _SYS_STR("'%s' and '%s' are different projects"), m_fallbackProj->getProjectRootPath().getAbsolutePath().data(), root.getAbsolutePath().data()); @@ -133,64 +133,64 @@ public: /* Default case: recursive at root */ if (m_selectedItems.empty()) - FindSelectedItems({*m_useProj, _S("")}, true); + FindSelectedItems({*m_useProj, _SYS_STR("")}, true); } static void Help(HelpOutput& help) { - help.secHead(_S("NAME")); + help.secHead(_SYS_STR("NAME")); help.beginWrap(); - help.wrap(_S("hecl-pack\n") - _S("hecl-package - Package objects within the project database\n")); + help.wrap(_SYS_STR("hecl-pack\n") + _SYS_STR("hecl-package - Package objects within the project database\n")); help.endWrap(); - help.secHead(_S("SYNOPSIS")); + help.secHead(_SYS_STR("SYNOPSIS")); help.beginWrap(); - help.wrap(_S("hecl package [--spec=] []\n")); + help.wrap(_SYS_STR("hecl package [--spec=] []\n")); help.endWrap(); - help.secHead(_S("DESCRIPTION")); + help.secHead(_SYS_STR("DESCRIPTION")); help.beginWrap(); - help.wrap(_S("This command initiates a packaging pass on the project database. Packaging ") - _S("is analogous to linking in software development. All objects necessary to ") - _S("generate a complete package are gathered, grouped, and indexed within a .upak file.\n")); + help.wrap(_SYS_STR("This command initiates a packaging pass on the project database. Packaging ") + _SYS_STR("is analogous to linking in software development. All objects necessary to ") + _SYS_STR("generate a complete package are gathered, grouped, and indexed within a .upak file.\n")); help.endWrap(); - help.secHead(_S("OPTIONS")); - help.optionHead(_S("--spec="), _S("data specification")); + help.secHead(_SYS_STR("OPTIONS")); + help.optionHead(_SYS_STR("--spec="), _SYS_STR("data specification")); help.beginWrap(); - help.wrap(_S("Specifies a DataSpec to use when cooking and generating the package. ") - _S("This build of hecl supports the following values of :\n")); + help.wrap(_SYS_STR("Specifies a DataSpec to use when cooking and generating the package. ") + _SYS_STR("This build of hecl supports the following values of :\n")); for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) { if (!spec->m_factory) continue; - help.wrap(_S(" ")); + help.wrap(_SYS_STR(" ")); help.wrapBold(spec->m_name.data()); - help.wrap(_S("\n")); + help.wrap(_SYS_STR("\n")); } help.endWrap(); - help.secHead(_S("OPTIONS")); - help.optionHead(_S(""), _S("input directory")); + help.secHead(_SYS_STR("OPTIONS")); + help.optionHead(_SYS_STR(""), _SYS_STR("input directory")); help.beginWrap(); - help.wrap(_S("Specifies a project subdirectory to root the resulting package from. ") - _S("If any dependent files fall outside this subdirectory, they will be implicitly ") - _S("gathered and packaged.\n")); + help.wrap(_SYS_STR("Specifies a project subdirectory to root the resulting package from. ") + _SYS_STR("If any dependent files fall outside this subdirectory, they will be implicitly ") + _SYS_STR("gathered and packaged.\n")); help.endWrap(); } - hecl::SystemString toolName() const {return _S("package");} + hecl::SystemString toolName() const {return _SYS_STR("package");} int run() { if (XTERM_COLOR) - hecl::Printf(_S("" GREEN BOLD "ABOUT TO PACKAGE:" NORMAL "\n")); + hecl::Printf(_SYS_STR("" GREEN BOLD "ABOUT TO PACKAGE:" NORMAL "\n")); else - hecl::Printf(_S("ABOUT TO PACKAGE:\n")); + hecl::Printf(_SYS_STR("ABOUT TO PACKAGE:\n")); for (auto& item : m_selectedItems) - hecl::Printf(_S(" %s\n"), item.getRelativePath().data()); + hecl::Printf(_SYS_STR(" %s\n"), item.getRelativePath().data()); fflush(stdout); if (continuePrompt()) @@ -200,7 +200,7 @@ public: for (const hecl::ProjectPath& path : m_selectedItems) { if (!m_useProj->packagePath(path, printer, m_fast, m_spec, &cp)) - LogModule.report(logvisor::Error, _S("Unable to package %s"), path.getAbsolutePath().data()); + LogModule.report(logvisor::Error, _SYS_STR("Unable to package %s"), path.getAbsolutePath().data()); } cp.waitUntilComplete(); } diff --git a/hecl/driver/ToolSpec.hpp b/hecl/driver/ToolSpec.hpp index bfc03d40e..932c80e22 100644 --- a/hecl/driver/ToolSpec.hpp +++ b/hecl/driver/ToolSpec.hpp @@ -27,9 +27,9 @@ public: hecl::SystemString firstArg = info.args.front(); hecl::ToLower(firstArg); - if (!firstArg.compare(_S("enable"))) + if (!firstArg.compare(_SYS_STR("enable"))) mode = MENABLE; - else if (!firstArg.compare(_S("disable"))) + else if (!firstArg.compare(_SYS_STR("disable"))) mode = MDISABLE; else return; @@ -54,38 +54,38 @@ public: } if (!found) LogModule.report(logvisor::Fatal, - _S("'%s' is not found in the dataspec registry"), + _SYS_STR("'%s' is not found in the dataspec registry"), it->c_str()); } } static void Help(HelpOutput& help) { - help.secHead(_S("NAME")); + help.secHead(_SYS_STR("NAME")); help.beginWrap(); - help.wrap(_S("hecl-spec - Configure target data options\n")); + help.wrap(_SYS_STR("hecl-spec - Configure target data options\n")); help.endWrap(); - help.secHead(_S("SYNOPSIS")); + help.secHead(_SYS_STR("SYNOPSIS")); help.beginWrap(); - help.wrap(_S("hecl spec [enable|disable] [...]\n")); + help.wrap(_SYS_STR("hecl spec [enable|disable] [...]\n")); help.endWrap(); - help.secHead(_S("DESCRIPTION")); + help.secHead(_SYS_STR("DESCRIPTION")); help.beginWrap(); - help.wrap(_S("This command configures the HECL project with the user's preferred target DataSpecs.\n\n") - _S("Providing enable/disable argument will bulk-set the enable status of the provided spec(s)") - _S("list. If enable/disable is not provided, a list of supported DataSpecs is printed.\n\n")); + help.wrap(_SYS_STR("This command configures the HECL project with the user's preferred target DataSpecs.\n\n") + _SYS_STR("Providing enable/disable argument will bulk-set the enable status of the provided spec(s)") + _SYS_STR("list. If enable/disable is not provided, a list of supported DataSpecs is printed.\n\n")); help.endWrap(); - help.secHead(_S("OPTIONS")); - help.optionHead(_S("..."), _S("DataSpec name(s)")); + help.secHead(_SYS_STR("OPTIONS")); + help.optionHead(_SYS_STR("..."), _SYS_STR("DataSpec name(s)")); help.beginWrap(); - help.wrap(_S("Specifies platform-names to enable/disable")); + help.wrap(_SYS_STR("Specifies platform-names to enable/disable")); help.endWrap(); } - hecl::SystemString toolName() const {return _S("spec");} + hecl::SystemString toolName() const {return _SYS_STR("spec");} int run() { @@ -94,10 +94,10 @@ public: for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) { if (XTERM_COLOR) - hecl::Printf(_S("" BOLD CYAN "%s" NORMAL "\n"), spec->m_name.data()); + hecl::Printf(_SYS_STR("" BOLD CYAN "%s" NORMAL "\n"), spec->m_name.data()); else - hecl::Printf(_S("%s\n"), spec->m_name.data()); - hecl::Printf(_S(" %s\n"), spec->m_desc.data()); + hecl::Printf(_SYS_STR("%s\n"), spec->m_name.data()); + hecl::Printf(_SYS_STR(" %s\n"), spec->m_desc.data()); } return 0; } @@ -108,17 +108,17 @@ public: for (auto& spec : specs) { if (XTERM_COLOR) - hecl::Printf(_S("" BOLD CYAN "%s" NORMAL ""), spec.spec.m_name.data()); + hecl::Printf(_SYS_STR("" BOLD CYAN "%s" NORMAL ""), spec.spec.m_name.data()); else - hecl::Printf(_S("%s"), spec.spec.m_name.data()); + hecl::Printf(_SYS_STR("%s"), spec.spec.m_name.data()); if (spec.active) { if (XTERM_COLOR) - hecl::Printf(_S(" " BOLD GREEN "[ENABLED]" NORMAL "")); + hecl::Printf(_SYS_STR(" " BOLD GREEN "[ENABLED]" NORMAL "")); else - hecl::Printf(_S(" [ENABLED]")); + hecl::Printf(_SYS_STR(" [ENABLED]")); } - hecl::Printf(_S("\n %s\n"), spec.spec.m_desc.data()); + hecl::Printf(_SYS_STR("\n %s\n"), spec.spec.m_desc.data()); } return 0; } diff --git a/hecl/driver/main.cpp b/hecl/driver/main.cpp index c1e7c3e73..8e5ceed93 100644 --- a/hecl/driver/main.cpp +++ b/hecl/driver/main.cpp @@ -47,25 +47,25 @@ bool XTERM_COLOR = false; static void printHelp(const hecl::SystemChar* pname) { if (XTERM_COLOR) - hecl::Printf(_S("" BOLD "HECL" NORMAL "")); + hecl::Printf(_SYS_STR("" BOLD "HECL" NORMAL "")); else - hecl::Printf(_S("HECL")); + hecl::Printf(_SYS_STR("HECL")); #if HECL_HAS_NOD # define TOOL_LIST "extract|init|cook|package|image|help" #else # define TOOL_LIST "extract|init|cook|package|help" #endif #if HECL_GIT - hecl::Printf(_S(" Commit " HECL_GIT_S " " HECL_BRANCH_S "\nUsage: %s " TOOL_LIST "\n"), pname); + hecl::Printf(_SYS_STR(" Commit " HECL_GIT_S " " HECL_BRANCH_S "\nUsage: %s " TOOL_LIST "\n"), pname); #elif HECL_VER - hecl::Printf(_S(" Version " HECL_VER_S "\nUsage: %s " TOOL_LIST "\n"), pname); + hecl::Printf(_SYS_STR(" Version " HECL_VER_S "\nUsage: %s " TOOL_LIST "\n"), pname); #else - hecl::Printf(_S("\nUsage: %s " TOOL_LIST "\n"), pname); + hecl::Printf(_SYS_STR("\nUsage: %s " TOOL_LIST "\n"), pname); #endif } /* Regex patterns */ -static const hecl::SystemRegex regOPEN(_S("-o([^\"]*|\\S*)"), std::regex::ECMAScript|std::regex::optimize); +static const hecl::SystemRegex regOPEN(_SYS_STR("-o([^\"]*|\\S*)"), std::regex::ECMAScript|std::regex::optimize); static ToolBase* ToolPtr = nullptr; @@ -100,7 +100,7 @@ static void SIGWINCHHandler(int sig) {} int main(int argc, const char** argv) #endif { - if (argc > 1 && !hecl::StrCmp(argv[1], _S("--dlpackage"))) + if (argc > 1 && !hecl::StrCmp(argv[1], _SYS_STR("--dlpackage"))) { printf("%s\n", HECL_DLPACKAGE); return 100; @@ -140,7 +140,7 @@ int main(int argc, const char** argv) } else if (argc == 0) { - printHelp(_S("hecl")); + printHelp(_SYS_STR("hecl")); #if WIN_PAUSE system("PAUSE"); #endif @@ -156,17 +156,17 @@ int main(int argc, const char** argv) if (hecl::Getcwd(cwdbuf, 1024)) { info.cwd = cwdbuf; - if (info.cwd.size() && info.cwd.back() != _S('/') && info.cwd.back() != _S('\\')) + if (info.cwd.size() && info.cwd.back() != _SYS_STR('/') && info.cwd.back() != _SYS_STR('\\')) #if _WIN32 - info.cwd += _S('\\'); + info.cwd += _SYS_STR('\\'); #else - info.cwd += _S('/'); + info.cwd += _SYS_STR('/'); #endif if (hecl::PathRelative(argv[0])) - ExeDir = hecl::SystemString(cwdbuf) + _S('/'); + ExeDir = hecl::SystemString(cwdbuf) + _SYS_STR('/'); hecl::SystemString Argv0(argv[0]); - hecl::SystemString::size_type lastIdx = Argv0.find_last_of(_S("/\\")); + hecl::SystemString::size_type lastIdx = Argv0.find_last_of(_SYS_STR("/\\")); if (lastIdx != hecl::SystemString::npos) ExeDir.insert(ExeDir.end(), Argv0.begin(), Argv0.begin() + lastIdx); } @@ -211,7 +211,7 @@ int main(int argc, const char** argv) for (auto it = args.cbegin() ; it != args.cend() ;) { const hecl::SystemString& arg = *it; - if (arg.size() < 2 || arg[0] != _S('-') || arg[1] == _S('-')) + if (arg.size() < 2 || arg[0] != _SYS_STR('-') || arg[1] == _SYS_STR('-')) { ++it; continue; @@ -219,13 +219,13 @@ int main(int argc, const char** argv) for (auto chit = arg.cbegin() + 1 ; chit != arg.cend() ; ++chit) { - if (*chit == _S('v')) + if (*chit == _SYS_STR('v')) ++info.verbosityLevel; - else if (*chit == _S('f')) + else if (*chit == _SYS_STR('f')) info.force = true; - else if (*chit == _S('y')) + else if (*chit == _SYS_STR('y')) info.yes = true; - else if (*chit == _S('g')) + else if (*chit == _SYS_STR('g')) info.gui = true; else info.flags.push_back(*chit); @@ -265,27 +265,27 @@ int main(int argc, const char** argv) std::unique_ptr tool; size_t ErrorRef = logvisor::ErrorCount; - if (toolName == _S("init")) + if (toolName == _SYS_STR("init")) tool.reset(new ToolInit(info)); - else if (toolName == _S("spec")) + else if (toolName == _SYS_STR("spec")) tool.reset(new ToolSpec(info)); - else if (toolName == _S("extract")) + else if (toolName == _SYS_STR("extract")) tool.reset(new ToolExtract(info)); - else if (toolName == _S("cook")) + else if (toolName == _SYS_STR("cook")) tool.reset(new ToolCook(info)); - else if (toolName == _S("package") || toolName == _S("pack")) + else if (toolName == _SYS_STR("package") || toolName == _SYS_STR("pack")) tool.reset(new ToolPackage(info)); #if HECL_HAS_NOD - else if (toolName == _S("image")) + else if (toolName == _SYS_STR("image")) tool.reset(new ToolImage(info)); #endif - else if (toolName == _S("help")) + else if (toolName == _SYS_STR("help")) tool.reset(new ToolHelp(info)); else { - FILE* fp = hecl::Fopen(argv[1], _S("rb")); + FILE* fp = hecl::Fopen(argv[1], _SYS_STR("rb")); if (!fp) - LogModule.report(logvisor::Error, _S("unrecognized tool '%s'"), toolName.c_str()); + LogModule.report(logvisor::Error, _SYS_STR("unrecognized tool '%s'"), toolName.c_str()); else { /* Shortcut-case: implicit extract */ @@ -304,7 +304,7 @@ int main(int argc, const char** argv) } if (info.verbosityLevel) - LogModule.report(logvisor::Info, _S("Constructed tool '%s' %d\n"), + LogModule.report(logvisor::Info, _SYS_STR("Constructed tool '%s' %d\n"), tool->toolName().c_str(), info.verbosityLevel); /* Run tool */ diff --git a/hecl/extern/boo b/hecl/extern/boo index f917d154b..592ffa137 160000 --- a/hecl/extern/boo +++ b/hecl/extern/boo @@ -1 +1 @@ -Subproject commit f917d154b2ff38a5cbeea8c536c91e7813be060d +Subproject commit 592ffa1372a363cc8a5a3c64fee5f4b1f76eb079 diff --git a/hecl/include/hecl/ApplicationReps.hpp.in b/hecl/include/hecl/ApplicationReps.hpp.in index 7db7f500c..d3d59e3d3 100644 --- a/hecl/include/hecl/ApplicationReps.hpp.in +++ b/hecl/include/hecl/ApplicationReps.hpp.in @@ -12,24 +12,5 @@ T, #define HECL_APPLICATION_PIPELINE_REPS_UNIVERSAL \ @HECL_APPLICATION_PIPELINE_REPS_UNIVERSAL_LOCAL@ -#define HECL_APPLICATION_PIPELINE_REPS_OPENGL \ -@HECL_APPLICATION_PIPELINE_REPS_OPENGL_LOCAL@ -#define HECL_APPLICATION_PIPELINE_REPS_VULKAN \ -@HECL_APPLICATION_PIPELINE_REPS_VULKAN_LOCAL@ -#define HECL_APPLICATION_PIPELINE_REPS_D3D11 \ -@HECL_APPLICATION_PIPELINE_REPS_D3D11_LOCAL@ -#define HECL_APPLICATION_PIPELINE_REPS_METAL \ -@HECL_APPLICATION_PIPELINE_REPS_METAL_LOCAL@ -#define HECL_APPLICATION_PIPELINE_REPS_NX \ -@HECL_APPLICATION_PIPELINE_REPS_NX_LOCAL@ - -#define HECL_APPLICATION_STAGE_REPS_OPENGL \ -@HECL_APPLICATION_STAGE_REPS_OPENGL_LOCAL@ -#define HECL_APPLICATION_STAGE_REPS_VULKAN \ -@HECL_APPLICATION_STAGE_REPS_VULKAN_LOCAL@ -#define HECL_APPLICATION_STAGE_REPS_D3D11 \ -@HECL_APPLICATION_STAGE_REPS_D3D11_LOCAL@ -#define HECL_APPLICATION_STAGE_REPS_METAL \ -@HECL_APPLICATION_STAGE_REPS_METAL_LOCAL@ -#define HECL_APPLICATION_STAGE_REPS_NX \ -@HECL_APPLICATION_STAGE_REPS_NX_LOCAL@ +#define HECL_APPLICATION_STAGE_REPS(P, S) \ +@HECL_APPLICATION_STAGE_REPS_LOCAL@ diff --git a/hecl/include/hecl/Compilers.hpp b/hecl/include/hecl/Compilers.hpp index 370261cbe..5ec0647ae 100644 --- a/hecl/include/hecl/Compilers.hpp +++ b/hecl/include/hecl/Compilers.hpp @@ -17,51 +17,40 @@ struct OpenGL { static constexpr PlatformEnum Enum = PlatformEnum::OpenGL; stati using Context = boo::GLDataFactory::Context; #endif }; -inline const char* OpenGL::Name = "OpenGL"; struct D3D11 { static constexpr PlatformEnum Enum = PlatformEnum::D3D11; static const char* Name; #if _WIN32 -using Context = boo::D3DDataFactory::Context; +using Context = boo::D3D11DataFactory::Context; #endif }; -inline const char* D3D11::Name = "D3D11"; struct Metal { static constexpr PlatformEnum Enum = PlatformEnum::Metal; static const char* Name; #if BOO_HAS_METAL using Context = boo::MetalDataFactory::Context; #endif }; -inline const char* Metal::Name = "Metal"; struct Vulkan { static constexpr PlatformEnum Enum = PlatformEnum::Vulkan; static const char* Name; #if BOO_HAS_VULKAN using Context = boo::VulkanDataFactory::Context; #endif }; -inline const char* Vulkan::Name = "Vulkan"; struct NX { static constexpr PlatformEnum Enum = PlatformEnum::NX; static const char* Name; #if BOO_HAS_NX using Context = boo::NXDataFactory::Context; #endif }; -inline const char* NX::Name = "NX"; } namespace PipelineStage { using StageEnum = boo::PipelineStage; struct Null { static constexpr StageEnum Enum = StageEnum::Null; static const char* Name; }; -inline const char* Null::Name = "Null"; struct Vertex { static constexpr StageEnum Enum = StageEnum::Vertex; static const char* Name; }; -inline const char* Vertex::Name = "Vertex"; struct Fragment { static constexpr StageEnum Enum = StageEnum::Fragment; static const char* Name; }; -inline const char* Fragment::Name = "Fragment"; struct Geometry { static constexpr StageEnum Enum = StageEnum::Geometry; static const char* Name; }; -inline const char* Geometry::Name = "Geometry"; struct Control { static constexpr StageEnum Enum = StageEnum::Control; static const char* Name; }; -inline const char* Control::Name = "Control"; struct Evaluation { static constexpr StageEnum Enum = StageEnum::Evaluation; static const char* Name; }; -inline const char* Evaluation::Name = "Evaluation"; } template std::pair, size_t> CompileShader(std::string_view text); -} \ No newline at end of file +} diff --git a/hecl/include/hecl/Database.hpp b/hecl/include/hecl/Database.hpp index 739f586ef..7b6f448c7 100644 --- a/hecl/include/hecl/Database.hpp +++ b/hecl/include/hecl/Database.hpp @@ -282,7 +282,7 @@ public: FILE* m_lockedFile = NULL; public: ConfigFile(const Project& project, SystemStringView name, - SystemStringView subdir=_S("/.hecl/")); + SystemStringView subdir=_SYS_STR("/.hecl/")); std::vector& lockAndRead(); void addLine(std::string_view line); void removeLine(std::string_view refLine); diff --git a/hecl/include/hecl/Pipeline.hpp b/hecl/include/hecl/Pipeline.hpp index a9dac6140..b8a1545b6 100644 --- a/hecl/include/hecl/Pipeline.hpp +++ b/hecl/include/hecl/Pipeline.hpp @@ -160,72 +160,125 @@ public: }; #endif -#define STAGE_COLLECTION_SPECIALIZATIONS(T, P) StageCollection>, - template struct pack {}; struct null_t {}; -template struct TypeDB {}; -template<> struct TypeDB -{ - using PipelineTypes = pack< +template struct ShaderDB {}; + +#define STAGE_COLLECTION_SPECIALIZATIONS(T, P) StageCollection>, +#define PIPELINE_RUNTIME_SPECIALIZATIONS(P) \ + HECLBackend

, \ + STAGE_COLLECTION_SPECIALIZATIONS(StageSourceText, P) \ + STAGE_COLLECTION_SPECIALIZATIONS(StageBinary, P) \ + STAGE_COLLECTION_SPECIALIZATIONS(StageRuntimeObject, P) \ + FinalPipeline

, +#define PIPELINE_OFFLINE_SPECIALIZATIONS(P) \ + HECLBackend

, \ + STAGE_COLLECTION_SPECIALIZATIONS(StageSourceText, P) +#define STAGE_RUNTIME_SPECIALIZATIONS(P, S) \ + StageBinary, \ + HECL_APPLICATION_STAGE_REPS(P, S) \ + StageRuntimeObject, +#define STAGE_OFFLINE_SPECIALIZATIONS(P, S) \ + HECL_APPLICATION_STAGE_REPS(P, S) + +#define SPECIALIZE_RUNTIME_AVAILABLE_STAGE(P, S) \ +template<> struct ShaderDB

::StageDB \ +{ \ + using StageTypes = pack< \ + STAGE_RUNTIME_SPECIALIZATIONS(P, S) \ + null_t \ + >; \ +}; +#define SPECIALIZE_RUNTIME_UNAVAILABLE_STAGE(P, S) \ +template<> struct ShaderDB

::StageDB \ +{ \ + using StageTypes = pack< \ + null_t \ + >; \ +}; +#define SPECIALIZE_OFFLINE_STAGE(P, S) \ +template<> struct ShaderDB

::StageDB \ +{ \ + using StageTypes = pack< \ + STAGE_OFFLINE_SPECIALIZATIONS(P, S) \ + null_t \ + >; \ +}; +#define SPECIALIZE_RUNTIME_AVAILABLE_PLATFORM(P) \ +template<> struct ShaderDB

\ +{ \ + using PipelineTypes = pack< \ + PIPELINE_RUNTIME_SPECIALIZATIONS(P) \ + null_t \ + >; \ + template struct StageDB {}; \ +}; \ +SPECIALIZE_RUNTIME_AVAILABLE_STAGE(P, hecl::PipelineStage::Vertex) \ +SPECIALIZE_RUNTIME_AVAILABLE_STAGE(P, hecl::PipelineStage::Fragment) \ +SPECIALIZE_RUNTIME_AVAILABLE_STAGE(P, hecl::PipelineStage::Geometry) \ +SPECIALIZE_RUNTIME_AVAILABLE_STAGE(P, hecl::PipelineStage::Control) \ +SPECIALIZE_RUNTIME_AVAILABLE_STAGE(P, hecl::PipelineStage::Evaluation) +#define SPECIALIZE_RUNTIME_UNAVAILABLE_PLATFORM(P) \ +template<> struct ShaderDB

\ +{ \ + using PipelineTypes = pack< \ + null_t \ + >; \ + template struct StageDB {}; \ +}; \ +SPECIALIZE_RUNTIME_UNAVAILABLE_STAGE(P, hecl::PipelineStage::Vertex) \ +SPECIALIZE_RUNTIME_UNAVAILABLE_STAGE(P, hecl::PipelineStage::Fragment) \ +SPECIALIZE_RUNTIME_UNAVAILABLE_STAGE(P, hecl::PipelineStage::Geometry) \ +SPECIALIZE_RUNTIME_UNAVAILABLE_STAGE(P, hecl::PipelineStage::Control) \ +SPECIALIZE_RUNTIME_UNAVAILABLE_STAGE(P, hecl::PipelineStage::Evaluation) +#define SPECIALIZE_OFFLINE_PLATFORM(P) \ +template<> struct ShaderDB

\ +{ \ + using PipelineTypes = pack< \ + PIPELINE_OFFLINE_SPECIALIZATIONS(P) \ + null_t \ + >; \ + template struct StageDB {}; \ +}; \ +SPECIALIZE_OFFLINE_STAGE(P, hecl::PipelineStage::Vertex) \ +SPECIALIZE_OFFLINE_STAGE(P, hecl::PipelineStage::Fragment) \ +SPECIALIZE_OFFLINE_STAGE(P, hecl::PipelineStage::Geometry) \ +SPECIALIZE_OFFLINE_STAGE(P, hecl::PipelineStage::Control) \ +SPECIALIZE_OFFLINE_STAGE(P, hecl::PipelineStage::Evaluation) + #if HECL_RUNTIME #if BOO_HAS_GL - HECLBackend, - STAGE_COLLECTION_SPECIALIZATIONS(StageSourceText, PlatformType::OpenGL) - STAGE_COLLECTION_SPECIALIZATIONS(StageBinary, PlatformType::OpenGL) - STAGE_COLLECTION_SPECIALIZATIONS(StageRuntimeObject, PlatformType::OpenGL) - FinalPipeline, -#endif +SPECIALIZE_RUNTIME_AVAILABLE_PLATFORM(hecl::PlatformType::OpenGL) #else - HECLBackend, - STAGE_COLLECTION_SPECIALIZATIONS(StageSourceText, PlatformType::OpenGL) +SPECIALIZE_RUNTIME_UNAVAILABLE_PLATFORM(hecl::PlatformType::OpenGL) #endif - null_t - >; - using StageTypes = pack< -#if HECL_RUNTIME -#if BOO_HAS_GL - STAGE_SPECIALIZATIONS(StageBinary, PlatformType::OpenGL) - HECL_APPLICATION_STAGE_REPS_OPENGL - STAGE_SPECIALIZATIONS(StageRuntimeObject, PlatformType::OpenGL) -#endif -#else - HECL_APPLICATION_STAGE_REPS_OPENGL -#endif - null_t - >; -}; -template<> struct TypeDB -{ - using PipelineTypes = pack< -#if HECL_RUNTIME #if BOO_HAS_VULKAN - HECLBackend, - STAGE_COLLECTION_SPECIALIZATIONS(StageSourceText, PlatformType::Vulkan) - STAGE_COLLECTION_SPECIALIZATIONS(StageBinary, PlatformType::Vulkan) - STAGE_COLLECTION_SPECIALIZATIONS(StageRuntimeObject, PlatformType::Vulkan) - FinalPipeline, +SPECIALIZE_RUNTIME_AVAILABLE_PLATFORM(hecl::PlatformType::Vulkan) +#else +SPECIALIZE_RUNTIME_UNAVAILABLE_PLATFORM(hecl::PlatformType::Vulkan) +#endif +#if _WIN32 +SPECIALIZE_RUNTIME_AVAILABLE_PLATFORM(hecl::PlatformType::D3D11) +#else +SPECIALIZE_RUNTIME_UNAVAILABLE_PLATFORM(hecl::PlatformType::D3D11) +#endif +#if BOO_HAS_METAL +SPECIALIZE_RUNTIME_AVAILABLE_PLATFORM(hecl::PlatformType::Metal) +#else +SPECIALIZE_RUNTIME_UNAVAILABLE_PLATFORM(hecl::PlatformType::Metal) +#endif +#if BOO_HAS_NX +SPECIALIZE_RUNTIME_AVAILABLE_PLATFORM(hecl::PlatformType::NX) +#else +SPECIALIZE_RUNTIME_UNAVAILABLE_PLATFORM(hecl::PlatformType::NX) #endif #else - HECLBackend, - STAGE_COLLECTION_SPECIALIZATIONS(StageSourceText, PlatformType::Vulkan) - STAGE_COLLECTION_SPECIALIZATIONS(StageBinary, PlatformType::Vulkan) +SPECIALIZE_OFFLINE_PLATFORM(hecl::PlatformType::OpenGL) +SPECIALIZE_OFFLINE_PLATFORM(hecl::PlatformType::Vulkan) +SPECIALIZE_OFFLINE_PLATFORM(hecl::PlatformType::D3D11) +SPECIALIZE_OFFLINE_PLATFORM(hecl::PlatformType::Metal) +SPECIALIZE_OFFLINE_PLATFORM(hecl::PlatformType::NX) #endif - null_t - >; - using StageTypes = pack< -#if HECL_RUNTIME -#if BOO_HAS_VULKAN - STAGE_SPECIALIZATIONS(StageBinary, PlatformType::Vulkan) - HECL_APPLICATION_STAGE_REPS_VULKAN - STAGE_SPECIALIZATIONS(StageRuntimeObject, PlatformType::Vulkan) -#endif -#else - HECL_APPLICATION_STAGE_REPS_VULKAN -#endif - null_t - >; -}; class ShaderCacheZipStream; @@ -293,7 +346,7 @@ class StageConverter } #endif - using StageTypes = typename TypeDB

::StageTypes; + using StageTypes = typename ShaderDB

::template StageDB::StageTypes; template static constexpr bool is_stage_constructible_v = @@ -427,7 +480,7 @@ class PipelineConverter : public PipelineConverterBase StageConverter m_controlConverter; StageConverter m_evaluationConverter; - using PipelineTypes = typename TypeDB

::PipelineTypes; + using PipelineTypes = typename ShaderDB

::PipelineTypes; template static constexpr bool is_pipeline_constructible_v = @@ -573,15 +626,15 @@ inline std::unique_ptr NewPipelineConverter(boo::IGraphic return std::make_unique>(gfxF); #endif #if _WIN32 - case boo::IGraphicsDataFactory::Platform::D3D11: + case boo::IGraphicsDataFactory::Platform::D3D11: return std::make_unique>(gfxF); #endif #if BOO_HAS_METAL - case boo::IGraphicsDataFactory::Platform::Metal: + case boo::IGraphicsDataFactory::Platform::Metal: return std::make_unique>(gfxF); #endif #if BOO_HAS_NX - case boo::IGraphicsDataFactory::Platform::NX: + case boo::IGraphicsDataFactory::Platform::NX: return std::make_unique>(gfxF); #endif default: diff --git a/hecl/include/hecl/PipelineBase.hpp b/hecl/include/hecl/PipelineBase.hpp index a1c6b7d4c..f4871ca76 100644 --- a/hecl/include/hecl/PipelineBase.hpp +++ b/hecl/include/hecl/PipelineBase.hpp @@ -189,6 +189,7 @@ public: } +#if 0 #define _STAGEOBJECT_PROTOTYPE_DECLARATIONS(T, P) \ template <> const hecl::StageBinary \ T::Prototype; \ @@ -200,6 +201,8 @@ template <> const hecl::StageBinary \ T::Prototype; \ template <> const hecl::StageBinary \ T::Prototype; +#endif +#define _STAGEOBJECT_PROTOTYPE_DECLARATIONS(T, P) #define STAGEOBJECT_PROTOTYPE_DECLARATIONS(T) \ _STAGEOBJECT_PROTOTYPE_DECLARATIONS(T, hecl::PlatformType::OpenGL) \ diff --git a/hecl/include/hecl/SystemChar.hpp b/hecl/include/hecl/SystemChar.hpp index 465f810cc..05b4aaef4 100644 --- a/hecl/include/hecl/SystemChar.hpp +++ b/hecl/include/hecl/SystemChar.hpp @@ -34,8 +34,8 @@ static inline void ToLower(SystemString& str) {std::transform(str.begin(), str.end(), str.begin(), towlower);} static inline void ToUpper(SystemString& str) {std::transform(str.begin(), str.end(), str.begin(), towupper);} -#ifndef _S -#define _S(val) L ## val +#ifndef _SYS_STR +#define _SYS_STR(val) L ## val #endif #ifndef FMT_CSTR_SYS #define FMT_CSTR_SYS "S" @@ -50,8 +50,8 @@ static inline void ToLower(SystemString& str) {std::transform(str.begin(), str.end(), str.begin(), tolower);} static inline void ToUpper(SystemString& str) {std::transform(str.begin(), str.end(), str.begin(), toupper);} -#ifndef _S -#define _S(val) val +#ifndef _SYS_STR +#define _SYS_STR(val) val #endif #ifndef FMT_CSTR_SYS #define FMT_CSTR_SYS "s" diff --git a/hecl/include/hecl/hecl.hpp b/hecl/include/hecl/hecl.hpp index 70440d741..8534e6801 100644 --- a/hecl/include/hecl/hecl.hpp +++ b/hecl/include/hecl/hecl.hpp @@ -206,7 +206,7 @@ static inline void MakeDir(const wchar_t* dir) HRESULT err; if (!CreateDirectoryW(dir, NULL)) if ((err = GetLastError()) != ERROR_ALREADY_EXISTS) - LogModule.report(logvisor::Fatal, _S("MakeDir(%s)"), dir); + LogModule.report(logvisor::Fatal, _SYS_STR("MakeDir(%s)"), dir); } #endif @@ -239,12 +239,12 @@ SystemString GetcwdStr(); static inline bool IsAbsolute(SystemStringView path) { #if _WIN32 - if (path.size() && (path[0] == _S('\\') || path[0] == _S('/'))) + if (path.size() && (path[0] == _SYS_STR('\\') || path[0] == _SYS_STR('/'))) return true; - if (path.size() >= 2 && iswalpha(path[0]) && path[1] == _S(':')) + if (path.size() >= 2 && iswalpha(path[0]) && path[1] == _SYS_STR(':')) return true; #else - if (path.size() && path[0] == _S('/')) + if (path.size() && path[0] == _SYS_STR('/')) return true; #endif return false; @@ -447,11 +447,11 @@ static inline bool CheckFreeSpace(const SystemChar* path, size_t reqSz) wchar_t* end; DWORD ret = GetFullPathNameW(path, 1024, buf, &end); if (!ret || ret > 1024) - LogModule.report(logvisor::Fatal, _S("GetFullPathNameW %s"), path); + LogModule.report(logvisor::Fatal, _SYS_STR("GetFullPathNameW %s"), path); if (end) end[0] = L'\0'; if (!GetDiskFreeSpaceExW(buf, &freeBytes, nullptr, nullptr)) - LogModule.report(logvisor::Fatal, _S("GetDiskFreeSpaceExW %s: %d"), path, GetLastError()); + LogModule.report(logvisor::Fatal, _SYS_STR("GetDiskFreeSpaceExW %s: %d"), path, GetLastError()); return reqSz < freeBytes.QuadPart; #else struct statvfs svfs; @@ -682,12 +682,12 @@ public: { SystemString absPathForward(absPath); for (SystemChar& ch : absPathForward) - if (ch == _S('\\')) - ch = _S('/'); + if (ch == _SYS_STR('\\')) + ch = _SYS_STR('/'); if (!absPathForward.compare(0, m_projRoot.size(), m_projRoot)) { auto beginIt = absPathForward.cbegin() + m_projRoot.size(); - while (*beginIt == _S('/')) + while (*beginIt == _SYS_STR('/')) ++beginIt; return SystemString(beginIt, absPathForward.cend()); } @@ -719,7 +719,7 @@ public: */ SystemStringView getLastComponent() const { - size_t pos = m_projRoot.rfind(_S('/')); + size_t pos = m_projRoot.rfind(_SYS_STR('/')); if (pos == SystemString::npos) return {}; return {m_projRoot.c_str() + pos + 1, size_t(m_projRoot.size() - pos - 1)}; @@ -850,7 +850,7 @@ public: { if (m_relPath.size()) return m_relPath; - static const SystemString dot = _S("."); + static const SystemString dot = _SYS_STR("."); return dot; } @@ -869,11 +869,11 @@ public: */ ProjectPath getParentPath() const { - if (m_relPath == _S(".")) + if (m_relPath == _SYS_STR(".")) LogModule.report(logvisor::Fatal, "attempted to resolve parent of root project path"); - size_t pos = m_relPath.rfind(_S('/')); + size_t pos = m_relPath.rfind(_SYS_STR('/')); if (pos == SystemString::npos) - return ProjectPath(*m_proj, _S("")); + return ProjectPath(*m_proj, _SYS_STR("")); return ProjectPath(*m_proj, SystemString(m_relPath.begin(), m_relPath.begin() + pos)); } @@ -883,14 +883,14 @@ public: */ SystemStringView getLastComponent() const { - size_t pos = m_relPath.rfind(_S('/')); + size_t pos = m_relPath.rfind(_SYS_STR('/')); if (pos == SystemString::npos) return m_relPath; return {m_relPath.c_str() + pos + 1, m_relPath.size() - pos - 1}; } std::string_view getLastComponentUTF8() const { - size_t pos = m_relPath.rfind(_S('/')); + size_t pos = m_relPath.rfind(_SYS_STR('/')); #if HECL_UCS2 if (pos == SystemString::npos) return m_utf8RelPath; @@ -913,7 +913,7 @@ public: const SystemChar* lastComp = end; while (lastComp != lastCompOrig.data()) { - if (*lastComp == _S('.')) + if (*lastComp == _SYS_STR('.')) return {lastComp + 1, size_t(end - lastComp - 1)}; --lastComp; } @@ -930,15 +930,15 @@ public: if (m_relPath.empty()) return ret; auto it = m_relPath.cbegin(); - if (*it == _S('/')) + if (*it == _SYS_STR('/')) { - ret.push_back(_S("/")); + ret.push_back(_SYS_STR("/")); ++it; } hecl::SystemString comp; for (; it != m_relPath.cend() ; ++it) { - if (*it == _S('/')) + if (*it == _SYS_STR('/')) { if (comp.empty()) continue; @@ -1036,13 +1036,13 @@ public: if (auxStr.empty()) return ProjectPath(getProject(), getRelativePath()); else - return ProjectPath(getProject(), SystemString(getRelativePath()) + _S('|') + auxStr.data()); + return ProjectPath(getProject(), SystemString(getRelativePath()) + _SYS_STR('|') + auxStr.data()); } #if HECL_UCS2 ProjectPath ensureAuxInfo(std::string_view auxStr) const { - return ProjectPath(getProject(), SystemString(getRelativePath()) + _S('|') + UTF8ToWide(auxStr)); + return ProjectPath(getProject(), SystemString(getRelativePath()) + _SYS_STR('|') + UTF8ToWide(auxStr)); } #endif @@ -1135,7 +1135,7 @@ public: { size_t count = 0; for (SystemChar ch : m_relPath) - if (ch == _S('/') || ch == _S('\\')) + if (ch == _SYS_STR('/') || ch == _SYS_STR('\\')) ++count; return count; } @@ -1159,7 +1159,7 @@ public: auto end = comps.cend(); if (end != comps.cbegin() && !includeLastComp) --end; - ProjectPath compPath(*m_proj, _S(".")); + ProjectPath compPath(*m_proj, _SYS_STR(".")); for (auto it=comps.cbegin() ; it != end ; ++it) { compPath = ProjectPath(compPath, *it); diff --git a/hecl/lib/Blender/Connection.cpp b/hecl/lib/Blender/Connection.cpp index 1ed6374b5..5028e879d 100644 --- a/hecl/lib/Blender/Connection.cpp +++ b/hecl/lib/Blender/Connection.cpp @@ -63,18 +63,18 @@ extern "C" size_t HECL_STARTUP_SZ; static void InstallBlendershell(const SystemChar* path) { - FILE* fp = hecl::Fopen(path, _S("w")); + FILE* fp = hecl::Fopen(path, _SYS_STR("w")); if (!fp) - BlenderLog.report(logvisor::Fatal, _S("unable to open %s for writing"), path); + BlenderLog.report(logvisor::Fatal, _SYS_STR("unable to open %s for writing"), path); fwrite(HECL_BLENDERSHELL, 1, HECL_BLENDERSHELL_SZ, fp); fclose(fp); } static void InstallAddon(const SystemChar* path) { - FILE* fp = hecl::Fopen(path, _S("wb")); + FILE* fp = hecl::Fopen(path, _SYS_STR("wb")); if (!fp) - BlenderLog.report(logvisor::Fatal, _S("Unable to install blender addon at '%s'"), path); + BlenderLog.report(logvisor::Fatal, _SYS_STR("Unable to install blender addon at '%s'"), path); fwrite(HECL_ADDON, 1, HECL_ADDON_SZ, fp); fclose(fp); } @@ -235,7 +235,7 @@ void Connection::_closePipe() void Connection::_blenderDied() { std::this_thread::sleep_for(std::chrono::milliseconds(100)); - FILE* errFp = hecl::Fopen(m_errPath.c_str(), _S("r")); + FILE* errFp = hecl::Fopen(m_errPath.c_str(), _SYS_STR("r")); if (errFp) { fseek(errFp, 0, SEEK_END); @@ -278,10 +278,10 @@ Connection::Connection(int verbosityLevel) #endif hecl::SystemString blenderShellPath(TMPDIR); - blenderShellPath += _S("/hecl_blendershell.py"); + blenderShellPath += _SYS_STR("/hecl_blendershell.py"); hecl::SystemString blenderAddonPath(TMPDIR); - blenderAddonPath += _S("/hecl_blenderaddon.zip"); + blenderAddonPath += _SYS_STR("/hecl_blenderaddon.zip"); m_startupBlend += "/hecl_startup.blend"; bool FalseCmp = false; @@ -344,10 +344,10 @@ Connection::Connection(int verbosityLevel) if (!blenderBin || !RegFileExists(blenderBin)) { /* Environment not set; try steam */ - steamBlender = hecl::FindCommonSteamApp(_S("Blender")); + steamBlender = hecl::FindCommonSteamApp(_SYS_STR("Blender")); if (steamBlender.size()) { - steamBlender += _S("\\blender.exe"); + steamBlender += _SYS_STR("\\blender.exe"); blenderBin = steamBlender.c_str(); } @@ -469,7 +469,7 @@ Connection::Connection(int verbosityLevel) } /* Try steam */ - steamBlender = hecl::FindCommonSteamApp(_S("Blender")); + steamBlender = hecl::FindCommonSteamApp(_SYS_STR("Blender")); if (steamBlender.size()) { #ifdef __APPLE__ @@ -511,10 +511,10 @@ Connection::Connection(int verbosityLevel) /* Stash error path and unlink existing file */ #if _WIN32 - m_errPath = hecl::SystemString(TMPDIR) + hecl::SysFormat(_S("/hecl_%016llX.derp"), + m_errPath = hecl::SystemString(TMPDIR) + hecl::SysFormat(_SYS_STR("/hecl_%016llX.derp"), (unsigned long long)m_pinfo.dwProcessId); #else - m_errPath = hecl::SystemString(TMPDIR) + hecl::SysFormat(_S("/hecl_%016llX.derp"), + m_errPath = hecl::SystemString(TMPDIR) + hecl::SysFormat(_SYS_STR("/hecl_%016llX.derp"), (unsigned long long)m_blenderProc); #endif hecl::Unlink(m_errPath.c_str()); @@ -532,10 +532,10 @@ Connection::Connection(int verbosityLevel) { _closePipe(); if (blenderBin) - BlenderLog.report(logvisor::Fatal, _S("Unable to find blender at '%s' or '%s'"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("Unable to find blender at '%s' or '%s'"), blenderBin, DEFAULT_BLENDER_BIN); else - BlenderLog.report(logvisor::Fatal, _S("Unable to find blender at '%s'"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("Unable to find blender at '%s'"), DEFAULT_BLENDER_BIN); } else if (!strcmp(lineBuf, "NOADDON")) @@ -544,14 +544,14 @@ Connection::Connection(int verbosityLevel) InstallAddon(blenderAddonPath.c_str()); ++installAttempt; if (installAttempt >= 2) - BlenderLog.report(logvisor::Fatal, _S("unable to install blender addon using '%s'"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("unable to install blender addon using '%s'"), blenderAddonPath.c_str()); continue; } else if (!strcmp(lineBuf, "ADDONINSTALLED")) { _closePipe(); - blenderAddonPath = _S("SKIPINSTALL"); + blenderAddonPath = _SYS_STR("SKIPINSTALL"); continue; } else if (strcmp(lineBuf, "READY")) @@ -715,7 +715,7 @@ void Connection::deleteBlend() if (m_loadedBlend) { hecl::Unlink(m_loadedBlend.getAbsolutePath().data()); - BlenderLog.report(logvisor::Info, _S("Deleted '%s'"), m_loadedBlend.getAbsolutePath().data()); + BlenderLog.report(logvisor::Info, _SYS_STR("Deleted '%s'"), m_loadedBlend.getAbsolutePath().data()); m_loadedBlend = ProjectPath(); } } @@ -1833,7 +1833,7 @@ std::pair DataStream::getMeshAABB() { if (m_parent->m_loadedType != BlendType::Mesh && m_parent->m_loadedType != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, _S("%s is not a MESH or ACTOR blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a MESH or ACTOR blend"), m_parent->m_loadedBlend.getAbsolutePath().data()); m_parent->_writeStr("MESHAABB"); @@ -1856,7 +1856,7 @@ const char* DataStream::MeshOutputModeString(HMDLTopology topology) Mesh DataStream::compileMesh(HMDLTopology topology, int skinSlotCount, Mesh::SurfProgFunc surfProg) { if (m_parent->getBlendType() != BlendType::Mesh) - BlenderLog.report(logvisor::Fatal, _S("%s is not a MESH blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a MESH blend"), m_parent->getBlendPath().getAbsolutePath().data()); char req[128]; @@ -1876,7 +1876,7 @@ Mesh DataStream::compileMesh(std::string_view name, HMDLTopology topology, int skinSlotCount, bool useLuv, Mesh::SurfProgFunc surfProg) { if (m_parent->getBlendType() != BlendType::Area) - BlenderLog.report(logvisor::Fatal, _S("%s is not an AREA blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an AREA blend"), m_parent->getBlendPath().getAbsolutePath().data()); char req[128]; @@ -1895,7 +1895,7 @@ Mesh DataStream::compileMesh(std::string_view name, HMDLTopology topology, ColMesh DataStream::compileColMesh(std::string_view name) { if (m_parent->getBlendType() != BlendType::Area) - BlenderLog.report(logvisor::Fatal, _S("%s is not an AREA blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an AREA blend"), m_parent->getBlendPath().getAbsolutePath().data()); char req[128]; @@ -1913,7 +1913,7 @@ ColMesh DataStream::compileColMesh(std::string_view name) std::vector DataStream::compileColMeshes() { if (m_parent->getBlendType() != BlendType::ColMesh) - BlenderLog.report(logvisor::Fatal, _S("%s is not a CMESH blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a CMESH blend"), m_parent->getBlendPath().getAbsolutePath().data()); char req[128]; @@ -1941,7 +1941,7 @@ Mesh DataStream::compileAllMeshes(HMDLTopology topology, int skinSlotCount, float maxOctantLength, Mesh::SurfProgFunc surfProg) { if (m_parent->getBlendType() != BlendType::Area) - BlenderLog.report(logvisor::Fatal, _S("%s is not an AREA blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an AREA blend"), m_parent->getBlendPath().getAbsolutePath().data()); char req[128]; @@ -1961,7 +1961,7 @@ Mesh DataStream::compileAllMeshes(HMDLTopology topology, int skinSlotCount, std::vector DataStream::compileLights() { if (m_parent->getBlendType() != BlendType::Area) - BlenderLog.report(logvisor::Fatal, _S("%s is not an AREA blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an AREA blend"), m_parent->getBlendPath().getAbsolutePath().data()); m_parent->_writeStr("LIGHTCOMPILEALL"); @@ -1986,7 +1986,7 @@ std::vector DataStream::compileLights() PathMesh DataStream::compilePathMesh() { if (m_parent->getBlendType() != BlendType::PathMesh) - BlenderLog.report(logvisor::Fatal, _S("%s is not a PATH blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a PATH blend"), m_parent->getBlendPath().getAbsolutePath().data()); m_parent->_writeStr("MESHCOMPILEPATH"); @@ -2003,7 +2003,7 @@ std::vector DataStream::compileGuiFrame(int version) { std::vector ret; if (m_parent->getBlendType() != BlendType::Frame) - BlenderLog.report(logvisor::Fatal, _S("%s is not a FRAME blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a FRAME blend"), m_parent->getBlendPath().getAbsolutePath().data()); char req[512]; @@ -2074,7 +2074,7 @@ std::vector DataStream::getTextures() Actor DataStream::compileActor() { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath().data()); m_parent->_writeStr("ACTORCOMPILE"); @@ -2090,7 +2090,7 @@ Actor DataStream::compileActor() Actor DataStream::compileActorCharacterOnly() { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath().data()); m_parent->_writeStr("ACTORCOMPILECHARACTERONLY"); @@ -2106,7 +2106,7 @@ Actor DataStream::compileActorCharacterOnly() Action DataStream::compileActionChannelsOnly(std::string_view name) { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath().data()); char req[128]; @@ -2124,7 +2124,7 @@ Action DataStream::compileActionChannelsOnly(std::string_view name) World DataStream::compileWorld() { if (m_parent->getBlendType() != BlendType::World) - BlenderLog.report(logvisor::Fatal, _S("%s is not an WORLD blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an WORLD blend"), m_parent->getBlendPath().getAbsolutePath().data()); m_parent->_writeStr("WORLDCOMPILE"); @@ -2140,7 +2140,7 @@ World DataStream::compileWorld() std::vector DataStream::getArmatureNames() { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath().data()); m_parent->_writeStr("GETARMATURENAMES"); @@ -2171,7 +2171,7 @@ std::vector DataStream::getArmatureNames() std::vector DataStream::getSubtypeNames() { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath().data()); m_parent->_writeStr("GETSUBTYPENAMES"); @@ -2202,7 +2202,7 @@ std::vector DataStream::getSubtypeNames() std::vector DataStream::getActionNames() { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath().data()); m_parent->_writeStr("GETACTIONNAMES"); @@ -2233,7 +2233,7 @@ std::vector DataStream::getActionNames() std::vector DataStream::getSubtypeOverlayNames(std::string_view name) { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath().data()); char req[128]; @@ -2266,7 +2266,7 @@ std::vector DataStream::getSubtypeOverlayNames(std::string_view nam std::vector DataStream::getAttachmentNames() { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath().data()); m_parent->_writeStr("GETATTACHMENTNAMES"); @@ -2301,7 +2301,7 @@ DataStream::getBoneMatrices(std::string_view name) return {}; if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath().data()); char req[128]; @@ -2351,7 +2351,7 @@ bool DataStream::renderPvs(std::string_view path, const atVec3f& location) return false; if (m_parent->getBlendType() != BlendType::Area) - BlenderLog.report(logvisor::Fatal, _S("%s is not an AREA blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an AREA blend"), m_parent->getBlendPath().getAbsolutePath().data()); char req[256]; @@ -2374,7 +2374,7 @@ bool DataStream::renderPvsLight(std::string_view path, std::string_view lightNam return false; if (m_parent->getBlendType() != BlendType::Area) - BlenderLog.report(logvisor::Fatal, _S("%s is not an AREA blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an AREA blend"), m_parent->getBlendPath().getAbsolutePath().data()); char req[256]; @@ -2393,7 +2393,7 @@ bool DataStream::renderPvsLight(std::string_view path, std::string_view lightNam MapArea DataStream::compileMapArea() { if (m_parent->getBlendType() != BlendType::MapArea) - BlenderLog.report(logvisor::Fatal, _S("%s is not a MAPAREA blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a MAPAREA blend"), m_parent->getBlendPath().getAbsolutePath().data()); m_parent->_writeStr("MAPAREACOMPILE"); @@ -2410,7 +2410,7 @@ MapArea DataStream::compileMapArea() MapUniverse DataStream::compileMapUniverse() { if (m_parent->getBlendType() != BlendType::MapUniverse) - BlenderLog.report(logvisor::Fatal, _S("%s is not a MAPUNIVERSE blend"), + BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a MAPUNIVERSE blend"), m_parent->getBlendPath().getAbsolutePath().data()); m_parent->_writeStr("MAPUNIVERSECOMPILE"); diff --git a/hecl/lib/CMakeLists.txt b/hecl/lib/CMakeLists.txt index 6910ec620..26015f4b7 100644 --- a/hecl/lib/CMakeLists.txt +++ b/hecl/lib/CMakeLists.txt @@ -86,7 +86,7 @@ add_library(hecl-light ${COMMON_SOURCES} ${HECL_HEADERS} ${PLAT_SRCS}) -add_library(hecl-compilers Compilers.cpp) +add_library(hecl-compilers Compilers.cpp WideStringConvert.cpp) add_dependencies(hecl-full ${HECL_APPLICATION_REPS_TARGETS_LIST}) add_dependencies(hecl-light ${HECL_APPLICATION_REPS_TARGETS_LIST}) diff --git a/hecl/lib/CVarManager.cpp b/hecl/lib/CVarManager.cpp index d6d0bcf2d..b9e72f9c2 100755 --- a/hecl/lib/CVarManager.cpp +++ b/hecl/lib/CVarManager.cpp @@ -96,16 +96,16 @@ void CVarManager::deserialize(CVar* cvar) return; #if _WIN32 - hecl::SystemString filename = hecl::SystemString(m_store.getStoreRoot()) + _S('/') + com_configfile->toWideLiteral(); + hecl::SystemString filename = hecl::SystemString(m_store.getStoreRoot()) + _SYS_STR('/') + com_configfile->toWideLiteral(); #else - hecl::SystemString filename = hecl::SystemString(m_store.getStoreRoot()) + _S('/') + com_configfile->toLiteral(); + hecl::SystemString filename = hecl::SystemString(m_store.getStoreRoot()) + _SYS_STR('/') + com_configfile->toLiteral(); #endif hecl::Sstat st; if (m_useBinary) { CVarContainer container; - filename += _S(".bin"); + filename += _SYS_STR(".bin"); if (hecl::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode)) return; athena::io::FileReader reader(filename); @@ -134,7 +134,7 @@ void CVarManager::deserialize(CVar* cvar) } else { - filename += _S(".yaml"); + filename += _SYS_STR(".yaml"); if (hecl::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode)) return; athena::io::FileReader reader(filename); @@ -168,9 +168,9 @@ void CVarManager::deserialize(CVar* cvar) void CVarManager::serialize() { #if _WIN32 - hecl::SystemString filename = hecl::SystemString(m_store.getStoreRoot()) + _S('/') + com_configfile->toWideLiteral(); + hecl::SystemString filename = hecl::SystemString(m_store.getStoreRoot()) + _SYS_STR('/') + com_configfile->toWideLiteral(); #else - hecl::SystemString filename = hecl::SystemString(m_store.getStoreRoot()) + _S('/') + com_configfile->toLiteral(); + hecl::SystemString filename = hecl::SystemString(m_store.getStoreRoot()) + _SYS_STR('/') + com_configfile->toLiteral(); #endif if (m_useBinary) @@ -182,14 +182,14 @@ void CVarManager::serialize() container.cvars.push_back(*pair.second); container.cvarCount = atUint32(container.cvars.size()); - filename += _S(".bin"); + filename += _SYS_STR(".bin"); athena::io::FileWriter writer(filename); if (writer.isOpen()) container.write(writer); } else { - filename += _S(".yaml"); + filename += _SYS_STR(".yaml"); athena::io::FileReader r(filename); athena::io::YAMLDocWriter docWriter(nullptr, r.isOpen() ? &r : nullptr); @@ -303,7 +303,7 @@ void CVarManager::parseCommandLine(const std::vector& args) athena::utility::tolower(developerName); for (const SystemString& arg : args) { - if (arg[0] == _S('+')) + if (arg[0] == _SYS_STR('+')) { std::string tmp = SystemUTF8Conv(arg).c_str(); diff --git a/hecl/lib/ClientProcess.cpp b/hecl/lib/ClientProcess.cpp index 2071abc15..0fe9f39f3 100644 --- a/hecl/lib/ClientProcess.cpp +++ b/hecl/lib/ClientProcess.cpp @@ -35,7 +35,7 @@ void ClientProcess::BufferTransaction::run(blender::Token& btok) athena::io::FileReader r(m_path.getAbsolutePath(), 32 * 1024, false); if (r.hasError()) { - CP_Log.report(logvisor::Fatal, _S("unable to background-buffer '%s'"), + CP_Log.report(logvisor::Fatal, _SYS_STR("unable to background-buffer '%s'"), m_path.getAbsolutePath().data()); return; } @@ -164,7 +164,7 @@ bool ClientProcess::syncCook(const hecl::ProjectPath& path, Database::IDataSpec* { hecl::ProjectPath cooked = path.getCookedPath(*specEnt); if (fast) - cooked = cooked.getWithExtension(_S(".fast")); + cooked = cooked.getWithExtension(_SYS_STR(".fast")); cooked.makeDirChain(false); if (force || cooked.getPathType() == ProjectPath::Type::None || path.getModtime() > cooked.getModtime()) @@ -173,19 +173,19 @@ bool ClientProcess::syncCook(const hecl::ProjectPath& path, Database::IDataSpec* { hecl::SystemString str; if (path.getAuxInfo().empty()) - str = hecl::SysFormat(_S("Cooking %s"), path.getRelativePath().data()); + str = hecl::SysFormat(_SYS_STR("Cooking %s"), path.getRelativePath().data()); else - str = hecl::SysFormat(_S("Cooking %s|%s"), path.getRelativePath().data(), path.getAuxInfo().data()); + str = hecl::SysFormat(_SYS_STR("Cooking %s|%s"), path.getRelativePath().data(), path.getAuxInfo().data()); m_progPrinter->print(str.c_str(), nullptr, -1.f, hecl::ClientProcess::GetThreadWorkerIdx()); m_progPrinter->flush(); } else { if (path.getAuxInfo().empty()) - LogModule.report(logvisor::Info, _S("Cooking %s"), + LogModule.report(logvisor::Info, _SYS_STR("Cooking %s"), path.getRelativePath().data()); else - LogModule.report(logvisor::Info, _S("Cooking %s|%s"), + LogModule.report(logvisor::Info, _SYS_STR("Cooking %s|%s"), path.getRelativePath().data(), path.getAuxInfo().data()); } @@ -194,9 +194,9 @@ bool ClientProcess::syncCook(const hecl::ProjectPath& path, Database::IDataSpec* { hecl::SystemString str; if (path.getAuxInfo().empty()) - str = hecl::SysFormat(_S("Cooked %s"), path.getRelativePath().data()); + str = hecl::SysFormat(_SYS_STR("Cooked %s"), path.getRelativePath().data()); else - str = hecl::SysFormat(_S("Cooked %s|%s"), path.getRelativePath().data(), path.getAuxInfo().data()); + str = hecl::SysFormat(_SYS_STR("Cooked %s|%s"), path.getRelativePath().data(), path.getAuxInfo().data()); m_progPrinter->print(str.c_str(), nullptr, -1.f, hecl::ClientProcess::GetThreadWorkerIdx()); m_progPrinter->flush(); } diff --git a/hecl/lib/Compilers.cpp b/hecl/lib/Compilers.cpp index 791e45871..697520531 100644 --- a/hecl/lib/Compilers.cpp +++ b/hecl/lib/Compilers.cpp @@ -7,11 +7,34 @@ #include #include #endif +#if _WIN32 +#include +extern pD3DCompile D3DCompilePROC; +#endif namespace hecl { logvisor::Module Log("hecl::Compilers"); +namespace PlatformType +{ +const char* OpenGL::Name = "OpenGL"; +const char* Vulkan::Name = "Vulkan"; +const char* D3D11::Name = "D3D11"; +const char* Metal::Name = "Metal"; +const char* NX::Name = "NX"; +} + +namespace PipelineStage +{ +const char* Null::Name = "Null"; +const char* Vertex::Name = "Vertex"; +const char* Fragment::Name = "Fragment"; +const char* Geometry::Name = "Geometry"; +const char* Control::Name = "Control"; +const char* Evaluation::Name = "Evaluation"; +} + template struct ShaderCompiler {}; template<> struct ShaderCompiler @@ -71,6 +94,43 @@ template<> struct ShaderCompiler } }; +#if _WIN32 +static const char* D3DShaderTypes[] = +{ + nullptr, + "vs_5_0", + "ps_5_0", + "gs_5_0", + "hs_5_0", + "ds_5_0" +}; +template<> struct ShaderCompiler +{ +#if _DEBUG && 0 +#define BOO_D3DCOMPILE_FLAG D3DCOMPILE_DEBUG | D3DCOMPILE_OPTIMIZATION_LEVEL0 +#else +#define BOO_D3DCOMPILE_FLAG D3DCOMPILE_OPTIMIZATION_LEVEL3 +#endif + template + static std::pair, size_t> Compile(std::string_view text) + { + ComPtr errBlob; + ComPtr blobOut; + if (FAILED(D3DCompilePROC(text.data(), text.size(), "Boo HLSL Source", nullptr, nullptr, "main", + D3DShaderTypes[int(S::Enum)], BOO_D3DCOMPILE_FLAG, 0, &blobOut, &errBlob))) + { + printf("%s\n", text.data()); + Log.report(logvisor::Fatal, "error compiling shader: %s", errBlob->GetBufferPointer()); + return {}; + } + std::pair, size_t> ret(new uint8_t[blobOut->GetBufferSize()], blobOut->GetBufferSize()); + memcpy(ret.first.get(), blobOut->GetBufferPointer(), blobOut->GetBufferSize()); + return ret; + } +}; +#endif + +#if HECL_NOUVEAU_NX template<> struct ShaderCompiler { template @@ -84,6 +144,7 @@ template<> struct ShaderCompiler return ret; } }; +#endif template std::pair, size_t> CompileShader(std::string_view text) @@ -108,33 +169,6 @@ SPECIALIZE_COMPILE_SHADER(PlatformType::Metal) SPECIALIZE_COMPILE_SHADER(PlatformType::NX) #endif -#if _WIN32 -static const char* ShaderTypes[] = -{ - "vs_5_0", - "ps_5_0", - "gs_5_0", - "hs_5_0", - "ds_5_0" -}; -template<> -std::vector CompileShader(std::string_view text, PipelineStage stage) -{ - ComPtr errBlob; - ComPtr blobOut; - if (FAILED(D3DCompilePROC(text.data(), text.size(), "Boo HLSL Source", nullptr, nullptr, "main", - ShaderTypes[int(stage)], BOO_D3DCOMPILE_FLAG, 0, &blobOut, &errBlob))) - { - printf("%s\n", source); - Log.report(logvisor::Fatal, "error compiling shader: %s", errBlob->GetBufferPointer()); - return {}; - } - std::vector ret(blobOut.GetBufferSize()); - memcpy(ret.data(), blobOut.GetBufferPointer(), blobOut.GetBufferSize()); - return ret; -}; -#endif - #if BOO_HAS_METAL static int HasMetalCompiler = -1; diff --git a/hecl/lib/MultiProgressPrinter.cpp b/hecl/lib/MultiProgressPrinter.cpp index 8f85330b2..63e1720aa 100644 --- a/hecl/lib/MultiProgressPrinter.cpp +++ b/hecl/lib/MultiProgressPrinter.cpp @@ -36,24 +36,24 @@ void MultiProgressPrinter::ThreadStat::print(const TermInfo& tinfo) const if (submessageLen) { if (messageLen > half-submessageLen-1) - hecl::Printf(_S(" %.*s... %s "), half-submessageLen-4, m_message.c_str(), m_submessage.c_str()); + hecl::Printf(_SYS_STR(" %.*s... %s "), half-submessageLen-4, m_message.c_str(), m_submessage.c_str()); else { - hecl::Printf(_S(" %s"), m_message.c_str()); + hecl::Printf(_SYS_STR(" %s"), m_message.c_str()); for (int i=half-messageLen-submessageLen-1 ; i>=0 ; --i) - hecl::Printf(_S(" ")); - hecl::Printf(_S("%s "), m_submessage.c_str()); + hecl::Printf(_SYS_STR(" ")); + hecl::Printf(_SYS_STR("%s "), m_submessage.c_str()); } } else { if (messageLen > half) - hecl::Printf(_S(" %.*s... "), half-3, m_message.c_str()); + hecl::Printf(_SYS_STR(" %.*s... "), half-3, m_message.c_str()); else { - hecl::Printf(_S(" %s"), m_message.c_str()); + hecl::Printf(_SYS_STR(" %s"), m_message.c_str()); for (int i=half-messageLen ; i>=0 ; --i) - hecl::Printf(_S(" ")); + hecl::Printf(_SYS_STR(" ")); } } @@ -66,24 +66,24 @@ void MultiProgressPrinter::ThreadStat::print(const TermInfo& tinfo) const if (tinfo.xtermColor) { - hecl::Printf(_S("" BOLD "%3d%% ["), iFactor); + hecl::Printf(_SYS_STR("" BOLD "%3d%% ["), iFactor); for (int b=0 ; b= 0.f) @@ -217,30 +217,30 @@ void MultiProgressPrinter::DoPrint() if (m_termInfo.xtermColor) { - hecl::Printf(_S("" BOLD " %3d%% ["), iFactor); + hecl::Printf(_SYS_STR("" BOLD " %3d%% ["), iFactor); for (int b=0 ; b& Project::ConfigFile::lockAndRead() if (m_lockedFile) return m_lines; - m_lockedFile = hecl::Fopen(m_filepath.c_str(), _S("a+"), FileLockType::Write); + m_lockedFile = hecl::Fopen(m_filepath.c_str(), _SYS_STR("a+"), FileLockType::Write); hecl::FSeek(m_lockedFile, 0, SEEK_SET); std::string mainString; @@ -153,8 +153,8 @@ bool Project::ConfigFile::unlockAndCommit() return false; } - SystemString newPath = m_filepath + _S(".part"); - FILE* newFile = hecl::Fopen(newPath.c_str(), _S("w"), FileLockType::Write); + SystemString newPath = m_filepath + _SYS_STR(".part"); + FILE* newFile = hecl::Fopen(newPath.c_str(), _SYS_STR("w"), FileLockType::Write); bool fail = false; for (const std::string& line : m_lines) { @@ -200,24 +200,24 @@ bool Project::ConfigFile::unlockAndCommit() Project::Project(const ProjectRootPath& rootPath) : m_rootPath(rootPath), - m_workRoot(*this, _S("")), - m_dotPath(m_workRoot, _S(".hecl")), - m_cookedRoot(m_dotPath, _S("cooked")), - m_specs(*this, _S("specs")), - m_paths(*this, _S("paths")), - m_groups(*this, _S("groups")) + m_workRoot(*this, _SYS_STR("")), + m_dotPath(m_workRoot, _SYS_STR(".hecl")), + m_cookedRoot(m_dotPath, _SYS_STR("cooked")), + m_specs(*this, _SYS_STR("specs")), + m_paths(*this, _SYS_STR("paths")), + m_groups(*this, _SYS_STR("groups")) { /* Stat for existing project directory (must already exist) */ Sstat myStat; if (hecl::Stat(m_rootPath.getAbsolutePath().data(), &myStat)) { - LogModule.report(logvisor::Error, _S("unable to stat %s"), m_rootPath.getAbsolutePath().data()); + LogModule.report(logvisor::Error, _SYS_STR("unable to stat %s"), m_rootPath.getAbsolutePath().data()); return; } if (!S_ISDIR(myStat.st_mode)) { - LogModule.report(logvisor::Error, _S("provided path must be a directory; '%s' isn't"), + LogModule.report(logvisor::Error, _SYS_STR("provided path must be a directory; '%s' isn't"), m_rootPath.getAbsolutePath().data()); return; } @@ -227,8 +227,8 @@ Project::Project(const ProjectRootPath& rootPath) m_cookedRoot.makeDir(); /* Ensure beacon is valid or created */ - ProjectPath beaconPath(m_dotPath, _S("beacon")); - FILE* bf = hecl::Fopen(beaconPath.getAbsolutePath().data(), _S("a+b")); + ProjectPath beaconPath(m_dotPath, _SYS_STR("beacon")); + FILE* bf = hecl::Fopen(beaconPath.getAbsolutePath().data(), _SYS_STR("a+b")); struct BeaconStruct { hecl::FourCC magic; @@ -320,7 +320,7 @@ void Project::rescanDataSpecs() { hecl::SystemString specStr(spec->m_name); SystemUTF8Conv specUTF8(specStr); - m_compiledSpecs.push_back({*spec, ProjectPath(m_cookedRoot, hecl::SystemString(spec->m_name) + _S(".spec")), + m_compiledSpecs.push_back({*spec, ProjectPath(m_cookedRoot, hecl::SystemString(spec->m_name) + _SYS_STR(".spec")), m_specs.checkForLine(specUTF8.str())}); } m_specs.unlockAndDiscard(); @@ -365,19 +365,19 @@ public: void reportFile(const DataSpecEntry* specEnt) { SystemString submsg(m_file); - submsg += _S(" ("); + submsg += _SYS_STR(" ("); submsg += specEnt->m_name.data(); - submsg += _S(')'); + submsg += _SYS_STR(')'); m_progPrinter.print(m_dir, submsg.c_str(), m_prog); } void reportFile(const DataSpecEntry* specEnt, const SystemChar* extra) { SystemString submsg(m_file); - submsg += _S(" ("); + submsg += _SYS_STR(" ("); submsg += specEnt->m_name.data(); - submsg += _S(", "); + submsg += _SYS_STR(", "); submsg += extra; - submsg += _S(')'); + submsg += _SYS_STR(')'); m_progPrinter.print(m_dir, submsg.c_str(), m_prog); } void reportDirComplete() @@ -406,7 +406,7 @@ static void VisitFile(const ProjectPath& path, bool force, bool fast, continue; ProjectPath cooked = path.getCookedPath(*override); if (fast) - cooked = cooked.getWithExtension(_S(".fast")); + cooked = cooked.getWithExtension(_SYS_STR(".fast")); if (force || cooked.getPathType() == ProjectPath::Type::None || path.getModtime() > cooked.getModtime()) { @@ -427,11 +427,11 @@ static void VisitDirectory(const ProjectPath& dir, std::vector>& specInsts, CookProgress& progress, ClientProcess* cp, int cookPass) { - if (dir.getLastComponent().size() > 1 && dir.getLastComponent()[0] == _S('.')) + if (dir.getLastComponent().size() > 1 && dir.getLastComponent()[0] == _SYS_STR('.')) return; - if (hecl::ProjectPath(dir, _S("!project.yaml")).isFile() && - hecl::ProjectPath(dir, _S("!pool.yaml")).isFile()) + if (hecl::ProjectPath(dir, _SYS_STR("!project.yaml")).isFile() && + hecl::ProjectPath(dir, _SYS_STR("!pool.yaml")).isFile()) { /* Handle AudioGroup case */ VisitFile(dir, force, fast, specInsts, progress, cp, cookPass); @@ -540,7 +540,7 @@ bool Project::packagePath(const ProjectPath& path, const hecl::MultiProgressPrin { if (spec.active && spec.spec.m_factory) { - if (hecl::StringUtils::EndsWith(spec.spec.m_name, _S("-PC"))) + if (hecl::StringUtils::EndsWith(spec.spec.m_name, _SYS_STR("-PC"))) { foundPC = true; specEntry = &spec.spec; diff --git a/hecl/lib/ProjectPath.cpp b/hecl/lib/ProjectPath.cpp index f59a8acfd..94e24bac5 100644 --- a/hecl/lib/ProjectPath.cpp +++ b/hecl/lib/ProjectPath.cpp @@ -4,8 +4,8 @@ namespace hecl { -static const SystemRegex regPATHCOMP(_S("[/\\\\]*([^/\\\\]+)"), SystemRegex::ECMAScript|SystemRegex::optimize); -static const SystemRegex regDRIVELETTER(_S("^([^/]*)/"), SystemRegex::ECMAScript|SystemRegex::optimize); +static const SystemRegex regPATHCOMP(_SYS_STR("[/\\\\]*([^/\\\\]+)"), SystemRegex::ECMAScript|SystemRegex::optimize); +static const SystemRegex regDRIVELETTER(_SYS_STR("^([^/]*)/"), SystemRegex::ECMAScript|SystemRegex::optimize); static SystemString CanonRelPath(SystemStringView path) { @@ -17,15 +17,15 @@ static SystemString CanonRelPath(SystemStringView path) for (; std::regex_search(in, matches, regPATHCOMP) ; in = matches.suffix().str()) { hecl::SystemRegexMatch::const_reference match = matches[1]; - if (!match.compare(_S("."))) + if (!match.compare(_SYS_STR("."))) continue; - else if (!match.compare(_S(".."))) + else if (!match.compare(_SYS_STR(".."))) { if (comps.empty()) { /* Unable to resolve outside project */ - LogModule.report(logvisor::Fatal, _S("Unable to resolve outside project root in %s"), path.data()); - return _S("."); + LogModule.report(logvisor::Fatal, _SYS_STR("Unable to resolve outside project root in %s"), path.data()); + return _SYS_STR("."); } comps.pop_back(); continue; @@ -42,13 +42,13 @@ static SystemString CanonRelPath(SystemStringView path) { if ((*it).size()) { - retval += _S('/'); + retval += _SYS_STR('/'); retval += *it; } } return retval; } - return _S("."); + return _SYS_STR("."); } static SystemString CanonRelPath(SystemStringView path, const ProjectRootPath& projectRoot) @@ -64,7 +64,7 @@ void ProjectPath::assign(Database::Project& project, SystemStringView path) m_proj = &project; SystemString usePath; - size_t pipeFind = path.rfind(_S('|')); + size_t pipeFind = path.rfind(_SYS_STR('|')); if (pipeFind != SystemString::npos) { m_auxInfo.assign(path.cbegin() + pipeFind + 1, path.cend()); @@ -74,7 +74,7 @@ void ProjectPath::assign(Database::Project& project, SystemStringView path) usePath = path; m_relPath = CanonRelPath(usePath, project.getProjectRootPath()); - m_absPath = SystemString(project.getProjectRootPath().getAbsolutePath()) + _S('/') + m_relPath; + m_absPath = SystemString(project.getProjectRootPath().getAbsolutePath()) + _SYS_STR('/') + m_relPath; SanitizePath(m_relPath); SanitizePath(m_absPath); @@ -94,7 +94,7 @@ void ProjectPath::assign(const ProjectPath& parentPath, SystemStringView path) m_proj = parentPath.m_proj; SystemString usePath; - size_t pipeFind = path.rfind(_S('|')); + size_t pipeFind = path.rfind(_SYS_STR('|')); if (pipeFind != SystemString::npos) { m_auxInfo.assign(path.cbegin() + pipeFind + 1, path.cend()); @@ -103,8 +103,8 @@ void ProjectPath::assign(const ProjectPath& parentPath, SystemStringView path) else usePath = path; - m_relPath = CanonRelPath(parentPath.m_relPath + _S('/') + usePath); - m_absPath = SystemString(m_proj->getProjectRootPath().getAbsolutePath()) + _S('/') + m_relPath; + m_relPath = CanonRelPath(parentPath.m_relPath + _SYS_STR('/') + usePath); + m_absPath = SystemString(m_proj->getProjectRootPath().getAbsolutePath()) + _SYS_STR('/') + m_relPath; SanitizePath(m_relPath); SanitizePath(m_absPath); @@ -130,12 +130,12 @@ ProjectPath ProjectPath::getWithExtension(const SystemChar* ext, bool replace) c auto absIt = pp.m_absPath.end(); if (absIt != pp.m_absPath.begin()) --absIt; - while (relIt != pp.m_relPath.begin() && *relIt != _S('.') && *relIt != _S('/')) + while (relIt != pp.m_relPath.begin() && *relIt != _SYS_STR('.') && *relIt != _SYS_STR('/')) { --relIt; --absIt; } - if (*relIt == _S('.') && relIt != pp.m_relPath.begin()) + if (*relIt == _SYS_STR('.') && relIt != pp.m_relPath.begin()) { pp.m_relPath.resize(relIt - pp.m_relPath.begin()); pp.m_absPath.resize(absIt - pp.m_absPath.begin()); @@ -157,14 +157,14 @@ ProjectPath ProjectPath::getCookedPath(const Database::DataSpecEntry& spec) cons ProjectPath ret(m_proj->getProjectCookedPath(spec), woExt.getRelativePath()); if (getAuxInfo().size()) - return ret.getWithExtension((SystemString(_S(".")) + getAuxInfo().data()).c_str()); + return ret.getWithExtension((SystemString(_SYS_STR(".")) + getAuxInfo().data()).c_str()); else return ret; } ProjectPath::Type ProjectPath::getPathType() const { - if (m_absPath.find(_S('*')) != SystemString::npos) + if (m_absPath.find(_SYS_STR('*')) != SystemString::npos) return Type::Glob; Sstat theStat; if (hecl::Stat(m_absPath.c_str(), &theStat)) @@ -180,7 +180,7 @@ Time ProjectPath::getModtime() const { Sstat theStat; time_t latestTime = 0; - if (m_absPath.find(_S('*')) != SystemString::npos) + if (m_absPath.find(_SYS_STR('*')) != SystemString::npos) { std::vector globResults; getGlobResults(globResults); @@ -215,7 +215,7 @@ Time ProjectPath::getModtime() const return Time(latestTime); } } - LogModule.report(logvisor::Fatal, _S("invalid path type for computing modtime in '%s'"), m_absPath.c_str()); + LogModule.report(logvisor::Fatal, _SYS_STR("invalid path type for computing modtime in '%s'"), m_absPath.c_str()); return Time(); } @@ -230,11 +230,11 @@ static void _recursiveGlob(Database::Project& proj, return; const SystemString& comp = matches[1]; - if (comp.find(_S('*')) == SystemString::npos) + if (comp.find(_SYS_STR('*')) == SystemString::npos) { SystemString nextItStr = itStr; if (needSlash) - nextItStr += _S('/'); + nextItStr += _SYS_STR('/'); nextItStr += comp; hecl::Sstat theStat; @@ -291,7 +291,7 @@ hecl::DirectoryEnumerator ProjectPath::enumerateDir() const void ProjectPath::getGlobResults(std::vector& outPaths) const { auto rootPath = m_proj->getProjectRootPath().getAbsolutePath(); - _recursiveGlob(*m_proj, outPaths, m_relPath, rootPath.data(), rootPath.back() != _S('/')); + _recursiveGlob(*m_proj, outPaths, m_relPath, rootPath.data(), rootPath.back() != _SYS_STR('/')); } ProjectRootPath SearchForProject(SystemStringView path) @@ -302,13 +302,13 @@ ProjectRootPath SearchForProject(SystemStringView path) while (begin != end) { SystemString testPath(begin, end); - SystemString testIndexPath = testPath + _S("/.hecl/beacon"); + SystemString testIndexPath = testPath + _SYS_STR("/.hecl/beacon"); Sstat theStat; if (!hecl::Stat(testIndexPath.c_str(), &theStat)) { if (S_ISREG(theStat.st_mode)) { - FILE* fp = hecl::Fopen(testIndexPath.c_str(), _S("rb")); + FILE* fp = hecl::Fopen(testIndexPath.c_str(), _SYS_STR("rb")); if (!fp) continue; char magic[4]; @@ -323,7 +323,7 @@ ProjectRootPath SearchForProject(SystemStringView path) } } - while (begin != end && *(end-1) != _S('/') && *(end-1) != _S('\\')) + while (begin != end && *(end-1) != _SYS_STR('/') && *(end-1) != _SYS_STR('\\')) --end; if (begin != end) --end; @@ -339,13 +339,13 @@ ProjectRootPath SearchForProject(SystemStringView path, SystemString& subpathOut while (begin != end) { SystemString testPath(begin, end); - SystemString testIndexPath = testPath + _S("/.hecl/beacon"); + SystemString testIndexPath = testPath + _SYS_STR("/.hecl/beacon"); Sstat theStat; if (!hecl::Stat(testIndexPath.c_str(), &theStat)) { if (S_ISREG(theStat.st_mode)) { - FILE* fp = hecl::Fopen(testIndexPath.c_str(), _S("rb")); + FILE* fp = hecl::Fopen(testIndexPath.c_str(), _SYS_STR("rb")); if (!fp) continue; char magic[4]; @@ -357,16 +357,16 @@ ProjectRootPath SearchForProject(SystemStringView path, SystemString& subpathOut continue; ProjectRootPath newRootPath = ProjectRootPath(testPath); auto origEnd = testRoot.getAbsolutePath().end(); - while (end != origEnd && *end != _S('/') && *end != _S('\\')) + while (end != origEnd && *end != _SYS_STR('/') && *end != _SYS_STR('\\')) ++end; - if (end != origEnd && (*end == _S('/') || *end == _S('\\'))) + if (end != origEnd && (*end == _SYS_STR('/') || *end == _SYS_STR('\\'))) ++end; subpathOut.assign(end, origEnd); return newRootPath; } } - while (begin != end && *(end-1) != _S('/') && *(end-1) != _S('\\')) + while (begin != end && *(end-1) != _SYS_STR('/') && *(end-1) != _SYS_STR('\\')) --end; if (begin != end) --end; diff --git a/hecl/lib/Runtime/FileStoreManager.cpp b/hecl/lib/Runtime/FileStoreManager.cpp index 56de3605a..23b34d1da 100644 --- a/hecl/lib/Runtime/FileStoreManager.cpp +++ b/hecl/lib/Runtime/FileStoreManager.cpp @@ -19,17 +19,17 @@ FileStoreManager::FileStoreManager(SystemStringView domain) #if !WINDOWS_STORE WCHAR home[MAX_PATH]; if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, home))) - Log.report(logvisor::Fatal, _S("unable to locate profile for file store")); + Log.report(logvisor::Fatal, _SYS_STR("unable to locate profile for file store")); SystemString path(home); #else StorageFolder^ cacheFolder = ApplicationData::Current->LocalCacheFolder; SystemString path(cacheFolder->Path->Data()); #endif - path += _S("/.heclrun"); + path += _SYS_STR("/.heclrun"); hecl::MakeDir(path.c_str()); - path += _S('/'); + path += _SYS_STR('/'); path += domain.data(); hecl::MakeDir(path.c_str()); diff --git a/hecl/lib/SteamFinder.cpp b/hecl/lib/SteamFinder.cpp index 44005e1c6..069fa98b4 100644 --- a/hecl/lib/SteamFinder.cpp +++ b/hecl/lib/SteamFinder.cpp @@ -23,16 +23,16 @@ hecl::SystemString FindCommonSteamApp(const hecl::SystemChar* name) #if !WINDOWS_STORE HKEY hkey; hecl::SystemChar _steamInstallDir[MAX_PATH] = {0}; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _S("Software\\Valve\\Steam"), + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _SYS_STR("Software\\Valve\\Steam"), 0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) { - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _S("Software\\Valve\\Steam"), + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _SYS_STR("Software\\Valve\\Steam"), 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &hkey) != ERROR_SUCCESS) return {}; } DWORD size = MAX_PATH; - if (RegQueryValueEx(hkey, _S("InstallPath"), nullptr, nullptr, + if (RegQueryValueEx(hkey, _SYS_STR("InstallPath"), nullptr, nullptr, (LPBYTE)_steamInstallDir, &size) == ERROR_SUCCESS) steamInstallDir = _steamInstallDir; RegCloseKey(hkey); @@ -62,17 +62,17 @@ hecl::SystemString FindCommonSteamApp(const hecl::SystemChar* name) #endif - hecl::SystemString appPath = hecl::SystemString(_S("common")) + PATH_SEP + name; + hecl::SystemString appPath = hecl::SystemString(_SYS_STR("common")) + PATH_SEP + name; /* Try main steam install directory first */ - hecl::SystemString steamAppsMain = steamInstallDir + PATH_SEP + _S("steamapps"); + hecl::SystemString steamAppsMain = steamInstallDir + PATH_SEP + _SYS_STR("steamapps"); hecl::SystemString mainAppPath = steamAppsMain + PATH_SEP + appPath; if (!hecl::Stat(mainAppPath.c_str(), &theStat) && S_ISDIR(theStat.st_mode)) return mainAppPath; /* Iterate alternate steam install dirs */ - hecl::SystemString libraryFoldersVdfPath = steamAppsMain + PATH_SEP + _S("libraryfolders.vdf"); - FILE* fp = hecl::Fopen(libraryFoldersVdfPath.c_str(), _S("r")); + hecl::SystemString libraryFoldersVdfPath = steamAppsMain + PATH_SEP + _SYS_STR("libraryfolders.vdf"); + FILE* fp = hecl::Fopen(libraryFoldersVdfPath.c_str(), _SYS_STR("r")); if (!fp) return {}; hecl::FSeek(fp, 0, SEEK_END); @@ -100,7 +100,7 @@ hecl::SystemString FindCommonSteamApp(const hecl::SystemChar* name) std::string match = dirMatch[1].str(); hecl::SystemStringConv otherInstallDir(match); hecl::SystemString otherAppPath = hecl::SystemString(otherInstallDir.sys_str()) + PATH_SEP + - _S("steamapps") + PATH_SEP + appPath; + _SYS_STR("steamapps") + PATH_SEP + appPath; if (!hecl::Stat(otherAppPath.c_str(), &theStat) && S_ISDIR(theStat.st_mode)) return otherAppPath; begin = dirMatch.suffix().first; diff --git a/hecl/lib/hecl.cpp b/hecl/lib/hecl.cpp index cf5b81b82..5920c555b 100644 --- a/hecl/lib/hecl.cpp +++ b/hecl/lib/hecl.cpp @@ -215,7 +215,7 @@ void ResourceLock::ClearThreadRes() bool IsPathPNG(const hecl::ProjectPath& path) { - FILE* fp = hecl::Fopen(path.getAbsolutePath().data(), _S("rb")); + FILE* fp = hecl::Fopen(path.getAbsolutePath().data(), _SYS_STR("rb")); if (!fp) return false; uint32_t buf = 0; @@ -234,9 +234,9 @@ bool IsPathPNG(const hecl::ProjectPath& path) bool IsPathBlend(const hecl::ProjectPath& path) { auto lastCompExt = path.getLastComponentExt(); - if (lastCompExt.empty() || hecl::StrCmp(lastCompExt.data(), _S("blend"))) + if (lastCompExt.empty() || hecl::StrCmp(lastCompExt.data(), _SYS_STR("blend"))) return false; - FILE* fp = hecl::Fopen(path.getAbsolutePath().data(), _S("rb")); + FILE* fp = hecl::Fopen(path.getAbsolutePath().data(), _SYS_STR("rb")); if (!fp) return false; uint32_t buf = 0; @@ -254,13 +254,13 @@ bool IsPathBlend(const hecl::ProjectPath& path) bool IsPathYAML(const hecl::ProjectPath& path) { - if (!hecl::StrCmp(path.getLastComponent().data(), _S("!catalog.yaml"))) + if (!hecl::StrCmp(path.getLastComponent().data(), _SYS_STR("!catalog.yaml"))) return false; /* !catalog.yaml is exempt from general use */ auto lastCompExt = path.getLastComponentExt(); if (lastCompExt.empty()) return false; - if (!hecl::StrCmp(lastCompExt.data(), _S("yaml")) || - !hecl::StrCmp(lastCompExt.data(), _S("yml"))) + if (!hecl::StrCmp(lastCompExt.data(), _SYS_STR("yaml")) || + !hecl::StrCmp(lastCompExt.data(), _SYS_STR("yml"))) return true; return false; } @@ -274,7 +274,7 @@ hecl::DirectoryEnumerator::DirectoryEnumerator(SystemStringView path, Mode mode, #if _WIN32 hecl::SystemString wc(path); - wc += _S("/*"); + wc += _SYS_STR("/*"); WIN32_FIND_DATAW d; HANDLE dir = FindFirstFileW(wc.c_str(), &d); if (dir == INVALID_HANDLE_VALUE) @@ -284,12 +284,12 @@ hecl::DirectoryEnumerator::DirectoryEnumerator(SystemStringView path, Mode mode, case Mode::Native: do { - if (!wcscmp(d.cFileName, _S(".")) || !wcscmp(d.cFileName, _S(".."))) + if (!wcscmp(d.cFileName, _SYS_STR(".")) || !wcscmp(d.cFileName, _SYS_STR(".."))) continue; if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) continue; hecl::SystemString fp(path); - fp += _S('/'); + fp += _SYS_STR('/'); fp += d.cFileName; hecl::Sstat st; if (hecl::Stat(fp.c_str(), &st)) @@ -313,12 +313,12 @@ hecl::DirectoryEnumerator::DirectoryEnumerator(SystemStringView path, Mode mode, std::map sort; do { - if (!wcscmp(d.cFileName, _S(".")) || !wcscmp(d.cFileName, _S(".."))) + if (!wcscmp(d.cFileName, _SYS_STR(".")) || !wcscmp(d.cFileName, _SYS_STR(".."))) continue; if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) continue; hecl::SystemString fp(path); - fp +=_S('/'); + fp +=_SYS_STR('/'); fp += d.cFileName; hecl::Sstat st; if (hecl::Stat(fp.c_str(), &st) || !S_ISDIR(st.st_mode)) @@ -348,12 +348,12 @@ hecl::DirectoryEnumerator::DirectoryEnumerator(SystemStringView path, Mode mode, std::multimap sort; do { - if (!wcscmp(d.cFileName, _S(".")) || !wcscmp(d.cFileName, _S(".."))) + if (!wcscmp(d.cFileName, _SYS_STR(".")) || !wcscmp(d.cFileName, _SYS_STR(".."))) continue; if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) continue; hecl::SystemString fp(path); - fp += _S('/'); + fp += _SYS_STR('/'); fp += d.cFileName; hecl::Sstat st; if (hecl::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode)) @@ -373,12 +373,12 @@ hecl::DirectoryEnumerator::DirectoryEnumerator(SystemStringView path, Mode mode, std::map sort; do { - if (!wcscmp(d.cFileName, _S(".")) || !wcscmp(d.cFileName, _S(".."))) + if (!wcscmp(d.cFileName, _SYS_STR(".")) || !wcscmp(d.cFileName, _SYS_STR(".."))) continue; if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) continue; hecl::SystemString fp(path); - fp += _S('/'); + fp += _SYS_STR('/'); fp += d.cFileName; hecl::Sstat st; if (hecl::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode)) @@ -847,9 +847,9 @@ int RunProcess(const SystemChar* path, const SystemChar* const args[]) const SystemChar* const* arg = &args[1]; while (*arg) { - cmdLine += _S(" \""); + cmdLine += _SYS_STR(" \""); cmdLine += *arg++; - cmdLine += _S('"'); + cmdLine += _SYS_STR('"'); } STARTUPINFO sinfo = {sizeof(STARTUPINFO)}; diff --git a/hecl/shaderc/main.cpp b/hecl/shaderc/main.cpp index 1d12eb291..afbc1ebad 100644 --- a/hecl/shaderc/main.cpp +++ b/hecl/shaderc/main.cpp @@ -7,6 +7,37 @@ static logvisor::Module Log("shaderc"); #if _WIN32 +#include +extern pD3DCompile D3DCompilePROC; +pD3DCompile D3DCompilePROC = nullptr; + +static bool FindBestD3DCompile() +{ + HMODULE d3dCompilelib = LoadLibraryW(L"D3DCompiler_47.dll"); + if (!d3dCompilelib) + { + d3dCompilelib = LoadLibraryW(L"D3DCompiler_46.dll"); + if (!d3dCompilelib) + { + d3dCompilelib = LoadLibraryW(L"D3DCompiler_45.dll"); + if (!d3dCompilelib) + { + d3dCompilelib = LoadLibraryW(L"D3DCompiler_44.dll"); + if (!d3dCompilelib) + { + d3dCompilelib = LoadLibraryW(L"D3DCompiler_43.dll"); + } + } + } + } + if (d3dCompilelib) + { + D3DCompilePROC = (pD3DCompile)GetProcAddress(d3dCompilelib, "D3DCompile"); + return D3DCompilePROC != nullptr; + } + return false; +} + int wmain(int argc, const hecl::SystemChar** argv) #else int main(int argc, const hecl::SystemChar** argv) @@ -15,6 +46,14 @@ int main(int argc, const hecl::SystemChar** argv) logvisor::RegisterConsoleLogger(); logvisor::RegisterStandardExceptions(); +#if _WIN32 + if (!FindBestD3DCompile()) + { + Log.report(logvisor::Info, "Unable to find D3DCompiler dll"); + return 1; + } +#endif + if (argc == 1) { Log.report(logvisor::Info, "Usage: shaderc -o [-D definevar=defineval]... ..."); @@ -63,7 +102,7 @@ int main(int argc, const hecl::SystemChar** argv) } hecl::SystemUTF8Conv conv(define); const char* defineU8 = conv.c_str(); - if (char* equals = strchr(defineU8, '=')) + if (const char* equals = strchr(defineU8, '=')) c.addDefine(std::string(defineU8, equals - defineU8), equals + 1); else c.addDefine(defineU8, ""); @@ -87,7 +126,7 @@ int main(int argc, const hecl::SystemChar** argv) } hecl::SystemStringView baseName; - auto slashPos = outPath.find_last_of("/\\"); + auto slashPos = outPath.find_last_of(_SYS_STR("/\\")); if (slashPos != hecl::SystemString::npos) baseName = outPath.data() + slashPos + 1; else @@ -105,22 +144,22 @@ int main(int argc, const hecl::SystemChar** argv) return 1; { - hecl::SystemString headerPath = outPath + _S(".hpp"); + hecl::SystemString headerPath = outPath + _SYS_STR(".hpp"); athena::io::FileWriter w(headerPath); if (w.hasError()) { - Log.report(logvisor::Error, _S("Error opening '%s' for writing"), headerPath.c_str()); + Log.report(logvisor::Error, _SYS_STR("Error opening '%s' for writing"), headerPath.c_str()); return 1; } w.writeBytes(ret.first.data(), ret.first.size()); } { - hecl::SystemString impPath = outPath + _S(".cpp"); + hecl::SystemString impPath = outPath + _SYS_STR(".cpp"); athena::io::FileWriter w(impPath); if (w.hasError()) { - Log.report(logvisor::Error, _S("Error opening '%s' for writing"), impPath.c_str()); + Log.report(logvisor::Error, _SYS_STR("Error opening '%s' for writing"), impPath.c_str()); return 1; } w.writeBytes(ret.second.data(), ret.second.size()); diff --git a/hecl/shaderc/shaderc.cpp b/hecl/shaderc/shaderc.cpp index 900126907..66fc12bbf 100644 --- a/hecl/shaderc/shaderc.cpp +++ b/hecl/shaderc/shaderc.cpp @@ -7,6 +7,7 @@ #include #include #include +#include using namespace std::literals; @@ -238,24 +239,24 @@ bool Compiler::includeFile(SystemStringView file, std::string& out, int depth) { if (depth > 32) { - Log.report(logvisor::Error, _S("Too many levels of includes (>32) at '%s'"), file.data()); + Log.report(logvisor::Error, _SYS_STR("Too many levels of includes (>32) at '%s'"), file.data()); return false; } const std::string* data = getFileContents(file); if (!data) { - Log.report(logvisor::Error, _S("Unable to access '%s'"), file.data()); + Log.report(logvisor::Error, _SYS_STR("Unable to access '%s'"), file.data()); return false; } const std::string& sdata = *data; SystemString directory; - auto slashPos = file.find_last_of("/\\"); + auto slashPos = file.find_last_of(_SYS_STR("/\\")); if (slashPos != SystemString::npos) directory = SystemString(file.begin(), file.begin() + slashPos); else - directory = _S("."); + directory = _SYS_STR("."); auto begin = sdata.cbegin(); auto end = sdata.cend(); @@ -274,13 +275,13 @@ bool Compiler::includeFile(SystemStringView file, std::string& out, int depth) std::string path = subMatch[1].str(); if (path.empty()) { - Log.report(logvisor::Error, _S("Empty path provided to include in '%s'"), file.data()); + Log.report(logvisor::Error, _SYS_STR("Empty path provided to include in '%s'"), file.data()); return false; } hecl::SystemString pathStr(hecl::SystemStringConv(path).sys_str()); if (!hecl::IsAbsolute(pathStr)) - pathStr = directory + _S('/') + pathStr; + pathStr = directory + _SYS_STR('/') + pathStr; if (!includeFile(pathStr, out, depth + 1)) return false; } @@ -871,58 +872,15 @@ bool Compiler::compileFile(SystemStringView file, std::string_view baseName, std } out.first += "\n"; - out.first += "#define OPENGL_STAGES_"; + out.first += "#define STAGES_"; out.first += baseName; + out.first += "(P, S)"; for (const auto& shader : shaderStageUses) { out.first += " \\\n"; - out.first += "STAGE_SPECIALIZATIONS(::StageObject_"; + out.first += "::StageObject_"; out.first += shader.first; - out.first += ", hecl::PlatformType::OpenGL)"; - } - out.first += "\n"; - - out.first += "#define VULKAN_STAGES_"; - out.first += baseName; - for (const auto& shader : shaderStageUses) - { - out.first += " \\\n"; - out.first += "STAGE_SPECIALIZATIONS(::StageObject_"; - out.first += shader.first; - out.first += ", hecl::PlatformType::Vulkan)"; - } - out.first += "\n"; - - out.first += "#define D3D11_STAGES_"; - out.first += baseName; - for (const auto& shader : shaderStageUses) - { - out.first += " \\\n"; - out.first += "STAGE_SPECIALIZATIONS(::StageObject_"; - out.first += shader.first; - out.first += ", hecl::PlatformType::D3D11)"; - } - out.first += "\n"; - - out.first += "#define METAL_STAGES_"; - out.first += baseName; - for (const auto& shader : shaderStageUses) - { - out.first += " \\\n"; - out.first += "STAGE_SPECIALIZATIONS(::StageObject_"; - out.first += shader.first; - out.first += ", hecl::PlatformType::Metal)"; - } - out.first += "\n"; - - out.first += "#define NX_STAGES_"; - out.first += baseName; - for (const auto& shader : shaderStageUses) - { - out.first += " \\\n"; - out.first += "STAGE_SPECIALIZATIONS(::StageObject_"; - out.first += shader.first; - out.first += ", hecl::PlatformType::NX)"; + out.first += ","; } out.first += "\n"; diff --git a/hecl/test/main.cpp b/hecl/test/main.cpp index 52736564d..74a6985b4 100644 --- a/hecl/test/main.cpp +++ b/hecl/test/main.cpp @@ -60,7 +60,7 @@ struct HECLApplicationCallback : boo::IApplicationCallback bool m_running = true; HECLApplicationCallback() - : m_fileStoreMgr(_S("heclTest")), + : m_fileStoreMgr(_SYS_STR("heclTest")), m_cvarManager(m_fileStoreMgr), m_console(&m_cvarManager) { @@ -75,7 +75,7 @@ struct HECLApplicationCallback : boo::IApplicationCallback hecl::VerbosityLevel = 2; /* Setup boo window */ - m_mainWindow = app->newWindow(_S("HECL Test")); + m_mainWindow = app->newWindow(_SYS_STR("HECL Test")); m_mainWindow->setCallback(&m_windowCb); boo::ObjToken renderTex; @@ -130,7 +130,8 @@ struct HECLApplicationCallback : boo::IApplicationCallback hecl::Backend::ShaderTag testShaderTag(testShader, 0, 1, 0, 0, boo::Primitive::TriStrips, hecl::Backend::ReflectionType::None, false, false, false); hecl::Frontend::Frontend FE; - hecl::HECLIR irObj(FE.compileSource(testShader, "booTest"), testShaderTag, 0); + hecl::Frontend::IR ir = FE.compileSource(testShader, "booTest"); + hecl::HECLIR irObj(ir, testShaderTag, 0); gfxF->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) { @@ -277,7 +278,7 @@ int main(int argc, const boo::SystemChar** argv) logvisor::RegisterConsoleLogger(); HECLApplicationCallback appCb; int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto, - appCb, _S("heclTest"), _S("HECL Test"), argc, argv); + appCb, _SYS_STR("heclTest"), _SYS_STR("HECL Test"), argc, argv); printf("IM DYING!!\n"); return ret; } @@ -291,7 +292,7 @@ int WINAPIV main(Platform::Array^ params) logvisor::RegisterConsoleLogger(); HECLApplicationCallback appCb; boo::ViewProvider^ viewProvider = - ref new boo::ViewProvider(appCb, _S("heclTest"), _S("HECL Test"), _S("heclTest"), params, false); + ref new boo::ViewProvider(appCb, _SYS_STR("heclTest"), _SYS_STR("HECL Test"), _SYS_STR("heclTest"), params, false); CoreApplication::Run(viewProvider); return 0; } diff --git a/hecl/test/test.shader b/hecl/test/test.shader index cfdf3ab67..a8bbf7742 100644 --- a/hecl/test/test.shader +++ b/hecl/test/test.shader @@ -1,3 +1,5 @@ +#shader test + #culling none #attribute position3 #attribute normal3 @@ -23,3 +25,36 @@ void main() { out_frag = texture(texs[0], out_uv); } + +#vertex hlsl +struct VertData +{ + float3 in_pos : POSITION; + float3 in_norm : NORMAL; + float2 in_uv : UV; +}; +struct VertToFrag +{ + float4 position : SV_Position; + float2 out_uv : UV; +}; +VertToFrag main(in VertData v) +{ + VertToFrag ret; + ret.position = float4(v.in_pos, 1.0); + ret.out_uv = v.in_uv; + return ret; +} + +#fragment hlsl +struct VertToFrag +{ + float4 position : SV_Position; + float2 out_uv : UV; +}; +Texture2D texs : register(t0); +SamplerState samp : register(s0); +float4 main(in VertToFrag vtf) : SV_Target0 +{ + return texs.Sample(samp, vtf.out_uv); +}