Skip to content

Commit

Permalink
Add Linux sdk items and fix toolchain downloader to really respect Ho…
Browse files Browse the repository at this point in the history
…stOS.

- fix Android SDK Tools location.
- add SDK/NDK items for Linux.
- xbuild condition did not work and downloaded all the items. It was because
  condition by metadata didn't work with the complicated expression.
  So, split filtering and transformation into different tasks.
- xbuild aborts when the specified metadata %(HostOS) does not exist, so
  specify dummy HostOS metadata (which is ugly but not too annoying).

(Linux build verification is still ongoing, not assuring that this fixes
all the possible existing issues.)
  • Loading branch information
atsushieno committed Apr 20, 2016
1 parent b3dca00 commit eb76539
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CONFIGURATION = Debug
MSBUILD = xbuild /p:Configuration=$(CONFIGURATION)
MSBUILD = xbuild /p:Configuration=$(CONFIGURATION) $(MSBUILD_ARGS)

all:
$(MSBUILD)
Expand Down
18 changes: 17 additions & 1 deletion build-tools/android-toolchain/android-toolchain.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
<AndroidUri Condition=" '$(AndroidUri)' == '' ">https://dl-ssl.google.com/android/repository</AndroidUri>
</PropertyGroup>
<ItemGroup>
<AndroidNdkItem Include="android-ndk-r11c-linux-x86_64.zip">
<HostOS>Linux</HostOS>
</AndroidNdkItem>
<AndroidSdkItem Include="build-tools_r23-linux.zip">
<HostOS>Linux</HostOS>
<DestDir>build-tools\23.0.0</DestDir>
</AndroidSdkItem>
<AndroidSdkItem Include="platform-tools_r23-linux.zip">
<HostOS>Linux</HostOS>
<DestDir>platform-tools</DestDir>
</AndroidSdkItem>
<AndroidSdkItem Include="tools_r24.4.1-linux.zip">
<HostOS>Linux</HostOS>
</AndroidSdkItem>
<AndroidNdkItem Include="android-ndk-r11c-darwin-x86_64.zip">
<HostOS>Darwin</HostOS>
</AndroidNdkItem>
Expand All @@ -15,13 +29,15 @@
<HostOS>Darwin</HostOS>
<DestDir>platform-tools</DestDir>
</AndroidSdkItem>
<AndroidSdkItem Include="android-sdk_r24.4.1-macosx.zip">
<AndroidSdkItem Include="tools_r24.4.1-macosx.zip">
<HostOS>Darwin</HostOS>
</AndroidSdkItem>
<AndroidSdkItem Include="platform-N_r01.zip">
<HostOS></HostOS>
<DestDir>platforms\android-N</DestDir>
</AndroidSdkItem>
<AndroidSdkItem Include="android-23_r01.zip">
<HostOS></HostOS>
<DestDir>platforms\android-23</DestDir>
</AndroidSdkItem>
</ItemGroup>
Expand Down
31 changes: 22 additions & 9 deletions build-tools/android-toolchain/android-toolchain.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,37 @@
<UsingTask AssemblyFile="$(OutputPath)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.CreateTemporaryDirectory" />
<UsingTask AssemblyFile="$(OutputPath)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.DownloadUri" />
<UsingTask AssemblyFile="$(OutputPath)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.UnzipDirectoryChildren" />
<Target Name="_DetermineItems">
<CreateItem
Include="@(AndroidSdkItem)"
Condition=" '%(HostOS)' == '$(HostOS)' Or '%(HostOS)' == '' ">
<Output TaskParameter="Include" ItemName="_PlatformAndroidSdkItem"/>
</CreateItem>
<CreateItem
Include="@(AndroidNdkItem)"
Condition=" '%(HostOS)' == '$(HostOS)' Or '%(HostOS)' == '' ">
<Output TaskParameter="Include" ItemName="_PlatformAndroidNdkItem"/>
</CreateItem>
</Target>
<Target Name="_DownloadItems"
Outputs="@(AndroidSdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)');@(AndroidNdkItems->'$(AndroidToolchainCacheDirectory)\%(Identity)')">
DependsOnTargets="_DetermineItems"
Outputs="@(_PlatformAndroidSdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)');@(_PlatformAndroidNdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)')">
<DownloadUri
SourceUris="@(AndroidSdkItem->'$(AndroidUri)/%(Identity)');@(AndroidNdkItem->'$(AndroidUri)/%(Identity)')"
DestinationFiles="@(AndroidSdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)');@(AndroidNdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)')"
SourceUris="@(_PlatformAndroidSdkItem->'$(AndroidUri)/%(Identity)');@(_PlatformAndroidNdkItem->'$(AndroidUri)/%(Identity)')"
DestinationFiles="@(_PlatformAndroidSdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)');@(_PlatformAndroidNdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)')"
/>
</Target>
<Target Name="_UnzipFiles"
Inputs="@(AndroidSdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)')"
DependsOnTargets="_DetermineItems"
Inputs="@(_PlatformAndroidSdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)')"
Outputs="$(AndroidToolchainDirectory)\.stamp-sdk">
<CreateItem
Include="@(AndroidSdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)"
Condition=" '%(AndroidSdkItem.HostOS)' == '$(HostOS)' Or '%(AndroidSdkItem.HostOS)' == '' ">
<Output TaskParameter="Include" ItemName="_AndroidSdkItems"/>
Include="@(_PlatformAndroidSdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)">
<Output TaskParameter="Include" ItemName="_AndroidSdkItems"/>
</CreateItem>
<CreateItem
Include="@(AndroidNdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)"
Condition=" '%(AndroidSdkItem.HostOS)' == '$(HostOS)' Or '%(AndroidSdkItem.HostOS)' == '' ">
Include="@(_PlatformAndroidNdkItem->'$(AndroidToolchainCacheDirectory)\%(Identity)"
Condition=" '%(HostOS)' == '$(HostOS)' Or '%(HostOS)' == '' ">
<Output TaskParameter="Include" ItemName="_AndroidNdkItems"/>
</CreateItem>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ async TTask DownloadFile (HttpClient client, string uri, string destinationFile)
Log.LogMessage (MessageImportance.Normal, $"Skipping uri '{uri}' as destination file already exists '{destinationFile}'.");
return;
}
Log.LogMessage (MessageImportance.Low, $"Downloading '{uri}'.");
using (var r = await client.GetAsync (uri))
using (var o = File.OpenWrite (destinationFile)) {
await r.Content.CopyToAsync (o);
Expand Down

0 comments on commit eb76539

Please sign in to comment.