Add Reactive Extensions as installed libs, take 2 (with fixed rpmspec this time).
[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         
46         var sources =
47                 monoass == "Tests.System.Reactive" ?
48                 Path.Combine ("Mono.Reactive.Testing", "Mono.Reactive.Testing_test.dll.sources") :
49                 Path.Combine (monoass, monoass + ".dll.sources");
50
51         var assdir = Path.Combine (monoass, "Assembly");
52         var assinfo = Path.Combine (monoass, "Assembly", "AssemblyInfo.cs");
53
54         if (monoass != "Tests.System.Reactive") {
55                 if (!Directory.Exists (assdir))
56                         Directory.CreateDirectory (assdir);
57                 using (var tw = File.CreateText (assinfo)) {
58                         tw.WriteLine ("// Due to InternalsVisibleTo issue we don't add versions so far...");
59                         tw.WriteLine ("// [assembly:System.Reflection.AssemblyVersion (\"0.0.0.0\")]");
60                 }
61         }
62
63         var doc = XDocument.Load (csproj);
64         var rootNS = doc.XPathSelectElement ("//*[local-name()='RootNamespace']").Value;
65         using (var tw = File.CreateText (sources)) {
66                 //if (monoass != "Tests.System.Reactive")
67                 //      tw.WriteLine ("Assembly/AssemblyInfo.cs");
68                 foreach (var path in doc.XPathSelectElements ("//*[local-name()='Compile']")
69                         .Select (el => el.Attribute ("Include").Value)
70                         .Select (s => s.Replace ("\\", "/")))
71                         if (!blacklist.Any (b => path.Contains (b)))
72                                 tw.WriteLine (Path.Combine (pathPrefix, basePath, ass, path));
73         }
74
75         var argsPath = Path.Combine (Path.GetDirectoryName (sources), "more_build_args");
76         using (var tw = File.CreateText (argsPath)) {
77                 tw.WriteLine ("-d:SIGNED");
78                 tw.WriteLine ("-delaysign");
79                 tw.WriteLine ("-keyfile:../reactive.pub");
80
81                 foreach (var path in doc.XPathSelectElements ("//*[local-name()='EmbeddedResource']")) {
82                         var res = path.Attribute ("Include").Value;
83                         var resx = Path.Combine (basePath, ass, res);
84                         var resFileName = res.Replace ("resx", "resources");
85                         var resxDest = Path.Combine (monoass, res);
86                         var resPath = Path.Combine (monoass, resFileName);
87                         if (File.Exists (resxDest))
88                                 File.Delete (resxDest);
89                         File.Copy (resx, resxDest);
90                         //Process.Start ("resgen", String.Format ("{0} {1}", resx, resPath));
91                         tw.WriteLine ("-resource:{0},{1}.{2}", resFileName, rootNS, resFileName);
92                 }
93         }
94 }
95