Skip to content

Commit d3df2f5

Browse files
committed
Copy FSharp support assemblies from nuget
Instead of building F# from sources as we've been doing so far, we'll now use a nuget to get the binaries we require. This makes the build time much shorter.
1 parent a3dfd4c commit d3df2f5

File tree

4 files changed

+106
-13
lines changed

4 files changed

+106
-13
lines changed

build-tools/mono-runtimes/mono-runtimes.targets

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\..\Configuration.props" />
4-
<Import Project="mono-runtimes.props" />
5-
<Import Project="mono-runtimes.projitems" />
63
<PropertyGroup>
7-
<_MonoPath>..\..\external\mono</_MonoPath>
4+
<_SourceTopDir>..\..</_SourceTopDir>
5+
<_BclFrameworkDir>$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0</_BclFrameworkDir>
6+
<_MonoPath>$(_SourceTopDir)\external\mono</_MonoPath>
87
</PropertyGroup>
8+
<UsingTask AssemblyFile="$(_SourceTopDir)\bin\Build$(Configuration)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.GetNugetPackageBasePath" />
9+
<Import Project="$(_SourceTopDir)\Configuration.props" />
10+
<Import Project="mono-runtimes.props" />
11+
<Import Project="mono-runtimes.projitems" />
912
<Target Name="_Autogen"
1013
Inputs="$(_MonoPath)\autogen.sh"
1114
Outputs="$(_MonoPath)\configure">
@@ -19,7 +22,7 @@
1922
Outputs="@(_MonoRuntime->'$(IntermediateOutputPath)\%(Identity)\.stamp')">
2023
<MakeDir Directories="@(_MonoRuntime->'$(IntermediateOutputPath)\%(Identity)')" />
2124
<Exec
22-
Command="..\..\..\$(_MonoPath)\configure LDFLAGS=&quot;%(_MonoRuntime.LdFlags)&quot; CFLAGS=&quot;%(_MonoRuntime.CFlags)&quot; CXXFLAGS=&quot;%(_MonoRuntime.CxxFlags)&quot; CC=&quot;%(_MonoRuntime.Cc)&quot; CXX=&quot;%(_MonoRuntime.Cxx)&quot; CPP=&quot;%(_MonoRuntime.Cpp)&quot; CXXCPP=&quot;%(_MonoRuntime.CxxCpp)&quot; LD=&quot;%(_MonoRuntime.Ld)&quot; AR=&quot;%(_MonoRuntime.Ar)&quot; AS=&quot;%(_MonoRuntime.As)&quot; RANLIB=&quot;%(_MonoRuntime.RanLib)&quot; STRIP=&quot;%(_MonoRuntime.Strip)&quot; --cache-file=..\%(_MonoRuntime.Identity).config.cache %(_MonoRuntime.ConfigureFlags)"
25+
Command="$(_SourceTopDir)\..\$(_MonoPath)\configure LDFLAGS=&quot;%(_MonoRuntime.LdFlags)&quot; CFLAGS=&quot;%(_MonoRuntime.CFlags)&quot; CXXFLAGS=&quot;%(_MonoRuntime.CxxFlags)&quot; CC=&quot;%(_MonoRuntime.Cc)&quot; CXX=&quot;%(_MonoRuntime.Cxx)&quot; CPP=&quot;%(_MonoRuntime.Cpp)&quot; CXXCPP=&quot;%(_MonoRuntime.CxxCpp)&quot; LD=&quot;%(_MonoRuntime.Ld)&quot; AR=&quot;%(_MonoRuntime.Ar)&quot; AS=&quot;%(_MonoRuntime.As)&quot; RANLIB=&quot;%(_MonoRuntime.RanLib)&quot; STRIP=&quot;%(_MonoRuntime.Strip)&quot; --cache-file=..\%(_MonoRuntime.Identity).config.cache %(_MonoRuntime.ConfigureFlags)"
2326
WorkingDirectory="@(_MonoRuntime->'$(IntermediateOutputPath)\%(Identity)')"
2427
/>
2528
<Touch
@@ -74,23 +77,34 @@
7477
<Target Name="_InstallBcl"
7578
Inputs="$(_MonoPath)\mcs\class\lib\monodroid\mscorlib.dll"
7679
Outputs="$(OutputPath)lib\xbuild-frameworks\MonoAndroid\v1.0\mscorlib.dll;$(OutputPath)lib\xbuild-frameworks\MonoAndroid\v1.0\RedistList\FrameworkList.xml">
77-
<MakeDir Directories="$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0" />
78-
<MakeDir Directories="$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0\RedistList" />
79-
<MakeDir Directories="$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0\Facades" />
80+
<MakeDir Directories="$(_BclFrameworkDir)" />
81+
<MakeDir Directories="$(_BclFrameworkDir)\RedistList" />
82+
<MakeDir Directories="$(_BclFrameworkDir)\Facades" />
8083
<ItemGroup>
84+
<_PackageConfigFiles Include="$(_SourceTopDir)\src\Xamarin.Android.Build.Tasks\packages.config" />
85+
</ItemGroup>
86+
<GetNugetPackageBasePath PackageConfigFiles="@(_PackageConfigFiles)" PackageName="FSharp.Core">
87+
<Output TaskParameter="BasePath" PropertyName="_FSharpCorePackagePath" />
88+
</GetNugetPackageBasePath>
89+
<ItemGroup>
90+
<_FSharp Include="$(_SourceTopDir)\$(_FSharpCorePackagePath)\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core*" />
8191
<_Assemblies Include="$(_MonoPath)\mcs\class\lib\monodroid\*.dll" />
8292
<_Facades Include="$(_MonoPath)\mcs\class\lib\monodroid\Facades\*.dll" />
8393
</ItemGroup>
8494
<Copy
8595
SourceFiles="@(_Assemblies)"
86-
DestinationFolder="$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0"
96+
DestinationFolder="$(_BclFrameworkDir)"
8797
/>
8898
<Copy
8999
SourceFiles="@(_Facades)"
90-
DestinationFolder="$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0\Facades"
100+
DestinationFolder="$(_BclFrameworkDir)\Facades"
101+
/>
102+
<Copy
103+
SourceFiles="@(_FSharp)"
104+
DestinationFolder="$(_BclFrameworkDir)"
91105
/>
92106
<Touch
93-
Files="$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0\mscorlib.dll"
107+
Files="$(_BclFrameworkDir)\mscorlib.dll"
94108
/>
95109
<ItemGroup>
96110
<FrameworkList Include="&lt;FileList Redist=&quot;MonoAndroid&quot; Name=&quot;Xamarin.Android Base Class Libraries&quot;&gt;" />

src/Xamarin.Android.Build.Tasks/packages.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
<package id="Irony" version="0.9.1" targetFramework="net45" />
66
<package id="Mono.Cecil" version="0.9.6.1" targetFramework="net45" />
77
<package id="Unofficial.Ionic.Zip" version="1.9.1.8" targetFramework="net45" />
8-
</packages>
8+
<package id="FSharp.Core" version="4.0.0.1" targetFramework="net45" />
9+
</packages>

src/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,19 @@
3030
<Reference Include="System.IO.Compression" />
3131
<Reference Include="System.IO.Compression.FileSystem" />
3232
<Reference Include="System.Net.Http" />
33+
<Reference Include="System.Xml" />
3334
</ItemGroup>
3435
<ItemGroup>
3536
<Compile Include="Properties\AssemblyInfo.cs" />
3637
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\DownloadUri.cs" />
3738
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\UnzipDirectoryChildren.cs" />
3839
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\GenerateProfile.cs" />
40+
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\GetNugetPackageBasePath.cs" />
3941
</ItemGroup>
4042
<ItemGroup>
4143
<Content Include="Xamarin.Android.Tools.BootstrapTasks.targets">
4244
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4345
</Content>
4446
</ItemGroup>
4547
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
46-
</Project>
48+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Xml;
6+
7+
using Microsoft.Build.Framework;
8+
using Microsoft.Build.Utilities;
9+
10+
namespace Xamarin.Android.Tools.BootstrapTasks
11+
{
12+
public class GetNugetPackageBasePath : Task
13+
{
14+
[Required]
15+
public ITaskItem [] PackageConfigFiles { get; set; }
16+
17+
[Required]
18+
public string PackageName { get; set; }
19+
20+
[Output]
21+
public ITaskItem BasePath { get; set; }
22+
23+
public override bool Execute ()
24+
{
25+
Log.LogMessage (MessageImportance.Low, "Task GetNugetPackageBasePath");
26+
Log.LogMessage (MessageImportance.Low, "\tPackageName : {0}", PackageName);
27+
Log.LogMessage (MessageImportance.Low, "\tPackageConfigFiles : ");
28+
foreach (ITaskItem file in PackageConfigFiles) {
29+
Log.LogMessage (MessageImportance.Low, "\t\t{0}", file.ItemSpec);
30+
}
31+
32+
Version latest = null;
33+
foreach (string file in PackageConfigFiles.Select (x => Path.GetFullPath (x.ItemSpec)).Distinct ().OrderBy (x => x)) {
34+
if (!File.Exists (file)) {
35+
Log.LogWarning ("\tPackages config file {0} not found", file);
36+
continue;
37+
}
38+
39+
Version tmp = GetPackageVersion (file);
40+
if (latest != null && latest >= tmp)
41+
continue;
42+
latest = tmp;
43+
}
44+
45+
if (latest == null)
46+
Log.LogError ("NuGet Package '{0}' not found", PackageName);
47+
else
48+
BasePath = new TaskItem (Path.Combine ("packages", $"{PackageName}.{latest}"));
49+
Log.LogMessage (MessageImportance.Low, $"BasePath == {BasePath}");
50+
return !Log.HasLoggedErrors;
51+
}
52+
53+
Version GetPackageVersion (string packageConfigFile)
54+
{
55+
Version ret = null;
56+
var doc = new XmlDocument ();
57+
doc.Load (packageConfigFile);
58+
59+
XmlNodeList nodes = doc.DocumentElement.SelectNodes ($"./package[@id='{PackageName}']");
60+
foreach (XmlNode n in nodes) {
61+
var e = n as XmlElement;
62+
if (e == null)
63+
continue;
64+
65+
Version tmp;
66+
if (!Version.TryParse (e.GetAttribute ("version"), out tmp))
67+
continue;
68+
if (ret != null && ret >= tmp)
69+
continue;
70+
ret = tmp;
71+
}
72+
73+
return ret;
74+
}
75+
}
76+
}

0 commit comments

Comments
 (0)