* Source/Build/Resources/OpenTK.Prebuild.xml: Added conditional
compiler define for assembly signing. * Source/Build/Build.cs: Removed unused code. Added check for the existence of OpenTK.snk. Improved help and usage information. Removed unused code. * Build.exe: Updated to 0.9.9-2. Added strong name.
This commit is contained in:
parent
0a33452e76
commit
8a9ee45b22
3 changed files with 60 additions and 81 deletions
BIN
Build.exe
BIN
Build.exe
Binary file not shown.
|
@ -22,12 +22,32 @@ namespace OpenTK.Build
|
||||||
class Project
|
class Project
|
||||||
{
|
{
|
||||||
static string RootPath;
|
static string RootPath;
|
||||||
static string SourcePath;
|
|
||||||
|
|
||||||
const string bindings = "Generator.Prebuild.xml";
|
const string bindings = "Generator.Prebuild.xml";
|
||||||
const string opentk = "OpenTK.Prebuild.xml";
|
const string opentk = "OpenTK.Prebuild.xml";
|
||||||
const string quickstart = "QuickStart.Prebuild.xml";
|
const string quickstart = "QuickStart.Prebuild.xml";
|
||||||
|
|
||||||
|
const string keyfile = "OpenTK.snk";
|
||||||
|
|
||||||
|
const string Usage = @"Usage: Build.exe target
|
||||||
|
target: one of vs, vs9, clean, distclean, help";
|
||||||
|
|
||||||
|
const string Help = Usage + @"
|
||||||
|
|
||||||
|
Available targets:
|
||||||
|
vs: Create Visual Studio 2005 project files.
|
||||||
|
vs9: Create Visual Studio 2008 project files.
|
||||||
|
clean: Delete intermediate files but leave final binaries and project
|
||||||
|
files intact.
|
||||||
|
distclean: Delete intermediate files, final binaries and project files.
|
||||||
|
help: Display this help.
|
||||||
|
|
||||||
|
Assembly signing:
|
||||||
|
To create strongly-named assemblies, place a keypair file named OpenTK.snk
|
||||||
|
to the root folder (the same folder as Build.exe). If OpenTK.snk does not
|
||||||
|
exist the resulting assemblies will not be signed.
|
||||||
|
";
|
||||||
|
|
||||||
static readonly Assembly Prebuild = Assembly.Load(Resources.Prebuild);
|
static readonly Assembly Prebuild = Assembly.Load(Resources.Prebuild);
|
||||||
|
|
||||||
enum BuildTarget
|
enum BuildTarget
|
||||||
|
@ -44,8 +64,12 @@ namespace OpenTK.Build
|
||||||
|
|
||||||
static void PrintUsage()
|
static void PrintUsage()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Usage: Build.exe target");
|
Console.WriteLine(Usage);
|
||||||
Console.WriteLine(" target: one of vs, vs9, clean, distclean");
|
}
|
||||||
|
|
||||||
|
static void PrintHelp()
|
||||||
|
{
|
||||||
|
Console.WriteLine(Help);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
|
@ -62,11 +86,12 @@ namespace OpenTK.Build
|
||||||
}
|
}
|
||||||
|
|
||||||
RootPath = Directory.GetCurrentDirectory();
|
RootPath = Directory.GetCurrentDirectory();
|
||||||
SourcePath = Path.Combine(RootPath, "Source");
|
|
||||||
|
|
||||||
File.WriteAllText(bindings, Resources.Generator);
|
string sign_assembly = CheckKeyFile(keyfile) ? "SIGN_ASSEMBLY" : "";
|
||||||
File.WriteAllText(opentk, Resources.OpenTK);
|
|
||||||
File.WriteAllText(quickstart, Resources.QuickStart);
|
File.WriteAllText(bindings, String.Format(Resources.Generator, sign_assembly));
|
||||||
|
File.WriteAllText(opentk, String.Format(Resources.OpenTK, sign_assembly));
|
||||||
|
File.WriteAllText(quickstart, String.Format(Resources.QuickStart,sign_assembly));
|
||||||
|
|
||||||
// Workaroung for nant on x64 windows (safe for other platforms too, as this affects only the current process).
|
// Workaroung for nant on x64 windows (safe for other platforms too, as this affects only the current process).
|
||||||
Environment.SetEnvironmentVariable("CommonProgramFiles(x86)", String.Empty, EnvironmentVariableTarget.Process);
|
Environment.SetEnvironmentVariable("CommonProgramFiles(x86)", String.Empty, EnvironmentVariableTarget.Process);
|
||||||
|
@ -80,6 +105,10 @@ namespace OpenTK.Build
|
||||||
case "":
|
case "":
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "help":
|
||||||
|
PrintHelp();
|
||||||
|
return;
|
||||||
|
|
||||||
case "mono":
|
case "mono":
|
||||||
case "xbuild":
|
case "xbuild":
|
||||||
target = BuildTarget.Mono;
|
target = BuildTarget.Mono;
|
||||||
|
@ -207,8 +236,8 @@ namespace OpenTK.Build
|
||||||
|
|
||||||
static void FindDirectories(string directory, string search, List<string> matches)
|
static void FindDirectories(string directory, string search, List<string> matches)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (string d in Directory.GetDirectories(directory))
|
foreach (string d in Directory.GetDirectories(directory))
|
||||||
{
|
{
|
||||||
foreach (string f in Directory.GetDirectories(d, search))
|
foreach (string f in Directory.GetDirectories(d, search))
|
||||||
|
@ -217,22 +246,6 @@ namespace OpenTK.Build
|
||||||
}
|
}
|
||||||
FindDirectories(d, search, matches);
|
FindDirectories(d, search, matches);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (System.Exception e)
|
|
||||||
{
|
|
||||||
Console.WriteLine(e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void FindFiles(string directory, string search, List<string> matches)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
foreach (string f in Directory.GetFiles(directory, search, SearchOption.AllDirectories))
|
|
||||||
{
|
|
||||||
matches.Add(f);
|
|
||||||
}
|
|
||||||
//FindFiles(d, search, matches);
|
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (System.Exception e)
|
||||||
{
|
{
|
||||||
|
@ -240,59 +253,6 @@ namespace OpenTK.Build
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ExecuteProcess(string path, string args)
|
|
||||||
{
|
|
||||||
ProcessStartInfo sinfo = new ProcessStartInfo();
|
|
||||||
using (Process p = new Process())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Unix && !path.ToLower().Contains("nant"))
|
|
||||||
{
|
|
||||||
sinfo.FileName = "mono";
|
|
||||||
sinfo.Arguments = path + " " + args;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sinfo.FileName = path;
|
|
||||||
sinfo.Arguments = args;
|
|
||||||
}
|
|
||||||
|
|
||||||
sinfo.WorkingDirectory = RootPath;
|
|
||||||
sinfo.CreateNoWindow = true;
|
|
||||||
sinfo.RedirectStandardOutput = true;
|
|
||||||
sinfo.UseShellExecute = false;
|
|
||||||
p.StartInfo = sinfo;
|
|
||||||
p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
|
|
||||||
p.Start();
|
|
||||||
p.BeginOutputReadLine();
|
|
||||||
//StreamReader sr = p.StandardOutput;
|
|
||||||
//while (!p.HasExited)
|
|
||||||
//{
|
|
||||||
// Console.WriteLine(sr.ReadLine());
|
|
||||||
// Console.Out.Flush();
|
|
||||||
//}
|
|
||||||
|
|
||||||
p.WaitForExit();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Failed to execute process: {0}", sinfo.FileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
|
|
||||||
{
|
|
||||||
if (!String.IsNullOrEmpty(e.Data))
|
|
||||||
{
|
|
||||||
// Eat the last \n, we use WriteLine instead. This way we get the same result
|
|
||||||
// in both windows and linux (linux would interpret both \n and WriteLine).
|
|
||||||
Console.WriteLine(e.Data.TrimEnd('\n'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void FileCopy(string srcdir, string destdir, Regex match)
|
static void FileCopy(string srcdir, string destdir, Regex match)
|
||||||
{
|
{
|
||||||
//DirectoryInfo dir;
|
//DirectoryInfo dir;
|
||||||
|
@ -325,6 +285,25 @@ namespace OpenTK.Build
|
||||||
{
|
{
|
||||||
Prebuild.EntryPoint.Invoke(null, new object[] { options });
|
Prebuild.EntryPoint.Invoke(null, new object[] { options });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool CheckKeyFile(string keyfile)
|
||||||
|
{
|
||||||
|
if (!File.Exists(keyfile))
|
||||||
|
{
|
||||||
|
//Console.WriteLine("Keyfile {0} not found. Generating temporary key pair.", keyfile);
|
||||||
|
//Process keygen = Process.Start("sn", "-k " + keyfile);
|
||||||
|
//keygen.WaitForExit();
|
||||||
|
Console.WriteLine("Keyfile {0} not found. Assemblies will not be signed.", keyfile);
|
||||||
|
Console.WriteLine();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Keyfile {0} found. Assemblies will be signed.", keyfile);
|
||||||
|
Console.WriteLine();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
<CompilerDefines>DEBUG;TRACE;</CompilerDefines>
|
<CompilerDefines>DEBUG;TRACE;{0}</CompilerDefines>
|
||||||
<OptimizeCode>false</OptimizeCode>
|
<OptimizeCode>false</OptimizeCode>
|
||||||
<DebugInformation>true</DebugInformation>
|
<DebugInformation>true</DebugInformation>
|
||||||
</Options>
|
</Options>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
<Configuration name="Release">
|
<Configuration name="Release">
|
||||||
<Options>
|
<Options>
|
||||||
<CompilerDefines>TRACE;</CompilerDefines>
|
<CompilerDefines>TRACE;{0}</CompilerDefines>
|
||||||
<OptimizeCode>true</OptimizeCode>
|
<OptimizeCode>true</OptimizeCode>
|
||||||
<DebugInformation>false</DebugInformation>
|
<DebugInformation>false</DebugInformation>
|
||||||
</Options>
|
</Options>
|
||||||
|
|
Loading…
Reference in a new issue