From 29a2d0db57d105caf2da97811e6d832baa6099a1 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Fri, 18 Apr 2014 23:18:38 -0400 Subject: [PATCH] [genproj] Steps towards making pre-build scripts cross platform; Lots more build now --- msvc/scripts/Makefile | 7 +++++-- msvc/scripts/System.Xml.pre | 12 ++++++------ msvc/scripts/csproj.tmpl | 2 -- msvc/scripts/genproj.cs | 36 +++++++++++++++++++++--------------- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/msvc/scripts/Makefile b/msvc/scripts/Makefile index 4bac35c3648..c274515298c 100644 --- a/msvc/scripts/Makefile +++ b/msvc/scripts/Makefile @@ -1,5 +1,8 @@ -all: genproj.exe +all: genproj.exe prepare.exe mono genproj.exe genproj.exe: genproj.cs - mcs genproj.cs -pkg:dotnet -r:System.Xml.Linq \ No newline at end of file + mcs genproj.cs -r:System.Xml.Linq + +prepare.exe: prepare.cs + mcs prepare.cs diff --git a/msvc/scripts/System.Xml.pre b/msvc/scripts/System.Xml.pre index b04cdc3975a..56e5764ee8a 100644 --- a/msvc/scripts/System.Xml.pre +++ b/msvc/scripts/System.Xml.pre @@ -1,7 +1,7 @@ -$(ProjectDir)\..\..\..\mono\msvc\scripts\prepare.exe $(ProjectDir)..\.. xml -$(ProjectDir)\..\..\jay\jay.exe -ct < $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\System.Xml.XPath\Parser.jay > $(ProjectDir)\System.Xml.XPath\Parser.cs -echo #define XSLT_PATTERN > $(ProjectDir)\Mono.Xml.Xsl\PatternParser.cs -$(ProjectDir)\..\..\jay\jay.exe -ct < $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\Mono.Xml.Xsl\PatternParser.jay >> $(ProjectDir)\Mono.Xml.Xsl\PatternParser.cs -echo #define XSLT_PATTERN > $(ProjectDir)\Mono.Xml.Xsl\PatternTokenizer.cs -type $(ProjectDir)\System.Xml.XPath\Tokenizer.cs >> $(ProjectDir)\Mono.Xml.Xsl\PatternTokenizer.cs +@MONO@ $(ProjectDir)\..\..\..\msvc\scripts\prepare.exe $(ProjectDir)..\.. xml +$(ProjectDir)\..\..\jay\jay -ct < $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\System.Xml.XPath\Parser.jay > $(ProjectDir)\System.Xml.XPath\Parser.cs +echo "#define XSLT_PATTERN" > $(ProjectDir)\Mono.Xml.Xsl\PatternParser.cs +$(ProjectDir)\..\..\jay\jay -ct < $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\Mono.Xml.Xsl\PatternParser.jay >> $(ProjectDir)\Mono.Xml.Xsl\PatternParser.cs +echo "#define XSLT_PATTERN" > $(ProjectDir)\Mono.Xml.Xsl\PatternTokenizer.cs +@CAT@ $(ProjectDir)\System.Xml.XPath\Tokenizer.cs >> $(ProjectDir)\Mono.Xml.Xsl\PatternTokenizer.cs \ No newline at end of file diff --git a/msvc/scripts/csproj.tmpl b/msvc/scripts/csproj.tmpl index 7ac01dd28ac..4e0e44e5915 100644 --- a/msvc/scripts/csproj.tmpl +++ b/msvc/scripts/csproj.tmpl @@ -53,9 +53,7 @@ --> - @PREBUILD@ - @POSTBUILD@ diff --git a/msvc/scripts/genproj.cs b/msvc/scripts/genproj.cs index 6f1020f50d8..8d60480fc6b 100644 --- a/msvc/scripts/genproj.cs +++ b/msvc/scripts/genproj.cs @@ -630,11 +630,26 @@ class MsbuildGenerator { // 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; + prebuild_windows = prebuild; + } + + const string condition_unix = "Condition=\" '$(OS)' != 'Windows_NT' \""; + const string condition_windows = "Condition=\" '$(OS)' == 'Windows_NT' \""; + prebuild = + " \n" + prebuild_unix + "\n \n" + + " \n" + prebuild_windows + "\n \n"; + var all_args = new Queue (); all_args.Enqueue (flags.Split ()); while (all_args.Count > 0) { @@ -794,8 +809,6 @@ class MsbuildGenerator { build_output_dir = "bin\\Debug\\" + library; - const string condition_unix = "Condition=\" '$(OS)' != 'Windows_NT' \""; - const string condition_windows = "Condition=\" '$(OS)' == 'Windows_NT' \""; string postbuild_unix = string.Empty; string postbuild_windows = string.Empty; @@ -850,23 +863,16 @@ class MsbuildGenerator { refs.AppendFormat (" {1}", GetRelativePath (result.csprojFileName, lastMatching.csprojFileName), NewLine); refs.Append (" " + lastMatching.projectGuid + "" + NewLine); refs.Append (" " + Path.GetFileNameWithoutExtension (lastMatching.csprojFileName) + "" + NewLine); - //refs.Append(" " + r + "" + NewLine); refs.Append (" " + NewLine); if (!result.projReferences.Contains (lastMatching)) result.projReferences.Add (lastMatching); } - static string GetRelativePath (string referencerPath, string referenceePath) + static string GetRelativePath (string from, string to) { - // F:\src\mono\msvc\scripts\ - //..\..\mcs\class\System\System-net_2_0.csproj - //..\..\mcs\class\corlib\corlib-net_2_0.csproj - // So from \System\, corlib needs to be referenced as: - // ..\corlib\corlib-net_2_0.csproj - - // Could be possible to use PathRelativePathTo, but this is a P/Invoke to Win32 API. - // For now, simpler but less robust: - return referenceePath.Replace (@"..\..\mcs\class", "..").Replace ("/", "\\"); + var fromUri = new Uri (Path.GetFullPath (from)); + var toUri = new Uri (Path.GetFullPath (to)); + return fromUri.MakeRelativeUri (toUri).ToString (); } static VsCsproj GetMatchingCsproj (string dllReferenceName, List projects) @@ -1032,4 +1038,4 @@ public class Driver { return false; } -} \ No newline at end of file +} -- GitLab