854 lines
51 KiB
C#
854 lines
51 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Ubi.Tools.GearConfigTool;
|
|
using System.Windows.Forms;
|
|
using System.Text.RegularExpressions;
|
|
using System.IO;
|
|
|
|
namespace GearCTConsole
|
|
{
|
|
class GearCTConsole
|
|
{
|
|
static string mSupportedPlatforms = "win32 win64 ps3 ps3_spu ps3_ppu xenon vita ctr mac iphone android gc2 cafe durango orbis";
|
|
|
|
[STAThread]
|
|
static void Main(string[] args)
|
|
{
|
|
try
|
|
{
|
|
bool bAsArguments = args.Length > 0;
|
|
bool bWarning = false;
|
|
|
|
Console.Out.WriteLine("");
|
|
|
|
if (bAsArguments)
|
|
{
|
|
Ubi.Tools.GearConfigTool.GUI.MainViewer gearGUI = new Ubi.Tools.GearConfigTool.GUI.MainViewer();
|
|
MainController gearPCCT = new MainController(true, gearGUI);
|
|
|
|
//check if the configuration tool has successfully loaded the configuration xml.
|
|
//if not we output a message and exit, the xml is a must as it contain
|
|
//all module/platform information.
|
|
if (!gearPCCT.InitSuccessful)
|
|
{
|
|
Console.Out.WriteLine("Could not load MHFCompanion.xml!");
|
|
System.Environment.Exit(1);
|
|
}
|
|
|
|
//process arguments
|
|
int argCounter = 0;
|
|
|
|
string strCommand = args[argCounter++];
|
|
string strSubCommand = "";
|
|
string strParam = "";
|
|
string strTarget = "";
|
|
string strCompile = "";
|
|
string strOut = "";
|
|
string strLimit = "";
|
|
string strConfigFileValue = "";
|
|
string strAdditionalInfo = "";
|
|
string mainOptChar = "/";
|
|
string subOptChar = "-";
|
|
|
|
if(System.Environment.OSVersion.Platform == PlatformID.Unix)
|
|
mainOptChar = "--";
|
|
|
|
List<string> Aliases = new List<string>();
|
|
List<string> Platforms = new List<string>();
|
|
|
|
switch (strCommand.Substring(mainOptChar.Length))
|
|
{
|
|
case "resave":
|
|
if (args.Length >= 2)
|
|
{
|
|
bool loadStatus = Ubi.Tools.GearConfigTool.Tools.IO.OpenFile(args[1], true, gearPCCT.AppSettings);
|
|
gearGUI.LoadConfigGUI(true, args[1], loadStatus, gearPCCT.AppSettings, new ProgressWindow());
|
|
Ubi.Tools.GearConfigTool.Tools.IO.SaveFile(CoreModel.CurrentConfiguration, true, gearPCCT.AppSettings, new ValidationWindow(gearPCCT), args[1], false);
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine("Argument missing : filename");
|
|
System.Environment.Exit(1);
|
|
}
|
|
|
|
break;
|
|
|
|
case "list":
|
|
if (args.Length >= 2)
|
|
{
|
|
strSubCommand = args[argCounter++];
|
|
|
|
switch (strSubCommand)
|
|
{
|
|
case "-subsystem":
|
|
|
|
if (args.Length >= 3)
|
|
{
|
|
strParam = args[argCounter++];
|
|
SubSystem oSubSystem = CoreModel.FindSubSystem(strParam);
|
|
|
|
if (oSubSystem != null)
|
|
{
|
|
Console.Out.WriteLine("");
|
|
Console.Out.WriteLine("List of all modules for subsystem :" + strParam);
|
|
Console.Out.WriteLine("");
|
|
ModuleCollection oModules = oSubSystem.Modules;
|
|
for (int j = 0; j < oModules.Count; j++)
|
|
{
|
|
Console.Out.WriteLine(oModules[j].ModuleName);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine("Unknown subsystem, given : " + strParam + ". Do /list -subsystem to list all subsystem");
|
|
System.Environment.Exit(1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine("");
|
|
Console.Out.WriteLine("List of all subsystems :");
|
|
Console.Out.WriteLine("");
|
|
SubSystemCollection oSystems = CoreModel.SubSystemList;
|
|
for (int k = 0; k < oSystems.Count; k++)
|
|
{
|
|
Console.Out.WriteLine(oSystems[k].SubSystemName);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "-all":
|
|
Console.Out.WriteLine("");
|
|
Console.Out.WriteLine("List of all modules :");
|
|
Console.Out.WriteLine("");
|
|
|
|
SubSystemCollection oSubSystems = CoreModel.SubSystemList;
|
|
for (int k = 0; k < oSubSystems.Count; k++)
|
|
{
|
|
ModuleCollection oModules = oSubSystems[k].Modules;
|
|
for (int j = 0; j < oModules.Count; j++)
|
|
{
|
|
Console.Out.WriteLine(oModules[j].ModuleName);
|
|
}
|
|
}
|
|
break;
|
|
|
|
default:
|
|
Console.Out.WriteLine("Unknown flag given : " + strSubCommand + " expected : -all or -subsystem");
|
|
System.Environment.Exit(1);
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine("Argument missing : flag expected -all or -subsystem ");
|
|
System.Environment.Exit(1);
|
|
}
|
|
break;
|
|
|
|
case "gen":
|
|
if (args.Length >= 2)
|
|
{
|
|
strSubCommand = args[argCounter++];
|
|
|
|
switch (strSubCommand)
|
|
{
|
|
case "-module":
|
|
if (args.Length >= 3)
|
|
{
|
|
|
|
while (argCounter < args.Length && !args[argCounter].StartsWith(mainOptChar))
|
|
strParam += args[argCounter++] + " ";
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine("Argument missing : module name expected.");
|
|
System.Environment.Exit(1);
|
|
}
|
|
break;
|
|
|
|
case "-seed":
|
|
if (argCounter < args.Length && !args[argCounter].StartsWith(mainOptChar) && !args[argCounter].StartsWith(subOptChar))
|
|
{
|
|
|
|
strParam = args[argCounter++];
|
|
Regex oRegex = new Regex("[0-9]+$");
|
|
|
|
if (!oRegex.IsMatch(strParam))
|
|
{
|
|
Console.Out.WriteLine("Unknown seed, given : " + strParam + " expected seed format : [0-9]+");
|
|
System.Environment.Exit(1);
|
|
}
|
|
|
|
}
|
|
|
|
if (args[argCounter].StartsWith(subOptChar))
|
|
{
|
|
argCounter++;
|
|
if (argCounter < args.Length && !args[argCounter].StartsWith(mainOptChar))
|
|
{
|
|
|
|
strLimit = args[argCounter++];
|
|
Regex oRegex = new Regex("[0-9]+$");
|
|
|
|
if (!oRegex.IsMatch(strLimit))
|
|
{
|
|
Console.Out.WriteLine("Unknown limit, given : " + strLimit + " expected limit format : [0-9]+");
|
|
System.Environment.Exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
break;
|
|
case "-mconfig":
|
|
break;
|
|
default:
|
|
Console.Out.WriteLine("Unknown flag, given : " + strSubCommand + " expected : -module or -mconfig or -seed");
|
|
System.Environment.Exit(1);
|
|
break;
|
|
}
|
|
|
|
string strArg = "";
|
|
while (argCounter < args.Length)
|
|
{
|
|
strArg = args[argCounter++];
|
|
|
|
switch (strArg.Substring(mainOptChar.Length))
|
|
{
|
|
case "target":
|
|
if (argCounter < args.Length)
|
|
{
|
|
while (argCounter < args.Length && !args[argCounter].StartsWith(mainOptChar))
|
|
{
|
|
string tempTarget;
|
|
tempTarget = args[argCounter++];
|
|
strTarget += tempTarget + " ";
|
|
|
|
Regex oRegex = new Regex("(all|debug[1-4]{0,1}|release[1-4]{0,1}|retail[1-4]{0,1}|debugdll[1-4]{0,1}|releasedll[1-4]{0,1}|retaildll[1-4]{0,1})$");
|
|
|
|
if (!oRegex.IsMatch(tempTarget))
|
|
{
|
|
Console.Out.WriteLine("Unknown target, given : " + strTarget + " expected : debug debug1...4 release release1...4 retail retail1...4");
|
|
System.Environment.Exit(1);
|
|
}
|
|
}
|
|
strTarget = strTarget.TrimEnd(' ');
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine("Argument missing, target expected : debug debug1...4 release release1...4 retail retail1...4");
|
|
System.Environment.Exit(1);
|
|
}
|
|
break;
|
|
|
|
case "platform":
|
|
if (argCounter < args.Length)
|
|
{
|
|
do
|
|
{
|
|
if (args[argCounter] == "ps3")
|
|
Platforms.Add("ps3_ppu");
|
|
else
|
|
Platforms.Add(args[argCounter]);
|
|
|
|
argCounter++;
|
|
}
|
|
while (argCounter < args.Length && !args[argCounter].StartsWith(mainOptChar) && !args[argCounter].StartsWith(subOptChar));
|
|
|
|
Regex oRegex = new Regex("(" + mSupportedPlatforms.Replace(' ', '|') + ")$");
|
|
|
|
foreach (string platform in Platforms)
|
|
{
|
|
if (!oRegex.IsMatch(platform))
|
|
{
|
|
Console.Out.WriteLine("Unknown platform, given : " + platform + " expected one of " + mSupportedPlatforms);
|
|
System.Environment.Exit(1);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine("Platform argument missing, expected one of " + mSupportedPlatforms);
|
|
System.Environment.Exit(1);
|
|
}
|
|
break;
|
|
|
|
case "compile":
|
|
if (argCounter < args.Length)
|
|
{
|
|
|
|
strCompile = args[argCounter++];
|
|
Regex oRegex = new Regex("(debug|release|retail)$");
|
|
|
|
if (!oRegex.IsMatch(strCompile))
|
|
{
|
|
Console.Out.WriteLine("Unknown compile mode, given : " + strCompile + " expected : debug release retail");
|
|
System.Environment.Exit(1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine("Argument missing, compile mode expected : debug release retail");
|
|
System.Environment.Exit(1);
|
|
}
|
|
|
|
break;
|
|
|
|
case "alias":
|
|
if (argCounter < args.Length)
|
|
{
|
|
|
|
string strAlias = args[argCounter++];
|
|
Regex oRegex = new Regex("^[a-zA-Z][a-zA-Z0-9_]*$");
|
|
|
|
if (!oRegex.IsMatch(strAlias))
|
|
{
|
|
Console.Out.WriteLine("Invalid alias name, given : " + strAlias + " expected format : [a-zA-Z][a-zA-Z0-9_]*");
|
|
System.Environment.Exit(1);
|
|
}
|
|
Aliases.Clear();
|
|
Aliases.Add(strAlias);
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine("Argument missing, alias name expected");
|
|
System.Environment.Exit(1);
|
|
}
|
|
break;
|
|
|
|
case "file":
|
|
if (argCounter < args.Length)
|
|
{
|
|
|
|
strConfigFileValue = args[argCounter++];
|
|
|
|
if (strConfigFileValue.StartsWith(mainOptChar))
|
|
{
|
|
Console.Out.WriteLine("No argument specified for " + mainOptChar + "file parameter, given : " + strConfigFileValue);
|
|
System.Environment.Exit(1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine("Argument missing, filename name expected");
|
|
System.Environment.Exit(1);
|
|
}
|
|
break;
|
|
|
|
case "out":
|
|
if (argCounter < args.Length)
|
|
{
|
|
|
|
strOut = args[argCounter++];
|
|
|
|
if (strOut.StartsWith(mainOptChar))
|
|
{
|
|
Console.Out.WriteLine("No argument specified for " + mainOptChar + "out parameter, given : " + strOut);
|
|
System.Environment.Exit(1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine("Argument missing, filename name expected");
|
|
System.Environment.Exit(1);
|
|
}
|
|
break;
|
|
|
|
default:
|
|
Console.Out.WriteLine("Unknown command, given : " + strArg + " skipping.");
|
|
System.Environment.Exit(1);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (strOut == "")
|
|
{
|
|
Console.Out.WriteLine(mainOptChar + "out parameter missing, closing program.");
|
|
System.Environment.Exit(1);
|
|
}
|
|
|
|
//check if list of config supplied
|
|
//check if this module is included in list ?
|
|
//change value for each line found.
|
|
|
|
List<ModuleConfigValue> vConfigs = new List<ModuleConfigValue>();
|
|
|
|
if (strConfigFileValue != "" && File.Exists(strConfigFileValue))
|
|
{
|
|
StreamReader inFile = null;
|
|
try
|
|
{
|
|
|
|
inFile = new StreamReader(strConfigFileValue);
|
|
|
|
string strLine = "";
|
|
string[] vInfos = null;
|
|
ModuleConfigValue oConfigValue = null;
|
|
|
|
while (!inFile.EndOfStream)
|
|
{
|
|
strLine = inFile.ReadLine();
|
|
vInfos = strLine.Split(new char[] { ' ', '\t' });
|
|
|
|
oConfigValue = null;
|
|
|
|
int y = 0;
|
|
for (int z = 0; z < vInfos.Length && y < 3; z++)
|
|
{
|
|
|
|
if (vInfos[z] != "")
|
|
{
|
|
if (y == 0)
|
|
{
|
|
oConfigValue = new ModuleConfigValue();
|
|
oConfigValue.ModuleName = vInfos[z];
|
|
y++;
|
|
}
|
|
else if (y == 1)
|
|
{
|
|
oConfigValue.ConfigName = vInfos[z];
|
|
y++;
|
|
}
|
|
else if (y == 2)
|
|
{
|
|
oConfigValue.ConfigValue = vInfos[z];
|
|
y++;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if (oConfigValue != null)
|
|
vConfigs.Add(oConfigValue);
|
|
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.Out.WriteLine("There was an error opening the " + mainOptChar + "file : " + strConfigFileValue + " -> " + e.Message);
|
|
System.Environment.Exit(1);
|
|
}
|
|
|
|
}
|
|
else if (strConfigFileValue != "")
|
|
{
|
|
Console.Out.WriteLine("Unknown " + mainOptChar + "file : " + strConfigFileValue + " -> file does not exist.");
|
|
System.Environment.Exit(1);
|
|
}
|
|
|
|
Profile oProfile = null;
|
|
Module oModule = null;
|
|
Module oModuleTemp = null;
|
|
SubSystem oSubSystem = null;
|
|
SubSystemCollection oSystems = null;
|
|
ModuleCollection oModules = null;
|
|
Configuration oConfig = null;
|
|
|
|
//now generate
|
|
switch (strSubCommand)
|
|
{
|
|
case "-module":
|
|
|
|
Console.Out.WriteLine("Generating config with specified modules...");
|
|
List<string> vTargetList = new List<string>(strTarget.Split(' '));
|
|
|
|
if (vTargetList.Contains("all"))
|
|
{
|
|
vTargetList = new List<string>(CoreModel.TargetsAlias.Keys);
|
|
}
|
|
|
|
foreach (string vTarget in vTargetList)
|
|
{
|
|
if (vTarget != "")
|
|
{
|
|
foreach (string platform in Platforms)
|
|
{
|
|
// make a string with the following syntax: PLATFORM_TARGET
|
|
string strTargetProfileName = platform.ToUpper() + '_' + vTarget.ToUpper();
|
|
Console.Out.WriteLine("Generating config for target: {0}", strTargetProfileName);
|
|
oProfile = gearPCCT.AddProfile(strTargetProfileName, platform, vTarget, null, Aliases);
|
|
|
|
if (!strParam.StartsWith("all"))
|
|
{
|
|
string[] vModules = strParam.Split(' ');
|
|
|
|
for (int j = 0; j < vModules.Length; j++)
|
|
{
|
|
if (vModules[j] != "")
|
|
{
|
|
oModule = oProfile.FindModule(vModules[j]);
|
|
|
|
if (oModule != null)
|
|
{
|
|
oProfile.FlagModule(oModule, true);
|
|
|
|
Console.Out.WriteLine(" Module : " + oModule.ModuleTag + " selected and flagged...");
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine(" Unknown module, given : " + vModules[j] + " skipping.");
|
|
bWarning = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
oSystems = oProfile.SubSystems;
|
|
oModules = null;
|
|
for (int k = 0; k < oSystems.Count; k++)
|
|
{
|
|
if (oSystems[k].SubSystemName != "shears" || !strParam.StartsWith("allbutshears"))
|
|
{
|
|
oModules = oSystems[k].Modules;
|
|
for (int l = 0; l < oModules.Count; l++)
|
|
{
|
|
oModule = oModules[l];
|
|
{
|
|
oProfile.FlagModule(oModule, true);
|
|
}
|
|
|
|
Console.Out.WriteLine(" Module : " + oModule.ModuleTag + " selected and flagged...");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Console.Out.WriteLine("");
|
|
|
|
if (vConfigs.Count > 0)
|
|
Console.Out.WriteLine(" Processing " + mainOptChar + "file command :");
|
|
|
|
//browse trough all config and assign value.
|
|
for (int n = 0; n < vConfigs.Count; n++)
|
|
{
|
|
oModule = oProfile.FindModule(vConfigs[n].ModuleName);
|
|
|
|
if (oModule != null)
|
|
{
|
|
oConfig = oModule.FindConfig(vConfigs[n].ConfigName);
|
|
|
|
if (oConfig != null)
|
|
{
|
|
oConfig.Value = vConfigs[n].ConfigValue;
|
|
if (!oModule.ModuleIsEnabled)
|
|
{
|
|
oProfile.FlagModule(oModule, true);
|
|
}
|
|
|
|
// Update dependencies when we update a config line.
|
|
ConfigurationManager.CheckModuleDelegate updateGUIDependencies = Ubi.Tools.GearConfigTool.Tools.UICheck.CheckModule;
|
|
oConfig.UpdateDependencies(oConfig.Value, updateGUIDependencies, oConfig.DefaultValue, oModule);
|
|
|
|
Console.Out.WriteLine(" Configuration value set successfully : " + vConfigs[n].ModuleName + " " + vConfigs[n].ConfigName + " " + vConfigs[n].ConfigValue);
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine(" Could not find configuration : " + vConfigs[n].ConfigName + " in entry : " + vConfigs[n].ModuleName + " " + vConfigs[n].ConfigName + " " + vConfigs[n].ConfigValue + " -> skipped.");
|
|
bWarning = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine(" Could not find module : " + vConfigs[n].ModuleName + " in entry : " + vConfigs[n].ModuleName + " " + vConfigs[n].ConfigName + " " + vConfigs[n].ConfigValue + " -> skipped.");
|
|
bWarning = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "-seed":
|
|
foreach (string platform in Platforms)
|
|
{
|
|
Console.Out.WriteLine("Generating config with random module from seed...");
|
|
int iSeed = 0;
|
|
Random oRand = null;
|
|
|
|
if (strParam != "")
|
|
{
|
|
try
|
|
{
|
|
iSeed = Convert.ToInt32(strParam);
|
|
Console.Out.WriteLine(" Seed number for this generated sequence : <" + iSeed.ToString() + ">");
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.Out.WriteLine("Problem occurred when converting seed to Int32 : " + e.Message + " Aborting execution.");
|
|
System.Environment.Exit(1);
|
|
}
|
|
oRand = new Random(iSeed);
|
|
}
|
|
else
|
|
{
|
|
UInt64 iTick = Convert.ToUInt64(DateTime.Now.Ticks);
|
|
iSeed = Convert.ToInt32(iTick & 0x000000007FFFFFFF);
|
|
oRand = new Random(iSeed);
|
|
|
|
Console.Out.WriteLine(" Seed number for this generated sequence : <" + iSeed.ToString() + ">");
|
|
}
|
|
|
|
int iLimit = 1;
|
|
|
|
if (strLimit != "")
|
|
{
|
|
try
|
|
{
|
|
iLimit = Convert.ToInt32(strLimit);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.Out.WriteLine("Problem occurred when converting limit to Int32 : " + e.Message + " Aborting execution.");
|
|
System.Environment.Exit(1);
|
|
}
|
|
}
|
|
|
|
oProfile = gearPCCT.AddProfile("PROFILE_SEED_GENERATED", platform, strTarget, null, Aliases);
|
|
|
|
int m = 0;
|
|
int iRand = 0;
|
|
|
|
strAdditionalInfo = "#define SEED_NUMBER " + iSeed.ToString() + "\r\n\r\n";
|
|
|
|
while (m < iLimit)
|
|
{
|
|
iRand = oRand.Next(oProfile.SubSystems.Count);
|
|
oSubSystem = oProfile.SubSystems[iRand];
|
|
|
|
iRand = oRand.Next(oSubSystem.Modules.Count);
|
|
|
|
oModule = oSubSystem.Modules[iRand];
|
|
|
|
oProfile.FlagModule(oModule, true);
|
|
|
|
if (oModule.ModuleIsEnabled)
|
|
{
|
|
Console.Out.WriteLine(" Module : " + oModule.ModuleTag + " randomly selected and added into config...");
|
|
|
|
iRand = oRand.Next(oModule.Configurations.Count);
|
|
|
|
if (iRand < oModule.Configurations.Count)
|
|
{
|
|
oConfig = oModule.Configurations[iRand];
|
|
|
|
if (oConfig.Type != ConfigurationType.STRING)
|
|
{
|
|
string oldValue = oConfig.Value;
|
|
string strRandValue = oConfig.GetRandomValue(oRand);
|
|
//cant randomize config of type string.
|
|
|
|
oConfig.Value = strRandValue;
|
|
Console.Out.WriteLine(" Config : " + oConfig.Tag + " in module randomly selected with value : " + strRandValue);
|
|
|
|
// Update dependencies when we update a config line.
|
|
ConfigurationManager.CheckModuleDelegate updateGUIDependencies = Ubi.Tools.GearConfigTool.Tools.UICheck.CheckModule;
|
|
oConfig.UpdateDependencies(oConfig.Value, updateGUIDependencies, oldValue, oModule);
|
|
}
|
|
}
|
|
}
|
|
m++;
|
|
}
|
|
|
|
oModuleTemp = oProfile.FindModule("memdefaultallocator");
|
|
|
|
if (oModuleTemp != null && oModuleTemp.ModuleIsEnabled)
|
|
{
|
|
oModuleTemp = oProfile.FindModule("memallocdl283");
|
|
|
|
if (oModuleTemp != null)
|
|
oProfile.FlagModule(oModuleTemp, true);
|
|
}
|
|
|
|
oModuleTemp = oProfile.FindModule("shearssatellitekernel");
|
|
|
|
if (oModuleTemp != null && oModuleTemp.ModuleIsEnabled)
|
|
{
|
|
oModuleTemp = oProfile.FindModule("shearstaskdispatcher");
|
|
|
|
if (oModuleTemp != null)
|
|
oProfile.FlagModule(oModuleTemp, true);
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case "-mconfig":
|
|
foreach (string platform in Platforms)
|
|
{
|
|
strAdditionalInfo = "#undef GEAR_TARGET_" + strTarget.ToUpper() + "\r\n\r\n";
|
|
strAdditionalInfo += "#include \"multiple_config.h\"\r\n\r\n";
|
|
|
|
Console.Out.WriteLine("Generating multiple config file.This may take several seconds...");
|
|
//create a dump profile to get all the module for the platform,target,compile mode specified
|
|
oProfile = gearPCCT.AddProfile("PROFILE_MCONFIG", platform, strTarget, null, null);
|
|
oSystems = oProfile.SubSystems;
|
|
oModules = null;
|
|
Profile oTempProfile = null;
|
|
int iModuleNumber = 0;
|
|
for (int k = 0; k < oSystems.Count; k++)
|
|
{
|
|
oModules = oSystems[k].Modules;
|
|
for (int l = 0; l < oModules.Count; l++)
|
|
{
|
|
oModule = oModules[l];
|
|
Console.Out.WriteLine(" Generating config for : " + oModule.ModuleTag);
|
|
Aliases = new List<string>();
|
|
Aliases.Add("MULTIPLE_CONFIG_MODULE_" + oModule.ModuleTag.ToUpper());
|
|
oTempProfile = gearPCCT.AddProfile("PROFILE_MCONFIG_" + oModule.ModuleTag.ToUpper(), platform, strTarget, null, Aliases);
|
|
oTempProfile.FlagModule(oTempProfile.SubSystems[k].Modules[l], true);
|
|
Application.DoEvents();
|
|
|
|
oModuleTemp = oTempProfile.FindModule("memdefaultallocator");
|
|
|
|
if (oModuleTemp != null && oModuleTemp.ModuleIsEnabled)
|
|
{
|
|
oModuleTemp = oTempProfile.FindModule("memallocdl283");
|
|
|
|
if (oModuleTemp != null)
|
|
oTempProfile.FlagModule(oModuleTemp, true);
|
|
}
|
|
|
|
oModuleTemp = oTempProfile.FindModule("shearssatellitekernel");
|
|
|
|
if (oModuleTemp != null && oModuleTemp.ModuleIsEnabled)
|
|
{
|
|
oModuleTemp = oTempProfile.FindModule("shearstaskdispatcher");
|
|
|
|
if (oModuleTemp != null)
|
|
oTempProfile.FlagModule(oModuleTemp, true);
|
|
}
|
|
|
|
if (iModuleNumber == 0)
|
|
strAdditionalInfo += "#if MULTIPLE_CONFIG_MODULE == " + iModuleNumber + "\r\n";
|
|
else
|
|
strAdditionalInfo += "#elif MULTIPLE_CONFIG_MODULE == " + iModuleNumber + "\r\n";
|
|
strAdditionalInfo += " #define MULTIPLE_CONFIG_MODULE_" + oModule.ModuleTag.ToUpper() + "\r\n";
|
|
|
|
iModuleNumber++;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
strAdditionalInfo += "#endif\r\n\r\n";
|
|
|
|
CoreModel.CurrentConfiguration.ProfileList.Remove(oProfile);
|
|
Console.Out.WriteLine(" Total Modules : " + (iModuleNumber - 1).ToString());
|
|
}
|
|
break;
|
|
|
|
default:
|
|
Console.Out.WriteLine("Unknown flag, given : " + strSubCommand + " expected : -module or -mconfig or -seed");
|
|
System.Environment.Exit(1);
|
|
break;
|
|
}
|
|
|
|
//always overwrite file.
|
|
if (File.Exists(strOut) && (File.GetAttributes(strOut) & FileAttributes.ReadOnly) > 0)
|
|
File.SetAttributes(strOut, FileAttributes.Normal);
|
|
|
|
//in case its seed we validate the profile generated
|
|
if (strSubCommand == "-seed")
|
|
{
|
|
//if there is any error we display them
|
|
if (gearPCCT.ValidationWindow.ValidateProfiles())
|
|
{
|
|
bool bAnyErrors = false;
|
|
|
|
Console.Out.WriteLine("");
|
|
Console.Out.WriteLine("The profile generated randomly encountered some validation errors or warnings : ");
|
|
Console.Out.WriteLine("");
|
|
for (int iRule = 0; iRule < gearPCCT.ValidationWindow.ValidationFailed.Count; iRule++)
|
|
{
|
|
bAnyErrors |= (gearPCCT.ValidationWindow.ValidationFailed[iRule].Second.Type == ValidationRule.ValidationRuleType.Error);
|
|
Console.Out.WriteLine(gearPCCT.ValidationWindow.ValidationFailed[iRule].Second.Message);
|
|
}
|
|
|
|
if (bAnyErrors)
|
|
{
|
|
System.Environment.Exit(3);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
FileIO fileWriter = new FileIO();
|
|
|
|
CoreModel.CurrentConfiguration.ClientSectionTop = strAdditionalInfo;
|
|
|
|
fileWriter.WriteHeaderFile(CoreModel.CurrentConfiguration, strOut, false, CoreModel.PerPlatformFile);
|
|
|
|
Console.Out.WriteLine("");
|
|
Console.Out.WriteLine(mainOptChar + "gen command executed successfully, please check your newly generated file : " + strOut);
|
|
|
|
|
|
if (bWarning)
|
|
System.Environment.Exit(2);
|
|
|
|
}
|
|
else
|
|
{
|
|
Console.Out.WriteLine("Argument missing : flag expected -module or -mconfig or -seed ");
|
|
System.Environment.Exit(1);
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
Console.Out.WriteLine("Unknown command : " + strCommand);
|
|
System.Environment.Exit(1);
|
|
break;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
ShowHelp();
|
|
}
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
Console.WriteLine(e.ToString());
|
|
System.Environment.Exit(-1);
|
|
}
|
|
}
|
|
|
|
static void ShowHelp()
|
|
{
|
|
string mainOptChar = "/";
|
|
if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
|
mainOptChar = "--";
|
|
|
|
Console.Out.WriteLine("***********************************************************");
|
|
Console.Out.WriteLine("* GearCTConsole Command line Help *");
|
|
Console.Out.WriteLine("***********************************************************");
|
|
Console.Out.WriteLine("");
|
|
Console.Out.WriteLine(" " + mainOptChar + "list -subsystem <name> : Display all modules from the selected subsystem. If no subsystem name specified, list all SubSystem.");
|
|
Console.Out.WriteLine(" " + mainOptChar + "list -all : Display all modules.");
|
|
Console.Out.WriteLine(" " + mainOptChar + "gen -module <name1> ...<nameN> : Generate a config file with all the modules specified separated by a space.");
|
|
Console.Out.WriteLine(" " + mainOptChar + "gen -module all : Generate a config file with all the modules.");
|
|
Console.Out.WriteLine(" " + mainOptChar + "gen -module allbutshears : Generate a config file with all the modules except shears.");
|
|
Console.Out.WriteLine(" " + mainOptChar + "gen -mconfig : Generate a config containing all modules standalone.");
|
|
Console.Out.WriteLine(" " + mainOptChar + "gen -seed <seed> -limit <number>: Randomly generate a config containing all modules depending the seed specified and the number of");
|
|
Console.Out.WriteLine(" module to randomly include.");
|
|
Console.Out.WriteLine(" If no seed specified, the config tool will generate one and print it to the console.");
|
|
Console.Out.WriteLine(" If no limit number specified, the config tool will randomly flag 1 module.");
|
|
|
|
Console.Out.WriteLine("");
|
|
Console.Out.WriteLine("Each " + mainOptChar + "gen command must be followed by these parameters :");
|
|
Console.Out.WriteLine("");
|
|
Console.Out.WriteLine(" " + mainOptChar + "target <target> : All the targets name separated by a space. Available targets are: debug,debug1...debug4,release,release1...release4,retail,retail1...retail4");
|
|
Console.Out.WriteLine(" " + mainOptChar + "platform <platform> : The platform name -> " + mSupportedPlatforms);
|
|
Console.Out.WriteLine(" " + mainOptChar + "alias <alias> : The target alias. [OPTIONAL PARAMETER]");
|
|
Console.Out.WriteLine(" " + mainOptChar + "out <filename> : The file output.");
|
|
Console.Out.WriteLine(" " + mainOptChar + "file <filename> : The filename containing the list configuration value of a given module. Each");
|
|
Console.Out.WriteLine(" line in the file correspond to a configuration value you want to change for a");
|
|
Console.Out.WriteLine(" module in this format : <moduleName> <configName> <configValue>. If the module");
|
|
Console.Out.WriteLine(" or config name don't exist the line is ignored. This option only work with the");
|
|
Console.Out.WriteLine(" '-module' flag. [OPTIONAL PARAMETER]");
|
|
}
|
|
}
|
|
}
|