Move property names to a separate class.

This commit is contained in:
Matthijs ter Woord 2015-10-03 14:19:37 +02:00
parent a05e3d3229
commit fc39e1e040
12 changed files with 147 additions and 123 deletions

View file

@ -10,14 +10,15 @@ namespace Cosmos.TestRunner.Core
{
partial class Engine
{
private void RunIsoInBochs(string iso)
private void RunIsoInBochs(string iso, string harddisk)
{
var xBochsConfig = Path.Combine(mBaseWorkingDirectory, "Kernel.bochsrc");
var xParams = new NameValueCollection();
xParams.Add("ISOFile", iso);
xParams.Add(BuildProperties.VisualStudioDebugPortString, "Pipe: Cosmos\\Serial");
xParams.Add(BuildProperties.EnableBochsDebugString, RunWithGDB.ToString());
xParams.Add(BuildPropertyNames.VisualStudioDebugPortString, "Pipe: Cosmos\\Serial");
xParams.Add(BuildPropertyNames.EnableBochsDebugString, RunWithGDB.ToString());
BuildProperties.
var xDebugConnector = new DebugConnectorPipeServer(DebugConnectorPipeServer.DefaultCosmosPipeName);
InitializeDebugConnector(xDebugConnector);

View file

@ -16,7 +16,6 @@ namespace Cosmos.TestRunner.Core
{
throw new ArgumentNullException("debugConnector");
}
debugConnector.OnDebugMsg = s => OutputHandler.LogDebugMessage(s);
debugConnector.CmdChannel = ChannelPacketReceived;
debugConnector.CmdStarted = () =>

View file

@ -15,8 +15,8 @@ namespace Cosmos.TestRunner.Core
var xParams = new NameValueCollection();
xParams.Add("ISOFile", iso);
xParams.Add(BuildProperties.VisualStudioDebugPortString, "Pipe: Cosmos\\Serial");
xParams.Add(BuildProperties.VMwareEditionString, "Workstation");
xParams.Add(BuildPropertyNames.VisualStudioDebugPortString, "Pipe: Cosmos\\Serial");
xParams.Add(BuildPropertyNames.VMwareEditionString, "Workstation");
var xDebugConnector = new DebugConnectorPipeServer(DebugConnectorPipeServer.DefaultCosmosPipeName);
InitializeDebugConnector(xDebugConnector);

View file

@ -16,7 +16,7 @@ namespace Cosmos.Build.Common {
// for C# a field which is readonly keyword would have both true but a const field would have only IsLiteral equal to true
if (xField.IsLiteral && !xField.IsInitOnly && xField.FieldType == typeof(string)) {
string xName = (string)xField.GetValue(null);
if (xName != BuildProperties.ProfileString) {
if (xName != BuildPropertyNames.ProfileString) {
PropNames.Add(xName);
}
}
@ -28,7 +28,8 @@ namespace Cosmos.Build.Common {
/// </summary>
public override string[] ProjectIndependentProperties
{
get { return new string[] { BinFormatString }; }
get { return new string[] {
BuildPropertyNames.BinFormatString }; }
}
/// <summary>
@ -69,7 +70,7 @@ namespace Cosmos.Build.Common {
{
xValue = GetProperty(aName + "_" + xName);
}
if (!string.IsNullOrWhiteSpace(xValue))
{
SetProperty(xName, xValue);
@ -119,84 +120,79 @@ namespace Cosmos.Build.Common {
}
// Profile
public const string ProfileString = "Profile";
public string Profile {
get { return GetProperty(ProfileString, "VMware"); }
set { SetProperty(ProfileString, value); }
public string Profile {
get { return GetProperty(BuildPropertyNames.ProfileString, "VMware"); }
set { SetProperty(BuildPropertyNames.ProfileString, value); }
}
public const string NameString = "Name";
public string Name {
get { return GetProperty(NameString, ""); }
set { SetProperty(NameString, value); }
public string Name {
get { return GetProperty(BuildPropertyNames.NameString, ""); }
set { SetProperty(BuildPropertyNames.NameString, value); }
}
public const string DescriptionString = "Description";
public string Description {
get { return GetProperty(DescriptionString, ""); }
set { SetProperty(DescriptionString, value); }
public string Description {
get { return GetProperty(BuildPropertyNames.DescriptionString, ""); }
set { SetProperty(BuildPropertyNames.DescriptionString, value); }
}
// Deployment
public const string DeploymentString = "Deployment";
public DeploymentType Deployment {
get { return GetProperty(DeploymentString, DeploymentType.ISO); }
set { SetProperty(DeploymentString, value); }
public DeploymentType Deployment {
get { return GetProperty(BuildPropertyNames.DeploymentString, DeploymentType.ISO); }
set { SetProperty(BuildPropertyNames.DeploymentString, value); }
}
// Launch
public const string LaunchString = "Launch";
public LaunchType Launch {
get { return GetProperty(LaunchString, LaunchType.VMware); }
set { SetProperty(LaunchString, value); }
public LaunchType Launch {
get { return GetProperty(BuildPropertyNames.LaunchString, LaunchType.VMware); }
set { SetProperty(BuildPropertyNames.LaunchString, value); }
}
public const string ShowLaunchConsoleString = "ShowLaunchConsole";
public bool ShowLaunchConsole {
get { return GetProperty(ShowLaunchConsoleString, false); }
set { SetProperty(ShowLaunchConsoleString, value); }
public bool ShowLaunchConsole {
get { return GetProperty(BuildPropertyNames.ShowLaunchConsoleString, false); }
set { SetProperty(BuildPropertyNames.ShowLaunchConsoleString, value); }
}
// Debug
public const string DebugEnabledString = "DebugEnabled";
public bool DebugEnabled {
get { return GetProperty(DebugEnabledString, true); }
set { SetProperty(DebugEnabledString, value); }
public bool DebugEnabled {
get { return GetProperty(BuildPropertyNames.DebugEnabledString, true); }
set { SetProperty(BuildPropertyNames.DebugEnabledString, value); }
}
public const string StackCorruptionDetectionEnabledString = "StackCorruptionDetectionEnabled";
public bool StackCorruptionDetectionEnabled
public bool StackCorruptionDetectionEnabled
{
get { return GetProperty(StackCorruptionDetectionEnabledString, true); }
set { SetProperty(StackCorruptionDetectionEnabledString, value); }
get { return GetProperty(BuildPropertyNames.StackCorruptionDetectionEnabledString, true); }
set { SetProperty(BuildPropertyNames.StackCorruptionDetectionEnabledString, value); }
}
public const string DebugModeString = "DebugMode";
public DebugMode DebugMode {
get { return GetProperty(DebugModeString, DebugMode.Source); }
set { SetProperty(DebugModeString, value); }
public DebugMode DebugMode {
get { return GetProperty(BuildPropertyNames.DebugModeString, DebugMode.Source); }
set { SetProperty(BuildPropertyNames.DebugModeString, value); }
}
public const string IgnoreDebugStubAttributeString = "IgnoreDebugStubAttribute";
public bool IgnoreDebugStubAttribute {
get { return GetProperty(IgnoreDebugStubAttributeString, false); }
set { SetProperty(IgnoreDebugStubAttributeString, value); }
public bool IgnoreDebugStubAttribute {
get { return GetProperty(BuildPropertyNames.IgnoreDebugStubAttributeString, false); }
set { SetProperty(BuildPropertyNames.IgnoreDebugStubAttributeString, value); }
}
public const string CosmosDebugPortString = "CosmosDebugPort";
public string CosmosDebugPort {
get { return GetProperty(CosmosDebugPortString, "Serial: COM1"); }
set { SetProperty(CosmosDebugPortString, value); }
public string CosmosDebugPort {
get { return GetProperty(BuildPropertyNames.CosmosDebugPortString, "Serial: COM1"); }
set { SetProperty(BuildPropertyNames.CosmosDebugPortString, value); }
}
public const string VisualStudioDebugPortString = "VisualStudioDebugPort";
public string VisualStudioDebugPort {
get { return GetProperty(VisualStudioDebugPortString, "Serial: COM1"); }
set { SetProperty(VisualStudioDebugPortString, value); }
public string VisualStudioDebugPort {
get { return GetProperty(BuildPropertyNames.VisualStudioDebugPortString, "Serial: COM1"); }
set { SetProperty(BuildPropertyNames.VisualStudioDebugPortString, value); }
}
// PXE
public const string PxeInterfaceString = "PxeInterface";
public string PxeInterface {
get { return GetProperty(PxeInterfaceString, "192.168.42.1"); }
set { SetProperty(PxeInterfaceString, value); }
public string PxeInterface {
get { return GetProperty(BuildPropertyNames.PxeInterfaceString, "192.168.42.1"); }
set { SetProperty(BuildPropertyNames.PxeInterfaceString, value); }
}
public const string SlavePortString = "SlavePort";
public string SlavePort {
get { return GetProperty(SlavePortString, "None"); }
set { SetProperty(SlavePortString, value); }
public string SlavePort {
get { return GetProperty(BuildPropertyNames.SlavePortString, "None"); }
set { SetProperty(BuildPropertyNames.SlavePortString, value); }
}
// Bochs
@ -212,64 +208,54 @@ namespace Cosmos.Build.Common {
}
// VMware
public const string VMwareEditionString = "VMwareEdition";
public VMwareEdition VMwareEdition {
get { return GetProperty(VMwareEditionString, VMwareEdition.Player); }
set { SetProperty(VMwareEditionString, value); }
public VMwareEdition VMwareEdition {
get { return GetProperty(BuildPropertyNames.VMwareEditionString, VMwareEdition.Player); }
set { SetProperty(BuildPropertyNames.VMwareEditionString, value); }
}
public const string OutputPathString = "OutputPath";
public String OutputPath {
get { return GetProperty(OutputPathString, @"bin\debug"); }
set { SetProperty(OutputPathString, value); }
}
public const string FrameworkString = "Framework";
public Framework Framework {
get { return GetProperty(FrameworkString, Common.Framework.MicrosoftNET); }
set { SetProperty(FrameworkString, value); }
}
public const string UseInternalAssemblerString = "UseInternalAssembler";
public Boolean UseInternalAssembler {
get { return GetProperty(UseInternalAssemblerString, false); }
set { SetProperty(UseInternalAssemblerString, value); }
public String OutputPath {
get { return GetProperty(BuildPropertyNames.OutputPathString, @"bin\debug"); }
set { SetProperty(BuildPropertyNames.OutputPathString, value); }
}
public const string TraceAssembliesString = "TraceAssemblies";
public TraceAssemblies TraceAssemblies {
get { return GetProperty(TraceAssembliesString, TraceAssemblies.User); }
set { SetProperty(TraceAssembliesString, value); }
public Framework Framework {
get { return GetProperty(BuildPropertyNames.FrameworkString, Common.Framework.MicrosoftNET); }
set { SetProperty(BuildPropertyNames.FrameworkString, value); }
}
public const string EnableGDBString = "EnableGDB";
public Boolean EnableGDB {
get { return GetProperty(EnableGDBString, false); }
set { SetProperty(EnableGDBString, value); }
}
public const string StartCosmosGDBString = "StartCosmosGDB";
public bool StartCosmosGDB {
get { return GetProperty(StartCosmosGDBString, false); }
set { SetProperty(StartCosmosGDBString, value); }
public Boolean UseInternalAssembler {
get { return GetProperty(BuildPropertyNames.UseInternalAssemblerString, false); }
set { SetProperty(BuildPropertyNames.UseInternalAssemblerString, value); }
}
public const string EnableBochsDebugString = "EnableBochsDebug";
public Boolean EnableBochsDebug
public TraceAssemblies TraceAssemblies {
get { return GetProperty(BuildPropertyNames.TraceAssembliesString, TraceAssemblies.User); }
set { SetProperty(BuildPropertyNames.TraceAssembliesString, value); }
}
public Boolean EnableGDB {
get { return GetProperty(BuildPropertyNames.EnableGDBString, false); }
set { SetProperty(BuildPropertyNames.EnableGDBString, value); }
}
public bool StartCosmosGDB {
get { return GetProperty(BuildPropertyNames.StartCosmosGDBString, false); }
set { SetProperty(BuildPropertyNames.StartCosmosGDBString, value); }
}
public Boolean EnableBochsDebug
{
get { return GetProperty(EnableBochsDebugString, false); }
set { SetProperty(EnableBochsDebugString, value); }
get { return GetProperty(BuildPropertyNames.EnableBochsDebugString, false); }
set { SetProperty(BuildPropertyNames.EnableBochsDebugString, value); }
}
/// <summary>
/// Name of the configuration property in the project file.
/// </summary>
public const string BinFormatString = "BinFormat";
/// <summary>
/// Gets or sets binary format which is used for producing kernel image.
/// </summary>
public BinFormat BinFormat
{
get { return GetProperty(BinFormatString, BinFormat.Bin); }
set { SetProperty(BinFormatString, value); }
get { return GetProperty(BuildPropertyNames.BinFormatString, BinFormat.Bin); }
set { SetProperty(BuildPropertyNames.BinFormatString, value); }
}
}
}

View file

@ -0,0 +1,37 @@
using System;
using System.Linq;
using System.Threading.Tasks;
namespace Cosmos.Build.Common
{
public static class BuildPropertyNames
{
public const string StackCorruptionDetectionEnabledString = "StackCorruptionDetectionEnabled";
public const string ProfileString = "Profile";
public const string NameString = "Name";
public const string DescriptionString = "Description";
public const string DeploymentString = "Deployment";
public const string LaunchString = "Launch";
public const string ShowLaunchConsoleString = "ShowLaunchConsole";
public const string DebugEnabledString = "DebugEnabled";
public const string DebugModeString = "DebugMode";
public const string IgnoreDebugStubAttributeString = "IgnoreDebugStubAttribute";
public const string CosmosDebugPortString = "CosmosDebugPort";
public const string VisualStudioDebugPortString = "VisualStudioDebugPort";
public const string PxeInterfaceString = "PxeInterface";
public const string SlavePortString = "SlavePort";
public const string VMwareEditionString = "VMwareEdition";
public const string OutputPathString = "OutputPath";
public const string FrameworkString = "Framework";
public const string UseInternalAssemblerString = "UseInternalAssembler";
public const string TraceAssembliesString = "TraceAssemblies";
public const string EnableGDBString = "EnableGDB";
public const string StartCosmosGDBString = "StartCosmosGDB";
public const string EnableBochsDebugString = "EnableBochsDebug";
/// <summary>
/// Name of the configuration property in the project file.
/// </summary>
public const string BinFormatString = "BinFormat";
}
}

View file

@ -78,6 +78,7 @@
<ItemGroup>
<Compile Include="BinFormat.cs" />
<Compile Include="BuildProperties.cs" />
<Compile Include="BuildPropertyNames.cs" />
<Compile Include="CosmosPaths.cs" />
<Compile Include="Enums.cs" />
<Compile Include="EnumValue.cs" />

View file

@ -281,7 +281,7 @@ namespace Cosmos.Debug.VSDebugEngine
{
mDbgConnector = null;
string xPort = mDebugInfo[BuildProperties.VisualStudioDebugPortString];
string xPort = mDebugInfo[BuildPropertyNames.VisualStudioDebugPortString];
// using (var xDebug = new StreamWriter(@"e:\debug.info", false))
// {
@ -294,7 +294,7 @@ namespace Cosmos.Debug.VSDebugEngine
if (String.IsNullOrWhiteSpace(xPort))
{
xPort = mDebugInfo[BuildProperties.CosmosDebugPortString];
xPort = mDebugInfo[BuildPropertyNames.CosmosDebugPortString];
}
var xParts = (null == xPort) ? null : xPort.Split(' ');
@ -308,7 +308,7 @@ namespace Cosmos.Debug.VSDebugEngine
string xPortType = xParts[0].ToLower();
string xPortParam = xParts[1].ToLower();
var xLaunch = mDebugInfo[BuildProperties.LaunchString];
var xLaunch = mDebugInfo[BuildPropertyNames.LaunchString];
OutputText("Starting debug connector.");
switch (xPortType)
@ -373,7 +373,7 @@ namespace Cosmos.Debug.VSDebugEngine
mCallback = aCallback;
mDebugInfo = aDebugInfo;
mLaunch = (LaunchType)Enum.Parse(typeof(LaunchType), aDebugInfo[BuildProperties.LaunchString]);
mLaunch = (LaunchType)Enum.Parse(typeof(LaunchType), aDebugInfo[BuildPropertyNames.LaunchString]);
if (mDebugDownPipe == null)
{
@ -397,11 +397,11 @@ namespace Cosmos.Debug.VSDebugEngine
OutputText("Using ISO file " + mISO + ".");
mProjectFile = mDebugInfo["ProjectFile"];
//
bool xUseGDB = string.Equals(mDebugInfo[BuildProperties.EnableGDBString], "true", StringComparison.InvariantCultureIgnoreCase);
bool xUseGDB = string.Equals(mDebugInfo[BuildPropertyNames.EnableGDBString], "true", StringComparison.InvariantCultureIgnoreCase);
OutputText("GDB " + (xUseGDB ? "Enabled" : "Disabled") + ".");
//
var xGDBClient = false;
Boolean.TryParse(mDebugInfo[BuildProperties.StartCosmosGDBString], out xGDBClient);
Boolean.TryParse(mDebugInfo[BuildPropertyNames.StartCosmosGDBString], out xGDBClient);
switch (mLaunch)
{

View file

@ -41,7 +41,7 @@ namespace Cosmos.Debug.VSDebugEngine.Host
InitializeKeyValues();
GenerateConfiguration(configurationFile.FullName);
_bochsConfigurationFile = configurationFile;
bool parseSucceeded = bool.TryParse(aParams[BuildProperties.EnableBochsDebugString], out _useDebugVersion);
bool parseSucceeded = bool.TryParse(aParams[BuildPropertyNames.EnableBochsDebugString], out _useDebugVersion);
return;
}

View file

@ -15,7 +15,7 @@ namespace Cosmos.Debug.VSDebugEngine.Host {
public Slave(NameValueCollection aParams, bool aUseGDB)
: base(aParams, aUseGDB) {
var xPort = mParams[BuildProperties.SlavePortString];
var xPort = mParams[BuildPropertyNames.SlavePortString];
if (xPort == "None") {
throw new Exception("No slave port is set.");
}

View file

@ -31,7 +31,7 @@ namespace Cosmos.Debug.VSDebugEngine.Host {
CheckIfHyperVServiceIsRunning();
string xFlavor = aParams[BuildProperties.VMwareEditionString].ToUpper();
string xFlavor = aParams[BuildPropertyNames.VMwareEditionString].ToUpper();
mEdition = VMwareEdition.Player;
if (xFlavor == "WORKSTATION") {
mEdition = VMwareEdition.Workstation;
@ -208,6 +208,6 @@ namespace Cosmos.Debug.VSDebugEngine.Host {
throw;
}
}
}
}
}
}
}

View file

@ -607,7 +607,7 @@ namespace Cosmos.VS.Package {
// Reset cache only on first one
// Get selected profile
mProps.SetProperty(BuildProperties.ProfileString, ProjectConfigs[0].GetConfigurationProperty(BuildProperties.ProfileString, true));
mProps.SetProperty(BuildPropertyNames.ProfileString, ProjectConfigs[0].GetConfigurationProperty(BuildPropertyNames.ProfileString, true));
LoadProjectProps();

View file

@ -31,9 +31,9 @@ namespace Cosmos.VS.Package {
// On first call, reset the cache, following calls will use the cached values
// Think we will change this to a dummy program when we get our debugger working
// This is the program that gest launched after build
var xDeployment = (DeploymentType)Enum.Parse(typeof(DeploymentType), GetConfigurationProperty(BuildProperties.DeploymentString, true));
var xLaunch = (LaunchType)Enum.Parse(typeof(LaunchType), GetConfigurationProperty(BuildProperties.LaunchString, false));
var xVSDebugPort = GetConfigurationProperty(BuildProperties.VisualStudioDebugPortString, false);
var xDeployment = (DeploymentType)Enum.Parse(typeof(DeploymentType), GetConfigurationProperty(BuildPropertyNames.DeploymentString, true));
var xLaunch = (LaunchType)Enum.Parse(typeof(LaunchType), GetConfigurationProperty(BuildPropertyNames.LaunchString, false));
var xVSDebugPort = GetConfigurationProperty(BuildPropertyNames.VisualStudioDebugPortString, false);
string xOutputAsm = ProjectMgr.GetOutputAssembly(ConfigName);
string xOutputPath = Path.GetDirectoryName(xOutputAsm);
@ -49,7 +49,7 @@ namespace Cosmos.VS.Package {
} else if (xDeployment == DeploymentType.PXE)
{
string xPxePath = Path.Combine(CosmosPaths.Build, "PXE");
string xPxeIntf = GetConfigurationProperty(BuildProperties.PxeInterfaceString, false);
string xPxeIntf = GetConfigurationProperty(BuildPropertyNames.PxeInterfaceString, false);
File.Copy(xBinFile, Path.Combine(xPxePath, "Cosmos.bin"), true);
Process.Start(Path.Combine(CosmosPaths.Tools, "Cosmos.Deploy.Pixie.exe"), xPxeIntf + " \"" + xPxePath + "\"");
}else if (xDeployment == DeploymentType.BinaryImage)