Skip to content

Commit f4f056a

Browse files
committed
[mono-sdks] Try to download the Mono SDKs before building them
1 parent f1d7f6e commit f4f056a

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/GitCommitHash.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public sealed class GitCommitHash : Git
1616
[Output]
1717
public string AbbreviatedCommitHash { get; set; }
1818

19+
[Output]
20+
public string CommitHash { get; set; }
21+
1922
protected override bool LogTaskMessages {
2023
get { return false; }
2124
}
@@ -38,17 +41,18 @@ public override bool Execute ()
3841

3942
protected override string GenerateCommandLineCommands ()
4043
{
41-
return "log --no-color --first-parent -n1 --pretty=format:%h";
44+
return "rev-parse HEAD";
4245
}
4346

4447
protected override void LogEventsFromTextOutput (string singleLine, MessageImportance messageImportance)
4548
{
4649
if (string.IsNullOrEmpty (singleLine))
4750
return;
48-
if (singleLine.Length < RequiredHashLength) {
49-
Log.LogError ("Abbreviated commit hash `{0}` is shorter than required length of {1} characters", singleLine, RequiredHashLength);
51+
if (singleLine.Length < 40) {
52+
Log.LogError ("Commit hash `{0}` is shorter than required length of {1} characters", singleLine, 40);
5053
return;
5154
}
55+
CommitHash = singleLine;
5256
AbbreviatedCommitHash = singleLine.Substring (0, RequiredHashLength);
5357
}
5458
}

src/mono-runtimes/mono-runtimes.targets

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.DownloadUri" />
34
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.GitCommitTime" />
5+
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.GitCommitHash" />
46
<Target Name="Build" DependsOnTargets="$(BuildDependsOn)" />
57
<PropertyGroup>
68
<_SourceTopDir>..\..</_SourceTopDir>
@@ -48,6 +50,7 @@
4850
</PropertyGroup>
4951
<PropertyGroup>
5052
<ForceBuildDependsOn>
53+
_DownloadArchive;
5154
_Autogen;
5255
_Build;
5356
_InstallRuntimes;
@@ -176,6 +179,18 @@
176179
/>
177180
</Target>
178181

182+
<Target Name="_GetMonoGitCommitHash">
183+
<GitCommitHash
184+
WorkingDirectory="$(MonoSourceFullPath)"
185+
ToolPath="$(GitToolPath)"
186+
ToolExe="$(GitToolExe)" >
187+
<Output TaskParameter="CommitHash" PropertyName="_MonoGitCommitHash" />
188+
</GitCommitHash>
189+
<PropertyGroup>
190+
<_MonoArchiveName>android-$(_MonoSdksConfiguration)-$(_MonoGitCommitHash)-$(HostOS)</_MonoArchiveName>
191+
</PropertyGroup>
192+
</Target>
193+
179194
<Target Name="_GetRuntimesOutputItems">
180195
<ItemGroup>
181196
<_RuntimeSource
@@ -267,12 +282,37 @@
267282
</ItemGroup>
268283
</Target>
269284

285+
<Target Name="_DownloadArchive"
286+
DependsOnTargets="_GetMonoGitCommitHash"
287+
Condition=" !Exists('$(MonoSourceFullPath)\sdks\out\.stamp-$(_MonoArchiveName)-download') " >
288+
<MakeDir
289+
Directories="$(MonoSourceFullPath)\sdks\out"
290+
/>
291+
<DownloadUri
292+
SourceUris="https://xamjenkinsartifact.blob.core.windows.net/mono-sdks/$(_MonoArchiveName).tar.gz"
293+
DestinationFiles="$(AndroidToolchainCacheDirectory)\$(_MonoArchiveName).tar.gz"
294+
ContinueOnError="True"
295+
/>
296+
<Exec
297+
Condition=" Exists('$(AndroidToolchainCacheDirectory)\$(_MonoArchiveName).tar.gz') "
298+
Command="tar -xvf $(AndroidToolchainCacheDirectory)\$(_MonoArchiveName).tar.gz"
299+
IgnoreStandardErrorWarningFormat="True"
300+
WorkingDirectory="$(MonoSourceFullPath)\sdks\out"
301+
/>
302+
<Touch
303+
Condition=" Exists('$(AndroidToolchainCacheDirectory)\$(_MonoArchiveName).tar.gz') "
304+
Files="$(MonoSourceFullPath)\sdks\out\.stamp-$(_MonoArchiveName)-download"
305+
AlwaysCreate="True"
306+
/>
307+
</Target>
308+
270309
<Target Name="_Build"
271310
Condition=" '@(_MonoRuntime)' != '' Or '@(_MonoCrossRuntime)' != '' Or '@(_MonoBcl)' != '' Or '@(_LlvmRuntime)' != '' "
272-
DependsOnTargets="_SetAutogenShTimeToLastCommitTimestamp;_GetRuntimesOutputItems;_PrepareLlvmItems"
311+
DependsOnTargets="_SetAutogenShTimeToLastCommitTimestamp;_GetRuntimesOutputItems;_PrepareLlvmItems;_GetMonoGitCommitHash;_DownloadArchive"
273312
Inputs="$(LlvmSourceFullPath)\CMakeLists.txt;$(MonoSourceFullPath)\autogen.sh"
274313
Outputs="@(_RuntimeSource);@(_RuntimeBinarySource);@(_CrossRuntimeBinarySource);@(_ProfilerSource);@(_MonoPosixHelperSource);@(_RuntimeEglibHeaderSource);@(_MonoBtlsSource);@(_BclTestOutput);@(_BclProfileItems);@(_LlvmSourceBinary)">
275314
<Exec
315+
Condition=" !Exists('$(MonoSourceFullPath)\sdks\out\.stamp-$(_MonoArchiveName)-download') "
276316
Command="make DISABLE_IOS=1 $(MakeConcurrency) @(_MonoRuntime->'package-android-%(Identity)', ' ') @(_MonoCrossRuntime->'package-android-%(Identity)', ' ') @(_MonoBcl->'package-android-%(Identity)', ' ') @(_LlvmRuntime->'provision-llvm-%(Identity)', ' ') $(_MonoSdksParameters)"
277317
IgnoreStandardErrorWarningFormat="True"
278318
WorkingDirectory="$(MonoSourceFullPath)\sdks\builds"

0 commit comments

Comments
 (0)