Skip to content

Commit

Permalink
Merge branch 'main' into dev/grendel/cpp-tweaks
Browse files Browse the repository at this point in the history
* main:
  Bump to dotnet/installer@fb7b9a4b9e 9.0.100-preview.2.24106.6 (#8700)
  [Mono.Android] Cache `Profiles/api-34.xml` contents (#8679)
  [monodroid] typemaps may need to load assemblies (#8625)
  Bump $(AndroidNetPreviousVersion) to 34.0.79 (#8693)
  Bump to xamarin/java.interop/main@07c73009 (#8681)
  Bump to dotnet/installer@1c496970b7 9.0.100-preview.2.24078.1 (#8685)
  [GetAndroidDependencies] Add Jdk dependency info (#8651)
  [xaprepare] Add support for newer SparkyLinux (#8684)
  • Loading branch information
grendello committed Feb 7, 2024
2 parents 3ea6c6a + dbefbad commit 66f3db0
Show file tree
Hide file tree
Showing 38 changed files with 199,351 additions and 87 deletions.
4 changes: 2 additions & 2 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<_StandardLibraryPath Condition=" '$(TargetFrameworkVersion)' == '' ">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPathToStandardLibraries('.NETFramework', 'v4.7.2', ''))</_StandardLibraryPath>
<TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' And '$(UsingMicrosoftNETSdk)' != 'true' And '$(_StandardLibraryPath)' != '' ">v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' And '$(UsingMicrosoftNETSdk)' != 'true' ">v4.7.1</TargetFrameworkVersion>
<AndroidJavaRuntimeApiLevel Condition="'$(AndroidJavaRuntimeApiLevel)' == ''">26</AndroidJavaRuntimeApiLevel>
<!-- The min API level supported by Microsoft.Android.Sdk -->
<AndroidMinimumDotNetApiLevel Condition="'$(AndroidMinimumDotNetApiLevel)' == ''">21</AndroidMinimumDotNetApiLevel>
<!-- *Latest* *stable* API level binding that we support; used when building src/Xamarin.Android.Build.Tasks -->
Expand All @@ -40,10 +39,11 @@
<AndroidPlatformId Condition=" '$(AndroidPlatformId)' == '' ">$(AndroidLatestStablePlatformId)</AndroidPlatformId>
<AndroidFrameworkVersion Condition=" '$(AndroidFrameworkVersion)' == '' ">$(AndroidLatestStableFrameworkVersion)</AndroidFrameworkVersion>
<AndroidUseLatestPlatformSdk Condition=" '$(AndroidFrameworkVersion)' == '' ">True</AndroidUseLatestPlatformSdk>
<AndroidJavaRuntimeApiLevel Condition="'$(AndroidJavaRuntimeApiLevel)' == ''">$(AndroidLatestStableApiLevel)</AndroidJavaRuntimeApiLevel>
<DebugType Condition=" '$(DebugType)' == '' ">portable</DebugType>
<Deterministic Condition=" '$(Deterministic)' == '' ">True</Deterministic>
<LangVersion Condition=" '$(LangVersion)' == '' ">latest</LangVersion>
<AndroidNetPreviousVersion Condition=" '$(AndroidNetPreviousVersion)' == '' ">34.0.56</AndroidNetPreviousVersion>
<AndroidNetPreviousVersion Condition=" '$(AndroidNetPreviousVersion)' == '' ">34.0.79</AndroidNetPreviousVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(HostOS)' == '' ">
<HostOS Condition="$([MSBuild]::IsOSPlatform('windows'))">Windows</HostOS>
Expand Down
7 changes: 7 additions & 0 deletions Documentation/guides/building-apps/build-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,13 @@ APK root directory. The format of the path is `lib\ARCH\wrap.sh` where
+ `x86_64`
+ `x86`

## AndroidInstallJavaDependencies

The default value is `true` for command line builds. When set to `true`, enables
installation of the Java SDK when running the `<InstallAndroidDependencies/>` target.

Support for this property was added in .NET 9.

## AndroidJavadocVerbosity

Specifies how "verbose"
Expand Down
9 changes: 8 additions & 1 deletion Documentation/workflow/HowToAddNewApiLevel.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@ the new platform will be downloaded to your local Android SDK.
- *or* run manually: `param-name-importer.exe -source-stub-zip C:/Users/USERNAME/android-toolchain/sdk/platforms/android-S/android-stubs-src.jar -output-text api-S.params.txt -output-xml api-S.params.xml -verbose -framework-only`
- Copy the produced `api-X.params.txt` file to `/src/Mono.Android/Profiles/`

### Other Infrastructure Changes
### Generate `api.xml` File

- Run `xaprepare android-sdk-platforms=all` to download all Android SDK platforms
- Add level to `/build-tools/api-merge/merge-configuration.xml` to create `api-S.xml.class-parse`
- Run the following command to create a merged `api.xml`:
- `dotnet-local.cmd build build-tools\create-android-api -t:GenerateApiDescription`
- Copy the `bin\BuildDebug\api\api-xx.xml` file to `src\Mono.Android\Profiles`

### Other Infrastructure Changes

- Add level to `/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs`
to enable running ApiCompat against the new level. (ex: `{ "v11.0.99", "v11.0" }`)
- Add level to `/build-tools/api-xml-adjuster/Makefile`
Expand Down
2 changes: 1 addition & 1 deletion build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ stages:
installLegacyDotNet: false
restoreNUnitConsole: false
updateMono: false
androidSdkPlatforms: 23,24,25,26,27,28,29,30,31,32,33,$(DefaultTestSdkPlatforms)
androidSdkPlatforms: $(DefaultTestSdkPlatforms)

- task: NuGetAuthenticate@1
displayName: authenticate with azure artifacts
Expand Down
3 changes: 1 addition & 2 deletions build-tools/create-android-api/create-android-api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@
</Target>

<!-- Merges various 'api-X.xml.in' files into single 'api.xml' file -->
<Target Name="_GenerateApiDescription"
BeforeTargets="Build"
<Target Name="GenerateApiDescription"
DependsOnTargets="_AdjustApiXml"
Inputs="@(ApiFileDefinition->'%(ApiAdjustedXml)')"
Outputs="@(_MergedXmlFiles->'%(MergedXml)')">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ public void AddToInventory ()
class AndroidPlatformComponent : AndroidToolchainComponent
{
public string ApiLevel { get; }
public bool IsLatestStable { get; }
public bool IsPreview { get; }

public AndroidPlatformComponent (string name, string apiLevel, string pkgRevision)
: base (name, Path.Combine ("platforms", $"android-{apiLevel}"), pkgRevision: pkgRevision, buildToolName: $"android-sdk-{name}", buildToolVersion:$"{apiLevel}.{pkgRevision}")
public AndroidPlatformComponent (string name, string apiLevel, string pkgRevision, bool isLatestStable = false, bool isPreview = false)
: base (name, Path.Combine ("platforms", $"android-{apiLevel}"), pkgRevision: pkgRevision, buildToolName: $"android-sdk-{name}", buildToolVersion: $"{apiLevel}.{pkgRevision}")
{
ApiLevel = apiLevel;
IsLatestStable = isLatestStable;
IsPreview = isPreview;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public AndroidToolchain ()
new AndroidPlatformComponent ("platform-31_r01", apiLevel: "31", pkgRevision: "1"),
new AndroidPlatformComponent ("platform-32_r01", apiLevel: "32", pkgRevision: "1"),
new AndroidPlatformComponent ("platform-33-ext3_r03", apiLevel: "33", pkgRevision: "3"),
new AndroidPlatformComponent ("platform-34-ext7_r02", apiLevel: "34", pkgRevision: "2"),
new AndroidPlatformComponent ("platform-34-ext7_r02", apiLevel: "34", pkgRevision: "2", isLatestStable: true),

new AndroidToolchainComponent ("sources-34_r01",
destDir: Path.Combine ("sources", "android-34"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected override void InitializeDependencies ()
if (DebianRelease.Major >= 10 || (IsTesting && String.Compare ("buster", CodeName, StringComparison.OrdinalIgnoreCase) == 0)) {
if (Context.IsRunningOnHostedAzureAgent)
Dependencies.AddRange (packages10AndNewerBuildBots);
if (DebianRelease.Major >= 13) {
if (DebianRelease.Major >= 13 || (String.Compare ("SparkyLinux", Name, StringComparison.OrdinalIgnoreCase) == 0 && DebianRelease.Major >= 7)) {
Dependencies.AddRange (packagesTrixieAndLater);
} else {
Dependencies.AddRange (packagesPreTrixie);
Expand Down
13 changes: 11 additions & 2 deletions build-tools/xaprepare/xaprepare/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sealed class ParsedOptions
public bool IgnoreMaxMonoVersion { get; set; }
public bool IgnoreMinMonoVersion { get; set; }
public RefreshableComponent RefreshList { get; set; }
public IEnumerable<string> AndroidSdkPlatforms { get; set; } = Enumerable.Empty<string> ();
public IEnumerable<string> AndroidSdkPlatforms { get; set; } = new [] { "latest" };
}

public static int Main (string[] args)
Expand Down Expand Up @@ -105,7 +105,7 @@ static async Task<int> Run (string[] args)
{"auto-provision-uses-sudo=", $"Allow use of sudo(1) when provisioning", v => parsedOptions.AutoProvisionUsesSudo = ParseBoolean (v)},
{"ignore-max-mono-version=", $"Ignore the maximum supported Mono version restriction", v => parsedOptions.IgnoreMaxMonoVersion = ParseBoolean (v)},
{"ignore-min-mono-version=", $"Ignore the minimum supported Mono version restriction", v => parsedOptions.IgnoreMinMonoVersion = ParseBoolean (v)},
{"android-sdk-platforms=", "Comma separated list of Android SDK platform levels to be installed. Defaults to all if no value is provided.", v => parsedOptions.AndroidSdkPlatforms = ParseAndroidSdkPlatformLevels (v?.Trim () ?? String.Empty) },
{"android-sdk-platforms=", "Comma separated list of Android SDK platform levels to be installed or 'latest' or 'all'. Defaults to 'latest' if no value is provided.", v => parsedOptions.AndroidSdkPlatforms = ParseAndroidSdkPlatformLevels (v?.Trim () ?? String.Empty) },
"",
{"h|help", "Show this help message", v => parsedOptions.ShowHelp = true },
};
Expand Down Expand Up @@ -333,6 +333,15 @@ RefreshableComponent ParseSingleComponent (string component) {

static IEnumerable<string> ParseAndroidSdkPlatformLevels (string list)
{
// If the user specified "all" we return 'all' to indicate that all platforms should be installed.
if (string.Compare ("all", list, StringComparison.OrdinalIgnoreCase) == 0)
return new string [] { "all" };

// If the user did not specify anything, we return "latest" to indicate that only the latest platform should be installed.
if (string.IsNullOrEmpty (list) || string.Compare ("latest", list, StringComparison.OrdinalIgnoreCase) == 0)
return new string [] { "latest" };

// The user specified a list of platform levels to install, so we should respect that.
return list.Split (',').Select (item => item.Trim ());
}
}
Expand Down
24 changes: 19 additions & 5 deletions build-tools/xaprepare/xaprepare/Steps/Step_Android_SDK_NDK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,9 @@ void Check (Context context, string packageCacheDir, string sdkRoot, AndroidTool
}

// If only specific Android SDK platforms were requested, ignore ones that were not requested
if (component is AndroidPlatformComponent apc && context.AndroidSdkPlatforms.Any ()) {
if (!context.AndroidSdkPlatforms.Contains (apc.ApiLevel)) {
LogStatus ($"skipping, not requested", padLeft, Log.InfoColor);
return;
}
if (component is AndroidPlatformComponent apc && !ShouldInstall (apc, context)) {
LogStatus ($"skipping, not requested", padLeft, Log.InfoColor);
return;
}

if (missing)
Expand All @@ -278,6 +276,22 @@ void Check (Context context, string packageCacheDir, string sdkRoot, AndroidTool
toInstall.Add (pkg);
}

bool ShouldInstall (AndroidPlatformComponent component, Context context)
{
var platforms = context.AndroidSdkPlatforms;

// If no specific platforms were requested, install everything
if (!platforms.Any () || platforms.Contains ("all"))
return true;

// If "latest" was requested, install the highest available stable version and any preview versions
if (platforms.Contains ("latest") && (component.IsLatestStable || component.IsPreview))
return true;

// Check if this is a user-requested platform
return context.AndroidSdkPlatforms.Contains (component.ApiLevel);
}

bool IsInstalled (AndroidToolchainComponent component, string path, out bool missing)
{
missing = true;
Expand Down
16 changes: 8 additions & 8 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="9.0.100-preview.2.24073.12">
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="9.0.100-preview.2.24106.6">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>5680e93cb251d7741e19f2d759f04141e9d95a93</Sha>
<Sha>fb7b9a4b9e578fa8c9f5fb67e22daf4b0d22668e</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="9.0.0-preview.2.24072.10" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="9.0.0-preview.2.24080.1" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>e3547f1d3ac768a14a0598abf7868641ecf0c9d7</Sha>
<Sha>d40c654c274fe4f4afe66328f0599130f3eb2ea6</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="9.0.0-preview.2.24072.10" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="9.0.0-preview.2.24080.1" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>e3547f1d3ac768a14a0598abf7868641ecf0c9d7</Sha>
<Sha>d40c654c274fe4f4afe66328f0599130f3eb2ea6</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport" Version="9.0.0-alpha.1.24068.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport" Version="9.0.0-preview.2.24076.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>fd99e59a43cfd6fe323c98ff267b620a67e71e67</Sha>
<Sha>687be2a32a302aaade82380c0eaafa5af85fb4da</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.4-alpha.24065.1" CoherentParentDependency="Microsoft.NET.ILLink.Tasks">
<Uri>https://github.com/dotnet/cecil</Uri>
Expand Down
8 changes: 4 additions & 4 deletions eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project>
<!--Package versions-->
<PropertyGroup>
<MicrosoftDotnetSdkInternalPackageVersion>9.0.100-preview.2.24073.12</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>9.0.0-preview.2.24072.10</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.2.24072.10</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftDotnetSdkInternalPackageVersion>9.0.100-preview.2.24106.6</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>9.0.0-preview.2.24080.1</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.2.24080.1</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftDotNetApiCompatPackageVersion>7.0.0-beta.22103.1</MicrosoftDotNetApiCompatPackageVersion>
<MicrosoftDotNetBuildTasksFeedPackageVersion>7.0.0-beta.22103.1</MicrosoftDotNetBuildTasksFeedPackageVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>9.0.0-alpha.1.24068.1</MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>9.0.0-preview.2.24076.1</MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>
<MicrosoftNETWorkloadEmscriptenPackageVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion)</MicrosoftNETWorkloadEmscriptenPackageVersion>
<MicrosoftTemplateEngineTasksPackageVersion>7.0.100-rc.1.22410.7</MicrosoftTemplateEngineTasksPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.24065.1</MicrosoftDotNetCecilPackageVersion>
Expand Down
2 changes: 1 addition & 1 deletion external/Java.Interop
24 changes: 17 additions & 7 deletions src/Mono.Android/Java.Interop/TypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ internal static IJavaPeerable CreateInstance (IntPtr handle, JniHandleOwnership
{
Type? type = null;
IntPtr class_ptr = JNIEnv.GetObjectClass (handle);
string class_name = GetClassName (class_ptr);
string? class_name = GetClassName (class_ptr);
lock (TypeManagerMapDictionaries.AccessLock) {
while (class_ptr != IntPtr.Zero && !TypeManagerMapDictionaries.JniToManaged.TryGetValue (class_name, out type)) {

Expand All @@ -279,23 +279,33 @@ internal static IJavaPeerable CreateInstance (IntPtr handle, JniHandleOwnership

IntPtr super_class_ptr = JNIEnv.GetSuperclass (class_ptr);
JNIEnv.DeleteLocalRef (class_ptr);
class_name = null;
class_ptr = super_class_ptr;
class_name = GetClassName (class_ptr);
if (class_ptr != IntPtr.Zero) {
class_name = GetClassName (class_ptr);
}
}
}

JNIEnv.DeleteLocalRef (class_ptr);
if (class_ptr != IntPtr.Zero) {
JNIEnv.DeleteLocalRef (class_ptr);
class_ptr = IntPtr.Zero;
}

if (targetType != null &&
(type == null ||
!targetType.IsAssignableFrom (type))) {
type = targetType;
}

if (type == null) {
class_name = JNIEnv.GetClassNameFromInstance (handle);
JNIEnv.DeleteRef (handle, transfer);
throw new NotSupportedException (
FormattableString.Invariant ($"Internal error finding wrapper class for '{JNIEnv.GetClassNameFromInstance (handle)}'. (Where is the Java.Lang.Object wrapper?!)"),
FormattableString.Invariant ($"Internal error finding wrapper class for '{class_name}'. (Where is the Java.Lang.Object wrapper?!)"),
CreateJavaLocationException ());
}

if (targetType != null && !targetType.IsAssignableFrom (type))
type = targetType;

if (type.IsInterface || type.IsAbstract) {
var invokerType = JavaObjectExtensions.GetInvokerType (type);
if (invokerType == null)
Expand Down
2 changes: 1 addition & 1 deletion src/Mono.Android/Mono.Android.targets
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ItemGroup>

<PropertyGroup>
<_ApiXmlLocation>..\..\bin\Build$(Configuration)\api\</_ApiXmlLocation>
<_ApiXmlLocation>Profiles\</_ApiXmlLocation>
</PropertyGroup>

<!-- Creates 'AssemblyInfo.cs' with appropriate version information -->
Expand Down
Loading

0 comments on commit 66f3db0

Please sign in to comment.