Introduce "none" project type

This commit is contained in:
Jan 2023-10-21 14:59:42 +02:00
parent 0b4a0ac070
commit 85b6c3f6bd

View File

@ -44,6 +44,7 @@ const IZoneCreator* const ZONE_CREATORS[]
enum class ProjectType enum class ProjectType
{ {
NONE,
FASTFILE, FASTFILE,
IPAK, IPAK,
@ -52,6 +53,7 @@ enum class ProjectType
constexpr const char* PROJECT_TYPE_NAMES[static_cast<unsigned>(ProjectType::MAX)] constexpr const char* PROJECT_TYPE_NAMES[static_cast<unsigned>(ProjectType::MAX)]
{ {
"none",
"fastfile", "fastfile",
"ipak" "ipak"
}; };
@ -271,7 +273,7 @@ class LinkerImpl final : public Linker
static bool GetProjectTypeFromZoneDefinition(ProjectType& projectType, const std::string& targetName, const ZoneDefinition& zoneDefinition) static bool GetProjectTypeFromZoneDefinition(ProjectType& projectType, const std::string& targetName, const ZoneDefinition& zoneDefinition)
{ {
auto firstGameEntry = true; auto firstTypeEntry = true;
const auto [rangeBegin, rangeEnd] = zoneDefinition.m_metadata_lookup.equal_range(METADATA_TYPE); const auto [rangeBegin, rangeEnd] = zoneDefinition.m_metadata_lookup.equal_range(METADATA_TYPE);
for (auto i = rangeBegin; i != rangeEnd; ++i) for (auto i = rangeBegin; i != rangeEnd; ++i)
{ {
@ -282,10 +284,10 @@ class LinkerImpl final : public Linker
return false; return false;
} }
if (firstGameEntry) if (firstTypeEntry)
{ {
projectType = parsedProjectType; projectType = parsedProjectType;
firstGameEntry = false; firstTypeEntry = false;
} }
else else
{ {
@ -298,8 +300,13 @@ class LinkerImpl final : public Linker
} }
} }
if (firstGameEntry) if (firstTypeEntry)
projectType = ProjectType::FASTFILE; {
if (zoneDefinition.m_assets.empty())
projectType = ProjectType::NONE;
else
projectType = ProjectType::FASTFILE;
}
return true; return true;
} }
@ -451,6 +458,11 @@ class LinkerImpl final : public Linker
return true; return true;
} }
bool BuildReferencedTargets(const std::string& projectName, const std::string& targetName, const ZoneDefinition& zoneDefinition) const
{
return true;
}
bool BuildProject(const std::string& projectName, const std::string& targetName) bool BuildProject(const std::string& projectName, const std::string& targetName)
{ {
auto sourceSearchPaths = m_search_paths.GetSourceSearchPathsForProject(projectName); auto sourceSearchPaths = m_search_paths.GetSourceSearchPathsForProject(projectName);
@ -463,30 +475,35 @@ class LinkerImpl final : public Linker
if (!GetProjectTypeFromZoneDefinition(projectType, targetName, *zoneDefinition)) if (!GetProjectTypeFromZoneDefinition(projectType, targetName, *zoneDefinition))
return false; return false;
std::string gameName;
if (!GetGameNameFromZoneDefinition(gameName, targetName, *zoneDefinition))
return false;
utils::MakeStringLowerCase(gameName);
auto assetSearchPaths = m_search_paths.GetAssetSearchPathsForProject(gameName, projectName);
auto gdtSearchPaths = m_search_paths.GetGdtSearchPathsForProject(gameName, projectName);
auto result = false; auto result = false;
switch (projectType) if (projectType != ProjectType::NONE)
{ {
case ProjectType::FASTFILE: std::string gameName;
result = BuildFastFile(projectName, targetName, *zoneDefinition, assetSearchPaths, gdtSearchPaths, sourceSearchPaths); if (!GetGameNameFromZoneDefinition(gameName, targetName, *zoneDefinition))
break; return false;
utils::MakeStringLowerCase(gameName);
case ProjectType::IPAK: auto assetSearchPaths = m_search_paths.GetAssetSearchPathsForProject(gameName, projectName);
result = BuildIPak(projectName, *zoneDefinition, assetSearchPaths); auto gdtSearchPaths = m_search_paths.GetGdtSearchPathsForProject(gameName, projectName);
break;
default: switch (projectType)
assert(false); {
break; case ProjectType::FASTFILE:
result = BuildFastFile(projectName, targetName, *zoneDefinition, assetSearchPaths, gdtSearchPaths, sourceSearchPaths);
break;
case ProjectType::IPAK:
result = BuildIPak(projectName, *zoneDefinition, assetSearchPaths);
break;
default:
assert(false);
break;
}
} }
result = result && BuildReferencedTargets(projectName, targetName, *zoneDefinition);
m_search_paths.UnloadProjectSpecificSearchPaths(); m_search_paths.UnloadProjectSpecificSearchPaths();
return result; return result;