diff --git a/source2/Build/Cosmos.Build.Builder/CosmosTask.cs b/source2/Build/Cosmos.Build.Builder/CosmosTask.cs index 1458b4ad9..e33196263 100644 --- a/source2/Build/Cosmos.Build.Builder/CosmosTask.cs +++ b/source2/Build/Cosmos.Build.Builder/CosmosTask.cs @@ -7,24 +7,24 @@ using System.IO; namespace Cosmos.Build.Builder { public class CosmosTask : Task { + protected string mCosmosPath; - public void Run(string aCosmosPath) { - string xOutputPath = aCosmosPath + @"\Build\VSIP"; + public CosmosTask(string aCosmosPath) { + mCosmosPath = aCosmosPath; + } - EchoOff(); + protected override void DoRun() { + string xOutputPath = mCosmosPath + @"\Build\VSIP"; - Echo("Compiling Cosmos"); - - CD(aCosmosPath + @"\source"); - Start(Paths.Windows + @"\Microsoft.NET\Framework\v4.0.30319\msbuild.exe", @"Cosmos.sln /maxcpucount /verbosity:normal /nologo /p:Configuration=Bootstrap /p:Platform=x86 /p:OutputPath=" + Quoted(xOutputPath)); - //%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild Cosmos.sln /maxcpucount /verbosity:normal /nologo /p:Configuration=Bootstrap /p:Platform=x86 /p:OutputPath="%THE_OUTPUT_PATH%" + Section("Compiling Cosmos"); + StartConsole(Paths.Windows + @"\Microsoft.NET\Framework\v4.0.30319\msbuild.exe", mCosmosPath + @"\source\Cosmos.sln /maxcpucount /verbosity:normal /nologo /p:Configuration=Bootstrap /p:Platform=x86 /p:OutputPath=" + Quoted(xOutputPath)); CD(xOutputPath); - Echo("Copying files"); + Section("Copying files"); // Copy templates // .iss does some of this as well.. why some here? And why is VB disabled in .iss? - SrcPath = aCosmosPath + @"source2\VSIP\Cosmos.VS.Package\obj\x86\Debug"; + SrcPath = mCosmosPath + @"source2\VSIP\Cosmos.VS.Package\obj\x86\Debug"; Copy("CosmosProject (C#).zip"); Copy("CosmosKernel (C#).zip"); Copy("CosmosProject (F#).zip"); diff --git a/source2/Build/Cosmos.Build.Builder/MainWindow.xaml b/source2/Build/Cosmos.Build.Builder/MainWindow.xaml index 5f0a7a0a4..da55e6cd3 100644 --- a/source2/Build/Cosmos.Build.Builder/MainWindow.xaml +++ b/source2/Build/Cosmos.Build.Builder/MainWindow.xaml @@ -1,8 +1,13 @@  - - - + Title="MainWindow" Height="389" Width="564" Loaded="Window_Loaded"> + + + + + + + + diff --git a/source2/Build/Cosmos.Build.Builder/MainWindow.xaml.cs b/source2/Build/Cosmos.Build.Builder/MainWindow.xaml.cs index 98d922440..f9872cee3 100644 --- a/source2/Build/Cosmos.Build.Builder/MainWindow.xaml.cs +++ b/source2/Build/Cosmos.Build.Builder/MainWindow.xaml.cs @@ -17,14 +17,38 @@ namespace Cosmos.Build.Builder { InitializeComponent(); } + protected StringBuilder mClipboard = new StringBuilder(); + public void Build() { - var xTask = new CosmosTask(); - xTask.Run(@"D:\source\Cosmos"); + var xTask = new CosmosTask(@"D:\source\Cosmos"); + xTask.Log.LogLine += new Installer.Log.LogLineHandler(Log_LogLine); + xTask.Log.LogSection += new Installer.Log.LogSectionHandler(Log_LogSection); + xTask.Run(); + } + + void Log_LogSection(string aLine) { + mClipboard.AppendLine(aLine); + + var xRun = new Run(aLine); + xRun.Background = Brushes.Red; + tblkLog.Inlines.Add(xRun); + tblkLog.Inlines.Add(new LineBreak()); + } + + void Log_LogLine(string aLine) { + mClipboard.AppendLine(aLine); + + tblkLog.Inlines.Add(aLine); + tblkLog.Inlines.Add(new LineBreak()); } private void Window_Loaded(object sender, RoutedEventArgs e) { Build(); } + private void butnCopy_Click(object sender, RoutedEventArgs e) { + Clipboard.SetText(mClipboard.ToString()); + } + } } diff --git a/source2/Build/Cosmos.Build.Installer/Log.cs b/source2/Build/Cosmos.Build.Installer/Log.cs index 6c0ac2094..8b6cbeb6f 100644 --- a/source2/Build/Cosmos.Build.Installer/Log.cs +++ b/source2/Build/Cosmos.Build.Installer/Log.cs @@ -5,30 +5,22 @@ using System.Text; namespace Cosmos.Build.Installer { public class Log { - public Log() { - mEchoing = true; + public void WriteLine(string aText) { + if (LogLine != null) { + LogLine(aText); + } } - protected bool mEchoing; - public bool Echoing { - get { return mEchoing; } + public void NewSection(string aText) { + if (LogSection != null) { + LogSection(aText); + } } - public void Echo() { - Echo(""); - } - - public void Echo(string aText) { - // TODO - } - - public void EchoOn() { - mEchoing = true; - } - - public void EchoOff() { - mEchoing = false; - } + public delegate void LogLineHandler(string aLine); + public event LogLineHandler LogLine; + public delegate void LogSectionHandler(string aLine); + public event LogSectionHandler LogSection; } } diff --git a/source2/Build/Cosmos.Build.Installer/Task.cs b/source2/Build/Cosmos.Build.Installer/Task.cs index cd04500e1..bd4774cfc 100644 --- a/source2/Build/Cosmos.Build.Installer/Task.cs +++ b/source2/Build/Cosmos.Build.Installer/Task.cs @@ -6,28 +6,43 @@ using System.IO; using System.Diagnostics; namespace Cosmos.Build.Installer { - public class Task { - public void Start(string aEXE, string aParams) { - Start(aEXE, aParams, true); + public abstract class Task { + protected abstract void DoRun(); + + public void Run() { + DoRun(); } - public void Start(string aExe, string aParams, bool aWait) { + + public void StartConsole(string aExe, string aParams) { var xStart = new ProcessStartInfo(); xStart.FileName = aExe; xStart.WorkingDirectory = CurrPath; xStart.Arguments = aParams; xStart.UseShellExecute = false; + xStart.CreateNoWindow = true; xStart.RedirectStandardOutput = true; - //xStart.RedirectStandardError = true; using (var xProcess = Process.Start(xStart)) { using (var xReader = xProcess.StandardOutput) { - string xRresult = xReader.ReadToEnd(); + string xLine; + while (true) { + xLine = xReader.ReadLine(); + if (xLine == null) { + break; + } + Log.WriteLine(xLine); + } } + xProcess.WaitForExit(); } } private Log mLog = new Log(); public Log Log { get { return mLog; } } + public void Section(string aText) { + Log.NewSection(aText); + } + public string CurrPath { get { return Directory.GetCurrentDirectory(); } set { Directory.SetCurrentDirectory(value); } @@ -56,20 +71,14 @@ namespace Cosmos.Build.Installer { Copy(aSrcPathname, Path.GetFileName(aSrcPathname)); } public void Copy(string aSrcPathname, string aDestPathname) { - File.Copy(Path.Combine(SrcPath, aSrcPathname), Path.Combine(CurrPath, aDestPathname)); + File.Copy(Path.Combine(SrcPath, aSrcPathname), Path.Combine(CurrPath, aDestPathname), true); } public void Echo() { - mLog.Echo(""); + mLog.WriteLine(""); } public void Echo(string aText) { - mLog.Echo(aText); - } - public void EchoOn() { - mLog.EchoOn(); - } - public void EchoOff() { - mLog.EchoOff(); + mLog.WriteLine(aText); } } }