Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update csproj generator to work on mac

  • Loading branch information...
commit 96d058749d61a7771febd009c84ce49479c5981f 1 parent 136f537
Marek Safar marek-safar authored
1  Makefile.am
@@ -174,7 +174,6 @@ package-inputs:
174 174 cat msvc/scripts/inputs/$$2.input | sed -e 's/\\\\/\\/g' -e 's/\\/\\\\/g' | \
175 175 (echo " <project dir=\"$$1\" library=\"$$2\">"; \
176 176 read boot; echo " <boot>$$boot</boot>"; \
177   - read mcs; echo " <mcs>$$mcs</mcs>"; \
178 177 read flags; echo " <flags>$$flags</flags>"; \
179 178 read output; echo " <output>$$output</output>"; \
180 179 read built; echo " <built_sources>`echo $$built | sed 's/\\\/\\\\/g'`</built_sources>"; \
1  mcs/build/executable.make
@@ -149,7 +149,6 @@ csproj-local:
149 149 config_file=`basename $(PROGRAM) .exe`-$(PROFILE).input; \
150 150 echo $(thisdir):$$config_file >> $(topdir)/../msvc/scripts/order; \
151 151 (echo $(is_boot); \
152   - echo $(MCS); \
153 152 echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS); \
154 153 echo $(PROGRAM); \
155 154 echo $(BUILT_SOURCES_cmdline); \
3  mcs/build/library.make
@@ -106,7 +106,6 @@ csproj-library:
106 106 for counter in 1 2 3 4 5 ; do if test -f $(topdir)/../msvc/scripts/inputs/$$config_file ; then config_file=`basename $(LIBRARY) .dll`-$(PROFILE)-$$counter.input; fi ; done ;\
107 107 echo $(thisdir):$$config_file >> $(topdir)/../msvc/scripts/order; \
108 108 (echo $(is_boot); \
109   - echo $(MCS); \
110 109 echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS); \
111 110 echo $(LIBRARY_NAME); \
112 111 echo $(BUILT_SOURCES_cmdline); \
@@ -198,12 +197,12 @@ csproj-test:
198 197 config_file=`basename $(LIBRARY) .dll`-tests-$(PROFILE).input; \
199 198 echo $(thisdir):$$config_file >> $(topdir)/../msvc/scripts/order; \
200 199 (echo false; \
201   - echo $(MCS); \
202 200 echo $(USE_MCS_FLAGS) -r:$(the_assembly) $(TEST_MCS_FLAGS); \
203 201 echo $(test_lib); \
204 202 echo $(BUILT_SOURCES_cmdline); \
205 203 echo $(test_lib); \
206 204 echo $(FRAMEWORK_VERSION); \
  205 + echo $(PROFILE); \
207 206 echo $(test_response)) > $(topdir)/../msvc/scripts/inputs/$$config_file
208 207
209 208 endif
12 mcs/mcs/Makefile
@@ -39,18 +39,6 @@ KEEP_OUTPUT_FILE_COPY = yes
39 39
40 40 include ../build/executable.make
41 41
42   -csproj-local:
43   - config_file=`basename $(PROGRAM) .exe`-$(PROFILE).input; \
44   - echo $(thisdir):$$config_file >> $(topdir)/../msvc/scripts/order; \
45   - (echo $(is_boot); \
46   - echo $(BOOTSTRAP_MCS); \
47   - echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS); \
48   - echo $(PROGRAM); \
49   - echo $(BUILT_SOURCES); \
50   - echo $(PROGRAM); \
51   - echo $(PROFILE); \
52   - echo $(response)) > $(topdir)/../msvc/scripts/inputs/$$config_file
53   -
54 42 #
55 43 # Below this line we have local targets used for testing and development
56 44 #
42 msvc/scripts/genproj.cs
@@ -20,7 +20,7 @@ public enum LanguageVersion {
20 20 }
21 21
22 22 class SlnGenerator {
23   - public static readonly string NewLine = Environment.NewLine; // "\n";
  23 + public static readonly string NewLine = "\r\n"; //Environment.NewLine; // "\n";
24 24 public SlnGenerator (string formatVersion = "2012")
25 25 {
26 26 switch (formatVersion) {
@@ -586,10 +586,9 @@ public VsCsproj Generate (XElement xproject, List<MsbuildGenerator.VsCsproj> pro
586 586
587 587 var result = new VsCsproj ();
588 588 string library = xproject.Attribute ("library").Value;
589   - string boot, mcs, flags, output_name, built_sources, library_output, response, fx_version, profile;
  589 + string boot, flags, output_name, built_sources, library_output, response, fx_version, profile;
590 590
591 591 boot = xproject.Element ("boot").Value;
592   - mcs = xproject.Element ("mcs").Value;
593 592 flags = xproject.Element ("flags").Value;
594 593 output_name = xproject.Element ("output").Value;
595 594 built_sources = xproject.Element ("built_sources").Value;
@@ -669,6 +668,9 @@ public VsCsproj Generate (XElement xproject, List<MsbuildGenerator.VsCsproj> pro
669 668 using (var reader = new StreamReader (NativeName (base_dir + "\\" + response))) {
670 669 source_files = reader.ReadToEnd ().Split ();
671 670 }
  671 +
  672 + Array.Sort (source_files);
  673 +
672 674 StringBuilder sources = new StringBuilder ();
673 675 foreach (string s in source_files) {
674 676 if (s.Length == 0)
@@ -678,9 +680,13 @@ public VsCsproj Generate (XElement xproject, List<MsbuildGenerator.VsCsproj> pro
678 680 if (src.StartsWith (@"Test\..\"))
679 681 src = src.Substring (8, src.Length - 8);
680 682
681   - sources.Append (String.Format (" <Compile Include=\"{0}\" />" + NewLine, src));
  683 + sources.AppendFormat (" <Compile Include=\"{0}\" />" + NewLine, src);
682 684 }
683   - foreach (string s in built_sources.Split ()) {
  685 +
  686 + source_files = built_sources.Split ();
  687 + Array.Sort (source_files);
  688 +
  689 + foreach (string s in source_files) {
684 690 if (s.Length == 0)
685 691 continue;
686 692
@@ -688,7 +694,7 @@ public VsCsproj Generate (XElement xproject, List<MsbuildGenerator.VsCsproj> pro
688 694 if (src.StartsWith (@"Test\..\"))
689 695 src = src.Substring (8, src.Length - 8);
690 696
691   - sources.Append (String.Format (" <Compile Include=\"{0}\" />" + NewLine, src));
  697 + sources.AppendFormat (" <Compile Include=\"{0}\" />" + NewLine, src);
692 698 }
693 699 sources.Remove (sources.Length - 1, 1);
694 700
@@ -705,8 +711,7 @@ public VsCsproj Generate (XElement xproject, List<MsbuildGenerator.VsCsproj> pro
705 711 //}
706 712
707 713 result.library = library;
708   - result.csprojFileName = ("..\\..\\mcs\\" + dir + "\\" + library + ".csproj").Replace ('/', '\\');
709   - var csprojDir = Path.GetDirectoryName (result.csprojFileName);
  714 + result.csprojFileName = "..\\..\\mcs\\" + dir + "\\" + library + ".csproj";
710 715
711 716 var refs = new StringBuilder ();
712 717
@@ -714,7 +719,7 @@ public VsCsproj Generate (XElement xproject, List<MsbuildGenerator.VsCsproj> pro
714 719 if (is_test) {
715 720 // F:\src\mono\mcs\class\lib\net_2_0\nunit.framework.dll
716 721 // F:\src\mono\mcs\class\SomeProject\SomeProject_test_-net_2_0.csproj
717   - var nunitLibPath = Path.Combine (@"..\lib", profile, "nunit.framework.dll");
  722 + var nunitLibPath = string.Format (@"..\lib\{0}\nunit.framework.dll", profile);
718 723 refs.Append (string.Format (" <Reference Include=\"{0}\" />" + NewLine, nunitLibPath));
719 724 }
720 725
@@ -744,9 +749,9 @@ public VsCsproj Generate (XElement xproject, List<MsbuildGenerator.VsCsproj> pro
744 749 if (lastMatching != null) {
745 750 addProjectReference (refs, result, lastMatching, r);
746 751 } else {
747   - var msg = string.Format ("From {0}, could not find a matching project reference for {1}", library, r);
748   - //throw new NotSupportedException (msg);
749   - Console.WriteLine ("WARNING: " + msg + NewLine + " --> Adding reference with hintpath instead");
  752 + var msg = string.Format ("", library, r);
  753 + Console.WriteLine ("{0}: Could not find a matching project reference for {1}", library, Path.GetFileName (r));
  754 + Console.WriteLine (" --> Adding reference with hintpath instead");
750 755 refs.Append (" <Reference Include=\"" + r + "\">" + NewLine);
751 756 refs.Append (" <SpecificVersion>False</SpecificVersion>" + NewLine);
752 757 refs.Append (" <HintPath>" + r + "</HintPath>" + NewLine);
@@ -833,7 +838,7 @@ public VsCsproj Generate (XElement xproject, List<MsbuildGenerator.VsCsproj> pro
833 838 Replace ("@SOURCES@", sources.ToString ());
834 839
835 840 //Console.WriteLine ("Generated {0}", ofile.Replace ("\\", "/"));
836   - using (var o = new StreamWriter (result.csprojFileName)) {
  841 + using (var o = new StreamWriter (NativeName (result.csprojFileName))) {
837 842 o.WriteLine (result.output);
838 843 }
839 844
@@ -842,8 +847,7 @@ public VsCsproj Generate (XElement xproject, List<MsbuildGenerator.VsCsproj> pro
842 847
843 848 private void addProjectReference (StringBuilder refs, VsCsproj result, VsCsproj lastMatching, string r)
844 849 {
845   - refs.Append (" <ProjectReference Include=\"" +
846   - getRelativePath (result.csprojFileName, lastMatching.csprojFileName) + "\">" + NewLine);
  850 + refs.AppendFormat (" <ProjectReference Include=\"{0}\">{1}", getRelativePath (result.csprojFileName, lastMatching.csprojFileName), NewLine);
847 851 refs.Append (" <Project>" + lastMatching.projectGuid + "</Project>" + NewLine);
848 852 refs.Append (" <Name>" + Path.GetFileNameWithoutExtension (lastMatching.csprojFileName) + "</Name>" + NewLine);
849 853 //refs.Append(" <HintPath>" + r + "</HintPath>" + NewLine);
@@ -852,7 +856,7 @@ private void addProjectReference (StringBuilder refs, VsCsproj result, VsCsproj
852 856 result.projReferences.Add (lastMatching);
853 857 }
854 858
855   - private string getRelativePath (string referencerPath, string referenceePath)
  859 + static string getRelativePath (string referencerPath, string referenceePath)
856 860 {
857 861 // F:\src\mono\msvc\scripts\
858 862 //..\..\mcs\class\System\System-net_2_0.csproj
@@ -862,12 +866,12 @@ private string getRelativePath (string referencerPath, string referenceePath)
862 866
863 867 // Could be possible to use PathRelativePathTo, but this is a P/Invoke to Win32 API.
864 868 // For now, simpler but less robust:
865   - return referenceePath.Replace (@"..\..\mcs\class", "..");
  869 + return referenceePath.Replace (@"..\..\mcs\class", "..").Replace ("/", "\\");
866 870 }
867 871
868   - private VsCsproj getMatchingCsproj (string dllReferenceName, List<VsCsproj> projects)
  872 + static VsCsproj getMatchingCsproj (string dllReferenceName, List<VsCsproj> projects)
869 873 {
870   - return projects.LastOrDefault ((x => x.library_output.EndsWith (dllReferenceName)));
  874 + return projects.LastOrDefault (x => Path.GetFileName (x.library_output).Replace (".dll", "") == dllReferenceName.Replace (".dll", ""));
871 875 }
872 876
873 877 }
1,910 msvc/scripts/order.xml
1,105 additions, 805 deletions not shown

0 comments on commit 96d0587

Please sign in to comment.
Something went wrong with that request. Please try again.