Skip to content

Copy FSharp support assemblies from nuget #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions build-tools/mono-runtimes/mono-runtimes.targets
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\Configuration.props" />
<Import Project="mono-runtimes.props" />
<Import Project="mono-runtimes.projitems" />
<PropertyGroup>
<_MonoPath>..\..\external\mono</_MonoPath>
<_SourceTopDir>..\..</_SourceTopDir>
<_BclFrameworkDir>$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0</_BclFrameworkDir>
<_MonoPath>$(_SourceTopDir)\external\mono</_MonoPath>
Copy link
Member

@jonpryor jonpryor May 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why introduce and use $(_SourceTopDir)?

Related: as part of monodroid integration, we may want to create a "toplevel" $(MonoPath) property that is the path to the Mono checkout to use, in lieu of using git submodule update, along with Java.Interop, so that we can bump mono/etc. without a xamarin-android commit. (Useful for a "rebuild xamarin-android with mono/master..." lane.)

As such, we may want to just do that now, possibly by altering Condfiguration.props with:

<MonoPath Condition=" '$(MonoPath)' != '' ">$([System.IO.Path]::GetFullPath('external/mono`))</MonoPath>

so that we have an absolute path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$(_SourceTopDir) - I don't like hard-coded constants all over the "code", makes it error prone should the value had to be changed. Plus, it makes reading the code easier.

I thought about MonoPath, just didn't want to introduce it in this diff as it is unrelated. I will open a separate PR for this.

</PropertyGroup>
<UsingTask AssemblyFile="$(_SourceTopDir)\bin\Build$(Configuration)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.GetNugetPackageBasePath" />
<Import Project="$(_SourceTopDir)\Configuration.props" />
<Import Project="mono-runtimes.props" />
<Import Project="mono-runtimes.projitems" />
<Target Name="_Autogen"
Inputs="$(_MonoPath)\autogen.sh"
Outputs="$(_MonoPath)\configure">
Expand Down Expand Up @@ -74,23 +77,34 @@
<Target Name="_InstallBcl"
Inputs="$(_MonoPath)\mcs\class\lib\monodroid\mscorlib.dll"
Outputs="$(OutputPath)lib\xbuild-frameworks\MonoAndroid\v1.0\mscorlib.dll;$(OutputPath)lib\xbuild-frameworks\MonoAndroid\v1.0\RedistList\FrameworkList.xml">
<MakeDir Directories="$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0" />
<MakeDir Directories="$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0\RedistList" />
<MakeDir Directories="$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0\Facades" />
<MakeDir Directories="$(_BclFrameworkDir)" />
<MakeDir Directories="$(_BclFrameworkDir)\RedistList" />
<MakeDir Directories="$(_BclFrameworkDir)\Facades" />
<ItemGroup>
<_PackageConfigFiles Include="$(_SourceTopDir)\src\Xamarin.Android.Build.Tasks\packages.config" />
</ItemGroup>
<GetNugetPackageBasePath PackageConfigFiles="@(_PackageConfigFiles)" PackageName="FSharp.Core">
<Output TaskParameter="BasePath" PropertyName="_FSharpCorePackagePath" />
</GetNugetPackageBasePath>
<ItemGroup>
<_FSharp Include="$(_SourceTopDir)\$(_FSharpCorePackagePath)\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core*" />
<_Assemblies Include="$(_MonoPath)\mcs\class\lib\monodroid\*.dll" />
<_Facades Include="$(_MonoPath)\mcs\class\lib\monodroid\Facades\*.dll" />
</ItemGroup>
<Copy
SourceFiles="@(_Assemblies)"
DestinationFolder="$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0"
DestinationFolder="$(_BclFrameworkDir)"
/>
<Copy
SourceFiles="@(_Facades)"
DestinationFolder="$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0\Facades"
DestinationFolder="$(_BclFrameworkDir)\Facades"
/>
<Copy
SourceFiles="@(_FSharp)"
DestinationFolder="$(_BclFrameworkDir)"
/>
<Touch
Files="$(OutputPath)\lib\xbuild-frameworks\MonoAndroid\v1.0\mscorlib.dll"
Files="$(_BclFrameworkDir)\mscorlib.dll"
/>
<ItemGroup>
<FrameworkList Include="&lt;FileList Redist=&quot;MonoAndroid&quot; Name=&quot;Xamarin.Android Base Class Libraries&quot;&gt;" />
Expand Down
3 changes: 2 additions & 1 deletion src/Xamarin.Android.Build.Tasks/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<package id="Irony" version="0.9.1" targetFramework="net45" />
<package id="Mono.Cecil" version="0.9.6.1" targetFramework="net45" />
<package id="Unofficial.Ionic.Zip" version="1.9.1.8" targetFramework="net45" />
</packages>
<package id="FSharp.Core" version="4.0.0.1" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\DownloadUri.cs" />
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\UnzipDirectoryChildren.cs" />
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\GenerateProfile.cs" />
<Compile Include="Xamarin.Android.Tools.BootstrapTasks\GetNugetPackageBasePath.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Xamarin.Android.Tools.BootstrapTasks.targets">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace Xamarin.Android.Tools.BootstrapTasks
{
public class GetNugetPackageBasePath : Task
{
[Required]
public ITaskItem [] PackageConfigFiles { get; set; }

[Required]
public string PackageName { get; set; }

[Output]
public ITaskItem BasePath { get; set; }

public override bool Execute ()
{
Log.LogMessage (MessageImportance.Low, "Task GetNugetPackageBasePath");
Log.LogMessage (MessageImportance.Low, "\tPackageName : {0}", PackageName);
Log.LogMessage (MessageImportance.Low, "\tPackageConfigFiles : ");
foreach (ITaskItem file in PackageConfigFiles) {
Log.LogMessage (MessageImportance.Low, "\t\t{0}", file.ItemSpec);
}

Version latest = null;
foreach (string file in PackageConfigFiles.Select (x => Path.GetFullPath (x.ItemSpec)).Distinct ().OrderBy (x => x)) {
if (!File.Exists (file)) {
Log.LogWarning ("\tPackages config file {0} not found", file);
continue;
}

Version tmp = GetPackageVersion (file);
if (latest != null && latest >= tmp)
continue;
latest = tmp;
}

if (latest == null)
Log.LogError ("NuGet Package '{0}' not found", PackageName);
else
BasePath = new TaskItem (Path.Combine ("packages", $"{PackageName}.{latest}"));
Log.LogMessage (MessageImportance.Low, $"BasePath == {BasePath}");
return !Log.HasLoggedErrors;
}

Version GetPackageVersion (string packageConfigFile)
{
Version ret = null;
var doc = new XmlDocument ();
doc.Load (packageConfigFile);

XmlNodeList nodes = doc.DocumentElement.SelectNodes ($"./package[@id='{PackageName}']");
foreach (XmlNode n in nodes) {
var e = n as XmlElement;
if (e == null)
continue;

Version tmp;
if (!Version.TryParse (e.GetAttribute ("version"), out tmp))
continue;
if (ret != null && ret >= tmp)
continue;
ret = tmp;
}

return ret;
}
}
}