public Project CreateSingleFileProject (string sourceFile) { ProjectCreateInformation info = new ProjectCreateInformation (); info.ProjectName = Path.GetFileNameWithoutExtension (sourceFile); info.SolutionPath = Path.GetDirectoryName (sourceFile); info.ProjectBasePath = Path.GetDirectoryName (sourceFile); Project project = null; project = new HaxeProject (info, null); project.Files.Add (new ProjectFile (sourceFile)); return project; }
public Project CreateSingleFileProject(string sourceFile) { ProjectCreateInformation info = new ProjectCreateInformation(); info.ProjectName = Path.GetFileNameWithoutExtension(sourceFile); info.SolutionPath = Path.GetDirectoryName(sourceFile); info.ProjectBasePath = Path.GetDirectoryName(sourceFile); Project project = null; project = new HaxeProject(info, null); project.Files.Add(new ProjectFile(sourceFile)); return(project); }
public static bool CanRun(HaxeProject project, HaxeProjectConfiguration configuration, ExecutionContext context) { // need to optimize so this caches the result ExecutionCommand cmd = CreateExecutionCommand (project, configuration); if (cmd == null) { return false; } else if (cmd is NativeExecutionCommand) { return context.ExecutionHandler.CanExecute (cmd); } else { return true; } }
public static BuildResult Compile(HaxeProject project, HaxeProjectConfiguration configuration, IProgressMonitor monitor) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(" -output \"{0}/{1}\" ", configuration.OutputDirectory, configuration.OutputFileName); if (configuration.DebugMode) sb.Append("-compiler.debug=true "); if (!String.IsNullOrEmpty(configuration.CompilerParameters)) { sb.Append(configuration.CompilerParameters); sb.Append(" "); } sb.Append(project.MainSource); string output = ""; string error = ""; string cmd = Path.Combine(Path.Combine(PropertyService.Get<string>("CBinding.FlexSdkPath"), "bin"), project.Compiler); string args = sb.ToString(); monitor.Log.WriteLine(cmd+" "+args); int exitCode = DoCompilation(cmd, args, project.BaseDirectory, ref output, ref error); BuildResult result = ParseOutput(output, error); if (result.CompilerOutput.Trim().Length != 0) monitor.Log.WriteLine(result.CompilerOutput); // If compiler crashes, output entire error string. if (result.ErrorCount == 0 && exitCode != 0) { if (!string.IsNullOrEmpty(error)) result.AddError(error); else result.AddError("The compiler appears to have crashed without any error output."); } FileService.DeleteFile(output); FileService.DeleteFile(error); return result; }
public void Load(HaxeProject project) { mProject = project; switch (mProject.TargetFormat) { case TargetFormat.SWF: wTargetCombo.Active = 0; break; } switch (mProject.MainLanguage) { case Language.Haxe : wLanguageCombo.Active = 0; break; } switch (mProject.RunMode) { case RunMode.StandalonePlayer : wRunCombo.Active = 0; break; case RunMode.SystemPlugin : wRunCombo.Active = 1; break; case RunMode.CustomPlugin : wRunCombo.Active = 2; break; } wMainSourceEntry.Text = mProject.MainSource; }
public static BuildResult Compile(HaxeProject project, HaxeProjectConfiguration configuration, IProgressMonitor monitor) { string exe = "haxe"; //string args = project.TargetHXMLFile; string hxmlPath = Path.GetFullPath (project.TargetHXMLFile); if (!File.Exists (hxmlPath)) { hxmlPath = Path.Combine (project.BaseDirectory, project.TargetHXMLFile); } string hxml = File.ReadAllText (hxmlPath); hxml = hxml.Replace (Environment.NewLine, " "); string[] hxmlArgs = hxml.Split (' '); bool createNext = false; foreach (string hxmlArg in hxmlArgs) { if (createNext) { if (!hxmlArg.StartsWith ("-")) { string path = Path.GetFullPath (Path.GetDirectoryName (hxmlArg)); if (!Directory.Exists (path)) { path = Path.Combine (project.BaseDirectory, hxmlArg); if (!Directory.Exists (Path.GetDirectoryName (path))) { Directory.CreateDirectory (Path.GetDirectoryName (path)); } } } createNext = false; } if (hxmlArg == "-js" || hxmlArg == "-swf" || hxmlArg == "-swf9" || hxmlArg == "-neko") { createNext = true; } } string args = String.Join (" ", hxmlArgs); if (configuration.DebugMode) { args += " -debug"; } if (project.AdditionalArguments != "") { args += " " + project.AdditionalArguments; } if (configuration.AdditionalArguments != "") { args += " " + configuration.AdditionalArguments; } string error = ""; int exitCode = DoCompilation (exe, args, project.BaseDirectory, monitor, ref error); BuildResult result = ParseOutput (project, error); if (result.CompilerOutput.Trim ().Length != 0) monitor.Log.WriteLine (result.CompilerOutput); if (result.ErrorCount == 0 && exitCode != 0) { string errorMessage = File.ReadAllText (error); if (!string.IsNullOrEmpty (errorMessage)) result.AddError (errorMessage); else result.AddError ("Build failed. Go to \"Build Output\" for more information"); } FileService.DeleteFile (error); return result; }
static void ParserOutputFile(HaxeProject project, BuildResult result, StringBuilder output, string filename) { StreamReader reader = File.OpenText (filename); string line; while ((line = reader.ReadLine()) != null) { output.AppendLine (line); line = line.Trim (); if (line.Length == 0 || line.StartsWith ("\t")) continue; BuildError error = CreateErrorFromString (project, line); if (error != null) result.Append (error); } reader.Close (); }
static BuildResult ParseOutput(HaxeProject project, string stderr) { BuildResult result = new BuildResult (); StringBuilder output = new StringBuilder (); ParserOutputFile (project, result, output, stderr); result.CompilerOutput = output.ToString (); return result; }
private static ExecutionCommand CreateExecutionCommand(HaxeProject project, HaxeProjectConfiguration configuration) { string hxmlPath = Path.GetFullPath (project.TargetHXMLFile); if (!File.Exists (hxmlPath)) { hxmlPath = Path.Combine (project.BaseDirectory, project.TargetHXMLFile); } string hxml = File.ReadAllText (hxmlPath); hxml = hxml.Replace (Environment.NewLine, " "); string[] hxmlArgs = hxml.Split (' '); List<string> platforms = new List<string> (); List<string> platformOutputs = new List<string> (); bool addNext = false; bool nextIsMain = false; string main = ""; foreach (string hxmlArg in hxmlArgs) { if (addNext) { if (!hxmlArg.StartsWith ("-")) { if (nextIsMain) { main = hxmlArg; nextIsMain = false; } else { platformOutputs.Add (hxmlArg); } } else { if (!nextIsMain) { platforms.RemoveAt (platforms.Count - 1); } } } addNext = true; switch (hxmlArg) { case "-cpp": platforms.Add ("cpp"); break; case "-swf": case "-swf9": platforms.Add ("flash"); break; case "-js": platforms.Add ("js"); break; case "-neko": platforms.Add ("neko"); break; case "-php": platforms.Add ("php"); break; case "-main": nextIsMain = true; break; default: addNext = false; break; } } int i = 0; //for (int i = 0; i < platforms.Count; i++) //{ string platform = platforms[i]; string output = platformOutputs[i]; if (platform == "cpp" || platform == "neko") { if (platform == "cpp") { output = Path.Combine (output, main); if (configuration.DebugMode) { output += "-debug"; } } if (!File.Exists (Path.GetFullPath (output))) { output = Path.Combine (project.BaseDirectory, output); } string exe = ""; string args = ""; if (platform == "cpp") { exe = output; } else { exe = "neko"; args = "\"" + output + "\""; } NativeExecutionCommand cmd = new NativeExecutionCommand (exe); cmd.Arguments = args; cmd.WorkingDirectory = Path.GetDirectoryName (output); if (configuration.DebugMode) { cmd.EnvironmentVariables.Add ("HXCPP_DEBUG_HOST", "gdb"); cmd.EnvironmentVariables.Add ("HXCPP_DEBUG", "1"); } //cmd.WorkingDirectory = project.BaseDirectory.FullPath; //MonoDevelop.Ide.MessageService.ShowMessage (cmd.Command); //MonoDevelop.Ide.MessageService.ShowMessage (cmd.Arguments); //MonoDevelop.Ide.MessageService.ShowMessage (cmd.WorkingDirectory); return cmd; } else if (platform == "flash" || platform == "js") { if (!File.Exists (Path.GetFullPath (output))) { output = Path.Combine (project.BaseDirectory, output); } if (platform == "js") { output = Path.Combine (Path.GetDirectoryName (output), "index.html"); } //string target = output; switch (Environment.OSVersion.Platform) { case PlatformID.MacOSX: //target = "open \"" + output + "\""; break; case PlatformID.Unix: //target = "xdg-open \"" + output + "\""; break; } ProcessExecutionCommand cmd = new ProcessExecutionCommand (); cmd.Command = output; return cmd; } //} return null; }
private static BuildError CreateErrorFromString(HaxeProject project, string text) { Match match = mErrorIgnore.Match (text); if (match.Success) return null; match = mErrorFull.Match (text); if (!match.Success) match = mErrorCmdLine.Match (text); if (!match.Success) match = mErrorFileChar.Match (text); if (!match.Success) match = mErrorFileChars.Match (text); if (!match.Success) match = mErrorFile.Match (text); if (!match.Success) match = mErrorSimple.Match (text); if (!match.Success) return null; int n; BuildError error = new BuildError (); error.FileName = match.Result ("${file}") ?? ""; error.IsWarning = match.Result ("${level}").ToLower () == "warning"; error.ErrorText = match.Result ("${message}"); if (error.FileName == "${file}") { error.FileName = ""; } else { if (!File.Exists (error.FileName)) { if (File.Exists (Path.GetFullPath (error.FileName))) { error.FileName = Path.GetFullPath (error.FileName); } else { error.FileName = Path.Combine (project.BaseDirectory, error.FileName); } } } if (Int32.TryParse (match.Result ("${line}"), out n)) error.Line = n; else error.Line = 0; if (Int32.TryParse (match.Result ("${column}"), out n)) error.Column = n+1; //haxe counts zero based else error.Column = -1; return error; }
public static void Run(HaxeProject project, HaxeProjectConfiguration configuration, IProgressMonitor monitor, ExecutionContext context) { ExecutionCommand cmd = CreateExecutionCommand (project, configuration); if (cmd is NativeExecutionCommand) { IConsole console; if (configuration.ExternalConsole) console = context.ExternalConsoleFactory.CreateConsole (false); else console = context.ConsoleFactory.CreateConsole (false); AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor); try { if (!context.ExecutionHandler.CanExecute (cmd)) { monitor.ReportError (String.Format ("Cannot execute '{0}'.", cmd.CommandString), null); return; } IProcessAsyncOperation operation = context.ExecutionHandler.Execute (cmd, console); operationMonitor.AddOperation (operation); operation.WaitForCompleted (); monitor.Log.WriteLine ("Player exited with code {0}.", operation.ExitCode); } catch (Exception) { monitor.ReportError (String.Format ("Error while executing '{0}'.", cmd.CommandString), null); } finally { operationMonitor.Dispose (); console.Dispose (); } } else { Process.Start (cmd.CommandString); } }