mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-25 22:27:53 -05:00
Add build log to templater
This commit is contained in:
@ -172,7 +172,7 @@ namespace templating
|
||||
m_default_output_file = (m_output_directory / filenamePath.replace_extension()).string();
|
||||
}
|
||||
|
||||
bool RunNextPass()
|
||||
bool RunNextPass(std::ostream* buildLogFile)
|
||||
{
|
||||
m_stream.clear();
|
||||
m_stream.seekg(0, std::ios::beg);
|
||||
@ -209,7 +209,7 @@ namespace templating
|
||||
|
||||
if (!m_write_output_to_file)
|
||||
{
|
||||
m_output_stream = std::ofstream(m_output_file);
|
||||
m_output_stream = std::ofstream(m_output_file, std::ios::out | std::ios::binary);
|
||||
if (!m_output_stream.is_open())
|
||||
{
|
||||
std::cerr << "Failed to open output file \"" << m_output_file << "\"\n";
|
||||
@ -223,6 +223,9 @@ namespace templating
|
||||
|
||||
std::cout << "Templated file \"" << m_output_file << "\"\n";
|
||||
|
||||
if(buildLogFile)
|
||||
*buildLogFile << "Templated file \"" << m_output_file << "\"\n";
|
||||
|
||||
m_first_line = true;
|
||||
m_write_output_to_file = false;
|
||||
m_output_cache.clear();
|
||||
@ -289,7 +292,7 @@ namespace templating
|
||||
return false;
|
||||
|
||||
m_output_file = (m_output_directory / fileName).string();
|
||||
m_output_stream = std::ofstream(m_output_file);
|
||||
m_output_stream = std::ofstream(m_output_file, std::ios::out | std::ios::binary);
|
||||
if (!m_output_stream.is_open())
|
||||
{
|
||||
std::cerr << "Failed to open output file \"" << m_output_file << "\"\n";
|
||||
@ -326,23 +329,29 @@ namespace templating
|
||||
|
||||
Templater::Templater(std::istream& stream, std::string fileName)
|
||||
: m_stream(stream),
|
||||
m_build_log(nullptr),
|
||||
m_file_name(std::move(fileName))
|
||||
{
|
||||
}
|
||||
|
||||
void Templater::SetBuildLogFile(std::ostream* buildLogFile)
|
||||
{
|
||||
m_build_log = buildLogFile;
|
||||
}
|
||||
|
||||
bool Templater::TemplateToDirectory(const std::string& outputDirectory) const
|
||||
{
|
||||
TemplaterControlImpl control(m_stream, m_file_name, outputDirectory);
|
||||
|
||||
try
|
||||
{
|
||||
if (!control.RunNextPass())
|
||||
if (!control.RunNextPass(m_build_log))
|
||||
return false;
|
||||
|
||||
control.AdvanceActiveVariations();
|
||||
while (control.HasActiveVariations())
|
||||
{
|
||||
if (!control.RunNextPass())
|
||||
if (!control.RunNextPass(m_build_log))
|
||||
return false;
|
||||
|
||||
control.AdvanceActiveVariations();
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Parsing/IParserLineStream.h"
|
||||
|
||||
namespace templating
|
||||
@ -9,11 +10,13 @@ namespace templating
|
||||
{
|
||||
public:
|
||||
Templater(std::istream& stream, std::string fileName);
|
||||
|
||||
bool TemplateToDirectory(const std::string& outputDirectory) const;
|
||||
|
||||
void SetBuildLogFile(std::ostream* buildLogFile);
|
||||
_NODISCARD bool TemplateToDirectory(const std::string& outputDirectory) const;
|
||||
|
||||
private:
|
||||
std::istream& m_stream;
|
||||
std::ostream* m_build_log;
|
||||
std::string m_file_name;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user