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

@@ -11,6 +11,7 @@
#include <filesystem>
#include <format>
#include <fstream>
namespace fs = std::filesystem;
@@ -176,7 +177,22 @@ bool CodeGenerator::GenerateCode(const IDataRepository* repository)
}
}
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;
}

View File

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

View File

@@ -85,6 +85,13 @@ const CommandLineOption* const OPTION_GENERATE =
.WithParameter("preset")
.Reusable()
.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
const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
@@ -97,6 +104,7 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
OPTION_OUTPUT_FOLDER,
OPTION_PRINT,
OPTION_GENERATE,
OPTION_BUILD_LOG,
};
namespace
@@ -170,6 +178,10 @@ bool ZoneCodeGeneratorArguments::ParseArgs(const int argc, const char** argv, bo
else
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
if (m_argument_parser.IsOptionSpecified(OPTION_HEADER))
{

View File

@@ -18,6 +18,10 @@ public:
std::vector<std::string> m_command_paths;
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;
private: