public void Load (SolutionConfiguration config)
		{
			configuration = config;

			store.Clear ();
			foreach (var it in solution.GetAllSolutionItems ().OfType<SolutionItem> ().Where (s => s.SupportsBuild ())) {
				var ce = config.GetEntryForItem (it);
				store.AppendValues (it.Name, ce != null && ce.Build, it);
			}
		}
Beispiel #2
0
 void CollectBuildableEntries(HashSet <SolutionItem> collected, ConfigurationSelector configuration, SolutionConfiguration slnConf, bool includeDependencies)
 {
     foreach (SolutionFolderItem item in Items)
     {
         if (item is SolutionFolder sf)
         {
             sf.CollectBuildableEntries(collected, configuration, slnConf, includeDependencies);
         }
         else if (item is SolutionItem si && slnConf.BuildEnabledForItem(si) && si.SupportsBuild() && collected.Add(si))
         {
             if (includeDependencies)
             {
                 CollectBuildableDependencies(collected, si, configuration, slnConf);
             }
         }
     }
 }
		public object ReadFile (FilePath fileName, bool hasParentSolution, ProgressMonitor monitor)
		{
			FilePath basePath = fileName.ParentDirectory;
			MonoMakefile mkfile = new MonoMakefile (fileName);
			string aname = mkfile.GetVariable ("LIBRARY");
			if (aname == null)
				aname = mkfile.GetVariable ("PROGRAM");

			if (!string.IsNullOrEmpty (aname)) {
				monitor.BeginTask ("Loading '" + fileName + "'", 0);
				var project = Services.ProjectService.CreateProject ("C#");
				project.FileName = fileName;

				var ext = new MonoMakefileProjectExtension ();
				project.AttachExtension (ext);
				ext.Read (mkfile);

				monitor.EndTask ();
				return project;
			}

			string subdirs;
			StringBuilder subdirsBuilder = new StringBuilder ();
			subdirsBuilder.Append (mkfile.GetVariable ("common_dirs"));
			if (subdirsBuilder.Length != 0) {
				subdirsBuilder.Append ("\t");
				subdirsBuilder.Append (mkfile.GetVariable ("net_2_0_dirs"));
			}
			if (subdirsBuilder.Length == 0)
				subdirsBuilder.Append (mkfile.GetVariable ("SUBDIRS"));

			subdirs = subdirsBuilder.ToString ();
			if (subdirs != null && (subdirs = subdirs.Trim (' ', '\t')) != "") {
				object retObject;
				SolutionFolder folder;
				if (!hasParentSolution) {
					Solution sol = new Solution ();
					sol.AttachExtension (new MonoMakefileSolutionExtension ());
					sol.FileName = fileName;
					folder = sol.RootFolder;
					retObject = sol;

					foreach (string conf in MonoMakefile.MonoConfigurations) {
						SolutionConfiguration sc = new SolutionConfiguration (conf);
						sol.Configurations.Add (sc);
					}
				} else {
					folder = new SolutionFolder ();
					folder.Name = Path.GetFileName (Path.GetDirectoryName (fileName));
					retObject = folder;
				}

				subdirs = subdirs.Replace ('\t', ' ');
				string[] dirs = subdirs.Split (' ');

				monitor.BeginTask ("Loading '" + fileName + "'", dirs.Length);
				HashSet<string> added = new HashSet<string> ();
				foreach (string dir in dirs) {
					if (!added.Add (dir))
						continue;
					monitor.Step (1);
					if (dir == null)
						continue;
					string tdir = dir.Trim ();
					if (tdir == "")
						continue;
					string mfile = Path.Combine (Path.Combine (basePath, tdir), "Makefile");
					if (File.Exists (mfile) && CanRead (mfile, typeof(SolutionItem))) {
						SolutionFolderItem it = (SolutionFolderItem) ReadFile (mfile, true, monitor);
						folder.Items.Add (it);
					}
				}
				monitor.EndTask ();
				return retObject;
			}
			return null;
		}
Beispiel #4
0
        public void AddProjectAndSolutionConfiguration(DubProjectConfiguration cfg)
        {
            if (ParentSolution != null)
            {
                var slnCfg = new SolutionConfiguration(cfg.Name, cfg.Platform);
                ParentSolution.Configurations.Add(slnCfg);
                slnCfg.AddItem(this).Build = true;
            }
            Configurations.Add(cfg);

            if (Configurations.Count == 1)
                DefaultConfigurationId = cfg.Id;
        }
Beispiel #5
0
        public static Solution CreateConsoleSolution(string hint)
        {
            string dir = Util.CreateTmpDir(hint);

            Solution sol = new Solution();
            SolutionConfiguration scDebug = sol.AddConfiguration("Debug", true);

            DotNetAssemblyProject project = new DotNetAssemblyProject("C#");

            sol.RootFolder.Items.Add(project);
            Assert.AreEqual(0, project.Configurations.Count);

            InitializeProject(dir, project, "TestProject");
            project.References.Add(new ProjectReference(ReferenceType.Package, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
            project.References.Add(new ProjectReference(ReferenceType.Package, "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
            project.References.Add(new ProjectReference(ReferenceType.Package, "System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
            project.Files.Add(new ProjectFile(Path.Combine(dir, "Program.cs")));
            project.Files.Add(new ProjectFile(Path.Combine(dir, "Resource.xml"), BuildAction.EmbeddedResource));
            project.Files.Add(new ProjectFile(Path.Combine(dir, "Excluded.xml"), BuildAction.Content));
            ProjectFile pf = new ProjectFile(Path.Combine(dir, "Copy.xml"), BuildAction.Content);

            pf.CopyToOutputDirectory = FileCopyMode.Always;
            project.Files.Add(pf);
            project.Files.Add(new ProjectFile(Path.Combine(dir, "Nothing.xml"), BuildAction.None));

            Assert.IsFalse(scDebug.GetEntryForItem(project).Build);
            scDebug.GetEntryForItem(project).Build = true;

            SolutionConfiguration scRelease = sol.AddConfiguration("Release", true);

            string file = Path.Combine(dir, "TestSolution.sln");

            sol.FileName = file;

            Assert.AreEqual(2, sol.Configurations.Count);
            Assert.AreEqual(1, scDebug.Configurations.Count);
            Assert.AreEqual(1, scRelease.Configurations.Count);
            Assert.AreEqual(2, project.Configurations.Count);
            foreach (var v in project.Files)
            {
                if (v.FilePath.FileName == "Program.cs")
                {
                    File.WriteAllText(v.FilePath,
                                      @"
using System;

namespace Foo {
	public class MainClass {
		public static void Main (string [] args)
		{
		}
	}
}");
                }
                else
                {
                    File.WriteAllText(v.FilePath, v.Name);
                }
            }
            return(sol);
        }
		public void Deserialize (ITypeSerializer handler, DataCollection data)
		{
			DataItem item = new DataItem ();
			item.Name = "SolutionConfiguration";
			DataCollection col = item.ItemData;
			
			foreach (DataNode val in data) {
				if (val.Name != "name" && val.Name != "ctype" && val.Name != "Entry")
					col.Add (val);
			}
			
			handler.Deserialize (this, data);
			
			if (data.Count > 0) {
				solutionConfiguration = new SolutionConfiguration (name);
				handler.SerializationContext.Serializer.Deserialize (solutionConfiguration, item);
			}
		}
		/**
		 * returns a set of projects that a combine contains and a set of projects
		 * that are referenced from combine projects but not part of the combine
		 */
		void GetAllProjects (SolutionFolder folder, SolutionConfiguration config, out Set<SolutionFolderItem> projects, out Set<SolutionFolderItem> references)
		{
			List<SolutionFolderItem> subitems = new List<SolutionFolderItem> ();
			GetSubItems (subitems, folder);

			projects = (Set<SolutionFolderItem>) combineProjects [folder];
			if (projects != null) {
				references = (Set<SolutionFolderItem>) combineReferences [folder];
				return;
			}

			projects = new Set<SolutionFolderItem>();
			references = new Set<SolutionFolderItem>();
			
			foreach (SolutionFolderItem item in subitems) 
			{
				if (item is SolutionItem)
				{
					SolutionItem entry = (SolutionItem) item;
					if (!config.BuildEnabledForItem (entry))
						continue;
					projects.Add (entry);
					references.Union (entry.GetReferencedItems (config.Selector));
				}
				else if (item is SolutionFolder) 
				{
					Set<SolutionFolderItem> subProjects;
					Set<SolutionFolderItem> subReferences;
					GetAllProjects ((SolutionFolder)item, config, out subProjects, out subReferences);
					projects.Union (subProjects);
					references.Union (subReferences);
				}
			}
			
			references.Without (projects);
			combineProjects [folder] = projects;
			combineReferences [folder] = references;
		}
Beispiel #8
0
 /*protected virtual*/ void OnWriteConfigurationData(ProgressMonitor monitor, SlnPropertySet properties, SolutionConfiguration configuration)
 {
     // Do nothing by default
 }
Beispiel #9
0
 internal protected override void OnReadConfigurationData(ProgressMonitor monitor, SlnPropertySet properties, SolutionConfiguration configuration)
 {
     Solution.OnReadConfigurationData(monitor, properties, configuration);
 }
Beispiel #10
0
 void GetAllBuildableReferences(List <SolutionItem> list, SolutionItem item, ConfigurationSelector configuration, SolutionConfiguration conf, bool includeExternalReferences, bool isDirectReference)
 {
     if (list.Contains(item) || !conf.BuildEnabledForItem(item))
     {
         return;
     }
     // Skip unsupported projects which are not directly referenced by other (supported) projects
     if (!isDirectReference && item.IsUnsupportedProject)
     {
         return;
     }
     list.Add(item);
     if (includeExternalReferences)
     {
         foreach (var it in item.GetReferencedItems(configuration))
         {
             GetAllBuildableReferences(list, it, configuration, conf, includeExternalReferences, true);
         }
     }
 }
Beispiel #11
0
 internal void WriteConfigurationData(ProgressMonitor monitor, SlnPropertySet properties, SolutionConfiguration configuration)
 {
     SolutionExtension.OnWriteConfigurationData(monitor, properties, configuration);
 }
		internal protected virtual void OnWriteConfigurationData (ProgressMonitor monitor, SlnPropertySet properties, SolutionConfiguration configuration)
		{
			next.OnWriteConfigurationData (monitor, properties, configuration);
		}
Beispiel #13
0
		internal void AddProjectAndSolutionConfiguration(DubProjectConfiguration cfg)
		{//TODO: Is an other config with the same id already existing?
			if (ParentSolution != null)
			{
				var slnCfg = new SolutionConfiguration(cfg.Name, cfg.Platform);
				ParentSolution.Configurations.Add(slnCfg);
				slnCfg.AddItem(this).Build = true;
			}
			Configurations.Add(cfg);

			if (Configurations.Count == 1)
				DefaultConfigurationId = cfg.Id;
		}
Beispiel #14
0
 internal protected virtual void OnWriteConfigurationData(ProgressMonitor monitor, SlnPropertySet properties, SolutionConfiguration configuration)
 {
     next.OnWriteConfigurationData(monitor, properties, configuration);
 }
		public void Load (SolutionConfiguration config)
		{
			configuration = config;

			store.Clear ();
			foreach (SolutionConfigurationEntry ce in configuration.Configurations) {
				if (ce.Item != null && !(ce.Item is UnknownSolutionItem))
					store.AppendValues (ce, ce.Item.Name, ce.Build);
			}
		}
Beispiel #16
0
 static void CollectBuildableDependencies(HashSet <SolutionItem> collected, SolutionItem item, ConfigurationSelector configuration, SolutionConfiguration conf)
 {
     foreach (var it in item.GetReferencedItems(configuration))
     {
         if (collected.Contains(it) || !conf.BuildEnabledForItem(it))
         {
             continue;
         }
         collected.Add(it);
         CollectBuildableDependencies(collected, it, configuration, conf);
     }
 }
		public object ReadFile (FilePath fileName, bool hasParentSolution, IProgressMonitor monitor)
		{
			FilePath basePath = fileName.ParentDirectory;
			MonoMakefile mkfile = new MonoMakefile (fileName);
			string aname = mkfile.GetVariable ("LIBRARY");
			if (aname == null) aname = mkfile.GetVariable ("PROGRAM");
			
			try {
				ProjectExtensionUtil.BeginLoadOperation ();
				if (aname != null) {
					// It is a project
					monitor.BeginTask ("Loading '" + fileName + "'", 0);
					DotNetAssemblyProject project = new DotNetAssemblyProject ("C#");
					MonoSolutionItemHandler handler = new MonoSolutionItemHandler (project);
					ProjectExtensionUtil.InstallHandler (handler, project);
					project.Name = Path.GetFileName (basePath);
					handler.Read (mkfile);
					monitor.EndTask ();
					return project;
				} else {
					string subdirs;
					StringBuilder subdirsBuilder = new StringBuilder ();
					subdirsBuilder.Append (mkfile.GetVariable ("common_dirs"));
					if (subdirsBuilder.Length != 0) {
						subdirsBuilder.Append ("\t");
						subdirsBuilder.Append (mkfile.GetVariable ("net_2_0_dirs"));
					}
					if (subdirsBuilder.Length == 0)
						subdirsBuilder.Append (mkfile.GetVariable ("SUBDIRS"));
	
					subdirs = subdirsBuilder.ToString ();
					if (subdirs != null && (subdirs = subdirs.Trim (' ','\t')) != "")
					{
						object retObject;
						SolutionFolder folder;
						if (!hasParentSolution) {
							Solution sol = new Solution ();
							sol.ConvertToFormat (Services.ProjectService.FileFormats.GetFileFormat ("MonoMakefile"), false);
							sol.FileName = fileName;
							folder = sol.RootFolder;
							retObject = sol;
							
							foreach (string conf in MonoMakefileFormat.Configurations) {
								SolutionConfiguration sc = new SolutionConfiguration (conf);
								sol.Configurations.Add (sc);
							}
						} else {
							folder = new SolutionFolder ();
							folder.Name = Path.GetFileName (Path.GetDirectoryName (fileName));
							retObject = folder;
						}
						
						subdirs = subdirs.Replace ('\t',' ');
						string[] dirs = subdirs.Split (' ');
						
						monitor.BeginTask ("Loading '" + fileName + "'", dirs.Length);
						Hashtable added = new Hashtable ();
						foreach (string dir in dirs) {
							if (added.Contains (dir)) continue;
							added.Add (dir, dir);
							monitor.Step (1);
							if (dir == null) continue;
							string tdir = dir.Trim ();
							if (tdir == "") continue;
							string mfile = Path.Combine (Path.Combine (basePath, tdir), "Makefile");
							if (File.Exists (mfile) && CanReadFile (mfile, typeof(SolutionItem))) {
								SolutionItem it = (SolutionItem) ReadFile (mfile, true, monitor);
								folder.Items.Add (it);
							}
						}
						monitor.EndTask ();
						return retObject;
					}
				}
			} finally {
				ProjectExtensionUtil.EndLoadOperation ();
			}
			return null;
		}
		internal SolutionConfigurationEntry (SolutionConfiguration parentConfig, SolutionConfigurationEntry other)
		{
			this.parentConfig = parentConfig;
			this.itemId = other.itemId;
			this.configuration = other.configuration;
			this.build = other.build;
			this.deploy = other.deploy;
		}
		// utility function for finding the correct order to process directories
		List<SolutionFolderItem> CalculateSubDirOrder (AutotoolsContext ctx, SolutionFolder folder, SolutionConfiguration config)
		{
			List<SolutionFolderItem> resultOrder = new List<SolutionFolderItem>();
			Set<SolutionFolderItem> dependenciesMet = new Set<SolutionFolderItem>();
			Set<SolutionFolderItem> inResult = new Set<SolutionFolderItem>();
			
			// We don't have to worry about projects built in parent combines
			dependenciesMet.Union (ctx.GetBuiltProjects ());

			bool added;
			string notMet;
			do 
			{
				added = false;
				notMet = null;
				
				List<SolutionFolderItem> items = new List<SolutionFolderItem> ();
				GetSubItems (items, folder);

				foreach (SolutionFolderItem item in items) 
				{
					Set<SolutionFolderItem> references, provides;
					
					if (inResult.Contains (item))
						continue;
					
					if (item is SolutionItem)
					{
						SolutionItem entry = (SolutionItem) item;
						if (!config.BuildEnabledForItem (entry))
							continue;
						
						references = new Set<SolutionFolderItem> ();
						provides = new Set<SolutionFolderItem>();
						references.Union (entry.GetReferencedItems (config.Selector));
						provides.Add (entry);
					}
					else if (item is SolutionFolder) {
						GetAllProjects ((SolutionFolder) item, config, out provides, out references);
					}
					else
						continue;
	
					if (dependenciesMet.ContainsSet (references) ) 
					{
						resultOrder.Add (item);
						dependenciesMet.Union(provides);
						inResult.Add(item);
						added = true;
					} 
					else notMet = item.Name;
				}
			} while (added);

			if (notMet != null) 
				throw new Exception("Impossible to find a solution order that satisfies project references for '" + notMet + "'");

			return resultOrder;
		}
		internal SolutionConfigurationEntry (SolutionConfiguration parentConfig, SolutionEntityItem item)
		{
			this.parentConfig = parentConfig;
			this.item = item;
			configuration = parentConfig.Id;
			itemId = item.ItemId;
		}
		bool ConfigurationEquals (Solution sol, SolutionConfiguration s1, SolutionConfiguration s2)
		{
			foreach (var p in sol.GetAllItems<SolutionItem> ()) {
				var c1 = s1.GetEntryForItem (p);
				var c2 = s2.GetEntryForItem (p);
				if (c1 == null && c2 == null)
					continue;
				if (c1 == null || c2 == null)
					return false;
				if (c1.Build != c2.Build || c1.ItemConfiguration != c2.ItemConfiguration)
					return false;
			}
			return true;
		}
        public static Solution CreateProjectWithFolders(string hint)
        {
            string dir = Util.CreateTmpDir(hint);

            Directory.CreateDirectory(Util.Combine(dir, "console-project"));
            Directory.CreateDirectory(Util.Combine(dir, "nested-solution1"));
            Directory.CreateDirectory(Util.Combine(dir, "nested-solution1", "library1"));
            Directory.CreateDirectory(Util.Combine(dir, "nested-solution1", "library2"));
            Directory.CreateDirectory(Util.Combine(dir, "nested-solution2"));
            Directory.CreateDirectory(Util.Combine(dir, "nested-solution2", "console-project2"));
            Directory.CreateDirectory(Util.Combine(dir, "nested-solution2", "nested-solution3"));
            Directory.CreateDirectory(Util.Combine(dir, "nested-solution2", "nested-solution3", "library3"));
            Directory.CreateDirectory(Util.Combine(dir, "nested-solution2", "nested-solution3", "library4"));

            Solution sol = new Solution();

            sol.FileName = Path.Combine(dir, "nested-solutions-mdp");
            SolutionConfiguration scDebug   = sol.AddConfiguration("Debug", true);
            SolutionConfiguration scRelease = sol.AddConfiguration("Release", true);

            DotNetProject project1 = CreateProject(Util.Combine(dir, "console-project"), "C#", "console-project");

            project1.Files.Add(new ProjectFile(Path.Combine(project1.BaseDirectory, "Program.cs")));
            project1.Files.Add(new ProjectFile(Path.Combine(project1.BaseDirectory, "Properties", "AssemblyInfo.cs")));
            sol.RootFolder.Items.Add(project1);

            // nested-solution1

            SolutionFolder folder1 = new SolutionFolder();

            sol.RootFolder.Items.Add(folder1);
            folder1.Name = "nested-solution1";

            DotNetProject projectLib1 = CreateProject(Util.Combine(dir, "nested-solution1", "library1"), "C#", "library1");

            projectLib1.References.Add(new ProjectReference(ReferenceType.Package, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
            projectLib1.Files.Add(new ProjectFile(Path.Combine(projectLib1.BaseDirectory, "MyClass.cs")));
            projectLib1.Files.Add(new ProjectFile(Path.Combine(projectLib1.BaseDirectory, "Properties", "AssemblyInfo.cs")));
            projectLib1.CompileTarget = CompileTarget.Library;
            folder1.Items.Add(projectLib1);

            DotNetProject projectLib2 = CreateProject(Util.Combine(dir, "nested-solution1", "library2"), "C#", "library2");

            projectLib2.References.Add(new ProjectReference(ReferenceType.Package, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
            projectLib2.Files.Add(new ProjectFile(Path.Combine(projectLib2.BaseDirectory, "MyClass.cs")));
            projectLib2.Files.Add(new ProjectFile(Path.Combine(projectLib2.BaseDirectory, "Properties", "AssemblyInfo.cs")));
            projectLib2.CompileTarget = CompileTarget.Library;
            folder1.Items.Add(projectLib2);

            // nested-solution2

            SolutionFolder folder2 = new SolutionFolder();

            folder2.Name = "nested-solution2";
            sol.RootFolder.Items.Add(folder2);

            DotNetProject project2 = CreateProject(Util.Combine(dir, "nested-solution2", "console-project2"), "C#", "console-project2");

            project2.Files.Add(new ProjectFile(Path.Combine(project2.BaseDirectory, "Program.cs")));
            project2.Files.Add(new ProjectFile(Path.Combine(project2.BaseDirectory, "Properties", "AssemblyInfo.cs")));
            project2.References.Add(new ProjectReference(ReferenceType.Package, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));

            // nested-solution3

            SolutionFolder folder3 = new SolutionFolder();

            folder3.Name = "nested-solution3";

            DotNetProject projectLib3 = CreateProject(Util.Combine(dir, "nested-solution2", "nested-solution3", "library3"), "C#", "library3");

            projectLib3.References.Add(new ProjectReference(ReferenceType.Package, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
            projectLib3.Files.Add(new ProjectFile(Path.Combine(projectLib3.BaseDirectory, "MyClass.cs")));
            projectLib3.Files.Add(new ProjectFile(Path.Combine(projectLib3.BaseDirectory, "Properties", "AssemblyInfo.cs")));
            projectLib3.CompileTarget = CompileTarget.Library;
            folder3.Items.Add(projectLib3);

            DotNetProject projectLib4 = CreateProject(Util.Combine(dir, "nested-solution2", "nested-solution3", "library4"), "C#", "library4");

            projectLib4.References.Add(new ProjectReference(ReferenceType.Package, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
            projectLib4.Files.Add(new ProjectFile(Path.Combine(projectLib4.BaseDirectory, "MyClass.cs")));
            projectLib4.Files.Add(new ProjectFile(Path.Combine(projectLib4.BaseDirectory, "Properties", "AssemblyInfo.cs")));
            projectLib4.CompileTarget = CompileTarget.Library;
            folder3.Items.Add(projectLib4);

            folder2.Items.Add(folder3);
            folder2.Items.Add(project2);

            string file = Path.Combine(dir, "TestSolution.sln");

            sol.FileName = file;

            project1.References.Add(new ProjectReference(ReferenceType.Package, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
            project1.References.Add(new ProjectReference(projectLib1));
            project1.References.Add(new ProjectReference(projectLib2));
            project1.References.Add(new ProjectReference(projectLib3));
            project1.References.Add(new ProjectReference(projectLib4));

            project2.References.Add(new ProjectReference(projectLib3));
            project2.References.Add(new ProjectReference(projectLib4));

            Assert.AreEqual(2, sol.Configurations.Count);
            Assert.AreEqual(6, scDebug.Configurations.Count);
            Assert.AreEqual(6, scRelease.Configurations.Count);

            return(sol);
        }