diff --git a/msvc/scripts/genproj.cs b/msvc/scripts/genproj.cs index c61e89c19bb9e0b935c562adbd786ded28107614..60b4036396213371311c9beeed78e78876abd830 100644 --- a/msvc/scripts/genproj.cs +++ b/msvc/scripts/genproj.cs @@ -38,7 +38,7 @@ class SlnGenerator { const string project_start = "Project(\"{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}\") = \"{0}\", \"{1}\", \"{2}\""; // Note: No need to double up on {} around {2} const string project_end = "EndProject"; - List libraries = new List (); + public List libraries = new List (); string header; string MakeHeader (string formatVersion, string yearTag) @@ -123,7 +123,7 @@ class MsbuildGenerator { } // The directory as specified in order.xml - string dir; + public string dir; string library; string projectGuid; string fx_version; @@ -153,7 +153,8 @@ class MsbuildGenerator { projectGuid = this.projectGuid, library_output = this.LibraryOutput, fx_version = double.Parse (fx_version), - library = this.library + library = this.library, + MsbuildGenerator = this }; if (dir == "mcs") { @@ -621,6 +622,7 @@ class MsbuildGenerator { public double fx_version; public List projReferences = new List (); public string library; + public MsbuildGenerator MsbuildGenerator; } public VsCsproj Csproj; @@ -916,7 +918,7 @@ class MsbuildGenerator { result.projReferences.Add (match.Csproj); } - static string GetRelativePath (string from, string to) + public static string GetRelativePath (string from, string to) { from = from.Replace ("\\", "/"); to = to.Replace ("\\", "/"); @@ -964,7 +966,7 @@ class MsbuildGenerator { public class Driver { - static IEnumerable GetProjects () + static IEnumerable GetProjects (bool full = false) { XDocument doc = XDocument.Load ("order.xml"); foreach (XElement project in doc.Root.Elements ()) { @@ -978,6 +980,12 @@ public class Driver { if (!(dir.StartsWith ("class") || dir.StartsWith ("mcs") || dir.StartsWith ("basic"))) continue; + if (full){ + if (!library.Contains ("tests")) + yield return project; + continue; + } + // // Do not do 2.1, it is not working yet // Do not do basic, as there is no point (requires a system mcs to be installed). @@ -1009,12 +1017,18 @@ public class Driver { Console.WriteLine (" assemblies (and dependencies) is included in the solution."); Console.WriteLine ("Example:"); Console.WriteLine ("genproj.exe 2012 false"); - Console.WriteLine ("genproj.exe with no arguments is equivalent to 'genproj.exe 2012 true'"); + Console.WriteLine ("genproj.exe with no arguments is equivalent to 'genproj.exe 2012 true'\n\n"); + Console.WriteLine ("genproj.exe deps"); + Console.WriteLine ("Generates a Makefile dependency file from the projects input"); Environment.Exit (0); } + var slnVersion = (args.Length > 0) ? args [0] : "2012"; bool fullSolutions = (args.Length > 1) ? bool.Parse (args [1]) : true; + // To generate makefile depenedencies + var makefileDeps = (args.Length > 0 && args [0] == "deps"); + var sln_gen = new SlnGenerator (slnVersion); var two_sln_gen = new SlnGenerator (slnVersion); var four_sln_gen = new SlnGenerator (slnVersion); @@ -1023,11 +1037,11 @@ public class Driver { var projects = new Dictionary (); var duplicates = new List (); - foreach (var project in GetProjects ()) { + foreach (var project in GetProjects (makefileDeps)) { var library_output = project.Element ("library_output").Value; projects [library_output] = new MsbuildGenerator (project); } - foreach (var project in GetProjects ()){ + foreach (var project in GetProjects (makefileDeps)){ var library_output = project.Element ("library_output").Value; var gen = projects [library_output]; try { @@ -1038,7 +1052,7 @@ public class Driver { } else { duplicates.Add (csprojFilename); } - + } catch (Exception e) { Console.WriteLine ("Error in {0}\n{1}", project, e); } @@ -1063,6 +1077,26 @@ public class Driver { WriteSolution (three_five_sln_gen, MakeSolutionName (MsbuildGenerator.profile_3_5)); WriteSolution (four_sln_gen, MakeSolutionName (MsbuildGenerator.profile_4_0)); WriteSolution (four_five_sln_gen, MakeSolutionName (MsbuildGenerator.profile_4_5)); + + if (makefileDeps){ + const string classDirPrefix = "./../../"; + Console.WriteLine ("here {0}", sln_gen.libraries.Count); + foreach (var p in sln_gen.libraries){ + string rebasedOutput = RebaseToClassDirectory (MsbuildGenerator.GetRelativePath ("../../mcs/class", p.library_output)); + + Console.Write ("{0}: ", rebasedOutput); + foreach (var r in p.projReferences){ + var lo = r.library_output; + if (lo.StartsWith (classDirPrefix)) + lo = lo.Substring (classDirPrefix.Length); + else + lo = "<>"; + Console.Write ("{0} ", lo); + } + Console.Write ("\n\t(cd {0}; make {1})", p.MsbuildGenerator.dir, p.library_output); + Console.WriteLine ("\n"); + } + } // A few other optional solutions // Solutions with 'everything' and the most common libraries used in development may be of interest @@ -1073,6 +1107,18 @@ public class Driver { //WriteSolution (build_sln_gen, "mcs_build.sln"); } + // Rebases a path, assuming that execution is taking place in the "class" subdirectory, + // so it strips ../class/ from a path, which is a no-op + static string RebaseToClassDirectory (string path) + { + const string prefix = "../class/"; + int p = path.IndexOf (prefix); + if (p == -1) + return path; + return path.Substring (0, p) + path.Substring (p+prefix.Length); + return path; + } + static string MakeSolutionName (string profileTag) { return "net" + profileTag + ".sln";