Last active
August 29, 2015 14:02
-
-
Save Alxandr/872873f4fe1329a4546e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Reflection; | |
namespace Kake | |
{ | |
class Bootstrap | |
{ | |
delegate int EntryPoint(string[] args); | |
static int Main(string[] args) | |
{ | |
if (!K.HasAlias("default")) | |
K.Upgrade().Wait(); | |
var bin = K.GetRuntime("default"); | |
var klrf = Path.Combine(bin, "klr.net45.managed.dll"); | |
var klr = Assembly.LoadFile(klrf); | |
var type = klr.GetType("klr.hosting.RuntimeBootstrapper"); | |
var method = type.GetMethod("Execute", BindingFlags.Public | BindingFlags.Static, null, new[] { typeof(string[]) }, null); | |
var dlg = (EntryPoint)Delegate.CreateDelegate(typeof(EntryPoint), method); | |
var dir = Environment.CurrentDirectory; | |
var name = Assembly.GetExecutingAssembly().GetName().Name; | |
var newArgs = new string[args.Length + 1]; | |
newArgs[0] = name; | |
Array.Copy(args, 0, newArgs, 1, args.Length); | |
// Set the default lib path to be next to the entry point location | |
Environment.SetEnvironmentVariable("KRE_DEFAULT_LIB", bin); | |
Environment.SetEnvironmentVariable("KRE_CONSOLE_HOST", "1"); | |
#if DEBUG | |
var ret = dlg(newArgs); | |
Console.ReadLine(); | |
return ret; | |
#else | |
return dlg(newArgs); | |
#endif | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment