コード例 #1
0
        internal static void GenerateMakefiles(SolutionItem entry, Solution solution)
        {
            if (solution == null)
            {
                AlertButton generateMakefilesButton = new AlertButton(GettextCatalog.GetString("_Generate Makefiles"));
                if (MessageService.AskQuestion(GettextCatalog.GetString("Generating Makefiles is not supported for single projects. Do you want to generate them for the full solution - '{0}' ?", entry.ParentSolution.Name),
                                               AlertButton.Cancel,
                                               generateMakefilesButton) == generateMakefilesButton)
                {
                    solution = ((SolutionItem)entry).ParentSolution;
                }
                else
                {
                    return;
                }
            }

            DeployContext    ctx     = null;
            IProgressMonitor monitor = null;

            GenerateMakefilesDialog dialog = new GenerateMakefilesDialog(solution);

            try
            {
                if (MessageService.RunCustomDialog(dialog) != (int)Gtk.ResponseType.Ok)
                {
                    return;
                }

                SolutionDeployer deployer = new SolutionDeployer(dialog.GenerateAutotools);
                if (deployer.HasGeneratedFiles(solution))
                {
                    string msg = GettextCatalog.GetString("{0} already exist for this solution.  Would you like to overwrite them?", dialog.GenerateAutotools ? "Autotools files" : "Makefiles");
                    if (MonoDevelop.Ide.MessageService.AskQuestion(msg, AlertButton.Cancel, AlertButton.OverwriteFile) != AlertButton.OverwriteFile)
                    {
                        return;
                    }
                }

                ctx     = new DeployContext(new TarballDeployTarget(dialog.GenerateAutotools), "Linux", null);
                monitor = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor(true);
                deployer.GenerateFiles(ctx, solution, dialog.DefaultConfiguration, monitor);
            }
            finally
            {
                dialog.Destroy();
                if (ctx != null)
                {
                    ctx.Dispose();
                }
                if (monitor != null)
                {
                    monitor.Dispose();
                }
            }
        }
コード例 #2
0
ファイル: Commands.cs プロジェクト: riverans/monodevelop
		internal static void GenerateMakefiles (SolutionItem entry, Solution solution)
		{
			if (solution == null) {
				AlertButton generateMakefilesButton = new AlertButton (GettextCatalog.GetString ("_Generate Makefiles"));
				if (MessageService.AskQuestion (GettextCatalog.GetString ("Generating Makefiles is not supported for single projects. Do you want to generate them for the full solution - '{0}' ?", entry.ParentSolution.Name),
				                                AlertButton.Cancel,
				                                generateMakefilesButton) == generateMakefilesButton) 
					solution = ((SolutionItem)entry).ParentSolution;
				else
					return;
			}

			DeployContext ctx = null;
			IProgressMonitor monitor = null;

			GenerateMakefilesDialog dialog = new GenerateMakefilesDialog (solution);
			try {
				if (MessageService.RunCustomDialog (dialog) != (int) Gtk.ResponseType.Ok)
					return;

				SolutionDeployer deployer = new SolutionDeployer (dialog.GenerateAutotools);
				if ( deployer.HasGeneratedFiles ( solution ) )
				{
					string msg = GettextCatalog.GetString ( "{0} already exist for this solution.  Would you like to overwrite them?", dialog.GenerateAutotools ? "Autotools files" : "Makefiles" );
					if (MonoDevelop.Ide.MessageService.AskQuestion (msg, AlertButton.Cancel, AlertButton.OverwriteFile) != AlertButton.OverwriteFile)
						return;
				}

				ctx = new DeployContext (new TarballDeployTarget (dialog.GenerateAutotools), "Linux", null);
				monitor = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (true);
				deployer.GenerateFiles (ctx, solution, dialog.DefaultConfiguration, monitor);
			} finally {
				dialog.Destroy ();
				dialog.Dispose ();
				if (ctx != null)
					ctx.Dispose ();
				if (monitor != null)
					monitor.Dispose ();
			}
		}
コード例 #3
0
		public int Run (string [] arguments)
		{
			Console.WriteLine ("MonoDevelop Makefile generator");
			if (arguments.Length == 0) {
				ShowUsage ();
				return 0;
			}

			// Parse arguments
			foreach (string s in arguments) {
				if (s == "--simple-makefiles" || s == "-s") {
					generateAutotools = false;
				} else if (s.StartsWith ("-d:")) {
					if (s.Length > 3)
						defaultConfig = s.Substring (3);
				} else if (s [0] == '-') {
					Console.WriteLine (GettextCatalog.GetString ("Error: Unknown option {0}", s));
					return 1;
				} else {
					if (filename != null) {
						Console.WriteLine (GettextCatalog.GetString ("Error: Filename already specified - {0}, another filename '{1}' cannot be specified.", filename, s));
						return 1;
					}

					filename = s;
				}
			}

			if (filename == null) {
				Console.WriteLine (GettextCatalog.GetString ("Error: Solution file not specified."));
				ShowUsage ();
				return 1;
			}

			Console.WriteLine (GettextCatalog.GetString ("Loading solution file {0}", filename));
			ConsoleProgressMonitor monitor = new ConsoleProgressMonitor ();
			
			Solution solution = Services.ProjectService.ReadWorkspaceItem (monitor, filename) as Solution;
			if (solution == null) {
				Console.WriteLine (GettextCatalog.GetString ("Error: Makefile generation supported only for solutions.\n"));
				return 1;
			}

			if (defaultConfig == null || !CheckValidConfig (solution, defaultConfig)) {
				Console.WriteLine (GettextCatalog.GetString ("\nInvalid configuration {0}. Valid configurations : ", defaultConfig));
				for (int i = 0; i < solution.Configurations.Count; i ++) {
					SolutionConfiguration cc = (SolutionConfiguration) solution.Configurations [i];
					Console.WriteLine ("\t{0}. {1}", i + 1, cc.Id);
				}

				int configCount = solution.Configurations.Count;
				int op = 0;
				do {
					Console.Write (GettextCatalog.GetString ("Select configuration : "));
					string s = Console.ReadLine ();
					if (s.Length == 0)
						return 1;
					if (int.TryParse (s, out op)) {
						if (op > 0 && op <= configCount)
							break;
					}
				} while (true);

				defaultConfig = solution.Configurations [op - 1].Id;

			}

			SolutionDeployer deployer = new SolutionDeployer (generateAutotools);
			if (deployer.HasGeneratedFiles (solution)) {
				string msg = GettextCatalog.GetString ( "{0} already exist for this solution.  Would you like to overwrite them? (Y/N)",
						generateAutotools ? "Autotools files" : "Makefiles" );
				bool op = false;
				do {
					Console.Write (msg);
					string line = Console.ReadLine ();
					if (line.Length == 0)
						return 1;

					if (line.Length == 1) {
						if (line [0] == 'Y' || line [0] == 'y')
							op = true;
						else if (line [0] == 'N' || line [0] == 'n')
							op = false;
						else
							continue;
					} else {
						if (String.Compare (line, "YES", true) == 0)
							op = true;
						else if (String.Compare (line, "NO", true) == 0)
							op = false;
						else
							continue;
					}
					break;
				} while (true);
				if (!op)
					return 0;
			}

			DeployContext ctx = new DeployContext (new TarballDeployTarget (), "Linux", null);
			try {
				deployer.GenerateFiles (ctx, solution, defaultConfig, monitor);
			}
			finally {
				ctx.Dispose ();
				monitor.Dispose ();
			}

			return 0;
		}
コード例 #4
0
ファイル: Handler.cs プロジェクト: Kalnor/monodevelop
		public override bool CanBuild (SolutionItem entry)
		{
			SolutionDeployer deployer = new SolutionDeployer (generateAutotools);
			return deployer.CanDeploy ( entry );
		}
コード例 #5
0
ファイル: Handler.cs プロジェクト: Kalnor/monodevelop
		protected override bool OnBuild (IProgressMonitor monitor, DeployContext ctx)
		{
			string tmpFolder = FileService.CreateTempDirectory ();
			Solution solution = null;
			SolutionItem entry = RootSolutionItem;
			
			try {
				if (generateFiles) {
					List<string> childEntries = new List<string> ();
					if (entry is SolutionFolder) {
						SolutionItem[] ents = GetChildEntries ();
						foreach (SolutionItem it in ents)
							childEntries.Add (it.ItemId);
					}
					else {
						// If the entry is not a combine, use the parent combine as base combine
						childEntries.Add (entry.ItemId);
						entry = entry.ParentFolder;
					}
							
					string sourceFile;
					if (entry is SolutionFolder)
						sourceFile = entry.ParentSolution.FileName;
					else
						sourceFile = ((SolutionEntityItem)entry).FileName;
					
					string efile = Services.ProjectService.Export (new FilteredProgressMonitor (monitor), sourceFile, childEntries.ToArray (), tmpFolder, null);
					if (efile == null) {
						monitor.ReportError (GettextCatalog.GetString ("The project could not be exported."), null);
						return false;
					}
					solution = Services.ProjectService.ReadWorkspaceItem (new NullProgressMonitor (), efile) as Solution;
				}
				else {
					solution = entry.ParentSolution;
				}
				
				solution.Build (monitor, (SolutionConfigurationSelector) defaultConfig);
			
				if (monitor.IsCancelRequested || !monitor.AsyncOperation.Success)
					return false;
			
				SolutionDeployer deployer = new SolutionDeployer (generateAutotools);
				deployer.AddSwitches (switchs);
				
				if (!deployer.Deploy ( ctx, solution, DefaultConfiguration, TargetDir, generateFiles, monitor ))
					return false;
				
			} finally {
				if (solution != null)
					solution.Dispose ();
				Directory.Delete (tmpFolder, true);
			}
			return true;
		}
コード例 #6
0
ファイル: Handler.cs プロジェクト: miaojiang1/monodevelop-1
        public override bool CanBuild(SolutionItem entry)
        {
            SolutionDeployer deployer = new SolutionDeployer(generateAutotools);

            return(deployer.CanDeploy(entry));
        }
コード例 #7
0
ファイル: Handler.cs プロジェクト: miaojiang1/monodevelop-1
        protected override bool OnBuild(IProgressMonitor monitor, DeployContext ctx)
        {
            string       tmpFolder = FileService.CreateTempDirectory();
            Solution     solution  = null;
            SolutionItem entry     = RootSolutionItem;

            try {
                if (generateFiles)
                {
                    List <string> childEntries = new List <string> ();
                    if (entry is SolutionFolder)
                    {
                        SolutionItem[] ents = GetChildEntries();
                        foreach (SolutionItem it in ents)
                        {
                            childEntries.Add(it.ItemId);
                        }
                    }
                    else
                    {
                        // If the entry is not a combine, use the parent combine as base combine
                        childEntries.Add(entry.ItemId);
                        entry = entry.ParentFolder;
                    }

                    string sourceFile;
                    if (entry is SolutionFolder)
                    {
                        sourceFile = entry.ParentSolution.FileName;
                    }
                    else
                    {
                        sourceFile = ((SolutionEntityItem)entry).FileName;
                    }

                    string efile = Services.ProjectService.Export(new FilteredProgressMonitor(monitor), sourceFile, childEntries.ToArray(), tmpFolder, null);
                    if (efile == null)
                    {
                        monitor.ReportError(GettextCatalog.GetString("The project could not be exported."), null);
                        return(false);
                    }
                    solution = Services.ProjectService.ReadWorkspaceItem(new NullProgressMonitor(), efile) as Solution;
                }
                else
                {
                    solution = entry.ParentSolution;
                }

                solution.Build(monitor, (SolutionConfigurationSelector)defaultConfig);

                if (monitor.IsCancelRequested || !monitor.AsyncOperation.Success)
                {
                    return(false);
                }

                SolutionDeployer deployer = new SolutionDeployer(generateAutotools);
                deployer.AddSwitches(switchs);

                if (!deployer.Deploy(ctx, solution, DefaultConfiguration, TargetDir, generateFiles, monitor))
                {
                    return(false);
                }
            } finally {
                if (solution != null)
                {
                    solution.Dispose();
                }
                Directory.Delete(tmpFolder, true);
            }
            return(true);
        }
コード例 #8
0
        public int Run(string [] arguments)
        {
            Console.WriteLine("MonoDevelop Makefile generator");
            if (arguments.Length == 0)
            {
                ShowUsage();
                return(0);
            }

            // Parse arguments
            foreach (string s in arguments)
            {
                if (s == "--simple-makefiles" || s == "-s")
                {
                    generateAutotools = false;
                }
                else if (s.StartsWith("-d:"))
                {
                    if (s.Length > 3)
                    {
                        defaultConfig = s.Substring(3);
                    }
                }
                else if (s [0] == '-')
                {
                    Console.WriteLine(GettextCatalog.GetString("Error: Unknown option {0}", s));
                    return(1);
                }
                else
                {
                    if (filename != null)
                    {
                        Console.WriteLine(GettextCatalog.GetString("Error: Filename already specified - {0}, another filename '{1}' cannot be specified.", filename, s));
                        return(1);
                    }

                    filename = s;
                }
            }

            if (filename == null)
            {
                Console.WriteLine(GettextCatalog.GetString("Error: Solution file not specified."));
                ShowUsage();
                return(1);
            }

            Console.WriteLine(GettextCatalog.GetString("Loading solution file {0}", filename));
            ConsoleProgressMonitor monitor = new ConsoleProgressMonitor();

            Solution solution = Services.ProjectService.ReadWorkspaceItem(monitor, filename) as Solution;

            if (solution == null)
            {
                Console.WriteLine(GettextCatalog.GetString("Error: Makefile generation supported only for solutions.\n"));
                return(1);
            }

            if (defaultConfig == null || !CheckValidConfig(solution, defaultConfig))
            {
                Console.WriteLine(GettextCatalog.GetString("\nInvalid configuration {0}. Valid configurations : ", defaultConfig));
                for (int i = 0; i < solution.Configurations.Count; i++)
                {
                    SolutionConfiguration cc = (SolutionConfiguration)solution.Configurations [i];
                    Console.WriteLine("\t{0}. {1}", i + 1, cc.Id);
                }

                int configCount = solution.Configurations.Count;
                int op          = 0;
                do
                {
                    Console.Write(GettextCatalog.GetString("Select configuration : "));
                    string s = Console.ReadLine();
                    if (s.Length == 0)
                    {
                        return(1);
                    }
                    if (int.TryParse(s, out op))
                    {
                        if (op > 0 && op <= configCount)
                        {
                            break;
                        }
                    }
                } while (true);

                defaultConfig = solution.Configurations [op - 1].Id;
            }

            SolutionDeployer deployer = new SolutionDeployer(generateAutotools);

            if (deployer.HasGeneratedFiles(solution))
            {
                string msg = GettextCatalog.GetString("{0} already exist for this solution.  Would you like to overwrite them? (Y/N)",
                                                      generateAutotools ? "Autotools files" : "Makefiles");
                bool op = false;
                do
                {
                    Console.Write(msg);
                    string line = Console.ReadLine();
                    if (line.Length == 0)
                    {
                        return(1);
                    }

                    if (line.Length == 1)
                    {
                        if (line [0] == 'Y' || line [0] == 'y')
                        {
                            op = true;
                        }
                        else if (line [0] == 'N' || line [0] == 'n')
                        {
                            op = false;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (String.Compare(line, "YES", true) == 0)
                        {
                            op = true;
                        }
                        else if (String.Compare(line, "NO", true) == 0)
                        {
                            op = false;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    break;
                } while (true);
                if (!op)
                {
                    return(0);
                }
            }

            DeployContext ctx = new DeployContext(new TarballDeployTarget(), "Linux", null);

            try {
                deployer.GenerateFiles(ctx, solution, defaultConfig, monitor);
            }
            finally {
                ctx.Dispose();
                monitor.Dispose();
            }

            return(0);
        }