diff --git a/src/Linker/Game/IW3/ZoneCreatorIW3.cpp b/src/Linker/Game/IW3/ZoneCreatorIW3.cpp index b43561564..23d230c2b 100644 --- a/src/Linker/Game/IW3/ZoneCreatorIW3.cpp +++ b/src/Linker/Game/IW3/ZoneCreatorIW3.cpp @@ -64,7 +64,7 @@ bool ZoneCreator::SupportsGame(const std::string& gameName) const std::unique_ptr ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const { - auto zone = std::make_unique(context.m_zone_name, 0, &g_GameIW3); + auto zone = std::make_unique(context.m_definition->m_name, 0, &g_GameIW3); CreateZoneAssetPools(zone.get()); for (const auto& assetEntry : context.m_definition->m_assets) diff --git a/src/Linker/Game/IW4/ZoneCreatorIW4.cpp b/src/Linker/Game/IW4/ZoneCreatorIW4.cpp index b14fe3086..3f1751684 100644 --- a/src/Linker/Game/IW4/ZoneCreatorIW4.cpp +++ b/src/Linker/Game/IW4/ZoneCreatorIW4.cpp @@ -63,7 +63,7 @@ bool ZoneCreator::SupportsGame(const std::string& gameName) const std::unique_ptr ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const { - auto zone = std::make_unique(context.m_zone_name, 0, &g_GameIW4); + auto zone = std::make_unique(context.m_definition->m_name, 0, &g_GameIW4); CreateZoneAssetPools(zone.get()); for (const auto& assetEntry : context.m_definition->m_assets) diff --git a/src/Linker/Game/IW5/ZoneCreatorIW5.cpp b/src/Linker/Game/IW5/ZoneCreatorIW5.cpp index 62e93ac87..9a1b1ac24 100644 --- a/src/Linker/Game/IW5/ZoneCreatorIW5.cpp +++ b/src/Linker/Game/IW5/ZoneCreatorIW5.cpp @@ -63,7 +63,7 @@ bool ZoneCreator::SupportsGame(const std::string& gameName) const std::unique_ptr ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const { - auto zone = std::make_unique(context.m_zone_name, 0, &g_GameIW5); + auto zone = std::make_unique(context.m_definition->m_name, 0, &g_GameIW5); CreateZoneAssetPools(zone.get()); for (const auto& assetEntry : context.m_definition->m_assets) diff --git a/src/Linker/Game/T5/ZoneCreatorT5.cpp b/src/Linker/Game/T5/ZoneCreatorT5.cpp index 2826f2580..7bd314781 100644 --- a/src/Linker/Game/T5/ZoneCreatorT5.cpp +++ b/src/Linker/Game/T5/ZoneCreatorT5.cpp @@ -64,7 +64,7 @@ bool ZoneCreator::SupportsGame(const std::string& gameName) const std::unique_ptr ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const { - auto zone = std::make_unique(context.m_zone_name, 0, &g_GameT5); + auto zone = std::make_unique(context.m_definition->m_name, 0, &g_GameT5); CreateZoneAssetPools(zone.get()); for (const auto& assetEntry : context.m_definition->m_assets) diff --git a/src/Linker/Game/T6/ZoneCreatorT6.cpp b/src/Linker/Game/T6/ZoneCreatorT6.cpp index 965d6f44b..90f5f14d8 100644 --- a/src/Linker/Game/T6/ZoneCreatorT6.cpp +++ b/src/Linker/Game/T6/ZoneCreatorT6.cpp @@ -118,7 +118,7 @@ bool ZoneCreator::SupportsGame(const std::string& gameName) const std::unique_ptr ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const { - auto zone = std::make_unique(context.m_zone_name, 0, &g_GameT6); + auto zone = std::make_unique(context.m_definition->m_name, 0, &g_GameT6); CreateZoneAssetPools(zone.get()); for (const auto& assetEntry : context.m_definition->m_assets) diff --git a/src/Linker/Linker.cpp b/src/Linker/Linker.cpp index 0f5e2a4de..511b881bf 100644 --- a/src/Linker/Linker.cpp +++ b/src/Linker/Linker.cpp @@ -42,11 +42,12 @@ const IZoneCreator* const ZONE_CREATORS[] class Linker::Impl { + static constexpr const char* METADATA_NAME = "name"; static constexpr const char* METADATA_GAME = "game"; static constexpr const char* METADATA_GDT = "gdt"; LinkerArgs m_args; - std::vector> m_loaded_zone_search_paths; + std::vector> m_loaded_project_search_paths; SearchPaths m_asset_search_paths; SearchPaths m_gdt_search_paths; SearchPaths m_source_search_paths; @@ -80,11 +81,11 @@ class Linker::Impl ObjLoading::UnloadIWDsInSearchPath(searchPath); } - SearchPaths GetAssetSearchPathsForZone(const std::string& gameName, const std::string& zoneName) + SearchPaths GetAssetSearchPathsForProject(const std::string& gameName, const std::string& projectName) { - SearchPaths searchPathsForZone; + SearchPaths searchPathsForProject; - for (const auto& searchPathStr : m_args.GetAssetSearchPathsForZone(gameName, zoneName)) + for (const auto& searchPathStr : m_args.GetAssetSearchPathsForProject(gameName, projectName)) { auto absolutePath = fs::absolute(searchPathStr); @@ -100,25 +101,25 @@ class Linker::Impl auto searchPath = std::make_unique(searchPathStr); LoadSearchPath(searchPath.get()); - searchPathsForZone.IncludeSearchPath(searchPath.get()); - m_loaded_zone_search_paths.emplace_back(std::move(searchPath)); + searchPathsForProject.IncludeSearchPath(searchPath.get()); + m_loaded_project_search_paths.emplace_back(std::move(searchPath)); } - searchPathsForZone.IncludeSearchPath(&m_asset_search_paths); + searchPathsForProject.IncludeSearchPath(&m_asset_search_paths); for (auto* iwd : IWD::Repository) { - searchPathsForZone.IncludeSearchPath(iwd); + searchPathsForProject.IncludeSearchPath(iwd); } - return searchPathsForZone; + return searchPathsForProject; } - SearchPaths GetGdtSearchPathsForZone(const std::string& gameName, const std::string& zoneName) + SearchPaths GetGdtSearchPathsForProject(const std::string& gameName, const std::string& projectName) { - SearchPaths searchPathsForZone; + SearchPaths searchPathsForProject; - for (const auto& searchPathStr : m_args.GetGdtSearchPathsForZone(gameName, zoneName)) + for (const auto& searchPathStr : m_args.GetGdtSearchPathsForProject(gameName, projectName)) { auto absolutePath = fs::absolute(searchPathStr); @@ -132,19 +133,19 @@ class Linker::Impl if (m_args.m_verbose) std::cout << "Adding gdt search path: " << absolutePath.string() << std::endl; - searchPathsForZone.CommitSearchPath(std::make_unique(searchPathStr)); + searchPathsForProject.CommitSearchPath(std::make_unique(searchPathStr)); } - searchPathsForZone.IncludeSearchPath(&m_gdt_search_paths); + searchPathsForProject.IncludeSearchPath(&m_gdt_search_paths); - return searchPathsForZone; + return searchPathsForProject; } - SearchPaths GetSourceSearchPathsForZone(const std::string& zoneName) + SearchPaths GetSourceSearchPathsForProject(const std::string& projectName) { - SearchPaths searchPathsForZone; + SearchPaths searchPathsForProject; - for (const auto& searchPathStr : m_args.GetSourceSearchPathsForZone(zoneName)) + for (const auto& searchPathStr : m_args.GetSourceSearchPathsForProject(projectName)) { auto absolutePath = fs::absolute(searchPathStr); @@ -158,21 +159,21 @@ class Linker::Impl if (m_args.m_verbose) std::cout << "Adding source search path: " << absolutePath.string() << std::endl; - searchPathsForZone.CommitSearchPath(std::make_unique(searchPathStr)); + searchPathsForProject.CommitSearchPath(std::make_unique(searchPathStr)); } - searchPathsForZone.IncludeSearchPath(&m_source_search_paths); + searchPathsForProject.IncludeSearchPath(&m_source_search_paths); - return searchPathsForZone; + return searchPathsForProject; } /** * \brief Initializes the Linker object's search paths based on the user's input. * \return \c true if building the search paths was successful, otherwise \c false. */ - bool BuildZoneIndependentSearchPaths() + bool BuildProjectIndependentSearchPaths() { - for (const auto& path : m_args.GetZoneIndependentAssetSearchPaths()) + for (const auto& path : m_args.GetProjectIndependentAssetSearchPaths()) { auto absolutePath = fs::absolute(path); @@ -191,7 +192,7 @@ class Linker::Impl m_asset_search_paths.CommitSearchPath(std::move(searchPath)); } - for (const auto& path : m_args.GetZoneIndependentGdtSearchPaths()) + for (const auto& path : m_args.GetProjectIndependentGdtSearchPaths()) { auto absolutePath = fs::absolute(path); @@ -208,7 +209,7 @@ class Linker::Impl m_gdt_search_paths.CommitSearchPath(std::make_unique(absolutePath.string())); } - for (const auto& path : m_args.GetZoneIndependentSourceSearchPaths()) + for (const auto& path : m_args.GetProjectIndependentSourceSearchPaths()) { auto absolutePath = fs::absolute(path); @@ -251,7 +252,7 @@ class Linker::Impl const auto definitionStream = sourceSearchPath->Open(definitionFileName); if (!definitionStream.IsOpen()) { - std::cout << "Could not find zone definition file for zone \"" << source << "\"." << std::endl; + std::cout << "Could not find zone definition file for project \"" << source << "\"." << std::endl; return false; } @@ -261,7 +262,7 @@ class Linker::Impl if (!includeDefinition) { - std::cout << "Failed to read zone definition file for zone \"" << source << "\"." << std::endl; + std::cout << "Failed to read zone definition file for project \"" << source << "\"." << std::endl; return false; } @@ -277,15 +278,42 @@ class Linker::Impl return true; } - std::unique_ptr ReadZoneDefinition(const std::string& zoneName, ISearchPath* sourceSearchPath) const + static bool GetNameFromZoneDefinition(std::string& name, const std::string& projectName, const ZoneDefinition& zoneDefinition) + { + auto firstNameEntry = true; + const auto [rangeBegin, rangeEnd] = zoneDefinition.m_metadata_lookup.equal_range(METADATA_NAME); + for (auto i = rangeBegin; i != rangeEnd; ++i) + { + if (firstNameEntry) + { + name = i->second->m_value; + firstNameEntry = false; + } + else + { + if (name != i->second->m_value) + { + std::cout << "Conflicting names in project \"" << projectName << "\": " << name << " != " << i->second << std::endl; + return false; + } + } + } + + if (firstNameEntry) + name = projectName; + + return true; + } + + std::unique_ptr ReadZoneDefinition(const std::string& projectName, ISearchPath* sourceSearchPath) const { std::unique_ptr zoneDefinition; { - const auto definitionFileName = zoneName + ".zone"; + const auto definitionFileName = projectName + ".zone"; const auto definitionStream = sourceSearchPath->Open(definitionFileName); if (!definitionStream.IsOpen()) { - std::cout << "Could not find zone definition file for zone \"" << zoneName << "\"." << std::endl; + std::cout << "Could not find zone definition file for project \"" << projectName << "\"." << std::endl; return nullptr; } @@ -295,11 +323,14 @@ class Linker::Impl if (!zoneDefinition) { - std::cout << "Failed to read zone definition file for zone \"" << zoneName << "\"." << std::endl; + std::cout << "Failed to read zone definition file for project \"" << projectName << "\"." << std::endl; return nullptr; } - if (!IncludeAdditionalZoneDefinitions(zoneName, *zoneDefinition, sourceSearchPath)) + if (!GetNameFromZoneDefinition(zoneDefinition->m_name, projectName, *zoneDefinition)) + return nullptr; + + if (!IncludeAdditionalZoneDefinitions(projectName, *zoneDefinition, sourceSearchPath)) return nullptr; return zoneDefinition; @@ -340,7 +371,7 @@ class Linker::Impl return false; } - bool ProcessZoneDefinitionIgnores(const std::string& zoneName, ZoneCreationContext& context, ISearchPath* sourceSearchPath) const + bool ProcessZoneDefinitionIgnores(const std::string& projectName, ZoneCreationContext& context, ISearchPath* sourceSearchPath) const { if (context.m_definition->m_ignores.empty()) return true; @@ -353,20 +384,20 @@ class Linker::Impl for (const auto& ignore : context.m_definition->m_ignores) { - if (ignore == zoneName) + if (ignore == projectName) continue; std::vector assetList; if (!ReadAssetList(ignore, context.m_ignored_assets, sourceSearchPath)) { - std::cout << "Failed to read asset listing for ignoring assets of zone \"" << ignore << "\"." << std::endl; + std::cout << "Failed to read asset listing for ignoring assets of project \"" << ignore << "\"." << std::endl; return false; } } return true; } - static bool GetGameNameFromZoneDefinition(std::string& gameName, const std::string& zoneName, const ZoneDefinition& zoneDefinition) + static bool GetGameNameFromZoneDefinition(std::string& gameName, const std::string& projectName, const ZoneDefinition& zoneDefinition) { auto firstGameEntry = true; const auto [rangeBegin, rangeEnd] = zoneDefinition.m_metadata_lookup.equal_range(METADATA_GAME); @@ -381,7 +412,7 @@ class Linker::Impl { if (gameName != i->second->m_value) { - std::cout << "Conflicting game names in zone \"" << zoneName << "\": " << gameName << " != " << i->second << std::endl; + std::cout << "Conflicting game names in project \"" << projectName << "\": " << gameName << " != " << i->second << std::endl; return false; } } @@ -389,14 +420,14 @@ class Linker::Impl if (firstGameEntry) { - std::cout << "No game name was specified for zone \"" << zoneName << "\"" << std::endl; + std::cout << "No game name was specified for project \"" << projectName << "\"" << std::endl; return false; } return true; } - static bool LoadGdtFilesFromZoneDefinition(std::vector>& gdtList, const std::string& zoneName, const ZoneDefinition& zoneDefinition, ISearchPath* gdtSearchPath) + static bool LoadGdtFilesFromZoneDefinition(std::vector>& gdtList, const ZoneDefinition& zoneDefinition, ISearchPath* gdtSearchPath) { const auto [rangeBegin, rangeEnd] = zoneDefinition.m_metadata_lookup.equal_range(METADATA_GDT); for (auto i = rangeBegin; i != rangeEnd; ++i) @@ -422,15 +453,15 @@ class Linker::Impl return true; } - std::unique_ptr CreateZoneForDefinition(const std::string& zoneName, ZoneDefinition& zoneDefinition, ISearchPath* assetSearchPath, ISearchPath* gdtSearchPath, + std::unique_ptr CreateZoneForDefinition(const std::string& projectName, ZoneDefinition& zoneDefinition, ISearchPath* assetSearchPath, ISearchPath* gdtSearchPath, ISearchPath* sourceSearchPath) const { - auto context = std::make_unique(zoneName, assetSearchPath, &zoneDefinition); - if (!ProcessZoneDefinitionIgnores(zoneName, *context, sourceSearchPath)) + const auto context = std::make_unique(assetSearchPath, &zoneDefinition); + if (!ProcessZoneDefinitionIgnores(projectName, *context, sourceSearchPath)) return nullptr; - if (!GetGameNameFromZoneDefinition(context->m_game_name, zoneName, zoneDefinition)) + if (!GetGameNameFromZoneDefinition(context->m_game_name, projectName, zoneDefinition)) return nullptr; - if (!LoadGdtFilesFromZoneDefinition(context->m_gdt_files, zoneName, zoneDefinition, gdtSearchPath)) + if (!LoadGdtFilesFromZoneDefinition(context->m_gdt_files, zoneDefinition, gdtSearchPath)) return nullptr; for (const auto* assetLoader : ZONE_CREATORS) @@ -442,9 +473,9 @@ class Linker::Impl return nullptr; } - bool WriteZoneToFile(Zone* zone) + bool WriteZoneToFile(const std::string& projectName, Zone* zone) const { - const fs::path zoneFolderPath(m_args.GetOutputFolderPathForZone(zone->m_name)); + const fs::path zoneFolderPath(m_args.GetOutputFolderPathForProject(projectName)); auto zoneFilePath(zoneFolderPath); zoneFilePath.append(zone->m_name + ".ff"); @@ -461,38 +492,40 @@ class Linker::Impl return false; } + std::cout << "Created zone \"" << zoneFilePath.string() << "\"\n"; + stream.close(); return true; } - bool BuildZone(const std::string& zoneName) + bool BuildProject(const std::string& projectName) { - auto sourceSearchPaths = GetSourceSearchPathsForZone(zoneName); + auto sourceSearchPaths = GetSourceSearchPathsForProject(projectName); - const auto zoneDefinition = ReadZoneDefinition(zoneName, &sourceSearchPaths); + const auto zoneDefinition = ReadZoneDefinition(projectName, &sourceSearchPaths); if (!zoneDefinition) return false; std::string gameName; - if (!GetGameNameFromZoneDefinition(gameName, zoneName, *zoneDefinition)) + if (!GetGameNameFromZoneDefinition(gameName, projectName, *zoneDefinition)) return false; for (auto& c : gameName) c = static_cast(std::tolower(c)); - auto assetSearchPaths = GetAssetSearchPathsForZone(gameName, zoneName); - auto gdtSearchPaths = GetGdtSearchPathsForZone(gameName, zoneName); + auto assetSearchPaths = GetAssetSearchPathsForProject(gameName, projectName); + auto gdtSearchPaths = GetGdtSearchPathsForProject(gameName, projectName); - const auto zone = CreateZoneForDefinition(zoneName, *zoneDefinition, &assetSearchPaths, &gdtSearchPaths, &sourceSearchPaths); + const auto zone = CreateZoneForDefinition(projectName, *zoneDefinition, &assetSearchPaths, &gdtSearchPaths, &sourceSearchPaths); auto result = zone != nullptr; if (zone) - result = WriteZoneToFile(zone.get()); + result = WriteZoneToFile(projectName, zone.get()); - for (const auto& loadedSearchPath : m_loaded_zone_search_paths) + for (const auto& loadedSearchPath : m_loaded_project_search_paths) { UnloadSearchPath(loadedSearchPath.get()); } - m_loaded_zone_search_paths.clear(); + m_loaded_project_search_paths.clear(); return result; } @@ -554,16 +587,16 @@ class Linker::Impl if (!m_args.ParseArgs(argc, argv)) return false; - if (!BuildZoneIndependentSearchPaths()) + if (!BuildProjectIndependentSearchPaths()) return false; if (!LoadZones()) return false; auto result = true; - for (const auto& zone : m_args.m_zones_to_build) + for (const auto& projectName : m_args.m_projects_to_build) { - if (!BuildZone(zone)) + if (!BuildProject(projectName)) { result = false; break; diff --git a/src/Linker/LinkerArgs.cpp b/src/Linker/LinkerArgs.cpp index b323db01d..83f52e8c1 100644 --- a/src/Linker/LinkerArgs.cpp +++ b/src/Linker/LinkerArgs.cpp @@ -36,7 +36,7 @@ const CommandLineOption* const OPTION_BASE_FOLDER = const CommandLineOption* const OPTION_OUTPUT_FOLDER = CommandLineOption::Builder::Create() .WithLongName("output-folder") - .WithDescription("Specifies the output folder containing the contents of the unlinked zones. Defaults to \"" + std::string(LinkerArgs::DEFAULT_OUTPUT_FOLDER) + "\".") + .WithDescription("Specifies the output folder containing the build artifacts. Defaults to \"" + std::string(LinkerArgs::DEFAULT_OUTPUT_FOLDER) + "\".") .WithParameter("outputFolderPath") .Build(); @@ -100,9 +100,9 @@ LinkerArgs::LinkerArgs() : m_argument_parser(COMMAND_LINE_OPTIONS, std::extent::value), m_base_pattern(R"(\?base\?)"), m_game_pattern(R"(\?game\?)"), - m_zone_pattern(R"(\?zone\?)"), - m_base_folder_depends_on_zone(false), - m_out_folder_depends_on_zone(false), + m_project_pattern(R"(\?project\?)"), + m_base_folder_depends_on_project(false), + m_out_folder_depends_on_project(false), m_verbose(false) { } @@ -116,7 +116,7 @@ void LinkerArgs::PrintUsage() usage.AddCommandLineOption(commandLineOption); } - usage.AddArgument("zoneName"); + usage.AddArgument("projectName"); usage.SetVariableArguments(true); usage.Print(); @@ -129,9 +129,9 @@ void LinkerArgs::SetVerbose(const bool isVerbose) ObjWriting::Configuration.Verbose = isVerbose; } -std::string LinkerArgs::GetBasePathForZone(const std::string& zoneName) const +std::string LinkerArgs::GetBasePathForProject(const std::string& projectName) const { - return std::regex_replace(m_base_folder, m_zone_pattern, zoneName); + return std::regex_replace(m_base_folder, m_project_pattern, projectName); } void LinkerArgs::SetDefaultBasePath() @@ -148,7 +148,7 @@ void LinkerArgs::SetDefaultBasePath() } } -std::set LinkerArgs::GetZoneIndependentSearchPaths(const std::set& set) const +std::set LinkerArgs::GetProjectIndependentSearchPaths(const std::set& set) const { std::set out; @@ -156,12 +156,12 @@ std::set LinkerArgs::GetZoneIndependentSearchPaths(const std::set LinkerArgs::GetZoneIndependentSearchPaths(const std::set LinkerArgs::GetSearchPathsForZone(const std::set& set, const std::string& gameName, const std::string& zoneName) const +std::set LinkerArgs::GetSearchPathsForProject(const std::set& set, const std::string& gameName, const std::string& projectName) const { std::set out; - const auto basePath = GetBasePathForZone(zoneName); + const auto basePath = GetBasePathForProject(projectName); for (const auto& path : set) { if (path.find(PATTERN_GAME) == std::string::npos - && path.find(PATTERN_ZONE) == std::string::npos - && (!m_base_folder_depends_on_zone || path.find(PATTERN_BASE) == std::string::npos)) + && path.find(PATTERN_PROJECT) == std::string::npos + && (!m_base_folder_depends_on_project || path.find(PATTERN_BASE) == std::string::npos)) { continue; } - out.emplace(std::regex_replace(std::regex_replace(std::regex_replace(path, m_zone_pattern, zoneName), m_game_pattern, gameName), m_base_pattern, basePath)); + out.emplace(std::regex_replace(std::regex_replace(std::regex_replace(path, m_project_pattern, projectName), m_game_pattern, gameName), m_base_pattern, basePath)); } return out; @@ -210,10 +210,10 @@ bool LinkerArgs::ParseArgs(const int argc, const char** argv) return false; } - m_zones_to_build = m_argument_parser.GetArguments(); - if (m_zones_to_build.empty()) + m_projects_to_build = m_argument_parser.GetArguments(); + if (m_projects_to_build.empty()) { - // No zones to build specified... + // No projects to build specified... PrintUsage(); return false; } @@ -226,14 +226,14 @@ bool LinkerArgs::ParseArgs(const int argc, const char** argv) m_base_folder = m_argument_parser.GetValueForOption(OPTION_BASE_FOLDER); else SetDefaultBasePath(); - m_base_folder_depends_on_zone = m_base_folder.find(PATTERN_GAME) != std::string::npos || m_base_folder.find(PATTERN_ZONE) != std::string::npos; + m_base_folder_depends_on_project = m_base_folder.find(PATTERN_GAME) != std::string::npos || m_base_folder.find(PATTERN_PROJECT) != std::string::npos; // --output-folder if (m_argument_parser.IsOptionSpecified(OPTION_OUTPUT_FOLDER)) m_out_folder = m_argument_parser.GetValueForOption(OPTION_OUTPUT_FOLDER); else m_out_folder = DEFAULT_OUTPUT_FOLDER; - m_out_folder_depends_on_zone = m_out_folder.find(PATTERN_ZONE) != std::string::npos; + m_out_folder_depends_on_project = m_out_folder.find(PATTERN_PROJECT) != std::string::npos; // --asset-search-path if (m_argument_parser.IsOptionSpecified(OPTION_ASSET_SEARCH_PATH)) @@ -286,37 +286,37 @@ bool LinkerArgs::ParseArgs(const int argc, const char** argv) return true; } -std::string LinkerArgs::GetOutputFolderPathForZone(const std::string& zoneName) const +std::string LinkerArgs::GetOutputFolderPathForProject(const std::string& projectName) const { - return std::regex_replace(std::regex_replace(m_out_folder, m_zone_pattern, zoneName), m_base_pattern, GetBasePathForZone(zoneName)); + return std::regex_replace(std::regex_replace(m_out_folder, m_project_pattern, projectName), m_base_pattern, GetBasePathForProject(projectName)); } -std::set LinkerArgs::GetZoneIndependentAssetSearchPaths() const +std::set LinkerArgs::GetProjectIndependentAssetSearchPaths() const { - return GetZoneIndependentSearchPaths(m_asset_search_paths); + return GetProjectIndependentSearchPaths(m_asset_search_paths); } -std::set LinkerArgs::GetZoneIndependentGdtSearchPaths() const +std::set LinkerArgs::GetProjectIndependentGdtSearchPaths() const { - return GetZoneIndependentSearchPaths(m_gdt_search_paths); + return GetProjectIndependentSearchPaths(m_gdt_search_paths); } -std::set LinkerArgs::GetZoneIndependentSourceSearchPaths() const +std::set LinkerArgs::GetProjectIndependentSourceSearchPaths() const { - return GetZoneIndependentSearchPaths(m_source_search_paths); + return GetProjectIndependentSearchPaths(m_source_search_paths); } -std::set LinkerArgs::GetAssetSearchPathsForZone(const std::string& gameName, const std::string& zoneName) const +std::set LinkerArgs::GetAssetSearchPathsForProject(const std::string& gameName, const std::string& projectName) const { - return GetSearchPathsForZone(m_asset_search_paths, gameName, zoneName); + return GetSearchPathsForProject(m_asset_search_paths, gameName, projectName); } -std::set LinkerArgs::GetGdtSearchPathsForZone(const std::string& gameName, const std::string& zoneName) const +std::set LinkerArgs::GetGdtSearchPathsForProject(const std::string& gameName, const std::string& projectName) const { - return GetSearchPathsForZone(m_gdt_search_paths, gameName, zoneName); + return GetSearchPathsForProject(m_gdt_search_paths, gameName, projectName); } -std::set LinkerArgs::GetSourceSearchPathsForZone(const std::string& zoneName) const +std::set LinkerArgs::GetSourceSearchPathsForProject(const std::string& projectName) const { - return GetSearchPathsForZone(m_source_search_paths, "", zoneName); + return GetSearchPathsForProject(m_source_search_paths, "", projectName); } diff --git a/src/Linker/LinkerArgs.h b/src/Linker/LinkerArgs.h index 1b7789d9e..6247724ee 100644 --- a/src/Linker/LinkerArgs.h +++ b/src/Linker/LinkerArgs.h @@ -12,20 +12,20 @@ class LinkerArgs public: static constexpr const char* PATTERN_BASE = "?base?"; static constexpr const char* PATTERN_GAME = "?game?"; - static constexpr const char* PATTERN_ZONE = "?zone?"; + static constexpr const char* PATTERN_PROJECT = "?project?"; static constexpr const char* DEFAULT_BASE_FOLDER = "."; static constexpr const char* DEFAULT_BASE_FOLDER_MOD_TOOLS = ".."; - static constexpr const char* DEFAULT_OUTPUT_FOLDER = "?base?/zone_out/?zone?"; - static constexpr const char* DEFAULT_ASSET_SEARCH_PATH = "?base?/raw;?base?/raw/?game?;?base?/zone_raw/?zone?"; - static constexpr const char* DEFAULT_GDT_SEARCH_PATH = "?base?/source_data;?base?/zone_raw/?zone?/source_data"; - static constexpr const char* DEFAULT_SOURCE_SEARCH_PATH = "?base?/zone_source;?base?/zone_raw/?zone?/zone_source"; + static constexpr const char* DEFAULT_OUTPUT_FOLDER = "?base?/zone_out/?project?"; + static constexpr const char* DEFAULT_ASSET_SEARCH_PATH = "?base?/raw;?base?/raw/?game?;?base?/zone_raw/?project?"; + static constexpr const char* DEFAULT_GDT_SEARCH_PATH = "?base?/source_data;?base?/zone_raw/?project?/source_data"; + static constexpr const char* DEFAULT_SOURCE_SEARCH_PATH = "?base?/zone_source;?base?/zone_raw/?project?/zone_source"; private: ArgumentParser m_argument_parser; std::regex m_base_pattern; std::regex m_game_pattern; - std::regex m_zone_pattern; + std::regex m_project_pattern; /** * \brief Prints a command line usage help text for the Linker tool to stdout. @@ -34,19 +34,19 @@ class LinkerArgs void SetVerbose(bool isVerbose); - _NODISCARD std::string GetBasePathForZone(const std::string& zoneName) const; + _NODISCARD std::string GetBasePathForProject(const std::string& projectName) const; void SetDefaultBasePath(); - _NODISCARD std::set GetZoneIndependentSearchPaths(const std::set& set) const; - _NODISCARD std::set GetSearchPathsForZone(const std::set& set, const std::string& gameName, const std::string& zoneName) const; + _NODISCARD std::set GetProjectIndependentSearchPaths(const std::set& set) const; + _NODISCARD std::set GetSearchPathsForProject(const std::set& set, const std::string& gameName, const std::string& projectName) const; public: std::vector m_zones_to_load; - std::vector m_zones_to_build; + std::vector m_projects_to_build; std::string m_base_folder; std::string m_out_folder; - bool m_base_folder_depends_on_zone; - bool m_out_folder_depends_on_zone; + bool m_base_folder_depends_on_project; + bool m_out_folder_depends_on_project; std::set m_asset_search_paths; std::set m_gdt_search_paths; @@ -58,17 +58,17 @@ class LinkerArgs bool ParseArgs(int argc, const char** argv); /** - * \brief Converts the output path specified by command line arguments to a path applies for the specified zone. - * \param zoneName The name of the zone to resolve the path input for. - * \return An output path for the zone based on the user input. + * \brief Converts the output path specified by command line arguments to a path applies for the specified project. + * \param projectName The name of the project to resolve the path input for. + * \return An output path for the project based on the user input. */ - _NODISCARD std::string GetOutputFolderPathForZone(const std::string& zoneName) const; + _NODISCARD std::string GetOutputFolderPathForProject(const std::string& projectName) const; - _NODISCARD std::set GetZoneIndependentAssetSearchPaths() const; - _NODISCARD std::set GetZoneIndependentGdtSearchPaths() const; - _NODISCARD std::set GetZoneIndependentSourceSearchPaths() const; + _NODISCARD std::set GetProjectIndependentAssetSearchPaths() const; + _NODISCARD std::set GetProjectIndependentGdtSearchPaths() const; + _NODISCARD std::set GetProjectIndependentSourceSearchPaths() const; - _NODISCARD std::set GetAssetSearchPathsForZone(const std::string& gameName, const std::string& zoneName) const; - _NODISCARD std::set GetGdtSearchPathsForZone(const std::string& gameName, const std::string& zoneName) const; - _NODISCARD std::set GetSourceSearchPathsForZone(const std::string& zoneName) const; + _NODISCARD std::set GetAssetSearchPathsForProject(const std::string& gameName, const std::string& projectName) const; + _NODISCARD std::set GetGdtSearchPathsForProject(const std::string& gameName, const std::string& projectName) const; + _NODISCARD std::set GetSourceSearchPathsForProject(const std::string& projectName) const; }; diff --git a/src/Linker/ZoneCreation/ZoneCreationContext.cpp b/src/Linker/ZoneCreation/ZoneCreationContext.cpp index d63a82be1..481816943 100644 --- a/src/Linker/ZoneCreation/ZoneCreationContext.cpp +++ b/src/Linker/ZoneCreation/ZoneCreationContext.cpp @@ -6,9 +6,8 @@ ZoneCreationContext::ZoneCreationContext() { } -ZoneCreationContext::ZoneCreationContext(std::string zoneName, ISearchPath* assetSearchPath, ZoneDefinition* definition) - : m_zone_name(std::move(zoneName)), - m_asset_search_path(assetSearchPath), +ZoneCreationContext::ZoneCreationContext(ISearchPath* assetSearchPath, ZoneDefinition* definition) + : m_asset_search_path(assetSearchPath), m_definition(definition) { } diff --git a/src/Linker/ZoneCreation/ZoneCreationContext.h b/src/Linker/ZoneCreation/ZoneCreationContext.h index d03ccbde6..2db20e1d4 100644 --- a/src/Linker/ZoneCreation/ZoneCreationContext.h +++ b/src/Linker/ZoneCreation/ZoneCreationContext.h @@ -12,7 +12,6 @@ class ZoneCreationContext { public: - std::string m_zone_name; std::string m_game_name; ISearchPath* m_asset_search_path; ZoneDefinition* m_definition; @@ -20,5 +19,5 @@ class ZoneCreationContext std::vector m_ignored_assets; ZoneCreationContext(); - ZoneCreationContext(std::string zoneName, ISearchPath* assetSearchPath, ZoneDefinition* definition); + ZoneCreationContext(ISearchPath* assetSearchPath, ZoneDefinition* definition); }; diff --git a/src/ZoneCommon/Zone/Definition/ZoneDefinition.h b/src/ZoneCommon/Zone/Definition/ZoneDefinition.h index ee6ccdeab..2a093f8dc 100644 --- a/src/ZoneCommon/Zone/Definition/ZoneDefinition.h +++ b/src/ZoneCommon/Zone/Definition/ZoneDefinition.h @@ -29,6 +29,7 @@ class ZoneMetaDataEntry class ZoneDefinition { public: + std::string m_name; std::vector> m_metadata; std::unordered_multimap m_metadata_lookup; std::vector m_includes;