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:
@@ -20,6 +20,8 @@ public:
|
||||
std::vector<std::string> m_input_files;
|
||||
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::pair<std::string, std::string>> m_defines;
|
||||
|
||||
@@ -347,6 +347,7 @@ function ZoneCode:project()
|
||||
.. ' -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') .. '"'
|
||||
.. ' -o "%{wks.location}/src/ZoneCode/Game/%{file.basename}"'
|
||||
.. ' --build-log "%{wks.location}/src/ZoneCode/Game/%{file.basename}.log"'
|
||||
.. ' -g ZoneLoad'
|
||||
.. ' -g ZoneMark'
|
||||
.. ' -g ZoneWrite'
|
||||
@@ -358,6 +359,9 @@ function ZoneCode:project()
|
||||
path.join(ProjectFolder(), "Common/Game/%{file.basename}/%{file.basename}_Assets.h"),
|
||||
TargetDirectoryBuildTools .. "/" .. ExecutableByOs('ZoneCodeGenerator')
|
||||
}
|
||||
buildoutputs {
|
||||
"%{wks.location}/src/ZoneCode/Game/%{file.basename}.log"
|
||||
}
|
||||
filter {}
|
||||
|
||||
filter "files:**/IW3.gen"
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user