Cosmos/source2/VSIP/Cosmos.VS.Package/VsProjectConfig.cs
BlueSkeye_cp 7372c8a9bd Bochs integration : alpha version
Limitations :

- Bochs must be installed on the system. This is not checked as a  prerequisite by the Builder.
- You will find a GuessForBochs Cosmos project under BlueSkeye user project folder that can be used to launch the Guess project under Bochs.
- You may have to fix manually the path for the following properties in Cosmos.bxrc file copied to the CosmosForBochs\Bin\Debug folder
  * romimage
  * vgaromimage
- The Cosmos project UI is not yet Bochs aware. If you do not use the GuessForBochs project you must manually edit your Cosmos project file to modify the following property in both the Debug and Release property group from the project file :

    <Launch>Bochs</Launch>

  You must also add the following properties in both the Debug and Release property group from the project file :

    <BochsConfig>Cosmos.bxrc</BochsConfig>
    <Bochs_Deployment>ISO</Bochs_Deployment>
    <Bochs_Launch>Bochs</Bochs_Launch>
    <Bochs_DebugEnabled>True</Bochs_DebugEnabled>
    <Bochs_DebugMode>Source</Bochs_DebugMode>
    <Bochs_IgnoreDebugStubAttribute />
    <Bochs_VMwareEdition>Player</Bochs_VMwareEdition>
    <Bochs_OutputPath>bin\Debug\</Bochs_OutputPath>
    <Bochs_Framework>MicrosoftNET</Bochs_Framework>
    <Bochs_UseInternalAssembler>False</Bochs_UseInternalAssembler>
    <Bochs_TraceAssemblies />
    <Bochs_EnableGDB>False</Bochs_EnableGDB>
    <Bochs_StartCosmosGDB>false</Bochs_StartCosmosGDB>
    <Bochs_Name>GuessForBochs</Bochs_Name>
    <Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
    <Bochs_VisualStudioDebugPort>Pipe: Cosmos\Serial</Bochs_VisualStudioDebugPort>
    <Bochs_PxeInterface>192.168.43.1</Bochs_PxeInterface>
    <Bochs_SlavePort>Serial: COM3</Bochs_SlavePort>
    <Bochs_ShowLaunchConsole>False</Bochs_ShowLaunchConsole>
2012-09-14 17:13:06 +00:00

97 lines
No EOL
4.5 KiB
C#

// The symbol defined below enables method call on LogUtility. Should you wish to disable logging
// please DO NOT remove this code line and DO comment it out.
#define FULL_DEBUG
using System;
using Path = System.IO.Path;
using Marshal = System.Runtime.InteropServices.Marshal;
using Microsoft.VisualStudio.Project;
using VSConstants = Microsoft.VisualStudio.VSConstants;
using Microsoft.VisualStudio.OLE.Interop;
using VsShellUtilities = Microsoft.VisualStudio.Shell.VsShellUtilities;
using Microsoft.VisualStudio.Shell.Interop;
using NameValueCollection = System.Collections.Specialized.NameValueCollection;
using NameValueCollectionHelper = Cosmos.Debug.Common.NameValueCollectionHelper;
using Cosmos.Build.Common;
using System.Linq;
using System.Diagnostics;
using System.IO;
namespace Cosmos.VS.Package {
public class VsProjectConfig : ProjectConfig {
public VsProjectConfig(ProjectNode project, string configuration)
: base(project, configuration) {
}
public override int DebugLaunch(uint aLaunch) {
LogUtility.LogString("Cosmos.VS.Package.VSProjectConfig debugger launching");
try {
// Second param is ResetCache. Must be called one time. Dunno why.
// Also dunno if this comment is still valid/needed:
// 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));
string xOutputAsm = ProjectMgr.GetOutputAssembly(ConfigName);
string xOutputPath = Path.GetDirectoryName(xOutputAsm);
string xIsoFile = Path.ChangeExtension(xOutputAsm, ".iso");
string xBinFile = Path.ChangeExtension(xOutputAsm, ".bin");
if (xDeployment == DeploymentType.ISO) {
IsoMaker.Generate(CosmosPaths.Build, xBinFile, xIsoFile);
} else if (xDeployment == DeploymentType.USB) {
Process.Start(Path.Combine(CosmosPaths.Tools, "Cosmos.Deploy.USB.exe"), "\"" + xBinFile + "\"");
} else if (xDeployment == DeploymentType.PXE) {
string xPxePath = Path.Combine(CosmosPaths.Build, "PXE");
string xPxeIntf = GetConfigurationProperty(BuildProperties.PxeInterfaceString, false);
File.Copy(xBinFile, Path.Combine(xPxePath, "Cosmos.bin"), true);
Process.Start(Path.Combine(CosmosPaths.Tools, "Cosmos.Deploy.Pixie.exe"), xPxeIntf + " \"" + xPxePath + "\"");
} else {
throw new Exception("Unknown deployment type.");
}
if (xLaunch == LaunchType.None) {
if (xDeployment == DeploymentType.ISO) {
Process.Start(xOutputPath);
}
}
else {
// http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.vsdebugtargetinfo_members.aspx
var xInfo = new VsDebugTargetInfo();
xInfo.cbSize = (uint)Marshal.SizeOf(xInfo);
xInfo.dlo = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
xInfo.fSendStdoutToOutputWindow = 0; // App keeps its stdout
xInfo.grfLaunch = aLaunch; // Just pass through for now.
xInfo.bstrRemoteMachine = null; // debug locally
var xValues = new NameValueCollection();
xValues.Add("ProjectFile", Path.Combine(ProjectMgr.ProjectFolder, ProjectMgr.ProjectFile));
xValues.Add("ISOFile", xIsoFile);
xValues.Add("BinFormat", GetConfigurationProperty("BinFormat", false));
foreach (var xName in BuildProperties.PropNames) {
xValues.Add(xName, GetConfigurationProperty(xName, false));
}
xInfo.bstrExe = NameValueCollectionHelper.DumpToString(xValues);
// Select the debugger
xInfo.clsidCustom = new Guid("{FA1DA3A6-66FF-4c65-B077-E65F7164EF83}"); // Debug engine identifier.
// ??? This identifier doesn't seems to appear anywhere else in souce code.
xInfo.clsidPortSupplier = new Guid("{708C1ECA-FF48-11D2-904F-00C04FA302A1}");
VsShellUtilities.LaunchDebugger(ProjectMgr.Site, xInfo);
}
} catch (Exception ex) {
LogUtility.LogException(ex, true);
return Marshal.GetHRForException(ex);
}
return VSConstants.S_OK;
}
}
}