Skip to content

[Xamarin.Android.Build.Tasks] Rethink default property values #9155

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 7 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions build-tools/scripts/XABuildConfig.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Xamarin.Android.Tools
public const string XamarinAndroidVersion = "@XAMARIN_ANDROID_VERSION@";
public const string XamarinAndroidCommitHash = "@XAMARIN_ANDROID_COMMIT_HASH@";
public const string XamarinAndroidBranch = "@XAMARIN_ANDROID_BRANCH@";
public const string AndroidSdkBuildToolsVersion = "@SDK_BUILD_TOOLS_VERSION@";
public const int AndroidMinimumDotNetApiLevel = @ANDROID_DEFAULT_MINIMUM_DOTNET_API_LEVEL@;
public const int AndroidLatestStableApiLevel = @ANDROID_LATEST_STABLE_API_LEVEL@;
public const int AndroidLatestUnstableApiLevel = @ANDROID_LATEST_UNSTABLE_API_LEVEL@;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ GeneratedFile Get_XABuildConfig_cs (Context context)
{ "@NDK_X86_API@", BuildAndroidPlatforms.NdkMinimumAPILegacy32.ToString ().ToString () },
{ "@NDK_X86_64_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString ().ToString () },
{ "@XA_SUPPORTED_ABIS@", context.Properties.GetRequiredValue (KnownProperties.AndroidSupportedTargetJitAbis).Replace (':', ';') },
{ "@SDK_BUILD_TOOLS_VERSION@", context.Properties.GetRequiredValue (KnownProperties.XABuildToolsFolder) },
{ "@ANDROID_DEFAULT_MINIMUM_DOTNET_API_LEVEL@", context.Properties.GetRequiredValue (KnownProperties.AndroidMinimumDotNetApiLevel) },
{ "@ANDROID_DEFAULT_TARGET_DOTNET_API_LEVEL@", context.Properties.GetRequiredValue (KnownProperties.AndroidDefaultTargetDotnetApiLevel) },
{ "@ANDROID_LATEST_STABLE_API_LEVEL@", context.Properties.GetRequiredValue (KnownProperties.AndroidLatestStableApiLevel) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,7 @@ public void GetDependencyWhenSDKIsMissingTest ([Values (true, false)] bool creat

static string GetExpectedBuildToolsVersion ()
{
var propsPath = Path.Combine (XABuildPaths.TopDirectory, "src", "Xamarin.Android.Build.Tasks", "Xamarin.Android.Common.props.in");
var props = XElement.Load (propsPath);
var AndroidSdkBuildToolsVersion = props.Elements (MSBuildXmlns + "PropertyGroup")
.Elements (MSBuildXmlns + "AndroidSdkBuildToolsVersion")
.FirstOrDefault ();
return AndroidSdkBuildToolsVersion?.Value?.Trim ();
return XABuildConfig.AndroidSdkBuildToolsVersion;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,22 @@
DestinationFile="Xamarin.Android.BuildInfo.txt"
Replacements="@JAVA_INTEROP_COMMIT@=$(_BuildInfo_JavaInteropCommit);@SQLITE_COMMIT@=$(_BuildInfo_SqliteCommit);@XAMARIN_ANDROID_TOOLS_COMMIT@=$(_BuildInfo_XamarinAndroidToolsCommit);">
</ReplaceFileContents>
<ItemGroup>
<_XACommonPropsReplacement Include="@BUNDLETOOL_VERSION@=$(XABundleToolVersion)" />
<_XACommonPropsReplacement Include="@NDK_ARM64_V8A_API@=$(AndroidNdkApiLevel_ArmV8a)" />
<_XACommonPropsReplacement Include="@NDK_ARMEABI_V7_API@=$(AndroidNdkApiLevel_ArmV7a)" />
<_XACommonPropsReplacement Include="@NDK_X86_64_API@=$(AndroidNdkApiLevel_X86_64)" />
<_XACommonPropsReplacement Include="@NDK_X86_API@=$(AndroidNdkApiLevel_X86)" />
<_XACommonPropsReplacement Include="@PACKAGE_VERSION_BUILD@=$(XAVersionCommitCount)" />
<_XACommonPropsReplacement Include="@PACKAGE_VERSION@=$(ProductVersion)" />
<_XACommonPropsReplacement Include="@SDK_BUILD_TOOLS_VERSION@=$(XABuildToolsFolder)" />
<_XACommonPropsReplacement Include="@SDK_PLATFORM_TOOLS_VERSION@=$(XAPlatformToolsVersion)" />
<_XACommonPropsReplacement Include="@SDK_PLATFORM_VERSION@=android-$(AndroidLatestStableApiLevel)" />
</ItemGroup>
<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);@BUNDLETOOL_VERSION@=$(XABundleToolVersion)">
Replacements="@(_XACommonPropsReplacement)">
</ReplaceFileContents>
</Target>
<Target Name="_GenerateSupportedPlatforms"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Android Sdk Tool versions are sourced from this file. This is maintained in the android-tools repo. -->
<PropertyGroup>
<AndroidSdkBuildToolsVersion Condition=" '$(AndroidSdkBuildToolsVersion)' == '' ">@SDK_BUILD_TOOLS_VERSION@</AndroidSdkBuildToolsVersion>
<AndroidSdkPlatformVersion Condition=" '$(AndroidSdkPlatformVersion)' == '' ">@SDK_PLATFORM_VERSION@</AndroidSdkPlatformVersion>
<AndroidSdkPlatformToolsVersion Condition="'$(AndroidSdkPlatformToolsVersion)' == ''">@SDK_PLATFORM_TOOLS_VERSION@</AndroidSdkPlatformToolsVersion>
</PropertyGroup>
<!-- Android Sdk Tool versions are sourced from this file. This is maintained in the dotnet/android-tools repo. -->
<Import Project="$(MSBuildThisFileDirectory)\Xamarin.Android.Tools.Versions.props" />
Copy link
Member

Choose a reason for hiding this comment

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

I think part of this goal would be to eventually remove Xamarin.Android.Tools.Versions.props from dotnet/android-tools? I think it would make sense to remove this import now, and update the properties above to also include the other properties in that file:

    <AndroidCommandLineToolsVersion>
    <AndroidSdkEmulatorVersion>
    <AndroidNdkVersion>
    <JavaSdkVersion>

We could base these off other values already defined in Configuration.props as well, to continue to improve our own build and test coverage against the versions of these tools that we're recommending:

<CommandLineToolsFolder Condition=" '$(CommandLineToolsFolder)' == '' ">11.0</CommandLineToolsFolder>

<EmulatorVersion Condition=" '$(EmulatorVersion)' == '' ">9364964</EmulatorVersion>

NDK and JDK versions may be a bit more tricky as we'd potentially need to introduce new props for these and also pass them to xaprepare:

public const string AndroidNdkPkgRevision = "27.0.12077973";

const string MicrosoftOpenJDK17Release = "17.0.11.9";

<PropertyGroup>
<_JavaInteropReferences>Java.Interop;System.Runtime</_JavaInteropReferences>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
*******************************************
-->

<Import Project="$(MSBuildThisFileDirectory)Xamarin.Installer.Common.props"
Condition="Exists('$(MSBuildThisFileDirectory)Xamarin.Installer.Common.props')"/>

<Import Project="$(MSBuildThisFileDirectory)Xamarin.Android.Common.props"
Condition="Exists('$(MSBuildThisFileDirectory)Xamarin.Android.Common.props')" />

Expand Down