2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-03-07 05:23:02 +00:00

chore: add build log for zcg

This commit is contained in:
Jan Laupetin
2026-03-05 20:20:00 +00:00
parent 027d47d549
commit f8b3361bbe
6 changed files with 41 additions and 3 deletions

View File

@@ -20,6 +20,8 @@ public:
std::vector<std::string> m_input_files; std::vector<std::string> m_input_files;
std::string m_output_directory; std::string m_output_directory;
// Generate a build log that is always written for the compiler to determine
// the last output time.
std::string m_build_log_file; std::string m_build_log_file;
std::vector<std::pair<std::string, std::string>> m_defines; std::vector<std::pair<std::string, std::string>> m_defines;

View File

@@ -347,6 +347,7 @@ function ZoneCode:project()
.. ' -h "' .. path.join(path.getabsolute(ProjectFolder()), 'ZoneCode/Game/%{file.basename}/%{file.basename}_ZoneCode.h') .. '"' .. ' -h "' .. path.join(path.getabsolute(ProjectFolder()), 'ZoneCode/Game/%{file.basename}/%{file.basename}_ZoneCode.h') .. '"'
.. ' -c "' .. path.join(path.getabsolute(ProjectFolder()), 'ZoneCode/Game/%{file.basename}/%{file.basename}_Commands.txt') .. '"' .. ' -c "' .. path.join(path.getabsolute(ProjectFolder()), 'ZoneCode/Game/%{file.basename}/%{file.basename}_Commands.txt') .. '"'
.. ' -o "%{wks.location}/src/ZoneCode/Game/%{file.basename}"' .. ' -o "%{wks.location}/src/ZoneCode/Game/%{file.basename}"'
.. ' --build-log "%{wks.location}/src/ZoneCode/Game/%{file.basename}.log"'
.. ' -g ZoneLoad' .. ' -g ZoneLoad'
.. ' -g ZoneMark' .. ' -g ZoneMark'
.. ' -g ZoneWrite' .. ' -g ZoneWrite'
@@ -358,6 +359,9 @@ function ZoneCode:project()
path.join(ProjectFolder(), "Common/Game/%{file.basename}/%{file.basename}_Assets.h"), path.join(ProjectFolder(), "Common/Game/%{file.basename}/%{file.basename}_Assets.h"),
TargetDirectoryBuildTools .. "/" .. ExecutableByOs('ZoneCodeGenerator') TargetDirectoryBuildTools .. "/" .. ExecutableByOs('ZoneCodeGenerator')
} }
buildoutputs {
"%{wks.location}/src/ZoneCode/Game/%{file.basename}.log"
}
filter {} filter {}
filter "files:**/IW3.gen" filter "files:**/IW3.gen"

View File

@@ -11,6 +11,7 @@
#include <filesystem> #include <filesystem>
#include <format> #include <format>
#include <fstream>
namespace fs = std::filesystem; namespace fs = std::filesystem;
@@ -176,7 +177,22 @@ bool CodeGenerator::GenerateCode(const IDataRepository* repository)
} }
} }
const auto end = std::chrono::steady_clock::now(); const auto end = std::chrono::steady_clock::now();
con::debug("Generating code took {}ms", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()); const auto timeInMs = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
con::debug("Generating code took {}ms", timeInMs);
if (!m_args->m_build_log_file.empty())
{
std::ofstream buildLogFile(m_args->m_build_log_file);
if (buildLogFile.is_open())
{
buildLogFile << "Generating code took " << timeInMs << "ms\n";
buildLogFile.close();
}
else
{
con::error("Failed to open build log file");
}
}
return true; return true;
} }

View File

@@ -49,7 +49,7 @@ public:
} }
private: private:
bool ReadHeaderData() [[nodiscard]] bool ReadHeaderData() const
{ {
for (const auto& headerFile : m_args.m_header_paths) for (const auto& headerFile : m_args.m_header_paths)
{ {
@@ -62,7 +62,7 @@ private:
return true; return true;
} }
bool ReadCommandsData() [[nodiscard]] bool ReadCommandsData() const
{ {
for (const auto& commandsFile : m_args.m_command_paths) for (const auto& commandsFile : m_args.m_command_paths)
{ {

View File

@@ -85,6 +85,13 @@ const CommandLineOption* const OPTION_GENERATE =
.WithParameter("preset") .WithParameter("preset")
.Reusable() .Reusable()
.Build(); .Build();
const CommandLineOption* const OPTION_BUILD_LOG =
CommandLineOption::Builder::Create()
.WithLongName("build-log")
.WithDescription("Specify a file to write a build log to.")
.WithParameter("logFilePath")
.Build();
// clang-format on // clang-format on
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{ const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
@@ -97,6 +104,7 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
OPTION_OUTPUT_FOLDER, OPTION_OUTPUT_FOLDER,
OPTION_PRINT, OPTION_PRINT,
OPTION_GENERATE, OPTION_GENERATE,
OPTION_BUILD_LOG,
}; };
namespace namespace
@@ -170,6 +178,10 @@ bool ZoneCodeGeneratorArguments::ParseArgs(const int argc, const char** argv, bo
else else
m_output_directory = "."; m_output_directory = ".";
// --build-log
if (m_argument_parser.IsOptionSpecified(OPTION_BUILD_LOG))
m_build_log_file = m_argument_parser.GetValueForOption(OPTION_BUILD_LOG);
// -h; --header // -h; --header
if (m_argument_parser.IsOptionSpecified(OPTION_HEADER)) if (m_argument_parser.IsOptionSpecified(OPTION_HEADER))
{ {

View File

@@ -18,6 +18,10 @@ public:
std::vector<std::string> m_command_paths; std::vector<std::string> m_command_paths;
std::string m_output_directory; std::string m_output_directory;
// Generate a build log that is always written for the compiler to determine
// the last output time.
std::string m_build_log_file;
std::vector<std::string> m_template_names; std::vector<std::string> m_template_names;
private: private: