コード例 #1
0
 public static bool CanRun(NMEProject project, NMEProjectConfiguration configuration, ExecutionContext context)
 {
     ExecutionCommand cmd = CreateExecutionCommand (project, configuration);
     if (cmd == null)
     {
         return false;
     }
     return context.ExecutionHandler.CanExecute (cmd);
 }
コード例 #2
0
		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 NMEProject (info, null);
			project.Files.Add (new ProjectFile (sourceFile));

			return project;
		}
コード例 #3
0
        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 NMEProject(info, null);
            project.Files.Add(new ProjectFile(sourceFile));

            return(project);
        }
コード例 #4
0
        public static string GetCompletionData(NMEProject project, string classPath, string fileName, int position)
        {
            NMEProjectConfiguration configuration = project.GetConfiguration (MonoDevelop.Ide.IdeApp.Workspace.ActiveConfiguration) as NMEProjectConfiguration;

            string platform = configuration.Platform.ToLower ();
            string path = project.TargetNMMLFile;

            if (!File.Exists (path))
            {
                path = Path.Combine (project.BaseDirectory, path);
            }

            DateTime time = File.GetLastWriteTime (Path.GetFullPath (path));

            if (!time.Equals (cacheNMMLTime) || platform != cachePlatform || configuration.AdditionalArguments != cacheArgumentsPlatform || project.AdditionalArguments != cacheArgumentsGlobal)
            {
                cacheHXML = GetHXMLData (project, configuration);
                cacheNMMLTime = time;
                cachePlatform = platform;
                cacheArgumentsGlobal = project.AdditionalArguments;
                cacheArgumentsPlatform = configuration.AdditionalArguments;
            }

            string exe = "haxe";
            string args = cacheHXML + " -cp \"" + classPath + "\" --display \"" + fileName + "\"@" + position + " -D use_rtti_doc";

            //MonoDevelop.Ide.MessageService.ShowMessage ("haxe " + args);

            Process process = new Process ();
            process.StartInfo.FileName = exe;
            process.StartInfo.Arguments = args;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.WorkingDirectory = project.BaseDirectory;
            process.Start ();

            string result = process.StandardError.ReadToEnd ();

            //MonoDevelop.Ide.MessageService.ShowMessage (result);

            process.WaitForExit ();

            return result;
        }
コード例 #5
0
		public static void Clean (NMEProject project, NMEProjectConfiguration configuration, IProgressMonitor monitor)
		{
			ProcessStartInfo info = new ProcessStartInfo ();
			
			info.FileName = "haxelib";
			info.Arguments = "run nme clean \"" + project.TargetNMMLFile + "\" " + configuration.Platform.ToLower () + " " + project.AdditionalArguments + " " + configuration.AdditionalArguments;
			info.UseShellExecute = false;
			info.RedirectStandardOutput = true;
			info.RedirectStandardError = true;
			info.WorkingDirectory = project.BaseDirectory;
			//info.WindowStyle = ProcessWindowStyle.Hidden;
			info.CreateNoWindow = true;
			
			using (Process process = Process.Start (info))
			{
				process.WaitForExit ();
			}
		}
コード例 #6
0
		public static BuildResult Compile (NMEProject project, NMEProjectConfiguration configuration, IProgressMonitor monitor)
		{
			string args = "run nme build \"" + project.TargetNMMLFile + "\" " + configuration.Platform.ToLower ();
			
			if (configuration.DebugMode)
			{
				args += " -debug";
			}
			
			if (project.AdditionalArguments != "")
			{
				args += " " + project.AdditionalArguments;
			}
			
			if (configuration.AdditionalArguments != "")
			{
				args += " " + configuration.AdditionalArguments;
			}
			
			string error = "";
			int exitCode = DoCompilation ("haxelib", 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;
		}
コード例 #7
0
        public static BuildResult Compile(NMEProject project, NMEProjectConfiguration configuration, IProgressMonitor monitor)
        {
            string args = "run nme build " + project.TargetNMMLFile + " " + configuration.Platform.ToLower ();

            if (configuration.DebugMode)
            {
                args += " -debug";
            }

            if (project.AdditionalArguments != "")
            {
                args += " " + project.AdditionalArguments;
            }

            if (configuration.AdditionalArguments != "")
            {
                args += " " + configuration.AdditionalArguments;
            }

            string error = "";
            int exitCode = DoCompilation ("haxelib", 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)
            {
                if (!string.IsNullOrEmpty (error))
                    result.AddError (error);
                else
                    result.AddError ("The compiler appears to have crashed without any error output.");
            }

            FileService.DeleteFile (error);
            return result;
        }
コード例 #8
0
		private static BuildError CreateErrorFromString (NMEProject 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;
		}
コード例 #9
0
		public static void Run (NMEProject project, NMEProjectConfiguration configuration, IProgressMonitor monitor, ExecutionContext context)
		{
			ExecutionCommand cmd = CreateExecutionCommand (project, configuration);

			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), 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), null);
			}
			finally
			{
				operationMonitor.Dispose ();
				console.Dispose ();
			}
		}
コード例 #10
0
		private static ExecutionCommand CreateExecutionCommand (NMEProject project, NMEProjectConfiguration configuration)
		{
			string exe = "haxelib";
			string args = "run nme run \"" + project.TargetNMMLFile + "\" " + configuration.Platform.ToLower ();
			
			if (configuration.DebugMode)
			{
				args += " -debug";
			}
			
			if (project.AdditionalArguments != "")
			{
				args += " " + project.AdditionalArguments;
			}
			
			if (configuration.AdditionalArguments != "")
			{
				args += " " + configuration.AdditionalArguments;
			}

			NativeExecutionCommand cmd = new NativeExecutionCommand (exe);
			cmd.Arguments = args;
			cmd.WorkingDirectory = project.BaseDirectory.FullPath;
			
			return cmd;
		}
コード例 #11
0
		static void ParserOutputFile (NMEProject 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 ();
		}
コード例 #12
0
		static BuildResult ParseOutput (NMEProject project, string stderr)
		{
			BuildResult result = new BuildResult ();

			StringBuilder output = new StringBuilder ();
			ParserOutputFile (project, result, output, stderr);

			result.CompilerOutput = output.ToString ();

			return result;
		}
コード例 #13
0
		public static string GetHXMLData (NMEProject project, NMEProjectConfiguration configuration)
		{
			ProcessStartInfo info = new ProcessStartInfo ();
			
			info.FileName = "haxelib";
			info.Arguments = "run nme update \"" + project.TargetNMMLFile + "\" " + configuration.Platform.ToLower () + " " + project.AdditionalArguments + " " + configuration.AdditionalArguments;
			info.UseShellExecute = false;
			info.RedirectStandardOutput = true;
			info.RedirectStandardError = true;
			info.WorkingDirectory = project.BaseDirectory;
			//info.WindowStyle = ProcessWindowStyle.Hidden;
			info.CreateNoWindow = true;
			
			using (Process process = Process.Start (info))
			{
				process.WaitForExit ();
			}
			
			info.Arguments = "run nme display \"" + project.TargetNMMLFile + "\" " + configuration.Platform.ToLower () + " " + project.AdditionalArguments + " " + configuration.AdditionalArguments;
			
			using (Process process = Process.Start (info))
			{
				string data = process.StandardOutput.ReadToEnd ();
				process.WaitForExit ();
				return data.Replace (Environment.NewLine, " ");
			}
		}
コード例 #14
0
        public static void Run(NMEProject project, NMEProjectConfiguration configuration, IProgressMonitor monitor, ExecutionContext context)
        {
            string exe = "haxelib";
            string args = "run nme run " + project.TargetNMMLFile + " " + configuration.Platform.ToLower ();

            if (configuration.DebugMode)
            {
                args += " -debug";
            }

            if (project.AdditionalArguments != "")
            {
                args += " " + project.AdditionalArguments;
            }

            if (configuration.AdditionalArguments != "")
            {
                args += " " + configuration.AdditionalArguments;
            }

            IConsole console;
            if (configuration.ExternalConsole)
                console = context.ExternalConsoleFactory.CreateConsole (false);
            else
                console = context.ConsoleFactory.CreateConsole (false);

            AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor);

            try
            {
                NativeExecutionCommand cmd = new NativeExecutionCommand (exe);
                cmd.Arguments = args;
                cmd.WorkingDirectory = project.BaseDirectory.FullPath;

                if (!context.ExecutionHandler.CanExecute (cmd))
                {
                    monitor.ReportError (String.Format ("Cannot execute '{0} {1}'.", exe, args), 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} {1}'.", exe, args), null);
            }
            finally
            {
                operationMonitor.Dispose ();
                console.Dispose ();
            }
        }
コード例 #15
0
        public static string GetHXMLPath(NMEProject project)
        {
            string directory = Path.GetDirectoryName (project.TargetNMMLFile);

            if (directory == "")
            {
                directory = project.BaseDirectory;
            }

            return Path.Combine (directory, Path.GetFileNameWithoutExtension (project.TargetNMMLFile) + ".hxml");
        }