This commit is contained in:
kudzu_cp 2012-06-08 16:57:38 +00:00
parent 17d32631a1
commit 6ec3bbe2ad
5 changed files with 81 additions and 51 deletions

View file

@ -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");

View file

@ -1,8 +1,13 @@
<Window x:Class="Cosmos.Build.Builder.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Grid>
</Grid>
Title="MainWindow" Height="389" Width="564" Loaded="Window_Loaded">
<DockPanel>
<WrapPanel DockPanel.Dock="Top">
<Button Name="butnCopy" Click="butnCopy_Click">Copy</Button>
</WrapPanel>
<ScrollViewer>
<TextBlock Name="tblkLog" Text="" TextWrapping="Wrap"/>
</ScrollViewer>
</DockPanel>
</Window>

View file

@ -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());
}
}
}

View file

@ -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;
}
}

View file

@ -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);
}
}
}