This commit is contained in:
kudzu_cp 2008-09-19 21:56:49 +00:00
parent 76b16b2a1b
commit 21430e5fb1
5 changed files with 128 additions and 162 deletions

View file

@ -4,19 +4,12 @@
xmlns:local="clr-namespace:Cosmos.Build.Windows"
Height="300" Width="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="15"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="10" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<ProgressBar Grid.Row="0" Grid.RowSpan="3" Grid.Column="1" x:Name="pbarMain" Orientation="Vertical"
Value="0" Width="Auto" Height="Auto"/>
<ListBox Grid.Row="0" Grid.Column="0" x:Name="listProgress" Height="Auto" Width="Auto"/>
<GridSplitter Grid.Row="1" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />

View file

@ -31,30 +31,32 @@ namespace Cosmos.Build.Windows {
public partial class BuildUC : UserControl {
public BuildUC() {
InitializeComponent();
Height = float.NaN;
Width = float.NaN;
}
public bool Display(Builder aBuilder, DebugModeEnum aDebugMode, byte aComPort) {
IEnumerable<BuildLogMessage> xMessages = new BuildLogMessage[0];
aBuilder.PreventFreezing += PreventFreezing;
aBuilder.DebugLog += DoDebugMessage;
aBuilder.ProgressChanged += DoProgressMessage;
//try {
aBuilder.Compile(aDebugMode, aComPort);
aBuilder.DebugLog -= DoDebugMessage;
aBuilder.ProgressChanged -= DoProgressMessage;
//} catch {
// return false;
//}
return true;
}
public void DoDebugMessage(LogSeverityEnum aSeverity, string aMessage) {
if (aSeverity == LogSeverityEnum.Informational) {
return;
}
//Dispatcher.BeginInvoke(DispatcherPriority.Input,
// new DispatcherOperationCallback(delegate(object aTheMessage) {
// Messages.Add((BuildLogMessage)aTheMessage);
// lboxLog.ScrollIntoView((BuildLogMessage)aTheMessage);
// return null;
// }),
// xMessage);
//var xFrame = new DispatcherFrame();
//Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, new DispatcherOperationCallback(delegate(object aParam) {
// xFrame.Continue = false;
// return null;
//}), null);
//Dispatcher.PushFrame(xFrame);
}
private int mMax;
private int mCurrent;
public void PreventFreezing() {
var xFrame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, new DispatcherOperationCallback(delegate(object aParam)
@ -65,19 +67,16 @@ namespace Cosmos.Build.Windows {
Dispatcher.PushFrame(xFrame);
}
protected delegate void ProgressMessageReceivedDelegate(string aMsg);
protected void ProgressMessageReceived(string aMsg) {
listProgress.Items.Add(aMsg);
// Old code
pbarMain.Maximum = mMax;
pbarMain.Value = mCurrent;
listProgress.SelectedIndex = listProgress.Items.Add(aMsg);
listProgress.ScrollIntoView(listProgress.Items[listProgress.SelectedIndex]);
}
public void DoProgressMessage(int aMax, int aCurrent, string aMessage) {
mCurrent = aCurrent;
mMax = aMax;
Dispatcher.BeginInvoke(DispatcherPriority.Input
, new ProgressMessageReceivedDelegate(ProgressMessageReceived), aMessage);
var xAction = (Action)delegate() {
ProgressMessageReceived(aMessage);
};
Dispatcher.BeginInvoke(DispatcherPriority.Input, xAction);
PreventFreezing();
}

View file

@ -1,13 +1,99 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Win32;
using Indy.IL2CPU;
namespace Cosmos.Build.Windows {
public class BuildUI {
[DllImport("user32.dll")]
protected static extern int ShowWindow(int Handle, int showState);
[DllImport("kernel32.dll")]
protected static extern int GetConsoleWindow();
public static void Run() {
// Hide the console window
int xConsoleWindow = GetConsoleWindow();
ShowWindow(xConsoleWindow, 0);
var xBuilder = new Builder();
var xOptionsWindow = new OptionsWindow();
xOptionsWindow.Display();
if (!xOptionsWindow.Display(xBuilder.BuildPath)) {
return;
}
// Call IL2CPU
if (xOptionsWindow.chbxCompileIL.IsChecked.Value) {
//TODO: Eventually eliminate the console window completely
if (xOptionsWindow.chbxShowConsoleWindow.IsChecked.Value) {
ShowWindow(xConsoleWindow, 1);
}
var xMainWindow = new MainWindow();
xMainWindow.Show();
var xBuildUC = new BuildUC();
xMainWindow.Content = xBuildUC;
if (!xBuildUC.Display(xBuilder, xOptionsWindow.DebugMode, xOptionsWindow.ComPort)) {
return;
}
xMainWindow.Close();
}
DebugWindow xDebugWindow = null;
// Debug Window is only displayed if Qemu + Debug checked
// or if other VM + Debugport selected
if (!xOptionsWindow.rdioDebugModeNone.IsChecked.Value) {
xDebugWindow = new DebugWindow();
if (xOptionsWindow.DebugMode == DebugModeEnum.Source) {
var xLabelByAddressMapping = ObjDump.GetLabelByAddressMapping(
xBuilder.BuildPath + "output.bin"
, xBuilder.ToolsPath + @"cygwin\objdump.exe");
var xSourceMappings = SourceInfo.GetSourceInfo(xLabelByAddressMapping
, xBuilder.BuildPath + "Tools/asm/debug.cxdb");
DebugConnector xDebugConnector;
if (xOptionsWindow.rdioQEMU.IsChecked.Value) {
xDebugConnector = new DebugConnectorQEMU();
} else if (xOptionsWindow.rdioVMWare.IsChecked.Value) {
xDebugConnector = new DebugConnectorVMWare();
} else {
throw new Exception("TODO: Make a connector for raw serial");
}
xDebugWindow.SetSourceInfoMap(xSourceMappings, xDebugConnector);
} else {
throw new Exception("Debug mode not supported: " + xOptionsWindow.DebugMode);
}
}
// Launch emulators or other final actions
if (xOptionsWindow.rdioQEMU.IsChecked.Value) {
// Uncomment if problems with QEMU to see output
// TODO: Capture and send to debug window
//ShowWindow(xConsoleWindow, 1);
xBuilder.MakeQEMU(xOptionsWindow.chbxQEMUUseHD.IsChecked.Value,
xOptionsWindow.chbxQEMUUseGDB.IsChecked.Value,
xOptionsWindow.DebugMode != DebugModeEnum.None,
xOptionsWindow.chckQEMUUseNetworkTAP.IsChecked.Value,
xOptionsWindow.cmboNetworkCards.SelectedValue,
xOptionsWindow.cmboAudioCards.SelectedValue);
} else if (xOptionsWindow.rdioVMWare.IsChecked.Value) {
xBuilder.MakeVMWare(xOptionsWindow.rdVMWareServer.IsChecked.Value);
} else if (xOptionsWindow.rdioVPC.IsChecked.Value) {
xBuilder.MakeVPC();
} else if (xOptionsWindow.rdioISO.IsChecked.Value) {
xBuilder.MakeISO();
} else if (xOptionsWindow.rdioPXE.IsChecked.Value) {
xBuilder.MakePXE();
} else if (xOptionsWindow.rdioUSB.IsChecked.Value) {
xBuilder.MakeUSB(xOptionsWindow.cmboUSBDevice.Text[0]);
}
if (xDebugWindow != null) {
xDebugWindow.ShowDialog();
}
}
}
}

View file

@ -18,47 +18,5 @@ namespace Cosmos.Build.Windows {
InitializeComponent();
}
// TODO: Move this into BuildUC
public bool PhaseBuild(Builder aBuilder, DebugModeEnum aDebugMode, byte aComPort) {
var xBuildUC = new BuildUC();
xBuildUC.Height = float.NaN;
xBuildUC.Width = float.NaN;
Content = xBuildUC;
IEnumerable<BuildLogMessage> xMessages = new BuildLogMessage[0];
aBuilder.PreventFreezing += xBuildUC.PreventFreezing;
aBuilder.DebugLog += xBuildUC.DoDebugMessage;
aBuilder.ProgressChanged += xBuildUC.DoProgressMessage;
try {
aBuilder.Compile(aDebugMode, aComPort);
aBuilder.DebugLog -= xBuildUC.DoDebugMessage;
aBuilder.ProgressChanged -= xBuildUC.DoProgressMessage;
//xMessages = (from item in xBuildUC.Messages
// where item.Severity != LogSeverityEnum.Informational
// select item).ToArray();
////If there were any warnings or errors, then show dialog again
//if (xMessages.Count() > 0) {
// return false;
//}
} catch (Exception E) {
//var xTheMessages = (from item in xBuildUC.Messages
// where item.Severity != LogSeverityEnum.Informational
// select item).ToList();
//xTheMessages.Add(new BuildLogMessage() {
// Severity = LogSeverityEnum.Error,
// Message = E.ToString()
//});
//xBuildUC.Messages.Clear();
//foreach (var item in xTheMessages) {
// xBuildUC.Messages.Add(item);
//}
//return false;
}
Close();
return true;
}
}
}

View file

@ -10,29 +10,29 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Runtime.InteropServices;
using System.Windows.Threading;
using Microsoft.Win32;
using Indy.IL2CPU;
using System.Windows.Threading;
namespace Cosmos.Build.Windows {
public partial class OptionsWindow : Window {
[DllImport("user32.dll")]
public static extern int ShowWindow(int Handle, int showState);
[DllImport("kernel32.dll")]
public static extern int GetConsoleWindow();
protected Block mOptionsBlockPrefix;
protected Builder mBuilder = new Builder();
protected string mLastSelectedUSBDrive;
protected DebugModeEnum mDebugMode;
public DebugModeEnum DebugMode {
get { return mDebugMode; }
}
protected byte mComPort;
public byte ComPort {
get { return mComPort; }
}
public void Display() {
// Hide the console window
int xConsoleWindow = GetConsoleWindow();
ShowWindow(xConsoleWindow, 0);
public bool Display(string aBuildPath) {
tblkBuildPath.Text = aBuildPath;
tblkISOPath.Text = aBuildPath + "Cosmos.iso";
bool xDoBuild = true;
var xShowOptions = chbxShowOptions.IsChecked.Value;
// If the user doenst have the option to auto show, then look
// for control key pressed
@ -44,12 +44,13 @@ namespace Cosmos.Build.Windows {
xShowOptions = KeyState.IsKeyDown(System.Windows.Forms.Keys.RControlKey)
|| KeyState.IsKeyDown(System.Windows.Forms.Keys.LControlKey);
}
bool xDoBuild = true;
if (xShowOptions) {
xDoBuild = ShowDialog().Value;
}
if (xDoBuild) {
SaveSettingsToRegistry();
mComPort = (byte)cmboDebugPort.SelectedIndex;
if (mComPort > 3) {
throw new Exception("Debug port not supported yet!");
@ -66,73 +67,8 @@ namespace Cosmos.Build.Windows {
} else {
throw new Exception("Unknown debug mode.");
}
// Call IL2CPU
if (chbxCompileIL.IsChecked.Value) {
//TODO: Eventually eliminate the console window completely
if (chbxShowConsoleWindow.IsChecked.Value) {
ShowWindow(xConsoleWindow, 1);
}
var xMainWindow = new MainWindow();
xMainWindow.Show();
if (xMainWindow.PhaseBuild(mBuilder, mDebugMode, mComPort) == false) {
return;
}
}
DebugWindow xDebugWindow = null;
// Debug Window is only displayed if Qemu + Debug checked
// or if other VM + Debugport selected
if (!rdioDebugModeNone.IsChecked.Value) {
xDebugWindow = new DebugWindow();
if (mDebugMode == DebugModeEnum.Source) {
var xLabelByAddressMapping = ObjDump.GetLabelByAddressMapping(
mBuilder.BuildPath + "output.bin"
, mBuilder.ToolsPath + @"cygwin\objdump.exe");
var xSourceMappings = SourceInfo.GetSourceInfo(xLabelByAddressMapping
, mBuilder.BuildPath + "Tools/asm/debug.cxdb");
DebugConnector xDebugConnector;
if (rdioQEMU.IsChecked.Value) {
xDebugConnector = new DebugConnectorQEMU();
} else if (rdioVMWare.IsChecked.Value) {
xDebugConnector = new DebugConnectorVMWare();
} else {
throw new Exception("TODO: Make a connector for raw serial");
}
xDebugWindow.SetSourceInfoMap(xSourceMappings, xDebugConnector);
} else {
throw new Exception("Debug mode not supported: " + mDebugMode);
}
}
// Launch emulators or other final actions
if (rdioQEMU.IsChecked.Value) {
// Uncomment if problems with QEMU to see output
// TODO: Capture and send to debug window
//ShowWindow(xConsoleWindow, 1);
mBuilder.MakeQEMU(chbxQEMUUseHD.IsChecked.Value,
chbxQEMUUseGDB.IsChecked.Value,
mDebugMode != DebugModeEnum.None,
chckQEMUUseNetworkTAP.IsChecked.Value,
cmboNetworkCards.SelectedValue,
cmboAudioCards.SelectedValue);
} else if (rdioVMWare.IsChecked.Value) {
mBuilder.MakeVMWare(rdVMWareServer.IsChecked.Value);
} else if (rdioVPC.IsChecked.Value) {
mBuilder.MakeVPC();
} else if (rdioISO.IsChecked.Value) {
mBuilder.MakeISO();
} else if (rdioPXE.IsChecked.Value) {
mBuilder.MakePXE();
} else if (rdioUSB.IsChecked.Value) {
mBuilder.MakeUSB(cmboUSBDevice.Text[0]);
}
if (xDebugWindow != null) {
xDebugWindow.ShowDialog();
}
}
return xDoBuild;
}
protected void TargetChanged(object aSender, RoutedEventArgs e) {
@ -182,9 +118,6 @@ namespace Cosmos.Build.Windows {
rdioPXE.Checked += new RoutedEventHandler(TargetChanged);
rdioUSB.Checked += new RoutedEventHandler(TargetChanged);
tblkBuildPath.Text = mBuilder.BuildPath;
tblkISOPath.Text = mBuilder.BuildPath + "Cosmos.iso";
cmboDebugPort.Items.Add("Disabled");
foreach (string xNIC in Enum.GetNames(typeof(Builder.QemuNetworkCard))) {
@ -200,9 +133,6 @@ namespace Cosmos.Build.Windows {
DialogResult = true;
}
private DebugModeEnum mDebugMode;
private byte mComPort;
private void butnCancel_Click(object sender, RoutedEventArgs e) {
DialogResult = false;
}