X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=msvc%2Fscripts%2Fgenproj.cs;h=378d1c00db7210c098bc3bd9b84f275633f77e4b;hb=82bc0ca4ced9d49ed9e1a483b415760ba8653500;hp=4f7343b9fe8e1a3fb213d56329e2f1b364f49cfd;hpb=8054793e5bc158015154fb8cdcdd56777a0c8351;p=mono.git diff --git a/msvc/scripts/genproj.cs b/msvc/scripts/genproj.cs index 4f7343b9fe8..378d1c00db7 100644 --- a/msvc/scripts/genproj.cs +++ b/msvc/scripts/genproj.cs @@ -563,7 +563,13 @@ class MsbuildGenerator { case "/publicsign": return true; - + + case "/deterministic": + return true; + + case "/runtimemetadataversion": + return true; + case "/-getresourcestrings": return true; } @@ -654,12 +660,19 @@ class MsbuildGenerator { public VsCsproj Csproj; - public VsCsproj Generate (Dictionary projects, bool showWarnings = false) + void AppendResource (StringBuilder resources, string source, string logical) + { + resources.AppendFormat (" " + NewLine, source); + resources.AppendFormat (" {0}" + NewLine, logical); + resources.AppendFormat (" " + NewLine); + } + + public VsCsproj Generate (string library_output, Dictionary projects, bool showWarnings = false) { var generatedProjFile = NativeName (Csproj.csProjFilename); //Console.WriteLine ("Generating: {0}", generatedProjFile); - string boot, flags, output_name, built_sources, response, profile; + string boot, flags, output_name, built_sources, response, profile, reskey; boot = xproject.Element ("boot").Value; flags = xproject.Element ("flags").Value; @@ -668,6 +681,7 @@ class MsbuildGenerator { Target = Target.Exe; built_sources = xproject.Element ("built_sources").Value; response = xproject.Element ("response").Value; + reskey = xproject.Element ("resources").Value; profile = xproject.Element ("profile").Value; if (string.IsNullOrEmpty (response)) { @@ -696,29 +710,10 @@ class MsbuildGenerator { } // // Prebuild code, might be in inputs, check: - // inputs/LIBRARY-PROFILE.pre // inputs/LIBRARY.pre // - string prebuild = Load (library + ".pre"); - string prebuild_windows, prebuild_unix; - - int q = library.IndexOf ("-"); - if (q != -1) - prebuild = prebuild + Load (library.Substring (0, q) + ".pre"); - - if (prebuild.IndexOf ("@MONO@") != -1){ - prebuild_unix = prebuild.Replace ("@MONO@", "mono").Replace ("@CAT@", "cat"); - prebuild_windows = prebuild.Replace ("@MONO@", "").Replace ("@CAT@", "type"); - } else { - prebuild_unix = prebuild.Replace ("jay.exe", "jay"); - prebuild_windows = prebuild; - } - - const string condition_unix = "Condition=\" '$(OS)' != 'Windows_NT' \""; - const string condition_windows = "Condition=\" '$(OS)' == 'Windows_NT' \""; - prebuild = - " " + NewLine + prebuild_unix + NewLine + " " + NewLine + - " " + NewLine + prebuild_windows + NewLine + " " + NewLine; + string prebuild = GenerateStep (library, ".pre", "PreBuildEvent"); + string postbuild = GenerateStep (library, ".post", "PostBuildEvent"); var all_args = new Queue (); all_args.Enqueue (flags.Split ()); @@ -736,7 +731,7 @@ class MsbuildGenerator { var resp_file_full = Path.Combine (base_dir, response_file); extra_args = LoadArgs (resp_file_full); if (extra_args == null) { - Console.WriteLine ("Unable to open response file: " + resp_file_full); + Console.WriteLine ($"{library_output}: Unable to open response file: {resp_file_full}"); Environment.Exit (1); } @@ -746,13 +741,12 @@ class MsbuildGenerator { if (CSCParseOption (f [i], ref f)) continue; - Console.WriteLine ("Failure with {0}", f [i]); + Console.WriteLine ("{library_output}: Failure with {0}", f [i]); Environment.Exit (1); } } string [] source_files; - //Console.WriteLine ("Base: {0} res: {1}", base_dir, response); using (var reader = new StreamReader (NativeName (base_dir + "\\" + response))) { source_files = reader.ReadToEnd ().Split (); } @@ -808,17 +802,45 @@ class MsbuildGenerator { refs.Append (string.Format (" " + NewLine, nunitLibPath)); } + // + // Generate resource referenced from the command line + // var resources = new StringBuilder (); if (embedded_resources.Count > 0) { - resources.AppendFormat (" " + NewLine); foreach (var dk in embedded_resources) { - resources.AppendFormat (" " + NewLine, dk.Key); - resources.AppendFormat (" {0}" + NewLine, dk.Value); - resources.AppendFormat (" " + NewLine); + var source = dk.Key; + if (source.EndsWith (".resources")) + source = source.Replace (".resources", ".resx"); + + // try to find a pre-built resource, and use that instead of trying to build it + if (source.EndsWith (".resx")) { + var probe_prebuilt = Path.Combine (base_dir, source.Replace (".resx", ".resources.prebuilt")); + if (File.Exists (probe_prebuilt)) { + + source = GetRelativePath (base_dir + "/", probe_prebuilt); + } + } + AppendResource (resources, source, dk.Value); + } + } + // + // Generate resources that were part of the explicit node + // + if (reskey != null && reskey != ""){ + var pairs = reskey.Split (' ', '\n', '\t'); + foreach (var pair in pairs){ + var p = pair.IndexOf (","); + if (p == -1){ + Console.Error.WriteLine ($"Found a resource without a filename: {pairs} for {Csproj.csProjFilename}"); + Environment.Exit (1); + } + AppendResource (resources, pair.Substring (p+1), pair.Substring (0, p) + ".resources"); } + } + if (resources.Length > 0){ + resources.Insert (0, " " + NewLine); resources.AppendFormat (" " + NewLine); } - if (references.Count > 0 || reference_aliases.Count > 0) { // -r:mscorlib.dll -r:System.dll @@ -833,7 +855,7 @@ class MsbuildGenerator { var refdistinct = references.Distinct (); foreach (string reference in refdistinct) { - var match = GetMatchingCsproj (reference, projects); + var match = GetMatchingCsproj (library_output, reference, projects); if (match != null) { AddProjectReference (refs, Csproj, match, reference, null); } else { @@ -853,7 +875,7 @@ class MsbuildGenerator { int index = r.IndexOf ('='); string alias = r.Substring (0, index); string assembly = r.Substring (index + 1); - var match = GetMatchingCsproj (assembly, projects, explicitPath: true); + var match = GetMatchingCsproj (library_output, assembly, projects, explicitPath: true); if (match != null) { AddProjectReference (refs, Csproj, match, r, alias); } else { @@ -877,15 +899,12 @@ class MsbuildGenerator { build_output_dir = Path.GetDirectoryName (LibraryOutput); else build_output_dir = "bin\\Debug\\" + library; - - string postbuild_unix = string.Empty; - string postbuild_windows = string.Empty; - - var postbuild = - " " + NewLine + postbuild_unix + NewLine + " " + NewLine + - " " + NewLine + postbuild_windows + NewLine + " "; - + if (build_output_dir.Contains ("-linux") || build_output_dir.Contains ("-darwin") || build_output_dir.Contains ("-win32")) + build_output_dir = build_output_dir + .Replace ("-linux", "-$(HostPlatform)") + .Replace ("-darwin", "-$(HostPlatform)") + .Replace ("-win32", "-$(HostPlatform)"); bool basic_or_build = (library.Contains ("-basic") || library.Contains ("-build")); @@ -923,8 +942,8 @@ class MsbuildGenerator { Replace ("@DEBUGTYPE@", want_debugging_support ? "full" : "pdbonly"). Replace ("@REFERENCES@", refs.ToString ()). Replace ("@PREBUILD@", prebuild). - Replace ("@STARTUPOBJECT@", main == null ? "" : $"{main}"). Replace ("@POSTBUILD@", postbuild). + Replace ("@STARTUPOBJECT@", main == null ? "" : $"{main}"). //Replace ("@ADDITIONALLIBPATHS@", String.Format ("{0}", string.Join (",", libs.ToArray ()))). Replace ("@ADDITIONALLIBPATHS@", String.Empty). Replace ("@RESOURCES@", resources.ToString ()). @@ -939,6 +958,34 @@ class MsbuildGenerator { return Csproj; } + string GenerateStep (string library, string suffix, string eventKey) + { + string target = Load (library + suffix); + string target_windows, target_unix; + + int q = library.IndexOf ("-"); + if (q != -1) + target = target + Load (library.Substring (0, q) + suffix); + + if (target.IndexOf ("@MONO@") != -1){ + target_unix = target.Replace ("@MONO@", "mono").Replace ("@CAT@", "cat"); + target_windows = target.Replace ("@MONO@", "").Replace ("@CAT@", "type"); + } else { + target_unix = target.Replace ("jay.exe", "jay"); + target_windows = target; + } + target_unix = target_unix.Replace ("@COPY@", "cp"); + target_windows = target_unix.Replace ("@COPY@", "copy"); + + target_unix = target_unix.Replace ("\r", ""); + const string condition_unix = "Condition=\" '$(OS)' != 'Windows_NT' \""; + const string condition_windows = "Condition=\" '$(OS)' == 'Windows_NT' \""; + var result = + $" <{eventKey} {condition_unix}>\n{target_unix}\n {NewLine}" + + $" <{eventKey} {condition_windows}>{NewLine}{target_windows}{NewLine} "; + return result; + } + void AddProjectReference (StringBuilder refs, VsCsproj result, MsbuildGenerator match, string r, string alias) { refs.AppendFormat (" {1}", GetRelativePath (result.csProjFilename, match.CsprojFilename), NewLine); @@ -962,7 +1009,7 @@ class MsbuildGenerator { return ret; } - MsbuildGenerator GetMatchingCsproj (string dllReferenceName, Dictionary projects, bool explicitPath = false) + MsbuildGenerator GetMatchingCsproj (string library_output, string dllReferenceName, Dictionary projects, bool explicitPath = false) { // libDir would be "./../../class/lib/net_4_x for example // project @@ -993,9 +1040,10 @@ class MsbuildGenerator { return project.Value; } - Console.WriteLine ("Did not find referenced {0} with libs={1}", dllReferenceName, String.Join (", ", libs)); + var ljoined = String.Join (", ", libs); + Console.WriteLine ($"{library_output}: did not find referenced {dllReferenceName} with libs={ljoined}"); foreach (var p in projects) { - // Console.WriteLine ("{0}", p.Value.AbsoluteLibraryOutput); + Console.WriteLine ("{0}", p.Value.AbsoluteLibraryOutput); } return null; } @@ -1012,7 +1060,7 @@ public class Driver { string library = project.Attribute ("library").Value; var profile = project.Element ("profile").Value; -#if true +#if false // Skip facades for now, the tool doesn't know how to deal with them yet. if (dir.Contains ("Facades")) continue; @@ -1043,8 +1091,14 @@ public class Driver { // The next ones are to make debugging easier for now if (profile == "basic") continue; + + // For now -- problem is, our resolver currently only considers the assembly name, and we ahve + // conflicing 2.0 and 2.4 versions so for now, we just skip the nunit20 versions + if (dir.Contains ("nunit20")) + continue; + #if true - if (profile != "net_4_x" || library.Contains ("tests")) + if (profile != "net_4_x" || library.Contains ("tests")) continue; #endif //Console.WriteLine ("Going to handle {0}", library); @@ -1089,10 +1143,10 @@ public class Driver { } foreach (var project in GetProjects (makefileDeps)){ var library_output = project.Element ("library_output").Value; - Console.WriteLine ("=== {0} ===", library_output); + //Console.WriteLine ("=== {0} ===", library_output); var gen = projects [library_output]; try { - var csproj = gen.Generate (projects); + var csproj = gen.Generate (library_output, projects); var csprojFilename = csproj.csProjFilename; if (!sln_gen.ContainsProjectIdentifier (csproj.library)) { sln_gen.Add (csproj);