Beispiel #1
0
        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);
        }
		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;
		}