[tools] Download aapt2 and bundletool from google. (#2763)

In order to support things like `AppBundle` we cannot use the version
of `aapt2` that is shipped with the Android SDK.  Google recommends
[downloading it from maven][1].

If we are shipping our own version of `aapt2` then we no longer need
to support using the Android SDK version.  If a user really wants to
use the Android SDK version they can set the `$(Aapt2ToolPath)`
MSBuild property manually.

We should also download `bundletool` and ship that too.  This will
mean we can rely on both of these being available when we start
looking at `AppBundle` support.

[1]: https://developer.android.com/studio/build/building-cmdline#download_aapt
This commit is contained in:
Dean Ellis 2019-03-14 18:52:43 +00:00 коммит произвёл Jonathan Pryor
Родитель 3eb9c78c72
Коммит 4ccbeb74c9
16 изменённых файлов: 402 добавлений и 162 удалений

Просмотреть файл

@ -97,6 +97,7 @@
<XAPlatformToolsVersion>28.0.0</XAPlatformToolsVersion>
<XAIntegratedTests Condition="'$(XAIntegratedTests)' == ''">False</XAIntegratedTests>
<XAIncludeProprietaryBits Condition="'$(XAIncludeProprietaryBits)' == ''">False</XAIncludeProprietaryBits>
<XABundleToolVersion Condition="'$(XABundleToolVersion)' == ''">0.8.0</XABundleToolVersion>
<PathSeparator>$([System.IO.Path]::PathSeparator)</PathSeparator>
<_TestsAotName Condition=" '$(AotAssemblies)' == 'true' ">-Aot</_TestsAotName>
<_TestsBundleName Condition=" '$(BundleAssemblies)' == 'true' ">-Bundle</_TestsBundleName>

Просмотреть файл

@ -123,6 +123,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Tools.Andro
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "r8", "src\r8\r8.csproj", "{1BAFA0CC-0377-46CE-AB7B-7BB2E7B62F63}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aapt2", "src\aapt2\aapt2.csproj", "{0C31DE30-F9DF-4312-BFFE-DCAD558CCF08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bundletool", "src\bundletool\bundletool.csproj", "{A0AEF446-3368-4591-9DE6-BC3B2B33337D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "proprietary", "build-tools\proprietary\proprietary.csproj", "{D93CAC27-3893-42A3-99F1-2BCA72E186F4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "download-bundle", "build-tools\download-bundle\download-bundle.csproj", "{1DA0CB12-5508-4E83-A242-0C8D6D99A49B}"
@ -361,6 +365,14 @@ Global
{1BAFA0CC-0377-46CE-AB7B-7BB2E7B62F63}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{1BAFA0CC-0377-46CE-AB7B-7BB2E7B62F63}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{1BAFA0CC-0377-46CE-AB7B-7BB2E7B62F63}.Release|AnyCPU.Build.0 = Release|Any CPU
{0C31DE30-F9DF-4312-BFFE-DCAD558CCF08}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{0C31DE30-F9DF-4312-BFFE-DCAD558CCF08}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{0C31DE30-F9DF-4312-BFFE-DCAD558CCF08}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{0C31DE30-F9DF-4312-BFFE-DCAD558CCF08}.Release|AnyCPU.Build.0 = Release|Any CPU
{A0AEF446-3368-4591-9DE6-BC3B2B33337D}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{A0AEF446-3368-4591-9DE6-BC3B2B33337D}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{A0AEF446-3368-4591-9DE6-BC3B2B33337D}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{A0AEF446-3368-4591-9DE6-BC3B2B33337D}.Release|AnyCPU.Build.0 = Release|Any CPU
{D93CAC27-3893-42A3-99F1-2BCA72E186F4}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{D93CAC27-3893-42A3-99F1-2BCA72E186F4}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{D93CAC27-3893-42A3-99F1-2BCA72E186F4}.Release|AnyCPU.ActiveCfg = Release|Any CPU
@ -439,6 +451,8 @@ Global
{1BAFA0CC-0377-46CE-AB7B-7BB2E7B62F63} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{F3CFF31C-037B-450F-B22D-1D6E529B2DCC} = {864062D3-A415-4A6F-9324-5820237BA058}
{46529930-A5CC-4205-A50D-0AAAC639F082} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
{0C31DE30-F9DF-4312-BFFE-DCAD558CCF08} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{A0AEF446-3368-4591-9DE6-BC3B2B33337D} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {53A1F287-EFB2-4D97-A4BB-4A5E145613F6}

Просмотреть файл

@ -141,6 +141,7 @@
<_MSBuildFiles Include="$(MSBuildSrcDir)\proguard\lib\proguard.jar"/>
<_MSBuildFiles Include="$(MSBuildSrcDir)\proguard\license.html" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\r8.jar" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\bundletool-all-$(XABundleToolVersion).jar" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\SgmlReaderDll.dll" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.Analysis.targets" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.Bindings.targets" />
@ -178,6 +179,8 @@
<_MSBuildFilesWin Include="$(MSBuildSrcDir)\libzip.dll" />
<_MSBuildFilesWin Include="$(MSBuildSrcDir)\x64\libzip.dll" />
<_MSBuildFilesWin Include="$(MSBuildSrcDir)\proguard\bin\proguard.bat" />
<_MSBuildFilesWin Include="$(MSBuildSrcDir)\aapt2.exe" />
<_MSBuildFilesWin Include="$(MSBuildSrcDir)\libwinpthread-1.dll" />
<_MSBuildLibHostFilesWin Include="$(MSBuildSrcDir)\lib\host-mxe-Win64\libmono-android.debug.dll" Condition=" '$(HostOS)' != 'Windows' " />
<_MSBuildLibHostFilesWin Include="$(MSBuildSrcDir)\lib\host-mxe-Win64\libmono-android.release.dll" Condition=" '$(HostOS)' != 'Windows' " />
<_MSBuildLibHostFilesWin Include="$(MSBuildSrcDir)\lib\host-mxe-Win64\libMonoPosixHelper.dll" />
@ -188,6 +191,8 @@
<_MSBuildFilesUnix Include="$(MSBuildSrcDir)\$(HostOS)\jit-times" />
<_MSBuildFilesUnix Include="$(MSBuildSrcDir)\$(HostOS)\mono" />
<_MSBuildFilesUnix Include="$(MSBuildSrcDir)\$(HostOS)\mono-symbolicate" />
<_MSBuildFilesUnix Include="$(MSBuildSrcDir)\$(HostOS)\aapt2" />
<_MSBuildFilesUnix Include="$(MSBuildSrcDir)\$(HostOS)\lib64\libc++.$(LibExtension)" />
<_MSBuildFilesUnix Include="$(MSBuildSrcDir)\lib\host-$(HostOS)\libmono-android.debug.$(LibExtension)" />
<_MSBuildFilesUnix Include="$(MSBuildSrcDir)\lib\host-$(HostOS)\libmono-android.release.$(LibExtension)" />
<_MSBuildFilesUnix Include="$(MSBuildSrcDir)\lib\host-$(HostOS)\libmono-profiler-aot.$(LibExtension)" />

Просмотреть файл

@ -0,0 +1,169 @@
<!--
***********************************************************************************************
Xamarin.Android.Aapt2.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
This file imports the version- and platform-specific targets for the project importing
this file. This file also defines targets to produce an error if the specified targets
file does not exist, but the project is built anyway (command-line or IDE build).
Copyright (C) 2010-2011 Novell. All rights reserved.
Copyright (C) 2011-2012 Xamarin. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="_ReadAapt2VersionCache">
<ReadLinesFromFile File="$(_AndroidAapt2VersionFile)"
Condition="Exists('$(_AndroidAapt2VersionFile)')">
<Output TaskParameter="Lines" ItemName="_Aapt2VersionCache"/>
</ReadLinesFromFile>
</Target>
<Target Name="_CreateAapt2VersionCache"
Condition=" '$(_AndroidUseAapt2)' == 'True' And '$(_Aapt2Version)' != '@(_Aapt2VersionCache)' "
DependsOnTargets="_ReadAapt2VersionCache"
>
<MakeDir Directories="$(IntermediateOutputPath)" Condition="!Exists('$(IntermediateOutputPath)')" />
<WriteLinesToFile
Condition=" '$(_Aapt2Version)' != '@(_Aapt2VersionCache)' "
File="$(_AndroidAapt2VersionFile)"
Lines="$(_Aapt2Version)"
Overwrite="true"
/>
<ItemGroup Condition="'$(_Aapt2Version)' != '@(_Aapt2VersionCache)'">
<_CompiledFlataArchive Include="$(_AndroidLibrayProjectIntermediatePath)**\*.flata" />
<_CompiledFlataArchive Include="$(IntermediateOutputPath)\*.flata" />
<_CompiledFlataStamp Include="$(_AndroidLibrayProjectIntermediatePath)**\compiled.stamp" />
</ItemGroup>
<Delete
Condition="'$(_Aapt2Version)' != '@(_Aapt2VersionCache)'"
Files="@(_CompiledFlataArchive);@(_CompiledFlataStamp)"
/>
</Target>
<Target Name="_CollectLibraryResourceDirectories"
Condition=" '$(_AndroidUseAapt2)' == 'True' "
>
<CollectNonEmptyDirectories Directories="@(LibraryResourceDirectories);@(_AdditonalAndroidResourceCachePaths->'%(Identity)\res')">
<Output TaskParameter="Output" ItemName="_LibraryResourceDirectories" />
</CollectNonEmptyDirectories>
<ComputeHash Source="@(_LibraryResourceDirectories)" >
<Output TaskParameter="Output" ItemName="_LibraryResourceHashDirectories" />
</ComputeHash>
</Target>
<Target Name="_ConvertLibraryResourcesCases"
Condition=" '$(_AndroidUseAapt2)' == 'True' "
DependsOnTargets="_CollectLibraryResourceDirectories"
Inputs="@(_LibraryResourceHashDirectories->'%(StampFile)')"
Outputs="$(_AndroidStampDirectory)_ConvertLibraryResourcesCases.stamp">
<ConvertResourcesCases
Condition=" '@(_LibraryResourceDirectories)' != '' "
ContinueOnError="$(DesignTimeBuild)"
AcwMapFile="$(_AcwMapFile)"
AndroidConversionFlagFile="$(_AndroidStampDirectory)_ConvertLibraryResourcesCases.stamp"
CustomViewMapFile="$(_CustomViewMapFile)"
ResourceDirectories="@(_LibraryResourceDirectories)"
ResourceNameCaseMap="$(_AndroidResourceNameCaseMap)"
/>
<Touch Files="$(_AndroidStampDirectory)_ConvertLibraryResourcesCases.stamp" AlwaysCreate="True" />
</Target>
<Target Name="_CompileAndroidLibraryResources"
Condition=" '$(_AndroidUseAapt2)' == 'True' "
DependsOnTargets="_ConvertLibraryResourcesCases"
Inputs="@(_LibraryResourceHashDirectories->'%(StampFile)')"
Outputs="@(_LibraryResourceHashDirectories->'$(_AndroidLibraryFlatArchivesDirectory)%(Hash).stamp')"
>
<MakeDir Directories="$(_AndroidLibraryFlatArchivesDirectory)" Condition="!Exists('$(_AndroidLibraryFlatArchivesDirectory)')" />
<Aapt2Compile
Condition=" '@(_LibraryResourceHashDirectories)' != '' "
ContinueOnError="$(DesignTimeBuild)"
ExplicitCrunch="$(AndroidExplicitCrunch)"
ExtraArgs="$(AndroidAapt2CompileExtraArgs)"
FlatArchivesDirectory="$(_AndroidLibraryFlatArchivesDirectory)"
ResourceDirectories="@(_LibraryResourceHashDirectories)"
ToolPath="$(Aapt2ToolPath)"
ToolExe="$(Aapt2ToolExe)"
/>
<ItemGroup>
<_HashStampFiles Include="@(_LibraryResourceHashDirectories->'$(_AndroidLibraryFlatArchivesDirectory)%(Hash).stamp')" />
<_HashFlataFiles Include="@(_LibraryResourceHashDirectories->'$(_AndroidLibraryFlatArchivesDirectory)%(Hash).flata')" />
</ItemGroup>
<Touch
Files="@(_HashStampFiles)"
AlwaysCreate="True"
/>
<ItemGroup>
<FileWrites Include="@(_HashStampFiles)" />
<FileWrites Include="@(_HashFlataFiles)" />
</ItemGroup>
</Target>
<Target Name="_CompileResources"
Condition=" '$(_AndroidUseAapt2)' == 'True' "
Inputs="@(AndroidResource)"
Outputs="$(_AndroidLibraryFlatArchivesDirectory)\compiled.stamp"
>
<MakeDir Directories="$(_AndroidLibraryFlatArchivesDirectory)" Condition="!Exists('$(_AndroidLibraryFlatArchivesDirectory)')" />
<!-- Change cases so we support mixed case resource names -->
<ConvertResourcesCases
ContinueOnError="$(DesignTimeBuild)"
AcwMapFile="$(_AcwMapFile)"
AdditionalResourceDirectories="@(_LibraryResourceDirectories)"
AndroidConversionFlagFile="$(_AndroidLibraryFlatArchivesDirectory)\compiled.flata"
CustomViewMapFile="$(_CustomViewMapFile)"
ResourceDirectories="$(MonoAndroidResDirIntermediate)"
ResourceNameCaseMap="$(_AndroidResourceNameCaseMap)"
/>
<Aapt2Compile
ContinueOnError="$(DesignTimeBuild)"
ExplicitCrunch="$(AndroidExplicitCrunch)"
ExtraArgs="$(AndroidAapt2CompileExtraArgs)"
FlatArchivesDirectory="$(_AndroidLibraryFlatArchivesDirectory)"
ResourceDirectories="$(MonoAndroidResDirIntermediate)"
ResourceNameCaseMap="$(_AndroidResourceNameCaseMap)"
ToolPath="$(Aapt2ToolPath)"
ToolExe="$(Aapt2ToolExe)"
/>
<Touch Files="$(_AndroidLibraryFlatArchivesDirectory)\compiled.stamp" AlwaysCreate="True" />
<ItemGroup>
<FileWrites Include="$(_AndroidLibraryFlatArchivesDirectory)\compiled.flata" />
<FileWrites Include="$(_AndroidLibraryFlatArchivesDirectory)\compiled.stamp" />
</ItemGroup>
</Target>
<Target Name="_GenerateJavaDesignerForComponentAapt2"
Condition=" '$(_AndroidUseAapt2)' == 'True' "
Inputs="@(_AdditonalAndroidResourceCacheFiles);@(_LibraryResourceDirectoryStamps);$(_AndroidResgenFlagFile)"
Outputs="$(_AndroidComponentResgenFlagFile)">
<!-- Run aapt to generate R.java for additional Android resources-->
<Aapt2Link
Condition=" '$(_AndroidUseAapt2)' == 'True' "
ContinueOnError="$(DesignTimeBuild)"
AdditionalAndroidResourcePaths="@(_LibraryResourceHashDirectories)"
AdditionalResourceArchives="@(_LibraryResourceHashDirectories->'$(_AndroidLibraryFlatArchivesDirectory)%(Hash).flata')"
ApplicationName="$(_AndroidPackage)"
AssemblyIdentityMapFile="$(_AndroidLibrayProjectAssemblyMapFile)"
CompiledResourceFlatArchive="$(_AndroidLibraryFlatArchivesDirectory)\compiled.flata"
ExtraArgs="$(AndroidAapt2LinkExtraArgs)"
ImportsDirectory="$(_LibraryProjectImportsDirectoryName)"
JavaDesignerOutputDirectory="$(IntermediateOutputPath)android\src"
JavaPlatformJarPath="$(JavaPlatformJarPath)"
ManifestFiles="@(_AdditonalAndroidResourceCachePaths->'%(Identity)\AndroidManifest.xml');@(LibraryResourceDirectories->'%(Identity)\..\AndroidManifest.xml')"
OutputImportDirectory="$(_AndroidLibrayProjectIntermediatePath)"
ResourceNameCaseMap="$(_AndroidResourceNameCaseMap)"
ResourceDirectories="$(MonoAndroidResDirIntermediate)"
ToolPath="$(Aapt2ToolPath)"
ToolExe="$(Aapt2ToolExe)"
UseShortFileNames="$(UseShortFileNames)"
YieldDuringToolExecution="$(YieldDuringToolExecution)"
/>
<Touch Files="$(_AndroidComponentResgenFlagFile)" AlwaysCreate="True" />
</Target>
</Project>

Просмотреть файл

@ -67,6 +67,9 @@ namespace Xamarin.Android.Tasks
[Output]
public string Aapt2Version { get; set; }
[Output]
public string Aapt2ToolPath { get; set; }
static readonly bool IsWindows = Path.DirectorySeparatorChar == '\\';
static readonly string ZipAlign = IsWindows ? "zipalign.exe" : "zipalign";
static readonly string Aapt = IsWindows ? "aapt.exe" : "aapt";
@ -133,7 +136,14 @@ namespace Xamarin.Android.Tasks
ApkSignerJar = Path.Combine (AndroidSdkBuildToolsBinPath, "lib", ApkSigner);
AndroidUseApkSigner = File.Exists (ApkSignerJar);
bool aapt2Installed = File.Exists (Path.Combine (AndroidSdkBuildToolsBinPath, Aapt2));
if (string.IsNullOrEmpty (Aapt2ToolPath)) {
var osBinPath = MonoAndroidHelper.GetOSBinPath ();
var aapt2 = Path.Combine (osBinPath, Aapt2);
if (File.Exists (aapt2))
Aapt2ToolPath = osBinPath;
}
bool aapt2Installed = !string.IsNullOrEmpty (Aapt2ToolPath) && File.Exists (Path.Combine (Aapt2ToolPath, Aapt2));
if (aapt2Installed && AndroidUseAapt2) {
if (!GetAapt2Version ()) {
AndroidUseAapt2 = false;
@ -224,7 +234,7 @@ namespace Xamarin.Android.Tasks
bool GetAapt2Version ()
{
var sb = new StringBuilder ();
var aapt2Tool = Path.Combine (AndroidSdkBuildToolsBinPath, Aapt2);
var aapt2Tool = Path.Combine (Aapt2ToolPath, Aapt2);
try {
MonoAndroidHelper.RunProcess (aapt2Tool, "version", (s, e) => {
if (!string.IsNullOrEmpty (e.Data))

Просмотреть файл

@ -341,7 +341,7 @@ namespace UnamedProject
// And so the built assembly changes between DTB and regular build, triggering `_LinkAssembliesNoShrink`
//"_LinkAssembliesNoShrink",
"_UpdateAndroidResgen",
"_GenerateJavaDesignerForComponent",
"_GenerateJavaDesignerForComponentAapt2",
"_BuildLibraryImportsCache",
"_CompileJava",
};
@ -446,7 +446,7 @@ namespace UnamedProject
var targetsToBeSkipped = new [] {
isRelease ? "_LinkAssembliesShrink" : "_LinkAssembliesNoShrink",
"_UpdateAndroidResgen",
"_GenerateJavaDesignerForComponent",
"_GenerateJavaDesignerForComponentAapt2",
"_BuildLibraryImportsCache",
"_CompileJava",
};

Просмотреть файл

@ -754,6 +754,16 @@
<Name>r8</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\aapt2\aapt2.csproj">
<Project>{0c31de30-f9df-4312-bffe-dcad558ccf08}</Project>
<Name>aapt2</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\bundletool\bundletool.csproj">
<Project>{a0aef446-3368-4591-9de6-bc3b2b33337d}</Project>
<Name>bundletool</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\external\LibZipSharp\libZipSharp.csproj">
<Project>{E248B2CA-303B-4645-ADDC-9D4459D550FD}</Project>
<Name>libZipSharp</Name>

Просмотреть файл

@ -71,6 +71,10 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>Xamarin.Android.Designer.targets</Link>
</None>
<None Include="MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>Xamarin.Android.Aapt2.targets</Link>
</None>
<None Include="Xamarin.Android.Analysis.targets">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@ -147,7 +151,7 @@
<ReplaceFileContents
SourceFile="Xamarin.Android.Common.props.in"
DestinationFile="Xamarin.Android.Common.props"
Replacements="@PACKAGE_VERSION@=$(ProductVersion);@PACKAGE_VERSION_BUILD@=$(XAVersionCommitCount);@NDK_ARMEABI_V7_API@=$(AndroidNdkApiLevel_ArmV7a);@NDK_ARM64_V8A_API@=$(AndroidNdkApiLevel_ArmV8a);@NDK_X86_API@=$(AndroidNdkApiLevel_X86);@NDK_X86_64_API@=$(AndroidNdkApiLevel_X86_64)">
Replacements="@PACKAGE_VERSION@=$(ProductVersion);@PACKAGE_VERSION_BUILD@=$(XAVersionCommitCount);@NDK_ARMEABI_V7_API@=$(AndroidNdkApiLevel_ArmV7a);@NDK_ARM64_V8A_API@=$(AndroidNdkApiLevel_ArmV8a);@NDK_X86_API@=$(AndroidNdkApiLevel_X86);@NDK_X86_64_API@=$(AndroidNdkApiLevel_X86_64);@BUNDLETOOL_VERSION@=$(XABundleToolVersion)">
</ReplaceFileContents>
</Target>
<Target Name="_GenerateProfileClass"

Просмотреть файл

@ -17,6 +17,7 @@
<AndroidSdkPlatformToolsVersion Condition="'$(AndroidSdkPlatformToolsVersion)' == ''">27.0.1</AndroidSdkPlatformToolsVersion>
<AndroidSdkToolsVersion Condition="'$(AndroidSdkToolsVersion)' == ''">26.1.1</AndroidSdkToolsVersion>
<AndroidNdkVersion Condition="'$(AndroidNdkVersion)' == ''">16.1</AndroidNdkVersion>
<BundleToolVersion Condition="'$(BundleToolVersion)' == ''">@BUNDLETOOL_VERSION@</BundleToolVersion>
<!-- Enable nuget package conflict resolution -->
<ResolveAssemblyConflicts>true</ResolveAssemblyConflicts>

Просмотреть файл

@ -374,6 +374,7 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
-->
<!-- As we split up/refactor this file, put new imports here -->
<Import Project="$(MSBuildThisFileDirectory)Xamarin.Android.D8.targets" />
<Import Project="$(MSBuildThisFileDirectory)Xamarin.Android.Aapt2.targets" />
<Import Project="$(MSBuildThisFileDirectory)Xamarin.Android.SkipCases.projitems" />
<Target Name="_SeparateAppExtensionReferences">
@ -777,6 +778,7 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
UseLatestAndroidPlatformSdk="$(AndroidUseLatestPlatformSdk)"
AndroidUseAapt2="$(AndroidUseAapt2)"
AotAssemblies="$(AotAssemblies)"
Aapt2ToolPath="$(Aapt2ToolPath)"
SequencePointsMode="$(_AndroidSequencePointsMode)"
ProjectFilePath="$(MSBuildProjectFullPath)"
LintToolPath="$(LintToolPath)"
@ -793,6 +795,7 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
<Output TaskParameter="AndroidUseApkSigner" PropertyName="AndroidUseApkSigner" Condition="'$(AndroidUseApkSigner)' == ''" />
<Output TaskParameter="AndroidUseAapt2" PropertyName="_AndroidUseAapt2" />
<Output TaskParameter="Aapt2Version" PropertyName="_Aapt2Version" />
<Output TaskParameter="Aapt2ToolPath" PropertyName="Aapt2ToolPath" Condition="'$(Aapt2ToolPath)' == ''" />
</ResolveAndroidTooling>
<CreateProperty Value="$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion),Profile=$(TargetFrameworkProfile)">
<Output TaskParameter="Value" PropertyName="TargetFrameworkMoniker"
@ -833,32 +836,6 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
</PropertyGroup>
</Target>
<Target Name="_ReadAapt2VersionCache">
<ReadLinesFromFile File="$(_AndroidAapt2VersionFile)"
Condition="Exists('$(_AndroidAapt2VersionFile)')">
<Output TaskParameter="Lines" ItemName="_Aapt2VersionCache"/>
</ReadLinesFromFile>
</Target>
<Target Name="_CreateAapt2VersionCache"
DependsOnTargets="_ReadAapt2VersionCache"
Condition="'$(_AndroidUseAapt2)' == 'True' And '$(_Aapt2Version)' != '@(_Aapt2VersionCache)'"
>
<MakeDir Directories="$(IntermediateOutputPath)" Condition="!Exists('$(IntermediateOutputPath)')" />
<WriteLinesToFile
Condition="'$(_Aapt2Version)' != '@(_Aapt2VersionCache)'"
File="$(_AndroidAapt2VersionFile)"
Lines="$(_Aapt2Version)"
Overwrite="true"
/>
<ItemGroup Condition="'$(_Aapt2Version)' != '@(_Aapt2VersionCache)'">
<_CompiledFlataArchive Include="$(_AndroidLibrayProjectIntermediatePath)**\*.flata" />
<_CompiledFlataArchive Include="$(IntermediateOutputPath)\*.flata" />
<_CompiledFlataStamp Include="$(_AndroidLibrayProjectIntermediatePath)**\compiled.stamp" />
</ItemGroup>
<Delete Files="@(_CompiledFlataArchive);@(_CompiledFlataStamp)" Condition="'$(_Aapt2Version)' != '@(_Aapt2VersionCache)'" />
</Target>
<PropertyGroup>
<_OnResolveMonoAndroidSdks>
_ResolveMonoAndroidSdks
@ -960,12 +937,6 @@ because xbuild doesn't support framework reference assemblies.
/>
</CreateProperty>
<CreateProperty Value="$(AndroidSdkBuildToolsBinPath)">
<Output TaskParameter="Value" PropertyName="Aapt2ToolPath"
Condition="'$(Aapt2ToolPath)' == ''"
/>
</CreateProperty>
<CreateProperty Value="$(AndroidSdkBuildToolsBinPath)">
<Output TaskParameter="Value" PropertyName="ZipAlignToolPath"
Condition="'$(ZipAlignToolPath)' == ''"
@ -1008,6 +979,12 @@ because xbuild doesn't support framework reference assemblies.
/>
</CreateProperty>
<CreateProperty Value="$(MonoAndroidToolsDirectory)\bundletool-all-$(BundleToolVersion).jar">
<Output TaskParameter="Value" PropertyName="AndroidBundleToolJarPath"
Condition="'$(AndroidBundleToolJarPath)' == ''"
/>
</CreateProperty>
<CreateProperty Value="--dex --no-strict">
<Output TaskParameter="Value" PropertyName="DxExtraArguments"
Condition="'$(DxExtraArguments)' == ''"
@ -1402,96 +1379,6 @@ because xbuild doesn't support framework reference assemblies.
<Touch Files="$(_AndroidStampDirectory)_ResolveLibraryProjectImports.stamp" AlwaysCreate="True" />
</Target>
<Target Name="_CollectLibraryResourceDirectories"
Condition="'$(_AndroidUseAapt2)' == 'True'"
>
<CollectNonEmptyDirectories Directories="@(LibraryResourceDirectories);@(_AdditonalAndroidResourceCachePaths->'%(Identity)\res')">
<Output TaskParameter="Output" ItemName="_LibraryResourceDirectories" />
</CollectNonEmptyDirectories>
<ComputeHash Source="@(_LibraryResourceDirectories)" >
<Output TaskParameter="Output" ItemName="_LibraryResourceHashDirectories" />
</ComputeHash>
</Target>
<Target Name="_ConvertLibraryResourcesCases" DependsOnTargets="_CollectLibraryResourceDirectories"
Condition="'$(_AndroidUseAapt2)' == 'True'"
Inputs="@(_LibraryResourceHashDirectories->'%(StampFile)')"
Outputs="$(_AndroidStampDirectory)_ConvertLibraryResourcesCases.stamp">
<ConvertResourcesCases
Condition=" '@(_LibraryResourceDirectories)' != '' "
ContinueOnError="$(DesignTimeBuild)"
ResourceDirectories="@(_LibraryResourceDirectories)"
ResourceNameCaseMap="$(_AndroidResourceNameCaseMap)"
AcwMapFile="$(_AcwMapFile)"
CustomViewMapFile="$(_CustomViewMapFile)"
AndroidConversionFlagFile="$(_AndroidStampDirectory)_ConvertLibraryResourcesCases.stamp"
/>
<Touch Files="$(_AndroidStampDirectory)_ConvertLibraryResourcesCases.stamp" AlwaysCreate="True" />
</Target>
<Target Name="_CompileAndroidLibraryResources" DependsOnTargets="_ConvertLibraryResourcesCases"
Condition="'$(_AndroidUseAapt2)' == 'True'"
Inputs="@(_LibraryResourceHashDirectories->'%(StampFile)')"
Outputs="@(_LibraryResourceHashDirectories->'$(_AndroidLibraryFlatArchivesDirectory)%(Hash).stamp')"
>
<MakeDir Directories="$(_AndroidLibraryFlatArchivesDirectory)" Condition="!Exists('$(_AndroidLibraryFlatArchivesDirectory)')" />
<Aapt2Compile
Condition=" '@(_LibraryResourceHashDirectories)' != '' "
ContinueOnError="$(DesignTimeBuild)"
ResourceDirectories="@(_LibraryResourceHashDirectories)"
ExplicitCrunch="$(AndroidExplicitCrunch)"
ExtraArgs="$(AndroidAapt2CompileExtraArgs)"
FlatArchivesDirectory="$(_AndroidLibraryFlatArchivesDirectory)"
ToolPath="$(Aapt2ToolPath)"
ToolExe="$(Aapt2ToolExe)"
/>
<ItemGroup>
<_HashStampFiles Include="@(_LibraryResourceHashDirectories->'$(_AndroidLibraryFlatArchivesDirectory)%(Hash).stamp')" />
<_HashFlataFiles Include="@(_LibraryResourceHashDirectories->'$(_AndroidLibraryFlatArchivesDirectory)%(Hash).flata')" />
</ItemGroup>
<Touch
Files="@(_HashStampFiles)"
AlwaysCreate="True"
/>
<ItemGroup>
<FileWrites Include="@(_HashStampFiles)" />
<FileWrites Include="@(_HashFlataFiles)" />
</ItemGroup>
</Target>
<Target Name="_CompileResources"
Condition="'$(_AndroidUseAapt2)' == 'True'"
Inputs="@(AndroidResource)"
Outputs="$(_AndroidLibraryFlatArchivesDirectory)\compiled.stamp"
>
<MakeDir Directories="$(_AndroidLibraryFlatArchivesDirectory)" Condition="!Exists('$(_AndroidLibraryFlatArchivesDirectory)')" />
<!-- Change cases so we support mixed case resource names -->
<ConvertResourcesCases
ContinueOnError="$(DesignTimeBuild)"
ResourceDirectories="$(MonoAndroidResDirIntermediate)"
AdditionalResourceDirectories="@(_LibraryResourceDirectories)"
ResourceNameCaseMap="$(_AndroidResourceNameCaseMap)"
AcwMapFile="$(_AcwMapFile)"
CustomViewMapFile="$(_CustomViewMapFile)"
AndroidConversionFlagFile="$(_AndroidLibraryFlatArchivesDirectory)\compiled.flata"
/>
<Aapt2Compile
ContinueOnError="$(DesignTimeBuild)"
ResourceDirectories="$(MonoAndroidResDirIntermediate)"
ResourceNameCaseMap="$(_AndroidResourceNameCaseMap)"
ExplicitCrunch="$(AndroidExplicitCrunch)"
ExtraArgs="$(AndroidAapt2CompileExtraArgs)"
FlatArchivesDirectory="$(_AndroidLibraryFlatArchivesDirectory)"
ToolPath="$(Aapt2ToolPath)"
ToolExe="$(Aapt2ToolExe)"
/>
<Touch Files="$(_AndroidLibraryFlatArchivesDirectory)\compiled.stamp" AlwaysCreate="True" />
<ItemGroup>
<FileWrites Include="$(_AndroidLibraryFlatArchivesDirectory)\compiled.flata" />
<FileWrites Include="$(_AndroidLibraryFlatArchivesDirectory)\compiled.stamp" />
</ItemGroup>
</Target>
<Target Name="_ExtractLibraryProjectImports" DependsOnTargets="_ResolveLibraryProjectImports">
<ReadLibraryProjectImportsCache
CacheFile="$(_AndroidLibraryProjectImportsCache)">
@ -1602,21 +1489,10 @@ because xbuild doesn't support framework reference assemblies.
</CreateItem>
</Target>
<PropertyGroup>
<_GenerateJavaDesignerForComponentDependsOnTargets>
_GetAdditionalResourcesFromAssemblies
;_CreateAdditionalResourceCache
;_CollectAdditionalResourceFiles
;_CollectLibraryResourceDirectories
;_CompileAndroidLibraryResources
;_CompileResources
</_GenerateJavaDesignerForComponentDependsOnTargets>
</PropertyGroup>
<Target Name="_GenerateJavaDesignerForComponent"
<Target Name="_GenerateJavaDesignerForComponentAapt"
Condition="'$(_AndroidUseAapt2)' != 'True'"
Inputs="@(_AdditonalAndroidResourceCacheFiles);@(_LibraryResourceDirectoryStamps);$(_AndroidResgenFlagFile)"
Outputs="$(_AndroidComponentResgenFlagFile)"
DependsOnTargets="$(_GenerateJavaDesignerForComponentDependsOnTargets)">
Outputs="$(_AndroidComponentResgenFlagFile)">
<!-- Run aapt to generate R.java for additional Android resources-->
<Aapt
@ -1642,30 +1518,24 @@ because xbuild doesn't support framework reference assemblies.
YieldDuringToolExecution="$(YieldDuringToolExecution)"
ExplicitCrunch="$(AndroidExplicitCrunch)"
/>
<Aapt2Link
Condition="'$(_AndroidUseAapt2)' == 'True'"
ContinueOnError="$(DesignTimeBuild)"
UseShortFileNames="$(UseShortFileNames)"
ImportsDirectory="$(_LibraryProjectImportsDirectoryName)"
OutputImportDirectory="$(_AndroidLibrayProjectIntermediatePath)"
AdditionalResourceArchives="@(_LibraryResourceHashDirectories->'$(_AndroidLibraryFlatArchivesDirectory)%(Hash).flata')"
AdditionalAndroidResourcePaths="@(_LibraryResourceHashDirectories)"
ApplicationName="$(_AndroidPackage)"
JavaPlatformJarPath="$(JavaPlatformJarPath)"
JavaDesignerOutputDirectory="$(IntermediateOutputPath)android\src"
CompiledResourceFlatArchive="$(_AndroidLibraryFlatArchivesDirectory)\compiled.flata"
ResourceNameCaseMap="$(_AndroidResourceNameCaseMap)"
ResourceDirectories="$(MonoAndroidResDirIntermediate)"
AssemblyIdentityMapFile="$(_AndroidLibrayProjectAssemblyMapFile)"
ManifestFiles="@(_AdditonalAndroidResourceCachePaths->'%(Identity)\AndroidManifest.xml');@(LibraryResourceDirectories->'%(Identity)\..\AndroidManifest.xml')"
YieldDuringToolExecution="$(YieldDuringToolExecution)"
ExtraArgs="$(AndroidAapt2LinkExtraArgs)"
ToolPath="$(Aapt2ToolPath)"
ToolExe="$(Aapt2ToolExe)"
/>
<Touch Files="$(_AndroidComponentResgenFlagFile)" AlwaysCreate="True" />
</Target>
<PropertyGroup>
<_GenerateJavaDesignerForComponentDependsOnTargets>
_GetAdditionalResourcesFromAssemblies
;_CreateAdditionalResourceCache
;_CollectAdditionalResourceFiles
;_CollectLibraryResourceDirectories
;_CompileAndroidLibraryResources
;_CompileResources
;_GenerateJavaDesignerForComponentAapt
;_GenerateJavaDesignerForComponentAapt2
</_GenerateJavaDesignerForComponentDependsOnTargets>
</PropertyGroup>
<Target Name="_GenerateJavaDesignerForComponent" DependsOnTargets="$(_GenerateJavaDesignerForComponentDependsOnTargets)" />
<Target Name="_FindLayoutsForBinding" Condition=" '$(Language)' == 'C#' ">
<FindLayoutsToBind
GenerateLayoutBindings="$(AndroidGenerateLayoutBindings)"

9
src/aapt2.tpnitems Normal file
Просмотреть файл

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition=" '$(TpnIncludeExternalDependencies)' == 'True' ">
<ThirdPartyNotice Include="google/aapt2">
<LicenseFile>$(MSBuildThisFileDirectory)..\build-tools\license-data\Apache-2.0.txt</LicenseFile>
<SourceUrl>https://mvnrepository.com/artifact/com.android.tools.build/aapt2</SourceUrl>
</ThirdPartyNotice>
</ItemGroup>
</Project>

22
src/aapt2/aapt2.csproj Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>0c31de30-f9df-4312-bffe-dcad558ccf08</ProjectGuid>
<OutputType>Exe</OutputType>
<OutputPath Condition="'$(OutputPath)'==''">bin\$(Configuration)</OutputPath>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" />
<PropertyGroup Condition="'$(Configuration)'=='Release'" />
<Import Project="..\..\Configuration.props" />
<Import Project="$(MSBuildBinPath)\Microsoft.Common.targets" />
<Import Project="aapt2.targets" />
<ItemGroup>
<ProjectReference Include="..\..\build-tools\android-toolchain\android-toolchain.csproj">
<Project>{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}</Project>
<Name>android-toolchain</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
</Project>

60
src/aapt2/aapt2.targets Normal file
Просмотреть файл

@ -0,0 +1,60 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.DownloadUri" />
<PropertyGroup>
<Aapt2Version>3.3.1-5013011</Aapt2Version>
<BuildDependsOn>
ResolveReferences;
_DownloadAapt2;
</BuildDependsOn>
<CleanDependsOn>
_CleanAapt2;
</CleanDependsOn>
<_Destination>$(XAInstallPrefix)xbuild\Xamarin\Android\</_Destination>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<_Aapt2Download Include="aapt2-$(Aapt2Version)-osx.zip">
<Platform>osx</Platform>
<HostOS>Darwin</HostOS>
</_Aapt2Download>
<_Aapt2Download Include="aapt2-$(Aapt2Version)-linux.zip">
<Platform>linux</Platform>
<HostOS>Linux</HostOS>
</_Aapt2Download>
<_Aapt2Download Include="aapt2-$(Aapt2Version)-windows.zip">
<Platform>windows</Platform>
<HostOS></HostOS>
</_Aapt2Download>
</ItemGroup>
<Target Name="Build" DependsOnTargets="$(BuildDependsOn)" />
<Target Name="Clean" DependsOnTargets="$(CleanDependsOn)" />
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.UnzipDirectoryChildren" />
<Target Name="_DownloadAapt2">
<ItemGroup>
<_DownloadUrl Include="%(_Aapt2Download.Identity)">
<Platform>%(_Aapt2Download.Platform)</Platform>
<HostOS>%(_Aapt2Download.HostOS)</HostOS>
<Url>https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/$(Aapt2Version)/aapt2-$(Aapt2Version)-%(_Aapt2Download.Platform).jar</Url>
</_DownloadUrl>
</ItemGroup>
<DownloadUri
SourceUris="%(_DownloadUrl.Url)"
DestinationFiles="@(_DownloadUrl->'$(AndroidToolchainCacheDirectory)\%(Filename)%(Extension)')"
/>
<UnzipDirectoryChildren
NoSubdirectory="True"
SourceFiles="$(AndroidToolchainCacheDirectory)\%(_DownloadUrl.Filename)%(_DownloadUrl.Extension)"
DestinationFolder="$(_Destination)%(_DownloadUrl.HostOS)"
/>
</Target>
<Target Name="_CleanAapt2">
<Delete Files="@(_Aapt2Download->'$(_Destination)\%(HostOS)')" />
</Target>
</Project>

9
src/bundletool.tpnitems Normal file
Просмотреть файл

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition=" '$(TpnIncludeExternalDependencies)' == 'True' ">
<ThirdPartyNotice Include="google/bundletool">
<LicenseFile>$(MSBuildThisFileDirectory)..\build-tools\license-data\Apache-2.0.txt</LicenseFile>
<SourceUrl>https://github.com/google/bundletool</SourceUrl>
</ThirdPartyNotice>
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,22 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>a0aef446-3368-4591-9de6-bc3b2b33337d</ProjectGuid>
<OutputType>Exe</OutputType>
<OutputPath Condition="'$(OutputPath)'==''">bin\$(Configuration)</OutputPath>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" />
<PropertyGroup Condition="'$(Configuration)'=='Release'" />
<Import Project="..\..\Configuration.props" />
<Import Project="$(MSBuildBinPath)\Microsoft.Common.targets" />
<Import Project="bundletool.targets" />
<ItemGroup>
<ProjectReference Include="..\..\build-tools\android-toolchain\android-toolchain.csproj">
<Project>{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}</Project>
<Name>android-toolchain</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,34 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\Configuration.props" />
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.DownloadUri" />
<PropertyGroup>
<BuildDependsOn>
ResolveReferences;
_DownloadBundleTool;
</BuildDependsOn>
<CleanDependsOn>
_CleanBundleTool;
</CleanDependsOn>
<_Destination>$(XAInstallPrefix)xbuild\Xamarin\Android\</_Destination>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<Target Name="Build" DependsOnTargets="$(BuildDependsOn)" />
<Target Name="Clean" DependsOnTargets="$(CleanDependsOn)" />
<Target Name="_DownloadBundleTool">
<DownloadUri
SourceUris="https://github.com/google/bundletool/releases/download/$(XABundleToolVersion)/bundletool-all-$(XABundleToolVersion).jar"
DestinationFiles="$(AndroidToolchainCacheDirectory)\bundletool-all-$(XABundleToolVersion).jar"
/>
<Copy
SourceFiles="$(AndroidToolchainCacheDirectory)\bundletool-all-$(XABundleToolVersion).jar"
DestinationFolder="$(_Destination)"
/>
</Target>
<Target Name="_CleanBundleTool">
<Delete Files="$(_Destination)bundletool.jar" />
</Target>
</Project>