public override bool CanRead(FilePath file, Type expectedType) { if (file.FileName != "Makefile") { return(false); } MonoMakefile mkfile = new MonoMakefile(file); if (mkfile.Content.IndexOf("build/rules.make") == -1) { return(false); } if (mkfile.GetVariable("LIBRARY") != null) { return(expectedType.IsAssignableFrom(typeof(DotNetProject))); } if (mkfile.GetVariable("PROGRAM") != null) { return(expectedType.IsAssignableFrom(typeof(DotNetProject))); } string subdirs = mkfile.GetVariable("SUBDIRS"); if (subdirs != null && subdirs.Trim(' ', '\t') != "") { return(expectedType.IsAssignableFrom(typeof(Solution)) || expectedType.IsAssignableFrom(typeof(SolutionFolder))); } return(false); }
public bool CanReadFile(string file) { if (Path.GetFileName (file) != "Makefile") return false; MonoMakefile mkfile = new MonoMakefile (file); if (mkfile.Content.IndexOf ("build/rules.make") == -1) return false; if (mkfile.GetVariable ("LIBRARY") != null) return true; if (mkfile.GetVariable ("PROGRAM") != null) return true; string subdirs = mkfile.GetVariable ("SUBDIRS"); if (subdirs != null && subdirs.Trim (' ','\t') != "") return true; return false; }
public bool CanReadFile (FilePath file, Type expectedType) { if (file.FileName != "Makefile") return false; MonoMakefile mkfile = new MonoMakefile (file); if (mkfile.Content.IndexOf ("build/rules.make") == -1) return false; if (mkfile.GetVariable ("LIBRARY") != null) return expectedType.IsAssignableFrom (typeof(DotNetProject)); if (mkfile.GetVariable ("PROGRAM") != null) return expectedType.IsAssignableFrom (typeof(DotNetProject)); string subdirs = mkfile.GetVariable ("SUBDIRS"); if (subdirs != null && subdirs.Trim (' ','\t') != "") return expectedType.IsAssignableFrom (typeof(Solution)) || expectedType.IsAssignableFrom (typeof(SolutionFolder)); return false; }
public object ReadFile(string fileName, IProgressMonitor monitor) { string basePath = Path.GetDirectoryName (fileName); MonoMakefile mkfile = new MonoMakefile (fileName); string aname = mkfile.GetVariable ("LIBRARY"); if (aname == null) aname = mkfile.GetVariable ("PROGRAM"); if (aname != null) { // It is a project monitor.BeginTask ("Loading '" + fileName + "'", 0); MonoProject project = new MonoProject (mkfile); monitor.EndTask (); return project; } else { string subdirs = mkfile.GetVariable ("SUBDIRS"); if (subdirs != null && (subdirs = subdirs.Trim (' ','\t')) != "") { Combine combine = new MonoCombine (); combine.FileName = fileName; combine.Name = Path.GetFileName (basePath); 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)) combine.AddEntry (mfile, monitor); } monitor.EndTask (); return combine; } } 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); }
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; }
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); }
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; }
internal void Read(MonoMakefile mkfile) { loading = true; string basePath = Path.GetDirectoryName(mkfile.FileName); string aname; string targetAssembly = mkfile.GetVariable("LIBRARY"); if (targetAssembly == null) { targetAssembly = mkfile.GetVariable("PROGRAM"); if (Path.GetDirectoryName(targetAssembly) == "") { targetAssembly = Path.Combine(basePath, targetAssembly); } aname = Path.GetFileName(targetAssembly); } else { aname = Path.GetFileName(targetAssembly); string targetName = mkfile.GetVariable("LIBRARY_NAME"); if (targetName != null) { targetAssembly = targetName; } targetAssembly = "$(topdir)/class/lib/$(PROFILE)/" + targetAssembly; } outFile = Path.Combine(basePath, aname); Project.FileName = mkfile.FileName; ArrayList checkedFolders = new ArrayList(); // Parse projects string sources = outFile + ".sources"; StreamReader sr = new StreamReader(sources); string line; while ((line = sr.ReadLine()) != null) { line = line.Trim(' ', '\t'); if (line != "") { string fname = Path.Combine(basePath, line); Project.Files.Add(new ProjectFile(fname)); string dir = Path.GetDirectoryName(fname); if (!checkedFolders.Contains(dir)) { checkedFolders.Add(dir); fname = Path.Combine(dir, "ChangeLog"); if (File.Exists(fname)) { Project.Files.Add(new ProjectFile(fname, BuildAction.Content)); } } } } sr.Close(); // Project references string refs = mkfile.GetVariable("LIB_MCS_FLAGS"); if (refs == null || refs == "") { refs = mkfile.GetVariable("LOCAL_MCS_FLAGS"); } if (refs != null && refs != "") { Regex var = new Regex(@"(.*?/r:(?<ref>.*?)(( |\t)|$).*?)*"); Match match = var.Match(refs); if (match.Success) { foreach (Capture c in match.Groups["ref"].Captures) { refNames.Add(Path.GetFileNameWithoutExtension(c.Value)); } } } int i = basePath.LastIndexOf("/mcs/", basePath.Length - 2); string topdir = basePath.Substring(0, i + 4); targetAssembly = targetAssembly.Replace("$(topdir)", topdir); if (mkfile.GetVariable("NO_TEST") != "yes") { string tname = Path.GetFileNameWithoutExtension(aname) + "_test_"; testFileBase = Path.Combine(basePath, tname); } foreach (string sconf in MonoMakefile.MonoConfigurations) { var conf = (DotNetProjectConfiguration)Project.CreateConfiguration(sconf); conf.OutputDirectory = basePath; conf.OutputAssembly = Path.GetFileName(targetAssembly); Project.Configurations.Add(conf); } loading = false; IdeApp.Workspace.SolutionLoaded += CombineOpened; }
internal void Read (MonoMakefile mkfile) { loading = true; string basePath = Path.GetDirectoryName (mkfile.FileName); string aname; string targetAssembly = mkfile.GetVariable ("LIBRARY"); if (targetAssembly == null) { targetAssembly = mkfile.GetVariable ("PROGRAM"); if (Path.GetDirectoryName (targetAssembly) == "") targetAssembly = Path.Combine (basePath, targetAssembly); aname = Path.GetFileName (targetAssembly); } else { aname = Path.GetFileName (targetAssembly); string targetName = mkfile.GetVariable ("LIBRARY_NAME"); if (targetName != null) targetAssembly = targetName; targetAssembly = "$(topdir)/class/lib/$(PROFILE)/" + targetAssembly; } outFile = Path.Combine (basePath, aname); project.FileName = mkfile.FileName; ArrayList checkedFolders = new ArrayList (); // Parse projects string sources = outFile + ".sources"; StreamReader sr = new StreamReader (sources); string line; while ((line = sr.ReadLine ()) != null) { line = line.Trim (' ','\t'); if (line != "") { string fname = Path.Combine (basePath, line); project.Files.Add (new ProjectFile (fname)); string dir = Path.GetDirectoryName (fname); if (!checkedFolders.Contains (dir)) { checkedFolders.Add (dir); fname = Path.Combine (dir, "ChangeLog"); if (File.Exists (fname)) project.Files.Add (new ProjectFile (fname, BuildAction.Content)); } } } sr.Close (); // Project references string refs = mkfile.GetVariable ("LIB_MCS_FLAGS"); if (refs == null || refs == "") refs = mkfile.GetVariable ("LOCAL_MCS_FLAGS"); if (refs != null && refs != "") { Regex var = new Regex(@"(.*?/r:(?<ref>.*?)(( |\t)|$).*?)*"); Match match = var.Match (refs); if (match.Success) { foreach (Capture c in match.Groups["ref"].Captures) refNames.Add (Path.GetFileNameWithoutExtension (c.Value)); } } int i = basePath.LastIndexOf ("/mcs/", basePath.Length - 2); string topdir = basePath.Substring (0, i + 4); targetAssembly = targetAssembly.Replace ("$(topdir)", topdir); if (mkfile.GetVariable ("NO_TEST") != "yes") { string tname = Path.GetFileNameWithoutExtension (aname) + "_test_"; testFileBase = Path.Combine (basePath, tname); } foreach (string sconf in MonoMakefileFormat.Configurations) { DotNetProjectConfiguration conf = new DotNetProjectConfiguration (sconf); conf.CompilationParameters = project.LanguageBinding.CreateCompilationParameters (null); conf.OutputDirectory = basePath; conf.OutputAssembly = Path.GetFileName (targetAssembly); project.Configurations.Add (conf); } loading = false; IdeApp.Workspace.SolutionLoaded += CombineOpened; }
internal MonoProject(MonoMakefile mkfile) { Read (mkfile); }
void Read(MonoMakefile mkfile) { loading = true; string basePath = Path.GetDirectoryName (mkfile.FileName); string aname; string targetAssembly = mkfile.GetVariable ("LIBRARY"); if (targetAssembly == null) { targetAssembly = mkfile.GetVariable ("PROGRAM"); if (Path.GetDirectoryName (targetAssembly) == "") targetAssembly = Path.Combine (basePath, targetAssembly); aname = Path.GetFileName (targetAssembly); } else { aname = Path.GetFileName (targetAssembly); string targetName = mkfile.GetVariable ("LIBRARY_NAME"); if (targetName != null) targetAssembly = targetName; targetAssembly = "$(topdir)/class/lib/$(PROFILE)/" + targetAssembly; } Name = Path.GetFileNameWithoutExtension (aname); outFile = Path.Combine (basePath, aname); FileName = mkfile.FileName; ArrayList checkedFolders = new ArrayList (); // Parse projects string sources = outFile + ".sources"; StreamReader sr = new StreamReader (sources); string line; while ((line = sr.ReadLine ()) != null) { line = line.Trim (' ','\t'); if (line != "") { string fname = Path.Combine (basePath, line); ProjectFiles.Add (new ProjectFile (fname)); string dir = Path.GetDirectoryName (fname); if (!checkedFolders.Contains (dir)) { checkedFolders.Add (dir); fname = Path.Combine (dir, "ChangeLog"); if (File.Exists (fname)) ProjectFiles.Add (new ProjectFile (fname, BuildAction.Exclude)); } } } sr.Close (); // Project references string refs = mkfile.GetVariable ("LIB_MCS_FLAGS"); if (refs == null || refs == "") refs = mkfile.GetVariable ("LOCAL_MCS_FLAGS"); if (refs != null && refs != "") { Regex var = new Regex(@"(.*?/r:(?<ref>.*?)(( |\t)|$).*?)*"); Match match = var.Match (refs); if (match.Success) { foreach (Capture c in match.Groups["ref"].Captures) refNames.Add (Path.GetFileNameWithoutExtension (c.Value)); } } int i = basePath.LastIndexOf ("/mcs/", basePath.Length - 2); string topdir = basePath.Substring (0, i + 4); targetAssembly = targetAssembly.Replace ("$(topdir)", topdir); if (mkfile.GetVariable ("NO_TEST") != "yes") { string tname = Path.GetFileNameWithoutExtension (aname) + "_test_"; string testFileBase = Path.Combine (basePath, tname); testSuite = new MonoTestSuite (this, Name, testFileBase); } MonoProjectConfiguration conf = new MonoProjectConfiguration ("default", "default"); conf.OutputDirectory = basePath; conf.AssemblyPathTemplate = targetAssembly; Configurations.Add (conf); conf = new MonoProjectConfiguration ("net_2_0", "net_2_0"); conf.OutputDirectory = basePath; conf.AssemblyPathTemplate = targetAssembly; Configurations.Add (conf); Console.WriteLine ("{0} {1}", aname, GetOutputFileName ()); loading = false; Runtime.ProjectService.CombineOpened += new CombineEventHandler (CombineOpened); }