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
#error "No Build configuration defined!"
@ -31,7 +32,7 @@ AppVersion={#ChangeSetVersion}
DefaultDirName={userappdata}\Cosmos User Kit
DefaultGroupName=Cosmos User Kit
OutputDir=.\Setup2\Output
OutputBaseFilename=CosmosUserKit
OutputBaseFilename=CosmosUserKit-{#ChangeSetVersion}
#ifdef Compress
Compression=lzma2/ultra64
InternalCompressLevel=ultra64

View file

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

View file

@ -10,11 +10,14 @@ namespace Cosmos.Build.Builder {
protected string mCosmosPath;
public bool ResetHive { get; set; }
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;
mUserKit = aUserKit;
mReleaseNo = aReleaseNo;
mInnoFile = mCosmosPath + @"\Setup2\Cosmos.iss";
}
protected void MsBuild(string aSlnFile, string aBuildCfg) {
@ -27,10 +30,51 @@ namespace Cosmos.Build.Builder {
Directory.CreateDirectory(mOutputPath);
}
Section("Compiling X# Compiler");
MsBuild(mCosmosPath + @"\source2\XSharp.sln", "Debug");
CompileXSharpCompiler();
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");
var xFiles = Directory.GetFiles(mCosmosPath + @"\source2\Compiler\Cosmos.Compiler.DebugStub\", "*.xs");
foreach (var xFile in xFiles) {
Echo("Compiling " + Path.GetFileName(xFile));
@ -42,15 +86,18 @@ namespace Cosmos.Build.Builder {
// This way we can build it and call it directly.
StartConsole(mOutputPath + @"\xsc.exe", Quoted(xFile) + @" Cosmos.Debug.DebugStub");
}
}
void CompileCosmos() {
Section("Compiling Cosmos");
MsBuild(mCosmosPath + @"\source\Cosmos.sln", "Builder");
}
void CopyTemplates() {
Section("Copying Templates");
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";
Copy("CosmosProject (C#).zip");
Copy("CosmosKernel (C#).zip");
@ -59,33 +106,46 @@ namespace Cosmos.Build.Builder {
Copy("CosmosProject (VB).zip");
Copy("CosmosKernel (VB).zip");
Copy(mCosmosPath + @"\source2\VSIP\Cosmos.VS.XSharp\Template\XSharpFileItem.zip");
}
void CreateSetup() {
Section("Creating Setup");
if (!File.Exists(Paths.ProgFiles32 + @"\Inno Setup 5\ISCC.exe")) {
throw new Exception("Cannot find Inno setup.");
}
string xCfg = mUserKit ? "UserKit" : "DevKit";
StartConsole(Paths.ProgFiles32 + @"\Inno Setup 5\ISCC.exe", @"/Q " + Quoted(mCosmosPath + @"\Setup2\Cosmos.iss") + " /dBuildConfiguration=" + xCfg);
string xCfg = IsUserKit ? "UserKit" : "DevKit";
StartConsole(Paths.ProgFiles32 + @"\Inno Setup 5\ISCC.exe", @"/Q " + Quoted(mInnoFile) + " /dBuildConfiguration=" + xCfg);
if (!mUserKit) {
Section("Running Setup");
Start(mCosmosPath + @"\Setup2\Output\CosmosUserKit.exe", @"/SILENT");
if (IsUserKit) {
File.Delete(mInnoFile);
}
}
Section("Launching Visual Studio");
string xVisualStudio = Paths.ProgFiles32 + @"\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe";
if (!File.Exists(xVisualStudio)) {
throw new Exception("Cannot find Visual Studio.");
}
if (ResetHive) {
Echo("Resetting hive");
Start(xVisualStudio, @"/setup /rootsuffix Exp /ranu");
}
Echo("Launching Visual Studio");
Start(xVisualStudio, mCosmosPath + @"\source\Cosmos.sln", false);
void LaunchVS() {
Section("Launching Visual Studio");
string xVisualStudio = Paths.ProgFiles32 + @"\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe";
if (!File.Exists(xVisualStudio)) {
throw new Exception("Cannot find Visual Studio.");
}
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!");
}
}

View file

@ -13,6 +13,7 @@ using System.Windows.Navigation;
using System.Security.Permissions;
using System.Windows.Threading;
using System.IO;
using Microsoft.VisualBasic;
namespace Cosmos.Build.Builder {
public partial class MainWindow : Window {
@ -39,23 +40,36 @@ namespace Cosmos.Build.Builder {
StringBuilder mClipboard = new StringBuilder();
DispatcherTimer mCloseTimer;
public void Build() {
public bool Build() {
// TODO: Check for Inno, VS SDK SP1, other prereqs
string xAppPath = System.AppDomain.CurrentDomain.BaseDirectory;
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.LogSection += new Installer.Log.LogSectionHandler(Log_LogSection);
xTask.Log.LogError += new Installer.Log.LogErrorHandler(Log_LogError);
xTask.ResetHive = mApp.Args.Contains("-RESETHIVE");
xTask.IsUserKit = xIsUserKit;
var xThread = new System.Threading.Thread(delegate() {
xTask.Run();
ThreadDone();
});
xThread.Start();
return true;
}
void ThreadDone() {
@ -152,7 +166,9 @@ namespace Cosmos.Build.Builder {
}
void Window_Loaded(object sender, RoutedEventArgs e) {
Build();
if (!Build()) {
Close();
}
}
void butnCopy_Click(object sender, RoutedEventArgs e) {