mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Build referenced targets from within zone definitions
This commit is contained in:
parent
85b6c3f6bd
commit
483d47d79e
@ -458,9 +458,19 @@ class LinkerImpl final : public Linker
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BuildReferencedTargets(const std::string& projectName, const std::string& targetName, const ZoneDefinition& zoneDefinition) const
|
bool BuildReferencedTargets(const std::string& projectName, const std::string& targetName, const ZoneDefinition& zoneDefinition)
|
||||||
{
|
{
|
||||||
return true;
|
return std::all_of(zoneDefinition.m_targets_to_build.begin(), zoneDefinition.m_targets_to_build.end(), [this, &projectName, &targetName](const std::string& buildTargetName)
|
||||||
|
{
|
||||||
|
if (buildTargetName == targetName)
|
||||||
|
{
|
||||||
|
std::cerr << "Cannot build target with same name: \"" << targetName << "\"\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Building referenced target \"" << buildTargetName << "\"\n";
|
||||||
|
return BuildProject(projectName, buildTargetName);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BuildProject(const std::string& projectName, const std::string& targetName)
|
bool BuildProject(const std::string& projectName, const std::string& targetName)
|
||||||
@ -475,7 +485,7 @@ class LinkerImpl final : public Linker
|
|||||||
if (!GetProjectTypeFromZoneDefinition(projectType, targetName, *zoneDefinition))
|
if (!GetProjectTypeFromZoneDefinition(projectType, targetName, *zoneDefinition))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto result = false;
|
auto result = true;
|
||||||
if (projectType != ProjectType::NONE)
|
if (projectType != ProjectType::NONE)
|
||||||
{
|
{
|
||||||
std::string gameName;
|
std::string gameName;
|
||||||
@ -498,14 +508,15 @@ class LinkerImpl final : public Linker
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
result = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = result && BuildReferencedTargets(projectName, targetName, *zoneDefinition);
|
|
||||||
|
|
||||||
m_search_paths.UnloadProjectSpecificSearchPaths();
|
m_search_paths.UnloadProjectSpecificSearchPaths();
|
||||||
|
|
||||||
|
result = result && BuildReferencedTargets(projectName, targetName, *zoneDefinition);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
#include "SequenceZoneDefinitionBuild.h"
|
||||||
|
|
||||||
|
#include "Parsing/ZoneDefinition/Matcher/ZoneDefinitionMatcherFactory.h"
|
||||||
|
|
||||||
|
SequenceZoneDefinitionBuild::SequenceZoneDefinitionBuild()
|
||||||
|
{
|
||||||
|
const ZoneDefinitionMatcherFactory create(this);
|
||||||
|
|
||||||
|
AddMatchers({
|
||||||
|
create.Keyword("build"),
|
||||||
|
create.Char(','),
|
||||||
|
create.Field().Capture(CAPTURE_BUILD_TARGET_NAME)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void SequenceZoneDefinitionBuild::ProcessMatch(ZoneDefinition* state, SequenceResult<ZoneDefinitionParserValue>& result) const
|
||||||
|
{
|
||||||
|
state->m_targets_to_build.emplace_back(result.NextCapture(CAPTURE_BUILD_TARGET_NAME).FieldValue());
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Parsing/ZoneDefinition/ZoneDefinitionParser.h"
|
||||||
|
|
||||||
|
class SequenceZoneDefinitionBuild final : public ZoneDefinitionParser::sequence_t
|
||||||
|
{
|
||||||
|
static constexpr auto CAPTURE_BUILD_TARGET_NAME = 1;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void ProcessMatch(ZoneDefinition* state, SequenceResult<ZoneDefinitionParserValue>& result) const override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SequenceZoneDefinitionBuild();
|
||||||
|
};
|
@ -1,6 +1,7 @@
|
|||||||
#include "ZoneDefinitionParser.h"
|
#include "ZoneDefinitionParser.h"
|
||||||
|
|
||||||
#include "Sequence/SequenceZoneDefinitionAssetList.h"
|
#include "Sequence/SequenceZoneDefinitionAssetList.h"
|
||||||
|
#include "Sequence/SequenceZoneDefinitionBuild.h"
|
||||||
#include "Sequence/SequenceZoneDefinitionEntry.h"
|
#include "Sequence/SequenceZoneDefinitionEntry.h"
|
||||||
#include "Sequence/SequenceZoneDefinitionIgnore.h"
|
#include "Sequence/SequenceZoneDefinitionIgnore.h"
|
||||||
#include "Sequence/SequenceZoneDefinitionInclude.h"
|
#include "Sequence/SequenceZoneDefinitionInclude.h"
|
||||||
@ -18,6 +19,7 @@ const std::vector<AbstractParser<ZoneDefinitionParserValue, ZoneDefinition>::seq
|
|||||||
new SequenceZoneDefinitionInclude(),
|
new SequenceZoneDefinitionInclude(),
|
||||||
new SequenceZoneDefinitionIgnore(),
|
new SequenceZoneDefinitionIgnore(),
|
||||||
new SequenceZoneDefinitionAssetList(),
|
new SequenceZoneDefinitionAssetList(),
|
||||||
|
new SequenceZoneDefinitionBuild(),
|
||||||
new SequenceZoneDefinitionEntry()
|
new SequenceZoneDefinitionEntry()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ public:
|
|||||||
std::vector<std::string> m_includes;
|
std::vector<std::string> m_includes;
|
||||||
std::vector<std::string> m_asset_lists;
|
std::vector<std::string> m_asset_lists;
|
||||||
std::vector<std::string> m_ignores;
|
std::vector<std::string> m_ignores;
|
||||||
|
std::vector<std::string> m_targets_to_build;
|
||||||
std::vector<ZoneDefinitionEntry> m_assets;
|
std::vector<ZoneDefinitionEntry> m_assets;
|
||||||
|
|
||||||
void AddMetaData(std::string key, std::string value);
|
void AddMetaData(std::string key, std::string value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user