public override Shell.ExecuteResult RunAndMakeExecuteResult(string executable, string arguments) { Shell.ExecuteArgs executeArgs = new Shell.ExecuteArgs { Executable = executable, Arguments = arguments, WorkingDirectory = Path.GetDirectoryName(executable), EnvVars = null }; return(Shell.Execute(executeArgs, null)); }
public static NPath Compile(List <SourceFileDescription> program, IEnumerable <NPath> additionalLibs, NPath outputFile = null) { var executable = outputFile ?? NPath.CreateTempDirectory("CSharp").Combine("program.exe"); var tmpDir = executable.Parent; foreach (var fileEntry in program) { var file = tmpDir.Combine(fileEntry.File).WriteAllText(fileEntry.Contents); //Console.WriteLine(".cs: " + file); } var csproj = tmpDir.Combine("program.csproj"); csproj.WriteAllText(CSProjContentsFor(program, additionalLibs)); Console.WriteLine("csproj: " + csproj); var compiler = new NPath(@"C:\il2cpp-dependencies\MonoBleedingEdge\builds\monodistribution\bin\mcs" + (Environment.OSVersion.Platform == PlatformID.Win32NT ? ".bat" : "")); if (additionalLibs == null) { additionalLibs = new NPath[0]; } var rsp = tmpDir.Combine("args.rsp"); rsp.WriteAllText(program.Select(f => f.File).InQuotes().SeperateWithSpace()); var args = new Shell.ExecuteArgs() { Executable = compiler.ToString(), Arguments = "@" + rsp + " " + additionalLibs.InQuotes().Select(l => "-r:" + l).SeperateWithSpace() + " -debug -langversion:6 -out:" + executable.InQuotes(), WorkingDirectory = tmpDir.ToString() }; Console.WriteLine(args.Arguments); var executeResult = Shell.Execute(args); Console.Write(executeResult.StdErr + executeResult.StdOut); if (executeResult.ExitCode != 0) { throw new Exception(); } foreach (var lib in additionalLibs) { lib.Copy(tmpDir); } return(executable); }
public string Summary() { Shell.ExecuteArgs args = this.ToExecuteArgs(); StringBuilder builder = new StringBuilder(); builder.AppendLine("Executable: " + args.Executable); builder.AppendLine("Arguments: " + args.Arguments); if (args.EnvVars != null) { foreach (KeyValuePair <string, string> pair in args.EnvVars) { builder.AppendLine("EnvArg key: " + pair.Key + " value: " + pair.Value); } } return(builder.ToString()); }
public override Shell.ExecuteResult RunAndMakeExecuteResult(string executable) { bool flag; Shell.ExecuteResult result; string[] append = new string[] { "AppxManifest.xml" }; NPath path = new NPath(Path.GetDirectoryName(executable)).Combine(append); if (!File.Exists(executable)) { throw new ArgumentException($"Specified executable (" { executable } ") does not exist!"); } if (!path.Exists("")) { throw new ArgumentException($"AppX manifest was not found next to the executable at " { path } "!"); } WinRTManifest.AddActivatableClasses(path); using (Mutex mutex = new Mutex(true, @"Global\WinRTRunnerBuild", out flag)) { if (!flag) { mutex.WaitOne(); } try { MakeSureRunnerIsBuilt(); Shell.ExecuteArgs executeArgs = new Shell.ExecuteArgs { Executable = WinRTRunnerExecutablePath.ToString(), Arguments = path.InQuotes(), WorkingDirectory = WinRTRunnerExecutablePath.Parent.ToString() }; using (TinyProfiler.Section("Run WinRT Application", "")) { result = Shell.Execute(executeArgs, null); } } finally { mutex.ReleaseMutex(); } } return(result); }
public override Shell.ExecuteResult RunAndMakeExecuteResult(string executable) { bool flag; Shell.ExecuteResult result; string[] append = new string[] { "AppxManifest.xml" }; NPath path = new NPath(Path.GetDirectoryName(executable)).Combine(append); if (!File.Exists(executable)) { throw new ArgumentException(string.Format("Specified executable (\"{0}\") does not exist!", executable)); } if (!path.Exists("")) { throw new ArgumentException(string.Format("AppX manifest was not found next to the executable at \"{0}\"!", path)); } WinRTManifest.AddActivatableClasses(path); using (Mutex mutex = new Mutex(true, @"Global\WinRTRunnerBuild", out flag)) { if (!flag) { mutex.WaitOne(); } try { MakeSureRunnerIsBuilt(); Shell.ExecuteArgs executeArgs = new Shell.ExecuteArgs { Executable = WinRTRunnerExecutablePath.ToString(), Arguments = path.InQuotes(), WorkingDirectory = WinRTRunnerExecutablePath.Parent.ToString() }; using (TinyProfiler.Section("Run WinRT Application", "")) { result = Shell.Execute(executeArgs, null); } } finally { mutex.ReleaseMutex(); } } return result; }
//[Ignore("Playground")] public void A() { var converter = new JamToCSharpConverter(); var basePath = new NPath("c:/unity"); var files = new List <NPath>(); files.AddRange(basePath.Combine("Runtime").Files("*.jam", true)); files.AddRange(basePath.Combine("Editor").Files("*.jam", true)); files.AddRange(basePath.Combine("Projects/Jam").Files("*.jam", true)); files.AddRange(basePath.Files("*.jam", false)); files.AddRange(basePath.Combine("PlatformDependent").Files("*.jam", true)); var program = files.Where(f => !f.ToString().Contains("Config")).Select(f => new SourceFileDescription() { File = f.RelativeTo(basePath), Contents = f.ReadAllText() }).ToArray(); var csProgram = converter.Convert(new ProgramDescripton(program)); var jambase = @"C:\jamconverter\external\jamplus\bin\Jambase.jam"; var instructions = new JamRunnerInstructions() { CSharpFiles = csProgram, WorkingDir = new NPath("c:/unity"), JamFileToInvokeOnStartup = jambase.InQuotes(), }; var tempDir = NPath.SystemTemp.Combine("JamRunner"); instructions.WorkingDir = instructions.WorkingDir ?? tempDir; foreach (var f1 in instructions.JamfilesToCreate) { instructions.WorkingDir.Combine(f1.File).WriteAllText(f1.Contents); } CSharpRunner.Compile(csProgram, JamToCSharpConverter.RuntimeDependencies, tempDir.Combine("csharp.exe")); string genericArgs = $"-f {jambase.InQuotes()} -C {instructions.WorkingDir} \"<StandalonePlayer>Runtime/Graphics/Texture2D.obj\" -sPLATFORM=win64 -q -dx"; var csharpOnlyArgs = "-m " + tempDir.Combine("csharp.exe").InQuotes(); var finalArg = genericArgs + " " + csharpOnlyArgs; Console.WriteLine("args: " + JamBinary() + " " + finalArg); throw new Exception(); var args2 = new Shell.ExecuteArgs() { Arguments = finalArg, Executable = JamBinary().ToString() }; var output_cs = DropBox().Combine("output_cs"); Shell.Execute(args2, null, output_cs); //Truncate(output_cs); var args = new Shell.ExecuteArgs() { Arguments = genericArgs, Executable = JamBinary().ToString() }; var output_jam = DropBox().Combine("output_jam"); Shell.Execute(args, null, output_jam); // Truncate(output_jam); }