mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
chore: use std format in linker
This commit is contained in:
parent
0e1f0eef7f
commit
e4beee3d7e
@ -59,10 +59,10 @@ constexpr const char* PROJECT_TYPE_NAMES[static_cast<unsigned>(ProjectType::MAX)
|
|||||||
|
|
||||||
class LinkerImpl final : public Linker
|
class LinkerImpl final : public Linker
|
||||||
{
|
{
|
||||||
static constexpr const char* METADATA_GAME = "game";
|
static constexpr auto METADATA_GAME = "game";
|
||||||
static constexpr const char* METADATA_GDT = "gdt";
|
static constexpr auto METADATA_GDT = "gdt";
|
||||||
static constexpr const char* METADATA_NAME = "name";
|
static constexpr auto METADATA_NAME = "name";
|
||||||
static constexpr const char* METADATA_TYPE = "type";
|
static constexpr auto METADATA_TYPE = "type";
|
||||||
|
|
||||||
LinkerArgs m_args;
|
LinkerArgs m_args;
|
||||||
LinkerSearchPaths m_search_paths;
|
LinkerSearchPaths m_search_paths;
|
||||||
@ -87,11 +87,11 @@ class LinkerImpl final : public Linker
|
|||||||
|
|
||||||
std::unique_ptr<ZoneDefinition> includeDefinition;
|
std::unique_ptr<ZoneDefinition> includeDefinition;
|
||||||
{
|
{
|
||||||
const auto definitionFileName = source + ".zone";
|
const auto definitionFileName = std::format("{}.zone", source);
|
||||||
const auto definitionStream = sourceSearchPath->Open(definitionFileName);
|
const auto definitionStream = sourceSearchPath->Open(definitionFileName);
|
||||||
if (!definitionStream.IsOpen())
|
if (!definitionStream.IsOpen())
|
||||||
{
|
{
|
||||||
std::cerr << "Could not find zone definition file for project \"" << source << "\".\n";
|
std::cerr << std::format("Could not find zone definition file for project \"{}\".\n", source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ class LinkerImpl final : public Linker
|
|||||||
|
|
||||||
if (!includeDefinition)
|
if (!includeDefinition)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to read zone definition file for project \"" << source << "\".\n";
|
std::cerr << std::format("Failed to read zone definition file for project \"{}\".\n", source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class LinkerImpl final : public Linker
|
|||||||
bool ReadAssetList(const std::string& zoneName, AssetList& assetList, ISearchPath* sourceSearchPath) const
|
bool ReadAssetList(const std::string& zoneName, AssetList& assetList, ISearchPath* sourceSearchPath) const
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
const auto assetListFileName = "assetlist/" + zoneName + ".csv";
|
const auto assetListFileName = std::format("assetlist/{}.csv", zoneName);
|
||||||
const auto assetListStream = sourceSearchPath->Open(assetListFileName);
|
const auto assetListStream = sourceSearchPath->Open(assetListFileName);
|
||||||
|
|
||||||
if (assetListStream.IsOpen())
|
if (assetListStream.IsOpen())
|
||||||
@ -159,7 +159,7 @@ class LinkerImpl final : public Linker
|
|||||||
AssetList assetList;
|
AssetList assetList;
|
||||||
if (!ReadAssetList(assetListName, assetList, sourceSearchPath))
|
if (!ReadAssetList(assetListName, assetList, sourceSearchPath))
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to read asset list \"" << assetListName << "\"\n";
|
std::cerr << std::format("Failed to read asset list \"{}\"\n", assetListName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ class LinkerImpl final : public Linker
|
|||||||
{
|
{
|
||||||
if (name != i->second->m_value)
|
if (name != i->second->m_value)
|
||||||
{
|
{
|
||||||
std::cerr << "Conflicting names in target \"" << targetName << "\": " << name << " != " << i->second << "\n";
|
std::cerr << std::format("Conflicting names in target \"{}\": {} != {}\n", targetName, name, i->second->m_value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ class LinkerImpl final : public Linker
|
|||||||
const auto definitionStream = sourceSearchPath->Open(definitionFileName);
|
const auto definitionStream = sourceSearchPath->Open(definitionFileName);
|
||||||
if (!definitionStream.IsOpen())
|
if (!definitionStream.IsOpen())
|
||||||
{
|
{
|
||||||
std::cerr << "Could not find zone definition file for target \"" << targetName << "\".\n";
|
std::cerr << std::format("Could not find zone definition file for target \"{}\".\n", targetName);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ class LinkerImpl final : public Linker
|
|||||||
|
|
||||||
if (!zoneDefinition)
|
if (!zoneDefinition)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to read zone definition file for target \"" << targetName << "\".\n";
|
std::cerr << std::format("Failed to read zone definition file for target \"{}\".\n", targetName);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ class LinkerImpl final : public Linker
|
|||||||
std::vector<AssetListEntry> assetList;
|
std::vector<AssetListEntry> assetList;
|
||||||
if (!ReadAssetList(ignore, context.m_ignored_assets, sourceSearchPath))
|
if (!ReadAssetList(ignore, context.m_ignored_assets, sourceSearchPath))
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to read asset listing for ignoring assets of project \"" << ignore << "\".\n";
|
std::cerr << std::format("Failed to read asset listing for ignoring assets of project \"{}\".\n", ignore);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,7 +279,7 @@ class LinkerImpl final : public Linker
|
|||||||
ProjectType parsedProjectType;
|
ProjectType parsedProjectType;
|
||||||
if (!ProjectTypeByName(parsedProjectType, i->second->m_value))
|
if (!ProjectTypeByName(parsedProjectType, i->second->m_value))
|
||||||
{
|
{
|
||||||
std::cerr << "Not a valid project type: \"" << i->second->m_value << "\"\n";
|
std::cerr << std::format("Not a valid project type: \"{}\"\n", i->second->m_value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,8 +292,10 @@ class LinkerImpl final : public Linker
|
|||||||
{
|
{
|
||||||
if (projectType != parsedProjectType)
|
if (projectType != parsedProjectType)
|
||||||
{
|
{
|
||||||
std::cerr << "Conflicting types in target \"" << targetName << "\": " << PROJECT_TYPE_NAMES[static_cast<unsigned>(projectType)]
|
std::cerr << std::format("Conflicting types in target \"{}\": {} != {}\n",
|
||||||
<< " != " << PROJECT_TYPE_NAMES[static_cast<unsigned>(parsedProjectType)] << "\n";
|
targetName,
|
||||||
|
PROJECT_TYPE_NAMES[static_cast<unsigned>(projectType)],
|
||||||
|
PROJECT_TYPE_NAMES[static_cast<unsigned>(parsedProjectType)]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,7 +327,7 @@ class LinkerImpl final : public Linker
|
|||||||
{
|
{
|
||||||
if (gameName != i->second->m_value)
|
if (gameName != i->second->m_value)
|
||||||
{
|
{
|
||||||
std::cerr << "Conflicting game names in target \"" << targetName << "\": " << gameName << " != " << i->second << "\n";
|
std::cerr << std::format("Conflicting game names in target \"{}\": {} != {}\n", targetName, gameName, i->second->m_value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,7 +335,7 @@ class LinkerImpl final : public Linker
|
|||||||
|
|
||||||
if (firstGameEntry)
|
if (firstGameEntry)
|
||||||
{
|
{
|
||||||
std::cerr << "No game name was specified for target \"" << targetName << "\"\n";
|
std::cerr << std::format("No game name was specified for target \"{}\"\n", targetName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +350,7 @@ class LinkerImpl final : public Linker
|
|||||||
const auto gdtFile = gdtSearchPath->Open(i->second->m_value + ".gdt");
|
const auto gdtFile = gdtSearchPath->Open(i->second->m_value + ".gdt");
|
||||||
if (!gdtFile.IsOpen())
|
if (!gdtFile.IsOpen())
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to open file for gdt \"" << i->second->m_value << "\"\n";
|
std::cerr << std::format("Failed to open file for gdt \"{}\"\n", i->second->m_value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +358,7 @@ class LinkerImpl final : public Linker
|
|||||||
auto gdt = std::make_unique<Gdt>();
|
auto gdt = std::make_unique<Gdt>();
|
||||||
if (!gdtReader.Read(*gdt))
|
if (!gdtReader.Read(*gdt))
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to read gdt file \"" << i->second << "\"\n";
|
std::cerr << std::format("Failed to read gdt file \"{}\"\n", i->second->m_value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,7 +412,7 @@ class LinkerImpl final : public Linker
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Created zone \"" << zoneFilePath.string() << "\"\n";
|
std::cout << std::format("Created zone \"{}\"\n", zoneFilePath.string());
|
||||||
|
|
||||||
stream.close();
|
stream.close();
|
||||||
return true;
|
return true;
|
||||||
@ -462,7 +464,7 @@ class LinkerImpl final : public Linker
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Created ipak \"" << ipakFilePath.string() << "\"\n";
|
std::cout << std::format("Created ipak \"{}\"\n", ipakFilePath.string());
|
||||||
|
|
||||||
stream.close();
|
stream.close();
|
||||||
return true;
|
return true;
|
||||||
@ -475,11 +477,11 @@ class LinkerImpl final : public Linker
|
|||||||
{
|
{
|
||||||
if (buildTargetName == targetName)
|
if (buildTargetName == targetName)
|
||||||
{
|
{
|
||||||
std::cerr << "Cannot build target with same name: \"" << targetName << "\"\n";
|
std::cerr << std::format("Cannot build target with same name: \"{}\"\n", targetName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Building referenced target \"" << buildTargetName << "\"\n";
|
std::cout << std::format("Building referenced target \"{}\"\n", buildTargetName);
|
||||||
return BuildProject(projectName, buildTargetName);
|
return BuildProject(projectName, buildTargetName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -537,7 +539,7 @@ class LinkerImpl final : public Linker
|
|||||||
{
|
{
|
||||||
if (!fs::is_regular_file(zonePath))
|
if (!fs::is_regular_file(zonePath))
|
||||||
{
|
{
|
||||||
std::cerr << "Could not find zone file to load \"" << zonePath << "\".\n";
|
std::cerr << std::format("Could not find zone file to load \"{}\".\n", zonePath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,13 +548,13 @@ class LinkerImpl final : public Linker
|
|||||||
auto zone = std::unique_ptr<Zone>(ZoneLoading::LoadZone(zonePath));
|
auto zone = std::unique_ptr<Zone>(ZoneLoading::LoadZone(zonePath));
|
||||||
if (zone == nullptr)
|
if (zone == nullptr)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to load zone \"" << zonePath << "\".\n";
|
std::cerr << std::format("Failed to load zone \"{}\".\n", zonePath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_args.m_verbose)
|
if (m_args.m_verbose)
|
||||||
{
|
{
|
||||||
std::cout << "Load zone \"" << zone->m_name << "\"\n";
|
std::cout << std::format("Load zone \"{}\"\n", zone->m_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_loaded_zones.emplace_back(std::move(zone));
|
m_loaded_zones.emplace_back(std::move(zone));
|
||||||
@ -571,7 +573,7 @@ class LinkerImpl final : public Linker
|
|||||||
loadedZone.reset();
|
loadedZone.reset();
|
||||||
|
|
||||||
if (m_args.m_verbose)
|
if (m_args.m_verbose)
|
||||||
std::cout << "Unloaded zone \"" << zoneName << "\"\n";
|
std::cout << std::format("Unloaded zone \"{}\"\n", zoneName);
|
||||||
}
|
}
|
||||||
m_loaded_zones.clear();
|
m_loaded_zones.clear();
|
||||||
}
|
}
|
||||||
@ -586,7 +588,7 @@ class LinkerImpl final : public Linker
|
|||||||
}
|
}
|
||||||
else if (projectSpecifier.find_first_of('/', targetNameSeparatorIndex + 1) != std::string::npos)
|
else if (projectSpecifier.find_first_of('/', targetNameSeparatorIndex + 1) != std::string::npos)
|
||||||
{
|
{
|
||||||
std::cerr << "Project specifier cannot have more than one target name: \"" << projectSpecifier << "\"\n";
|
std::cerr << std::format("Project specifier cannot have more than one target name: \"{}\"\n", projectSpecifier);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -597,13 +599,13 @@ class LinkerImpl final : public Linker
|
|||||||
|
|
||||||
if (projectName.empty())
|
if (projectName.empty())
|
||||||
{
|
{
|
||||||
std::cerr << "Project name cannot be empty: \"" << projectSpecifier << "\"\n";
|
std::cerr << std::format("Project name cannot be empty: \"{}\"\n", projectSpecifier);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetName.empty())
|
if (targetName.empty())
|
||||||
{
|
{
|
||||||
std::cerr << "Target name cannot be empty: \"" << projectSpecifier << "\"\n";
|
std::cerr << std::format("Target name cannot be empty: \"{}\"\n", projectSpecifier);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user