Integrating github/staging through commit ab87ed9
This commit is contained in:
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "ResourceCompiler_precompiled.h"
|
||||
#include "CmdLine.h"
|
||||
#include "Config.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static void AddParameterToConfig(Config* config, const char* parameter)
|
||||
{
|
||||
// Split on key/value pair
|
||||
const string p = parameter;
|
||||
const size_t splitterPos = p.find('=');
|
||||
if (splitterPos != string::npos)
|
||||
{
|
||||
const string key = p.substr(0, splitterPos);
|
||||
const string value = p.substr(splitterPos + 1);
|
||||
if (!key.empty())
|
||||
{
|
||||
config->SetKeyValue(eCP_PriorityCmdline, key.c_str(), value.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
config->SetKeyValue(eCP_PriorityCmdline, p.c_str(), "");
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//Return true if the parameter is a file spec
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
static bool isValidFileSpecCheck(const string& path)
|
||||
{
|
||||
if (path[0] == '-')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Since Macs can have '/' in the file paths check for '='
|
||||
//to confirm that it is a file spec and not a config argument.
|
||||
if (path[0] == '/')
|
||||
{
|
||||
const size_t equalPos = path.find('=');
|
||||
if (equalPos != string::npos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//You can have a config argument that does not have a '='. Use
|
||||
//extension path to determine if it is a file spec.
|
||||
return PathHelpers::FindExtension(path) != "";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CmdLine::Parse(const std::vector<string>& args, Config* config, string& fileSpec)
|
||||
{
|
||||
assert(config);
|
||||
|
||||
fileSpec.clear();
|
||||
|
||||
for (int i = 1; i < (int)args.size(); ++i)
|
||||
{
|
||||
const char* const parameter = args[i].c_str();
|
||||
|
||||
bool isValidFileSpec = isValidFileSpecCheck(string(parameter));
|
||||
|
||||
if (isValidFileSpec)
|
||||
{
|
||||
if (fileSpec.empty())
|
||||
{
|
||||
fileSpec = parameter;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddParameterToConfig(config, parameter + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_TOOLS_RC_RESOURCECOMPILER_CMDLINE_H
|
||||
#define CRYINCLUDE_TOOLS_RC_RESOURCECOMPILER_CMDLINE_H
|
||||
#pragma once
|
||||
|
||||
class Config;
|
||||
|
||||
// Command line parser
|
||||
namespace CmdLine
|
||||
{
|
||||
void Parse(const std::vector<string>& args, Config* config, string& fileSpec);
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_TOOLS_RC_RESOURCECOMPILER_CMDLINE_H
|
||||
@@ -1294,7 +1294,7 @@ void ResourceCompiler::LogMultiLine(const char* szText)
|
||||
void ResourceCompiler::ShowHelp(const bool bDetailed)
|
||||
{
|
||||
RCLog("");
|
||||
RCLog("Usage: RC filespec /p=<platform> [/Key1=Value1] [/Key2=Value2] etc...");
|
||||
RCLog("Usage: RC filespec --platform=<platform> [--Key1=Value1] [--Key2=Value2] etc...");
|
||||
|
||||
if (bDetailed)
|
||||
{
|
||||
@@ -2372,8 +2372,6 @@ typedef std::set<const char*, stl::less_strcmp<const char*> > References;
|
||||
|
||||
void ResourceCompiler::ScanForAssetReferences(std::vector<string>& outReferences, const string& refsRoot)
|
||||
{
|
||||
const IConfig* const config = &m_multiConfig.getConfig();
|
||||
|
||||
const char* const scanRoot = ".";
|
||||
|
||||
RCLog("Scanning for asset references in \"%s\"", scanRoot);
|
||||
@@ -2526,8 +2524,6 @@ static bool MatchesWildcardsSet(const string& str, const std::vector<string>& ma
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ResourceCompiler::SaveAssetReferences(const std::vector<string>& references, const string& filename, const string& includeMasksStr, const string& excludeMasksStr)
|
||||
{
|
||||
const IConfig* const config = &m_multiConfig.getConfig();
|
||||
|
||||
std::vector<string> includeMasks;
|
||||
StringHelpers::Split(includeMasksStr, ";", false, includeMasks);
|
||||
|
||||
@@ -2868,8 +2864,6 @@ int ResourceCompiler::ProcessJobFile()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ResourceCompiler::ExtractJobDefaultProperties(std::vector<string>& properties, const XmlNodeRef& jobNode)
|
||||
{
|
||||
IConfig* const config = &m_multiConfig.getConfig();
|
||||
|
||||
if (jobNode->isTag("DefaultProperties"))
|
||||
{
|
||||
// Attributes are config modifiers.
|
||||
@@ -3109,12 +3103,12 @@ int ResourceCompiler::EvaluateJobXmlNode(CPropertyVars& properties, XmlNodeRef&
|
||||
// Check current platform property against start-up platform setting
|
||||
// Reason: This setting cannot be modified after start-up
|
||||
const char* pCurrentPlatform = NULL;
|
||||
if (config->GetKeyValue("p", pCurrentPlatform) && pCurrentPlatform)
|
||||
if (config->GetKeyValue("platform", pCurrentPlatform) && pCurrentPlatform)
|
||||
{
|
||||
int currentPlatformIndex = FindPlatform(pCurrentPlatform);
|
||||
if (GetMultiplatformConfig().getActivePlatform() != currentPlatformIndex)
|
||||
{
|
||||
RCLogWarning("The platform property '/p=%s' is ignored because it can only be specified on the command-line", pCurrentPlatform);
|
||||
RCLogWarning("The platform property '--platform=%s' is ignored because it can only be specified on the command-line", pCurrentPlatform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3257,6 +3251,8 @@ void ResourceCompiler::RegisterDefaultKeys()
|
||||
{
|
||||
RegisterKey("_debug", ""); // hidden key for debug-related activities. parsing is module-dependent and subject to change without prior notice.
|
||||
|
||||
RegisterKey("project-path", "Path to project. Used to find files related to the project.");
|
||||
RegisterKey("project-name", R"(Name of the project. It's value is derived from the project.json file "project_name" field.)");
|
||||
RegisterKey("wait",
|
||||
"wait for an user action on start and/or finish of RC:\n"
|
||||
"0-don't wait (default),\n"
|
||||
@@ -3267,7 +3263,7 @@ void ResourceCompiler::RegisterDefaultKeys()
|
||||
RegisterKey("wx", "pause and display message box in case of warning or error");
|
||||
RegisterKey("recursive", "traverse input directory with sub folders");
|
||||
RegisterKey("refresh", "force recompilation of resources with up to date timestamp");
|
||||
RegisterKey("p", "to specify platform (for supported names see [_platform] sections in ini)");
|
||||
RegisterKey("platform", "to specify platform (for supported names see [_platform] sections in ini)");
|
||||
RegisterKey("pi", "provides the platform id from the Asset Processor");
|
||||
RegisterKey("statistics", "log statistics to rc_stats_* files");
|
||||
RegisterKey("dependencies",
|
||||
@@ -3281,7 +3277,6 @@ void ResourceCompiler::RegisterDefaultKeys()
|
||||
RegisterKey("logfiles", "to suppress generating log file rc_log.log");
|
||||
RegisterKey("logprefix", "prepends this prefix to every log file name used (by default the prefix is the exe's folder).");
|
||||
RegisterKey("logtime", "logs time passed: 0=off, 1=on (default)");
|
||||
RegisterKey("gameroot", "The root of the current game project. Used to find files related to the current game.");
|
||||
RegisterKey("watchfolder", "The watched root folder that this file is located in. Used to produce the relative asset name.");
|
||||
RegisterKey("nosourcecontrol", "Boolean - if true, disables initialization of source control. Disabling Source Control in the editor automatically disables it here, too.");
|
||||
RegisterKey("sourceroot", "list of source folders separated by semicolon");
|
||||
@@ -3334,7 +3329,6 @@ void ResourceCompiler::RegisterDefaultKeys()
|
||||
RegisterKey("job", "Process a job xml file");
|
||||
RegisterKey("jobtarget", "Run only a job with specific name instead of whole job-file. Used only with /job option");
|
||||
RegisterKey("unittest", "Run the unit tests for resource compiler and nothing else");
|
||||
RegisterKey("gamesubdirectory", "The relative path to game folder from root from @devroot@. Defines @devassets@ when concatenated with @devroot@. Used to find files related to the this game.");
|
||||
RegisterKey("unattended", "Prevents RC from opening any dialogs or message boxes");
|
||||
RegisterKey("createjobs", "Instructs RC to read the specified input file (a CreateJobsRequest) and output a CreateJobsResponse");
|
||||
RegisterKey("port", "Specifies the port that should be used to connect to the asset processor. If not set, the default from the bootstrap cfg will be used instead");
|
||||
|
||||
@@ -204,9 +204,6 @@ bool ZipEncryptor::ParseKey(uint32 outputKey[4], const char* inputString)
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* p = inputString;
|
||||
const char* end = p + len;
|
||||
|
||||
size_t i = 0;
|
||||
while (i != numBytes)
|
||||
{
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
|
||||
#include <ResourceCompiler.h>
|
||||
#include <IResourceCompilerHelper.h>
|
||||
#include <CmdLine.h>
|
||||
#include <CryLibrary.h>
|
||||
#include <ZipEncryptor.h>
|
||||
|
||||
@@ -295,7 +294,7 @@ static bool RegisterConvertors(ResourceCompiler* pRc)
|
||||
strDir.append(AZ_CORRECT_FILESYSTEM_SEPARATOR_STRING);
|
||||
|
||||
AZ::IO::LocalFileIO localFile;
|
||||
bool foundOK = localFile.FindFiles(strDir.c_str(), CryLibraryDefName("ResourceCompiler*"), [&](const char* pluginFilename) -> bool
|
||||
localFile.FindFiles(strDir.c_str(), CryLibraryDefName("ResourceCompiler*"), [&](const char* pluginFilename) -> bool
|
||||
{
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
HMODULE hPlugin = CryLoadLibrary(pluginFilename);
|
||||
@@ -413,7 +412,21 @@ int rcmain(int argc, char** argv, [[maybe_unused]] char** envp)
|
||||
bool enableSourceControl = settings.value("RC_EnableSourceControl", true).toBool();
|
||||
mainConfig.SetKeyValue(eCP_PriorityCmdline, "nosourcecontrol", enableSourceControl ? "0" : "1");
|
||||
|
||||
CmdLine::Parse(args, &mainConfig, fileSpec);
|
||||
AZ::CommandLine commandLine;
|
||||
commandLine.Parse(argc, argv);
|
||||
|
||||
for (auto&& [option, value] : commandLine)
|
||||
{
|
||||
if (!option.empty())
|
||||
{
|
||||
mainConfig.SetKeyValue(EConfigPriority::eCP_PriorityCmdline, option.c_str(), value.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
fileSpec = commandLine.GetMiscValue(0).c_str();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// initialize rc (also initializes logs)
|
||||
rc.Init(mainConfig);
|
||||
@@ -518,16 +531,20 @@ int rcmain(int argc, char** argv, [[maybe_unused]] char** envp)
|
||||
// Obtain target platform
|
||||
int platform;
|
||||
{
|
||||
string platformStr = mainConfig.GetAsString("p", "", "");
|
||||
string platformStr = mainConfig.GetAsString("platform", "", "");
|
||||
if (platformStr.empty())
|
||||
{
|
||||
platformStr = mainConfig.GetAsString("p", "", "");
|
||||
}
|
||||
if (platformStr.empty())
|
||||
{
|
||||
if (!mainConfig.GetAsBool("version", false, true))
|
||||
{
|
||||
RCLog("Platform (/p) not specified, defaulting to 'pc'.");
|
||||
RCLog("Platform (-p) not specified, defaulting to 'pc'.");
|
||||
RCLog("");
|
||||
}
|
||||
platformStr = "pc";
|
||||
mainConfig.SetKeyValue(eCP_PriorityCmdline, "p", platformStr.c_str());
|
||||
mainConfig.SetKeyValue(eCP_PriorityCmdline, "platform", platformStr.c_str());
|
||||
}
|
||||
|
||||
platform = rc.FindPlatform(platformStr.c_str());
|
||||
@@ -548,7 +565,7 @@ int rcmain(int argc, char** argv, [[maybe_unused]] char** envp)
|
||||
}
|
||||
}
|
||||
|
||||
const IConfig& config = rc.GetMultiplatformConfig().getConfig();
|
||||
IConfig& config = rc.GetMultiplatformConfig().getConfig();
|
||||
|
||||
{
|
||||
RCLog("Initializing pak management");
|
||||
@@ -567,23 +584,28 @@ int rcmain(int argc, char** argv, [[maybe_unused]] char** envp)
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_O3deUserRegistry(settingsRegistry, AZ_TRAIT_OS_PLATFORM_CODENAME, {});
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(settingsRegistry, commandLine, false);
|
||||
|
||||
string projectPath = config.GetAsString("gameroot", "", "");
|
||||
const auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString::format(
|
||||
"%s/project_path", AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey);
|
||||
string projectPath = config.GetAsString("project-path", "", "");
|
||||
if (!projectPath.empty())
|
||||
{
|
||||
const auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString::format(
|
||||
"%s/project_path", AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey);
|
||||
settingsRegistry.Set(projectPathKey, projectPath.c_str());
|
||||
}
|
||||
|
||||
string gameName = config.GetAsString("gamesubdirectory", "", "");
|
||||
if (!gameName.empty())
|
||||
// Update the Runtime FilePaths and project settings
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(settingsRegistry);
|
||||
// Set the project-path and project-name entries from the Settings registry into the RC config structure
|
||||
if (AZ::IO::FixedMaxPathString projPath; settingsRegistry.Get(projPath, AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath))
|
||||
{
|
||||
const auto projectNameKey = AZ::SettingsRegistryInterface::FixedValueString::format(
|
||||
"%s/project_name", AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey);
|
||||
settingsRegistry.Set(projectNameKey, gameName.c_str());
|
||||
config.SetKeyValue(eCP_PriorityCmdline, "project-path", projPath.c_str());
|
||||
}
|
||||
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(settingsRegistry);
|
||||
const auto projectNameKey = AZ::SettingsRegistryInterface::FixedValueString::format(
|
||||
"%s/project_name", AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey);
|
||||
if (AZ::IO::FixedMaxPathString projName; settingsRegistry.Get(projName, projectNameKey))
|
||||
{
|
||||
config.SetKeyValue(eCP_PriorityCmdline, "project-name", projName.c_str());
|
||||
}
|
||||
// and because we're a tool, add the tool folders:
|
||||
if (AZ::SettingsRegistryInterface::FixedValueString appRoot; settingsRegistry.Get(appRoot, AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder))
|
||||
{
|
||||
|
||||
@@ -28,7 +28,6 @@ set(FILES
|
||||
PakHelpers.h
|
||||
PakManager.h
|
||||
CfgFile.cpp
|
||||
CmdLine.cpp
|
||||
Config.cpp
|
||||
DependencyList.cpp
|
||||
ExcelExport.cpp
|
||||
@@ -40,7 +39,6 @@ set(FILES
|
||||
ResourceCompiler_precompiled.h
|
||||
TextFileReader.cpp
|
||||
CfgFile.h
|
||||
CmdLine.h
|
||||
Config.h
|
||||
ConvertContext.h
|
||||
DebugLog.h
|
||||
|
||||
Reference in New Issue
Block a user