Merge pull request #487 from mayerwin/patch-1
[mono.git] / mcs / class / build-rx-dll-sources.sh
1
2 // useful grep
3 // grep -h "#if" /svn/mono/external/rx/Rx.NET/System.Reactive.*/*.cs /svn/mono/external/rx/Rx.NET/System.Reactive.*/*/*.cs /svn/mono/external/rx/Rx.NET/System.Reactive.*/*/*/*.cs | sort | uniq
4
5 using System.Diagnostics;
6 using System.IO;
7 using System.Xml.Linq;
8 using System.Xml.XPath;
9
10 var asses = new string [] {
11         "System.Reactive.Interfaces",
12         "System.Reactive.Core",
13         "System.Reactive.PlatformServices",
14         "System.Reactive.Linq",
15         "System.Reactive.Debugger", // maybe needed for testing assembly.
16         "System.Reactive.Experimental", // needed for testing assembly.
17         "System.Reactive.Providers",
18         "System.Reactive.Runtime.Remoting",
19         "System.Reactive.Windows.Forms",
20         "System.Reactive.Windows.Threading",
21         "Microsoft.Reactive.Testing",
22         "Tests.System.Reactive",
23         };
24
25 var blacklist = new string [] {
26         // FIXME: this is the only source that we cannot build.
27         //Test/../../../../external/rx/Rx.NET/Tests.System.Reactive/Tests/ObservableExTest.cs(1478,27): error CS0411: The type arguments for method `System.Reactive.Linq.ObservableEx.ManySelect<TSource,TResult>(this System.IObservable<TSource>, System.Func<System.IObservable<TSource>,TResult>)' cannot be inferred from the usage. Try specifying the type arguments explicitly
28         "ObservableExTest.cs",
29
30         // WPF Dispatcher.Invoke() is not implemented.
31         "DispatcherSchedulerTest.cs",
32         // This is not limited to Dispatcher, but many of them are relevant to it, or Winforms (we filter it out by not defining HAS_WINFORMS)
33         "ObservableConcurrencyTest.cs",
34         };
35
36 foreach (var ass in asses) {
37
38         var monoass = ass == "Microsoft.Reactive.Testing" ?
39                 "Mono.Reactive.Testing" : ass;
40         var basePath = "../../external/rx/Rx.NET";
41         var csproj = Path.Combine (basePath, ass, ass + ".csproj");
42         var pathPrefix = ass == "Tests.System.Reactive" ? "../../" : "../";
43
44         // tests are built under Mono.Reactive.Testing directory.
45         var sources =
46                 monoass == "Tests.System.Reactive" ?
47                 Path.Combine ("Mono.Reactive.Testing", "Mono.Reactive.Testing_test.dll.sources") :
48                 Path.Combine (monoass, monoass + ".dll.sources");
49
50         var doc = XDocument.Load (csproj);
51         var rootNS = doc.XPathSelectElement ("//*[local-name()='RootNamespace']").Value;
52         using (var tw = File.CreateText (sources)) {
53                 foreach (var path in doc.XPathSelectElements ("//*[local-name()='Compile']")
54                         .Select (el => el.Attribute ("Include").Value)
55                         .Select (s => s.Replace ("\\", "/")))
56                         if (!blacklist.Any (b => path.Contains (b)))
57                                 tw.WriteLine (Path.Combine (pathPrefix, basePath, ass, path));
58         }
59
60         var argsPath = Path.Combine (Path.GetDirectoryName (sources), "more_build_args");
61         using (var tw = File.CreateText (argsPath)) {
62                 tw.WriteLine ("-d:SIGNED");
63                 tw.WriteLine ("-delaysign");
64                 tw.WriteLine ("-keyfile:../reactive.pub");
65
66                 foreach (var path in doc.XPathSelectElements ("//*[local-name()='EmbeddedResource']")) {
67                         var res = path.Attribute ("Include").Value;
68                         var resx = Path.Combine (basePath, ass, res);
69                         var resFileName = res.Replace ("resx", "resources");
70                         var resxDest = Path.Combine (monoass, res);
71                         var resPath = Path.Combine (monoass, resFileName);
72                         if (File.Exists (resxDest))
73                                 File.Delete (resxDest);
74                         File.Copy (resx, resxDest);
75                         //Process.Start ("resgen", String.Format ("{0} {1}", resx, resPath));
76                         tw.WriteLine ("-resource:{0},{1}.{2}", resFileName, rootNS, resFileName);
77                 }
78         }
79 }
80