UserKit Build support

This commit is contained in:
kudzu_cp 2012-06-16 14:26:07 +00:00
parent 456e8cdbdb
commit e2b2bf641a
4 changed files with 110 additions and 32 deletions

View file

@ -1,4 +1,5 @@
#define ChangeSetVersion "92560" ; Do NOT change this next line in Dev Kit
#define ChangeSetVersion "7"
#ifndef BuildConfiguration #ifndef BuildConfiguration
#error "No Build configuration defined!" #error "No Build configuration defined!"
@ -31,7 +32,7 @@ AppVersion={#ChangeSetVersion}
DefaultDirName={userappdata}\Cosmos User Kit DefaultDirName={userappdata}\Cosmos User Kit
DefaultGroupName=Cosmos User Kit DefaultGroupName=Cosmos User Kit
OutputDir=.\Setup2\Output OutputDir=.\Setup2\Output
OutputBaseFilename=CosmosUserKit OutputBaseFilename=CosmosUserKit-{#ChangeSetVersion}
#ifdef Compress #ifdef Compress
Compression=lzma2/ultra64 Compression=lzma2/ultra64
InternalCompressLevel=ultra64 InternalCompressLevel=ultra64

View file

@ -58,6 +58,7 @@
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules> <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />

View file

@ -10,11 +10,14 @@ namespace Cosmos.Build.Builder {
protected string mCosmosPath; protected string mCosmosPath;
public bool ResetHive { get; set; } public bool ResetHive { get; set; }
protected string mOutputPath; protected string mOutputPath;
protected bool mUserKit; public bool IsUserKit { get; set; }
protected int mReleaseNo;
protected string mInnoFile;
public CosmosTask(string aCosmosPath, bool aUserKit) { public CosmosTask(string aCosmosPath, int aReleaseNo) {
mCosmosPath = aCosmosPath; mCosmosPath = aCosmosPath;
mUserKit = aUserKit; mReleaseNo = aReleaseNo;
mInnoFile = mCosmosPath + @"\Setup2\Cosmos.iss";
} }
protected void MsBuild(string aSlnFile, string aBuildCfg) { protected void MsBuild(string aSlnFile, string aBuildCfg) {
@ -27,10 +30,51 @@ namespace Cosmos.Build.Builder {
Directory.CreateDirectory(mOutputPath); Directory.CreateDirectory(mOutputPath);
} }
Section("Compiling X# Compiler"); CompileXSharpCompiler();
MsBuild(mCosmosPath + @"\source2\XSharp.sln", "Debug"); CompileXSharpSource();
CompileCosmos();
CopyTemplates();
if (IsUserKit) {
CreateUserKitScript();
}
CreateSetup();
if (!IsUserKit) {
RunSetup();
LaunchVS();
}
Done();
}
void CreateUserKitScript() {
Section("Creating User Kit Script");
// Read in Cosmos.iss
using (var xSrc = new StreamReader(mInnoFile)) {
mInnoFile = Path.Combine(Path.GetDirectoryName(mInnoFile), "UserKit.iss");
// Write out UserKit.iss
using (var xDest = new StreamWriter(mInnoFile)) {
string xLine;
while ((xLine = xSrc.ReadLine()) != null) {
if (xLine.StartsWith("#define ChangeSetVersion ", StringComparison.InvariantCultureIgnoreCase)) {
xDest.WriteLine("#define ChangeSetVersion " + Quoted(mReleaseNo.ToString()));
} else {
xDest.WriteLine(xLine);
}
}
}
}
}
void CompileXSharpCompiler() {
Section("Compiling X# Compiler");
MsBuild(mCosmosPath + @"\source2\XSharp.sln", "Debug");
}
void CompileXSharpSource() {
Section("Compiling X# Sources"); Section("Compiling X# Sources");
var xFiles = Directory.GetFiles(mCosmosPath + @"\source2\Compiler\Cosmos.Compiler.DebugStub\", "*.xs"); var xFiles = Directory.GetFiles(mCosmosPath + @"\source2\Compiler\Cosmos.Compiler.DebugStub\", "*.xs");
foreach (var xFile in xFiles) { foreach (var xFile in xFiles) {
Echo("Compiling " + Path.GetFileName(xFile)); Echo("Compiling " + Path.GetFileName(xFile));
@ -42,15 +86,18 @@ namespace Cosmos.Build.Builder {
// This way we can build it and call it directly. // This way we can build it and call it directly.
StartConsole(mOutputPath + @"\xsc.exe", Quoted(xFile) + @" Cosmos.Debug.DebugStub"); StartConsole(mOutputPath + @"\xsc.exe", Quoted(xFile) + @" Cosmos.Debug.DebugStub");
} }
}
void CompileCosmos() {
Section("Compiling Cosmos"); Section("Compiling Cosmos");
MsBuild(mCosmosPath + @"\source\Cosmos.sln", "Builder"); MsBuild(mCosmosPath + @"\source\Cosmos.sln", "Builder");
}
void CopyTemplates() {
Section("Copying Templates");
CD(mOutputPath); CD(mOutputPath);
Section("Copying Templates");
// Copy templates
// .iss does some of this as well.. why some here? And why is VB disabled in .iss?
SrcPath = mCosmosPath + @"\source2\VSIP\Cosmos.VS.Package\obj\x86\Debug"; SrcPath = mCosmosPath + @"\source2\VSIP\Cosmos.VS.Package\obj\x86\Debug";
Copy("CosmosProject (C#).zip"); Copy("CosmosProject (C#).zip");
Copy("CosmosKernel (C#).zip"); Copy("CosmosKernel (C#).zip");
@ -59,33 +106,46 @@ namespace Cosmos.Build.Builder {
Copy("CosmosProject (VB).zip"); Copy("CosmosProject (VB).zip");
Copy("CosmosKernel (VB).zip"); Copy("CosmosKernel (VB).zip");
Copy(mCosmosPath + @"\source2\VSIP\Cosmos.VS.XSharp\Template\XSharpFileItem.zip"); Copy(mCosmosPath + @"\source2\VSIP\Cosmos.VS.XSharp\Template\XSharpFileItem.zip");
}
void CreateSetup() {
Section("Creating Setup"); Section("Creating Setup");
if (!File.Exists(Paths.ProgFiles32 + @"\Inno Setup 5\ISCC.exe")) { if (!File.Exists(Paths.ProgFiles32 + @"\Inno Setup 5\ISCC.exe")) {
throw new Exception("Cannot find Inno setup."); throw new Exception("Cannot find Inno setup.");
} }
string xCfg = mUserKit ? "UserKit" : "DevKit"; string xCfg = IsUserKit ? "UserKit" : "DevKit";
StartConsole(Paths.ProgFiles32 + @"\Inno Setup 5\ISCC.exe", @"/Q " + Quoted(mCosmosPath + @"\Setup2\Cosmos.iss") + " /dBuildConfiguration=" + xCfg); StartConsole(Paths.ProgFiles32 + @"\Inno Setup 5\ISCC.exe", @"/Q " + Quoted(mInnoFile) + " /dBuildConfiguration=" + xCfg);
if (!mUserKit) { if (IsUserKit) {
Section("Running Setup"); File.Delete(mInnoFile);
Start(mCosmosPath + @"\Setup2\Output\CosmosUserKit.exe", @"/SILENT"); }
}
Section("Launching Visual Studio"); void LaunchVS() {
string xVisualStudio = Paths.ProgFiles32 + @"\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"; Section("Launching Visual Studio");
if (!File.Exists(xVisualStudio)) {
throw new Exception("Cannot find Visual Studio.");
}
if (ResetHive) { string xVisualStudio = Paths.ProgFiles32 + @"\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe";
Echo("Resetting hive"); if (!File.Exists(xVisualStudio)) {
Start(xVisualStudio, @"/setup /rootsuffix Exp /ranu"); throw new Exception("Cannot find Visual Studio.");
}
Echo("Launching Visual Studio");
Start(xVisualStudio, mCosmosPath + @"\source\Cosmos.sln", false);
} }
if (ResetHive) {
Echo("Resetting hive");
Start(xVisualStudio, @"/setup /rootsuffix Exp /ranu");
}
Echo("Launching Visual Studio");
Start(xVisualStudio, mCosmosPath + @"\source\Cosmos.sln", false);
}
void RunSetup() {
Section("Running Setup");
Start(mCosmosPath + @"\Setup2\Output\CosmosUserKit-" + mReleaseNo + ".exe", @"/SILENT");
}
void Done() {
Section("Build Complete!"); Section("Build Complete!");
} }
} }

View file

@ -13,6 +13,7 @@ using System.Windows.Navigation;
using System.Security.Permissions; using System.Security.Permissions;
using System.Windows.Threading; using System.Windows.Threading;
using System.IO; using System.IO;
using Microsoft.VisualBasic;
namespace Cosmos.Build.Builder { namespace Cosmos.Build.Builder {
public partial class MainWindow : Window { public partial class MainWindow : Window {
@ -39,23 +40,36 @@ namespace Cosmos.Build.Builder {
StringBuilder mClipboard = new StringBuilder(); StringBuilder mClipboard = new StringBuilder();
DispatcherTimer mCloseTimer; DispatcherTimer mCloseTimer;
public void Build() { public bool Build() {
// TODO: Check for Inno, VS SDK SP1, other prereqs // TODO: Check for Inno, VS SDK SP1, other prereqs
string xAppPath = System.AppDomain.CurrentDomain.BaseDirectory; string xAppPath = System.AppDomain.CurrentDomain.BaseDirectory;
string xCosmosPath = Path.GetFullPath(xAppPath + @"..\..\..\..\..\"); string xCosmosPath = Path.GetFullPath(xAppPath + @"..\..\..\..\..\");
bool xIsUserKit = mApp.Args.Contains("-USERKIT");
int xReleaseNo = 7;
var xTask = new CosmosTask(xCosmosPath, mApp.Args.Contains("-USERKIT")); if (xIsUserKit) {
string x = Interaction.InputBox("Enter Release Number", "Cosmos Builder");
if (string.IsNullOrEmpty(x)) {
return false;
}
xReleaseNo = int.Parse(x);
}
var xTask = new CosmosTask(xCosmosPath, xReleaseNo);
xTask.Log.LogLine += new Installer.Log.LogLineHandler(Log_LogLine); xTask.Log.LogLine += new Installer.Log.LogLineHandler(Log_LogLine);
xTask.Log.LogSection += new Installer.Log.LogSectionHandler(Log_LogSection); xTask.Log.LogSection += new Installer.Log.LogSectionHandler(Log_LogSection);
xTask.Log.LogError += new Installer.Log.LogErrorHandler(Log_LogError); xTask.Log.LogError += new Installer.Log.LogErrorHandler(Log_LogError);
xTask.ResetHive = mApp.Args.Contains("-RESETHIVE"); xTask.ResetHive = mApp.Args.Contains("-RESETHIVE");
xTask.IsUserKit = xIsUserKit;
var xThread = new System.Threading.Thread(delegate() { var xThread = new System.Threading.Thread(delegate() {
xTask.Run(); xTask.Run();
ThreadDone(); ThreadDone();
}); });
xThread.Start(); xThread.Start();
return true;
} }
void ThreadDone() { void ThreadDone() {
@ -152,7 +166,9 @@ namespace Cosmos.Build.Builder {
} }
void Window_Loaded(object sender, RoutedEventArgs e) { void Window_Loaded(object sender, RoutedEventArgs e) {
Build(); if (!Build()) {
Close();
}
} }
void butnCopy_Click(object sender, RoutedEventArgs e) { void butnCopy_Click(object sender, RoutedEventArgs e) {