From 858cdc0e82e9c20bb6227fd7a51038bc225dbd43 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Fri, 17 Feb 2023 21:33:56 +0100 Subject: [PATCH 01/10] Remove support for classic XA from the native code - Remove Designer support - Remove Designer test CI jobs - Remove support for classic XA from the native runtime - Remove support for Designer from the native runtime - Stop building classic versions of libmonodroid - Stop building host versions of libmonodroid --- build-tools/automation/azure-pipelines.yaml | 167 ---- .../yaml-templates/run-designer-tests.yml | 79 -- build-tools/scripts/Ndk.projitems.in | 8 - .../GeneratedMonodroidCmakeFiles.cs | 131 +-- .../ConfigAndData/BuildAndroidPlatforms.cs | 9 - .../xaprepare/ConfigAndData/CmakeBuilds.cs | 94 +- .../Steps/Step_BuildMonoRuntimes.Unix.cs | 4 +- .../xaprepare/Steps/Step_GenerateFiles.cs | 8 +- .../Xamarin.Android.Build.Tasks.csproj | 4 - .../Xamarin.Android.Build.Tasks.targets | 24 +- src/monodroid/CMakeLists.txt | 22 +- src/monodroid/jni/android-system.cc | 173 +--- src/monodroid/jni/android-system.hh | 68 +- src/monodroid/jni/basic-android-system.hh | 8 - src/monodroid/jni/basic-utilities.cc | 75 +- src/monodroid/jni/basic-utilities.hh | 17 - src/monodroid/jni/build-info.hh | 2 - src/monodroid/jni/cpp-util.hh | 27 - src/monodroid/jni/cppcompat.hh | 18 - src/monodroid/jni/cpu-arch-detect.cc | 118 --- src/monodroid/jni/cpu-arch.hh | 3 - src/monodroid/jni/debug-app-helper.cc | 38 - src/monodroid/jni/debug.cc | 28 +- src/monodroid/jni/debug.hh | 2 +- src/monodroid/jni/embedded-assemblies-zip.cc | 25 +- src/monodroid/jni/embedded-assemblies.cc | 77 +- src/monodroid/jni/embedded-assemblies.hh | 46 +- src/monodroid/jni/globals.cc | 4 +- src/monodroid/jni/globals.hh | 4 - src/monodroid/jni/logger.cc | 25 +- src/monodroid/jni/logger.hh | 14 - src/monodroid/jni/mkbundle-api.h | 35 - src/monodroid/jni/mono-image-loader.hh | 8 +- src/monodroid/jni/monodroid-glue-designer.cc | 147 --- src/monodroid/jni/monodroid-glue-internal.hh | 125 +-- src/monodroid/jni/monodroid-glue.cc | 924 +----------------- src/monodroid/jni/xa-internal-api-impl.hh | 54 - src/monodroid/jni/xa-internal-api.cc | 347 ------- src/monodroid/jni/xa-internal-api.hh | 72 -- src/monodroid/monodroid.targets | 115 +-- src/sqlite-xamarin/sqlite-xamarin.targets | 2 +- tools/xabuild/xabuild.csproj | 3 +- 42 files changed, 156 insertions(+), 2998 deletions(-) delete mode 100644 build-tools/automation/yaml-templates/run-designer-tests.yml delete mode 100644 src/monodroid/jni/mkbundle-api.h delete mode 100644 src/monodroid/jni/monodroid-glue-designer.cc delete mode 100644 src/monodroid/jni/xa-internal-api-impl.hh delete mode 100644 src/monodroid/jni/xa-internal-api.cc delete mode 100644 src/monodroid/jni/xa-internal-api.hh diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index acbac80bda7..6b76827abd1 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -770,173 +770,6 @@ stages: - template: yaml-templates/fail-on-issue.yaml - - -- stage: designer_tests - displayName: Designer Tests - dependsOn: mac_build - condition: and(succeeded(), or(eq(variables['RunAllTests'], true), contains(dependencies.mac_build.outputs['mac_build_create_installers.TestConditions.TestAreas'], 'Designer'))) - jobs: - # Check - "Xamarin.Android (macOS > Tests > Designer Integration)" - - job: designer_integration_mac - condition: false #TODO: Enable once test issues are fixed. - displayName: macOS > Tests > Designer Integration - pool: - vmImage: $(HostedMacImage) - timeoutInMinutes: 120 - cancelTimeoutInMinutes: 5 - workspace: - clean: all - variables: - EnableRegressionTest: true - steps: - - checkout: uitools - clean: true - submodules: recursive - path: s/UITools - persistCredentials: true - - - powershell: | - # Use the branch name of the source being built or the PR target branch name. Fall back to 'main' if the branch is unknown. - $branchPrefix = "/refs/heads/" - $branchName = "$(Build.SourceBranch)" -replace $branchPrefix, "" - if ("$(Build.Reason)" -eq "PullRequest") { - $branchName = "$(System.PullRequest.TargetBranch)" -replace $branchPrefix, "" - } - if (("$branchName" -ne "main") -and ("$branchName" -notlike "d1*")) { - $branchName = "main" - } - Set-Location -Path $(System.DefaultWorkingDirectory)/UITools - git checkout $branchName - git submodule update -q --init --recursive - displayName: Clone and update UITools - - - task: NuGetAuthenticate@0 - displayName: authenticate with azure artifacts - inputs: - forceReinstallCredentialProvider: true - - - task: provisionator@2 - displayName: provision designer dependencies - inputs: - github_token: $(GitHub.Token) - provisioning_script: $(System.DefaultWorkingDirectory)/UITools/src/bot-provisioning/dependencies.csx - provisioning_extra_args: -remove Xamarin.Android -vv DEVDIV_PKGS_NUGET_TOKEN=$(DevDiv.NuGet.Token) SECTOOLS_PKGS_NUGET_TOKEN=$(SecTools.NuGet.Token) - env: - PROVISIONATOR_CHANNEL: ${{ parameters.provisionatorChannel }} - - - template: yaml-templates/setup-test-environment.yaml - parameters: - xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android - jdkTestFolder: $(JAVA_HOME_8_X64) - provisionatorChannel: ${{ parameters.provisionatorChannel }} - - - template: designer/android-designer-build-mac.yaml@yaml-templates - parameters: - designerSourcePath: $(System.DefaultWorkingDirectory)/UITools/src - - - template: designer/android-designer-tests.yaml@yaml-templates - parameters: - designerSourcePath: $(System.DefaultWorkingDirectory)/UITools/src - runAddinTests: false - - - task: CopyFiles@2 - displayName: 'Copy binlogs' - inputs: - sourceFolder: $(System.DefaultWorkingDirectory)/UITools/src/Xamarin.Designer.Android - contents: '**/*.binlog' - targetFolder: $(Build.ArtifactStagingDirectory)/designer-binlogs - overWrite: true - flattenFolders: true - condition: ne(variables['Agent.JobStatus'], 'Succeeded') - - - template: yaml-templates/publish-artifact.yaml - parameters: - displayName: upload designer binlogs - artifactName: Test Results - Designer - macOS - targetPath: $(Build.ArtifactStagingDirectory)/designer-binlogs - condition: ne(variables['Agent.JobStatus'], 'Succeeded') - - # Check - "Xamarin.Android (Windows > Tests > Designer Integration)" - - job: designer_integration_win - displayName: Windows > Tests > Designer Integration - pool: - vmImage: $(HostedWinImage) - timeoutInMinutes: 120 - cancelTimeoutInMinutes: 5 - workspace: - clean: all - variables: - EnableRegressionTest: true - RegressionTestSuiteOutputDir: C:\Git\ADesRegTestSuite - VisualStudioInstallationPath: C:\Program Files\Microsoft Visual Studio\2022\Enterprise - steps: - - checkout: uitools - clean: true - submodules: recursive - path: s\UITools - persistCredentials: true - - - powershell: | - # Use the branch name of the source being built or the PR target branch name. Fall back to 'main' if the branch is unknown. - $branchPrefix = "/refs/heads/" - $branchName = "$(Build.SourceBranch)" -replace $branchPrefix, "" - if ("$(Build.Reason)" -eq "PullRequest") { - $branchName = "$(System.PullRequest.TargetBranch)" -replace $branchPrefix, "" - } - if (("$branchName" -ne "main") -and ("$branchName" -notlike "d1*")) { - $branchName = "main" - } - Set-Location -Path $(System.DefaultWorkingDirectory)\UITools - git checkout $branchName - git submodule update -q --init --recursive - displayName: Clone and update UITools - - - task: NuGetAuthenticate@0 - displayName: authenticate with azure artifacts - inputs: - forceReinstallCredentialProvider: true - - - task: provisionator@2 - displayName: provision designer dependencies - inputs: - github_token: $(GitHub.Token) - provisioning_script: $(System.DefaultWorkingDirectory)\UITools\src\bot-provisioning\dependencies.csx - provisioning_extra_args: -vv DEVDIV_PKGS_NUGET_TOKEN=$(DevDiv.NuGet.Token) SECTOOLS_PKGS_NUGET_TOKEN=$(SecTools.NuGet.Token) - env: - PROVISIONATOR_CHANNEL: ${{ parameters.provisionatorChannel }} - - - template: yaml-templates\setup-test-environment.yaml - parameters: - xaSourcePath: $(System.DefaultWorkingDirectory)\xamarin-android - jdkTestFolder: $(JAVA_HOME_8_X64) - provisionatorChannel: ${{ parameters.provisionatorChannel }} - - - task: VSBuild@1 - displayName: Restore Xamarin.AndroidDesigner - inputs: - solution: $(System.DefaultWorkingDirectory)\UITools\src\Xamarin.Designer.Android\Xamarin.AndroidDesigner.sln - vsVersion: 17.0 - msbuildArgs: >- - /t:Restore /p:RestoreDisableParallel=true - /p:RestoreConfigFile="$(System.DefaultWorkingDirectory)\UITools\NuGet.Config" - /p:JavaSdkDirectory="$(JAVA_HOME_8_X64)" - platform: Any CPU - configuration: DebugWin32 - - - task: VSBuild@1 - displayName: Build Xamarin.AndroidDesigner - inputs: - solution: $(System.DefaultWorkingDirectory)\UITools\src\Xamarin.Designer.Android\Xamarin.AndroidDesigner.sln - vsVersion: 17.0 - msbuildArgs: /t:Build /p:GitHubToken=$(GitHub.Token) - platform: Any CPU - configuration: DebugWin32 - - - template: yaml-templates/run-designer-tests.yml - parameters: - designerSourcePath: $(System.DefaultWorkingDirectory)\UITools\src - - stage: bcl_tests displayName: BCL Emulator Tests dependsOn: mac_build diff --git a/build-tools/automation/yaml-templates/run-designer-tests.yml b/build-tools/automation/yaml-templates/run-designer-tests.yml deleted file mode 100644 index f6a63f5adc6..00000000000 --- a/build-tools/automation/yaml-templates/run-designer-tests.yml +++ /dev/null @@ -1,79 +0,0 @@ -parameters: - designerSourcePath: $(System.DefaultWorkingDirectory) - nunitConsoleVersion: '3.9.0' - runAddinTests: true - testResultArtifactName: Test Results - Designer - Windows - -steps: -- task: DeleteFiles@1 - displayName: Delete Test Outputs - inputs: - SourceFolder: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android/Xamarin.AndroidDesigner.Tests - Contents: | - CustomControlsOutput - AndroidCustomControlsClass/obj - AndroidCustomControlsBinding/obj - AndroidCustomControls/obj - AndroidCustomControlsClass/bin - AndroidCustomControlsBinding/bin - AndroidCustomControls/bin - -- task: NuGetCommand@2 - displayName: Install NUnit.Console ${{ parameters.nunitConsoleVersion }} - inputs: - command: custom - arguments: install NUnit.Console -version ${{ parameters.nunitConsoleVersion }} -OutputDirectory ${{ parameters.designerSourcePath }}/packages - -- powershell: | - $nunitConsole = [IO.Path]::Combine("${{ parameters.designerSourcePath }}", "packages", "NUnit.ConsoleRunner.${{ parameters.nunitConsoleVersion }}", "tools", "nunit3-console.exe") - if ([Environment]::OSVersion.Platform -eq "Unix") - { - mono64 "$nunitConsole" "-labels=All" "-result=TestResult_AndroidDesignerUnitTests.xml" "Xamarin.AndroidDesigner.UnitTests.dll" - } - else - { - ."$nunitConsole" "-labels=All" "-result=TestResult_AndroidDesignerUnitTests.xml" "Xamarin.AndroidDesigner.UnitTests.dll" - } - displayName: Run Unit Tests - workingDirectory: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android/Xamarin.AndroidDesigner.Tests/bin-tests/Debug - -- powershell: | - if ([Environment]::OSVersion.Platform -eq "Unix") - { - mono64 "--debug" "GuiUnit.exe" "-labels=All" "-result=TestResult_AndroidDesigner.xml" "Xamarin.AndroidDesigner.Tests.dll" - } - else - { - .\GuiUnit.exe "-labels=All" "-result=TestResult_AndroidDesigner.xml" "Xamarin.AndroidDesigner.Tests.dll" - } - displayName: Run GUI Tests - workingDirectory: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android/Xamarin.AndroidDesigner.Tests/bin/Debug - condition: false # https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1583237 - -- task: PublishTestResults@2 - displayName: Publish Core Unit Test Results - inputs: - testResultsFormat: NUnit - testResultsFiles: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android/Xamarin.AndroidDesigner.Tests/**/TestResult_*.xml - testRunTitle: Xamarin.AndroidDesigner.Tests - condition: succeededOrFailed() - -- task: CopyFiles@2 - displayName: 'Copy binlogs' - inputs: - sourceFolder: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android - contents: | - **/*.binlog - **/hs*.log - **/hs*.mdmp - targetFolder: $(Build.ArtifactStagingDirectory)/designer-binlogs - overWrite: true - flattenFolders: true - condition: ne(variables['Agent.JobStatus'], 'Succeeded') - -- template: publish-artifact.yaml - parameters: - displayName: upload designer binlogs - artifactName: ${{ parameters.testResultArtifactName }} - targetPath: $(Build.ArtifactStagingDirectory)/designer-binlogs - condition: ne(variables['Agent.JobStatus'], 'Succeeded') diff --git a/build-tools/scripts/Ndk.projitems.in b/build-tools/scripts/Ndk.projitems.in index 50cce76bec0..11db54c5be5 100644 --- a/build-tools/scripts/Ndk.projitems.in +++ b/build-tools/scripts/Ndk.projitems.in @@ -2,13 +2,9 @@ @NDK_RELEASE@ - @NDK_ARMEABI_V7_API@ @NDK_ARMEABI_V7_API_NET@ - @NDK_ARM64_V8A_API@ @NDK_ARM64_V8A_API_NET@ - @NDK_X86_API@ @NDK_X86_API_NET@ - @NDK_X86_64_API@ @NDK_X86_64_API_NET@ @@ -16,7 +12,6 @@ - $(AndroidNdkApiLevel_ArmV7a) $(AndroidNdkApiLevel_Arm) android-arm @@ -24,7 +19,6 @@ - $(AndroidNdkApiLevel_ArmV8a) $(AndroidNdkApiLevel_Arm64) android-arm64 @@ -32,7 +26,6 @@ - $(AndroidNdkApiLevel_X86_Legacy) $(AndroidNdkApiLevel_X86) android-x86 @@ -40,7 +33,6 @@ - $(AndroidNdkApiLevel_X86_64) $(AndroidNdkApiLevel_X64) android-x64 diff --git a/build-tools/xaprepare/xaprepare/Application/GeneratedMonodroidCmakeFiles.cs b/build-tools/xaprepare/xaprepare/Application/GeneratedMonodroidCmakeFiles.cs index 746f3f50d89..1a3072c7794 100644 --- a/build-tools/xaprepare/xaprepare/Application/GeneratedMonodroidCmakeFiles.cs +++ b/build-tools/xaprepare/xaprepare/Application/GeneratedMonodroidCmakeFiles.cs @@ -45,12 +45,6 @@ public override void Generate (Context context) AbiNames.TargetJit.AndroidX86_64, }; - static readonly string[] HostAbis = new [] { - Context.Instance.OS.Type, - AbiNames.HostJit.Win32, - AbiNames.HostJit.Win64, - }; - void GenerateShellConfig (Context context, StreamWriter sw) { var commonReplacements = new Dictionary (StringComparer.Ordinal) { @@ -73,15 +67,7 @@ void GenerateShellConfig (Context context, StreamWriter sw) { "@AndroidToolchainPath@", GetRelativeToolchainDefinitionPath () }, }; - var hostRuntimeReplacements = new Dictionary (StringComparer.Ordinal) { - { "@CmakeHostFlags@", "" }, - { "@MingwDependenciesRootDirectory@", CmakeBuilds.MingwDependenciesRootDirectory }, - { "@MxeToolchainBasePath@", "${MXE_TOOLCHAIN_BASE_PATH}" }, - { "@BITNESS@", "" }, - }; - AddReplacements (commonReplacements, androidRuntimeReplacements); - AddReplacements (commonReplacements, hostRuntimeReplacements); string monodroidObjDir = Path.Combine (Configurables.Paths.MonodroidSourceDir, "obj", context.Configuration); string jdkInfoPropsPath = Path.Combine (Configurables.Paths.ExternalJavaInteropDir, "bin", $"Build{context.Configuration}", "JdkInfo.props"); @@ -136,58 +122,10 @@ void GenerateShellConfig (Context context, StreamWriter sw) sw.WriteLine ("}"); sw.WriteLine (); - sw.WriteLine ("function __xa_configure_host_runtime()"); - sw.WriteLine ("{"); - sw.WriteLine ($"{indent}local is_mxe=$1"); - sw.WriteLine (); - - WriteVariableValidationCode ("__BUILD_DIR"); - WriteVariableValidationCode ("__CONFIGURATION"); - WriteVariableValidationCode ("__BUILD_TYPE"); - WriteVariableValidationCode ("__OUTPUT_DIR"); - - sw.WriteLine ($"{indent}cleanup_build_dir"); - sw.WriteLine (); - - sw.WriteLine ($"{indent}shift"); - sw.WriteLine (); - sw.WriteLine ($"{indent}if [ \"${{is_mxe}}\" = \"yes\" ]; then"); - indent = "\t\t"; - - // Windows cross builds - flags.Clear (); - indent = "\t\t\t"; - AppendFlags (flags, CmakeBuilds.CommonFlags, indent); - AppendFlags (flags, CmakeBuilds.MonodroidCommonDefines, indent); - AppendFlags (flags, CmakeBuilds.MonodroidMxeCommonFlags, indent); - AppendFlags (flags, CmakeBuilds.ConfigureHostRuntimeCommandsCommonFlags, indent); - indent = "\t\t"; - WriteCmakeCall (flags, hostRuntimeReplacements); - - // Host build - sw.WriteLine ($"\telse"); - indent = "\t\t\t"; - flags.Clear (); - AppendFlags (flags, CmakeBuilds.CommonFlags, indent); - AppendFlags (flags, CmakeBuilds.MonodroidCommonDefines, indent); - AppendFlags (flags, CmakeBuilds.ConfigureHostRuntimeCommandsCommonFlags, indent); - indent = "\t\t"; - WriteCmakeCall (flags, hostRuntimeReplacements); - - indent = "\t"; - sw.WriteLine ($"{indent}fi"); - - sw.WriteLine ("}"); - sw.WriteLine (); - foreach (CmakeBuilds.RuntimeCommand rc in CmakeBuilds.AndroidRuntimeCommands) { WriteShellRuntimeCommand (sw, JitAbis, rc, androidRuntimeReplacements); } - foreach (CmakeBuilds.RuntimeCommand rc in CmakeBuilds.HostRuntimeCommands) { - WriteShellRuntimeCommand (sw, HostAbis, rc, hostRuntimeReplacements); - } - void WriteCmakeCall (StringBuilder args, Dictionary replacements) { sw.WriteLine ($"{indent}\"${{CMAKE}}\" \\"); @@ -223,30 +161,12 @@ void WriteShellRuntimeCommand (StreamWriter sw, IEnumerable abis, CmakeB foreach (var a in abis) { string abi = a; - uint minApiLevel = command.IsDotNet ? BuildAndroidPlatforms.NdkMinimumAPI : !command.IsHost ? BuildAndroidPlatforms.NdkMinimumAPIMap [abi] : 0; - string outputDirName = command.IsDotNet ? AbiNames.AbiToRuntimeIdentifier (abi) : abi; + uint minApiLevel = BuildAndroidPlatforms.NdkMinimumAPI; + string outputDirName = AbiNames.AbiToRuntimeIdentifier (abi); string isMxe = "no"; string mxeBitness = String.Empty; bool forMxe = false; - if (command.IsHost) { - if (String.Compare (abi, AbiNames.HostJit.Win32, StringComparison.OrdinalIgnoreCase) == 0) { - mxeBitness = "32"; - } else if (String.Compare (abi, AbiNames.HostJit.Win64, StringComparison.OrdinalIgnoreCase) == 0) { - mxeBitness = "64"; - } - - if (mxeBitness.Length > 0) { - isMxe = "yes"; - forMxe = true; - } - } - - if (command.IsHost) { - outputDirName = $"host-{outputDirName}"; - abi = $"host-{abi}"; - } - funcName.Clear (); funcName.Append (abi.ToLowerInvariant ()); funcName.Append ('_'); @@ -269,16 +189,11 @@ void WriteShellRuntimeCommand (StreamWriter sw, IEnumerable abis, CmakeB sw.WriteLine ($"{indent}__BUILD_TYPE={command.BuildType}"); sw.WriteLine ($"{indent}__REBUILD=\"${{rebuild}}\""); sw.WriteLine ($"{indent}__FORCE=\"${{force}}\""); - if (!command.IsHost) { - sw.WriteLine ($"{indent}__NATIVE_ABI={abi}"); - sw.WriteLine ($"{indent}__NATIVE_API_LEVEL=${{{minApiLevel}}}"); - } + sw.WriteLine ($"{indent}__NATIVE_ABI={abi}"); + sw.WriteLine ($"{indent}__NATIVE_API_LEVEL=${{{minApiLevel}}}"); sw.WriteLine (); - if (!command.IsHost) { - sw.Write ($"{indent}__xa_configure_android_runtime"); - } else { - sw.Write ($"{indent}__xa_configure_host_runtime {isMxe}"); - } + + sw.Write ($"{indent}__xa_configure_android_runtime"); StringBuilder? flags = null; if (forMxe) { @@ -339,27 +254,16 @@ void GenerateMonodroidTargets (Context context, StreamWriter sw) { "@OUTPUT_DIRECTORY@", "" }, }; - var hostRuntimeReplacements = new Dictionary (StringComparer.Ordinal) { - { "@CmakeHostFlags@", "%(_HostRuntime.CmakeFlags)" }, - { "@JdkIncludePath@", "@(JdkIncludePath->'%(Identity)', ' ')" }, - { "@OUTPUT_DIRECTORY@", "" }, - }; - AddReplacements (commonReplacements, androidRuntimeReplacements); - AddReplacements (commonReplacements, hostRuntimeReplacements); WriteMSBuildProjectStart (sw); - sw.WriteLine (" "); + sw.WriteLine (" "); string indent = " "; foreach (CmakeBuilds.RuntimeCommand rc in CmakeBuilds.AndroidRuntimeCommands) { WriteMSBuildConfigureAndroidRuntimeCommands (sw, indent, rc, androidRuntimeReplacements); } - foreach (CmakeBuilds.RuntimeCommand rc in CmakeBuilds.HostRuntimeCommands) { - WriteMSBuildConfigureHostRuntimeCommands (sw, indent, rc, hostRuntimeReplacements); - }; - sw.WriteLine (" "); WriteMSBuildProjectEnd (sw); } @@ -405,14 +309,13 @@ string EnsureRequired (string name, string v) void WriteMSBuildConfigureAndroidRuntimeCommands (StreamWriter sw, string indent, CmakeBuilds.RuntimeCommand command, Dictionary replacements) { - const string LegacyOutputDirectory = "%(AndroidSupportedTargetJitAbi.Identity)"; const string OutputDirectory = "%(AndroidSupportedTargetJitAbi.AndroidRID)"; WriteMSBuildConfigureRuntimeCommands ( sw, indent, - command.IsDotNet ? $"$(IntermediateOutputPath){OutputDirectory}-{command.Suffix}" : $"$(IntermediateOutputPath){LegacyOutputDirectory}-{command.Suffix}", - command.IsDotNet ? $"$(OutputPath){OutputDirectory}" : $"$(OutputPath){LegacyOutputDirectory}", + $"$(IntermediateOutputPath){OutputDirectory}-{command.Suffix}", + $"$(OutputPath){OutputDirectory}", "@(AndroidSupportedTargetJitAbi)", CmakeBuilds.ConfigureAndroidRuntimeCommandsCommonFlags, command, @@ -421,21 +324,6 @@ void WriteMSBuildConfigureAndroidRuntimeCommands (StreamWriter sw, string indent ); } - void WriteMSBuildConfigureHostRuntimeCommands (StreamWriter sw, string indent, CmakeBuilds.RuntimeCommand command, Dictionary replacements) - { - WriteMSBuildConfigureRuntimeCommands ( - sw, - indent, - $"$(IntermediateOutputPath)%(_HostRuntime.OutputDirectory)-{command.Suffix}", - "$(OutputPath)/%(_HostRuntime.OutputDirectory)", - "@(_HostRuntime)", - CmakeBuilds.ConfigureHostRuntimeCommandsCommonFlags, - command, - replacements, - false - ); - } - void GenerateMSBuildProps (Context context, StreamWriter sw) { var MSBuildReplacements = new Dictionary (StringComparer.Ordinal) { @@ -468,7 +356,6 @@ void GenerateMSBuildProps (Context context, StreamWriter sw) string propertyIndent = " "; sw.WriteLine (" "); WriteProperty (sw, propertyIndent, "_CmakeAndroidFlags", flags, MSBuildReplacements); - WriteProperty (sw, propertyIndent, "_CmakeCommonHostFlags", sharedByAll, MSBuildReplacements); sw.WriteLine (" "); if (CmakeBuilds.MxeToolchainBasePath.Length > 0 && CmakeBuilds.MingwDependenciesRootDirectory.Length > 0) { diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs index 0dbf3ca9f74..90517fb5ee8 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs @@ -8,7 +8,6 @@ class BuildAndroidPlatforms public const string AndroidNdkVersion = "25b"; public const string AndroidNdkPkgRevision = "25.1.8937393"; public const int NdkMinimumAPI = 21; - public const int NdkMinimumAPILegacy32 = 19; public static readonly List AllPlatforms = new List { new AndroidPlatform (apiName: "", apiLevel: 1, platformID: "1"), @@ -45,13 +44,5 @@ class BuildAndroidPlatforms new AndroidPlatform (apiName: "Sv2", apiLevel: 32, platformID: "32", include: "v12.1", framework: "v12.1"), new AndroidPlatform (apiName: "Tiramisu", apiLevel: 33, platformID: "33", include: "v13.0", framework: "v13.0"), }; - - public static readonly Dictionary NdkMinimumAPIMap = new Dictionary { - { AbiNames.TargetJit.AndroidArmV7a, NdkMinimumAPILegacy32 }, - { AbiNames.TargetJit.AndroidArmV8a, NdkMinimumAPI }, - { AbiNames.TargetJit.AndroidX86, NdkMinimumAPILegacy32 }, - { AbiNames.TargetJit.AndroidX86_64, NdkMinimumAPI }, - }; - } } diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/CmakeBuilds.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/CmakeBuilds.cs index 6763232c0e8..af299f75f8d 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/CmakeBuilds.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/CmakeBuilds.cs @@ -20,8 +20,6 @@ public sealed class RuntimeCommand public string Suffix = String.Empty; public string MSBuildApiLevel = String.Empty; public List? ExtraOptions = null; - public bool IsDotNet = false; - public bool IsHost = false; }; const string msbuildApiLevelLegacy = "%(AndroidSupportedTargetJitAbi.ApiLevel)"; @@ -95,51 +93,13 @@ public sealed class RuntimeCommand "-DANDROID_CPP_FEATURES=\"rtti exceptions\"", }; - const string enableNet = "-DENABLE_NET=ON"; - public static readonly List NetExtraOptions = new List { - enableNet, - }; - - public static readonly List NetAsanExtraOptions = new List (AsanExtraOptions) { - enableNet, - }; - - public static readonly List NetUbsanExtraOptions = new List (UbsanExtraOptions) { - enableNet, - }; - public static readonly List AndroidRuntimeCommands = new List { // Debug builds - new RuntimeCommand { - Suffix = "Debug", - Configuration = "Release", - BuildType = "Debug", - MSBuildApiLevel = msbuildApiLevelLegacy, - }, - - new RuntimeCommand { - Suffix = "asan-Debug", - Configuration = "Release", - BuildType = "Debug", - MSBuildApiLevel = msbuildApiLevelLegacy, - ExtraOptions = AsanExtraOptions, - }, - - new RuntimeCommand { - Suffix = "ubsan-Debug", - Configuration = "Release", - BuildType = "Debug", - MSBuildApiLevel = msbuildApiLevelLegacy, - ExtraOptions = UbsanExtraOptions, - }, - new RuntimeCommand { Suffix = "Debug", Configuration = "Release", BuildType = "Debug", MSBuildApiLevel = msbuildApiLevel, - ExtraOptions = NetExtraOptions, - IsDotNet = true, }, new RuntimeCommand { @@ -147,8 +107,7 @@ public sealed class RuntimeCommand Configuration = "Release", BuildType = "Debug", MSBuildApiLevel = msbuildApiLevel, - ExtraOptions = NetAsanExtraOptions, - IsDotNet = true, + ExtraOptions = AsanExtraOptions, }, new RuntimeCommand { @@ -156,42 +115,15 @@ public sealed class RuntimeCommand Configuration = "Release", BuildType = "Debug", MSBuildApiLevel = msbuildApiLevel, - ExtraOptions = NetUbsanExtraOptions, - IsDotNet = true, - }, - - // Release builds - - new RuntimeCommand { - Suffix = "Release", - Configuration = "Debug", - BuildType = "Release", - MSBuildApiLevel = msbuildApiLevelLegacy, - }, - - new RuntimeCommand { - Suffix = "asan-Release", - Configuration = "Debug", - BuildType = "Release", - MSBuildApiLevel = msbuildApiLevelLegacy, - ExtraOptions = AsanExtraOptions, - }, - - new RuntimeCommand { - Suffix = "ubsan-Release", - Configuration = "Debug", - BuildType = "Release", - MSBuildApiLevel = msbuildApiLevelLegacy, ExtraOptions = UbsanExtraOptions, }, + // Release builds new RuntimeCommand { Suffix = "Release", Configuration = "Debug", BuildType = "Release", MSBuildApiLevel = msbuildApiLevel, - ExtraOptions = NetExtraOptions, - IsDotNet = true, }, new RuntimeCommand { @@ -199,8 +131,7 @@ public sealed class RuntimeCommand Configuration = "Debug", BuildType = "Release", MSBuildApiLevel = msbuildApiLevel, - ExtraOptions = NetAsanExtraOptions, - IsDotNet = true, + ExtraOptions = AsanExtraOptions, }, new RuntimeCommand { @@ -208,24 +139,7 @@ public sealed class RuntimeCommand Configuration = "Debug", BuildType = "Release", MSBuildApiLevel = msbuildApiLevel, - ExtraOptions = NetUbsanExtraOptions, - IsDotNet = true, - }, - }; - - public static readonly List HostRuntimeCommands = new List { - new RuntimeCommand { - Suffix = "Debug", - Configuration = "Release", - BuildType = "Debug", - IsHost = true, - }, - - new RuntimeCommand { - Suffix = "Release", - Configuration = "Debug", - BuildType = "Release", - IsHost = true, + ExtraOptions = UbsanExtraOptions, }, }; } diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_BuildMonoRuntimes.Unix.cs b/build-tools/xaprepare/xaprepare/Steps/Step_BuildMonoRuntimes.Unix.cs index efbaef311d2..b55d16263de 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_BuildMonoRuntimes.Unix.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_BuildMonoRuntimes.Unix.cs @@ -428,9 +428,9 @@ List PrepareMakeArguments (Context context, string workingDirectory, Lis "IGNORE_PROVISION_ANDROID=true", $"ANDROID_CMAKE_VERSION={GetProperty (KnownProperties.AndroidCmakeVersionPath)}", $"ANDROID_NDK_VERSION=r{BuildAndroidPlatforms.AndroidNdkVersion}", - $"ANDROID_SDK_VERSION_armeabi-v7a={BuildAndroidPlatforms.NdkMinimumAPILegacy32}", + $"ANDROID_SDK_VERSION_armeabi-v7a={BuildAndroidPlatforms.NdkMinimumAPI}", $"ANDROID_SDK_VERSION_arm64-v8a={BuildAndroidPlatforms.NdkMinimumAPI}", - $"ANDROID_SDK_VERSION_x86={BuildAndroidPlatforms.NdkMinimumAPILegacy32}", + $"ANDROID_SDK_VERSION_x86={BuildAndroidPlatforms.NdkMinimumAPI}", $"ANDROID_SDK_VERSION_x86_64={BuildAndroidPlatforms.NdkMinimumAPI}", $"ANDROID_TOOLCHAIN_DIR={GetProperty (KnownProperties.AndroidToolchainDirectory)}", $"ANDROID_TOOLCHAIN_CACHE_DIR={GetProperty (KnownProperties.AndroidToolchainCacheDirectory)}", diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs index 07684b87ff9..c3ae93971e2 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs @@ -172,9 +172,9 @@ GeneratedFile Get_XABuildConfig_cs (Context context) { "@NDK_VERSION_MAJOR@", context.BuildInfo.NDKVersionMajor }, { "@NDK_VERSION_MINOR@", context.BuildInfo.NDKVersionMinor }, { "@NDK_VERSION_MICRO@", context.BuildInfo.NDKVersionMicro }, - { "@NDK_ARMEABI_V7_API@", BuildAndroidPlatforms.NdkMinimumAPILegacy32.ToString () }, + { "@NDK_ARMEABI_V7_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () }, { "@NDK_ARM64_V8A_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () }, - { "@NDK_X86_API@", BuildAndroidPlatforms.NdkMinimumAPILegacy32.ToString ().ToString () }, + { "@NDK_X86_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString ().ToString () }, { "@NDK_X86_64_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString ().ToString () }, { "@XA_SUPPORTED_ABIS@", context.Properties.GetRequiredValue (KnownProperties.AndroidSupportedTargetJitAbis).Replace (':', ';') }, { "@ANDROID_DEFAULT_TARGET_DOTNET_API_LEVEL@", context.Properties.GetRequiredValue (KnownProperties.AndroidDefaultTargetDotnetApiLevel) }, @@ -198,13 +198,9 @@ GeneratedFile Get_Ndk_projitems (Context context) var replacements = new Dictionary (StringComparer.Ordinal) { { "@NDK_RELEASE@", BuildAndroidPlatforms.AndroidNdkVersion }, - { "@NDK_ARMEABI_V7_API@", BuildAndroidPlatforms.NdkMinimumAPILegacy32.ToString () }, { "@NDK_ARMEABI_V7_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () }, - { "@NDK_ARM64_V8A_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () }, { "@NDK_ARM64_V8A_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () }, - { "@NDK_X86_API@", BuildAndroidPlatforms.NdkMinimumAPILegacy32.ToString () }, { "@NDK_X86_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () }, - { "@NDK_X86_64_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () }, { "@NDK_X86_64_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () }, }; diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj index dd902240461..ad980b06223 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj @@ -361,10 +361,6 @@ LayoutBinding.cs PreserveNewest - - mkbundle-api.h - PreserveNewest - PreserveNewest diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets index cd4782e7bba..922902a4552 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets @@ -198,7 +198,7 @@ + Replacements="@PACKAGE_VERSION@=$(ProductVersion);@PACKAGE_VERSION_BUILD@=$(XAVersionCommitCount);@NDK_ARMEABI_V7_API@=$(AndroidNdkApiLevel_Arm);@NDK_ARM64_V8A_API@=$(AndroidNdkApiLevel_Arm64);@NDK_X86_API@=$(AndroidNdkApiLevel_X86);@NDK_X86_64_API@=$(AndroidNdkApiLevel_X64);@BUNDLETOOL_VERSION@=$(XABundleToolVersion)"> - - - - - - - diff --git a/src/monodroid/CMakeLists.txt b/src/monodroid/CMakeLists.txt index 8a6951991f9..9ec15a12695 100644 --- a/src/monodroid/CMakeLists.txt +++ b/src/monodroid/CMakeLists.txt @@ -44,7 +44,6 @@ else() set(STRIP_DEBUG_DEFAULT ON) endif() -option(ENABLE_NET "Enable compilation for .NET 6+" OFF) option(ENABLE_TIMING "Build with timing support" OFF) option(STRIP_DEBUG "Strip debugging information when linking" ${STRIP_DEBUG_DEFAULT}) option(DISABLE_DEBUG "Disable the built-in debugging code" OFF) @@ -182,7 +181,7 @@ endif() include("${XA_BUILD_DIR}/xa_build_configuration.cmake") -if(ENABLE_NET) +if(ANDROID) if(ANDROID_ABI MATCHES "^arm64-v8a") set(NET_RUNTIME_DIR "${NETCORE_APP_RUNTIME_DIR_ARM64}") elseif(ANDROID_ABI MATCHES "^armeabi-v7a") @@ -243,7 +242,7 @@ if (WIN32) include_directories(BEFORE "jni/win32") endif() -if(ENABLE_NET) +if(ANDROID) include_directories("${NET_RUNTIME_DIR}/native/include/mono-2.0") else() include_directories("${XA_BIN_DIR}/include/mono-2.0") @@ -275,7 +274,7 @@ add_compile_definitions(_REENTRANT) add_compile_definitions(JI_DLL_EXPORT) add_compile_definitions(MONO_DLL_EXPORT) -if(ENABLE_NET) +if(ANDROID) add_compile_definitions(NET) add_compile_definitions(JI_NO_VISIBILITY) endif() @@ -425,13 +424,8 @@ endif() # Library directories if(ANDROID) - if(ENABLE_NET) - set(XA_LIBRARY_OUTPUT_DIRECTORY "${XA_LIB_TOP_DIR}/lib/${ANDROID_RID}") - link_directories("${NET_RUNTIME_DIR}/native") - else() - set(XA_LIBRARY_OUTPUT_DIRECTORY "${XA_LIB_TOP_DIR}/lib/${ANDROID_ABI}") - link_directories("${XA_LIBRARY_OUTPUT_DIRECTORY}") - endif() + set(XA_LIBRARY_OUTPUT_DIRECTORY "${XA_LIB_TOP_DIR}/lib/${ANDROID_RID}") + link_directories("${NET_RUNTIME_DIR}/native") endif() if(WIN32 OR MINGW) @@ -507,7 +501,7 @@ if(ANDROID) ${LZ4_SOURCES} ) - if(NOT DEBUG_BUILD AND ENABLE_NET) + if(NOT DEBUG_BUILD) list(APPEND XAMARIN_MONODROID_SOURCES ${SOURCES_DIR}/xamarin-android-app-context.cc ) @@ -537,7 +531,7 @@ if(UNIX) ) endif() -if(ANDROID AND ENABLE_NET) +if(ANDROID) list(APPEND XAMARIN_MONODROID_SOURCES ${SOURCES_DIR}/monovm-properties.cc ${SOURCES_DIR}/pinvoke-override-api.cc @@ -579,7 +573,7 @@ else() list(APPEND MONOSGEN_LIB_LINK -lmonosgen-2.0) endif() -if(NOT (ANDROID AND ENABLE_NET)) +if(NOT ANDROID) add_library( ${XAMARIN_INTERNAL_API_LIB} SHARED diff --git a/src/monodroid/jni/android-system.cc b/src/monodroid/jni/android-system.cc index cf8c0a82692..cf9f5c65e89 100644 --- a/src/monodroid/jni/android-system.cc +++ b/src/monodroid/jni/android-system.cc @@ -4,15 +4,6 @@ #include #include -#if defined (WINDOWS) -#include -#include -#include -#include -#include -#include -#endif - #include "globals.hh" #include "android-system.hh" #include "monodroid.h" @@ -23,7 +14,7 @@ #include "java-interop-dlfcn.h" #include "java-interop.h" -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) namespace xamarin::android::internal { struct BundledProperty { char *name; @@ -32,22 +23,17 @@ namespace xamarin::android::internal { struct BundledProperty *next; }; } -#endif // DEBUG || !ANDROID +#endif // DEBUG using namespace microsoft::java_interop; using namespace xamarin::android; using namespace xamarin::android::internal; -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) BundledProperty *AndroidSystem::bundled_properties = nullptr; -#endif // DEBUG || !ANDROID +#endif // DEBUG -#if defined (WINDOWS) -std::mutex AndroidSystem::readdir_mutex; -char *AndroidSystem::libmonoandroid_directory_path = nullptr; -#endif - -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) BundledProperty* AndroidSystem::lookup_system_property (const char *name) { @@ -58,19 +44,19 @@ AndroidSystem::lookup_system_property (const char *name) } return nullptr; } -#endif // DEBUG || !ANDROID +#endif // DEBUG const char* AndroidSystem::lookup_system_property (const char *name, size_t &value_len) { value_len = 0; -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) BundledProperty *p = lookup_system_property (name); if (p != nullptr) { value_len = p->value_len; return p->name; } -#endif // DEBUG || !ANDROID +#endif // DEBUG if (application_config.system_property_count == 0) return nullptr; @@ -102,7 +88,7 @@ AndroidSystem::lookup_system_property (const char *name, size_t &value_len) return nullptr; } -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) void AndroidSystem::add_system_property (const char *name, const char *value) { @@ -138,57 +124,8 @@ AndroidSystem::add_system_property (const char *name, const char *value) p->next = bundled_properties; bundled_properties = p; } -#endif // DEBUG || !ANDROID - -#ifndef ANDROID -void -AndroidSystem::monodroid_strreplace (char *buffer, char old_char, char new_char) -{ - if (buffer == nullptr) - return; - while (*buffer != '\0') { - if (*buffer == old_char) - *buffer = new_char; - buffer++; - } -} +#endif // DEBUG -int -AndroidSystem::_monodroid__system_property_get (const char *name, char *sp_value, size_t sp_value_len) -{ - if (!name || !sp_value) - return -1; - - char *env_name = utils.monodroid_strdup_printf ("__XA_%s", name); - monodroid_strreplace (env_name, '.', '_'); - char *env_value = getenv (env_name); - free (env_name); - - size_t env_value_len = env_value ? strlen (env_value) : 0; - if (env_value_len == 0) { - sp_value[0] = '\0'; - return 0; - } - - if (env_value_len >= sp_value_len) - log_warn (LOG_DEFAULT, "System property buffer size too small by %u bytes", env_value_len == sp_value_len ? 1 : env_value_len - sp_value_len); - - // - // sp_value_len includes the terminating nul, avoid a mingw g++ warning about string truncation - // by making the amount of data copied one less than the indicated length. The warning reported - // is: - // - // In function ‘int xamarin::android::internal::AndroidSystem::_monodroid__system_property_get(const char*, char*, size_t)’, - // inlined from ‘int xamarin::android::internal::AndroidSystem::monodroid_get_system_property(const char*, char**)’ at ../../../jni/android-system.cc:243:44: - // ../../../jni/android-system.cc(206,10): warning G20816D19: ‘char* strncpy(char*, const char*, size_t)’ specified bound 93 equals destination size [-Wstringop-truncation] [/home/grendel/vc/xamarin/xamarin-android-worktrees/code-quality-improvements/src/monodroid/monodroid.csproj] - // strncpy (sp_value, env_value, sp_value_len); - // - strncpy (sp_value, env_value, sp_value_len - 2); - sp_value[sp_value_len - 1] = '\0'; - - return static_cast(strlen (sp_value)); -} -#else int AndroidSystem::_monodroid__system_property_get (const char *name, char *sp_value, size_t sp_value_len) { @@ -211,7 +148,6 @@ AndroidSystem::_monodroid__system_property_get (const char *name, char *sp_value return len; } -#endif int AndroidSystem::monodroid_get_system_property (const char *name, dynamic_local_string& value) @@ -263,7 +199,7 @@ AndroidSystem::monodroid_get_system_property (const char *name, char **value) return len; } -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) size_t AndroidSystem::_monodroid_get_system_property_from_file (const char *path, char **value) { @@ -299,12 +235,12 @@ AndroidSystem::_monodroid_get_system_property_from_file (const char *path, char } return len; } -#endif +#endif // def DEBUG size_t AndroidSystem::monodroid_get_system_property_from_overrides ([[maybe_unused]] const char *name, [[maybe_unused]] char ** value) { -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) for (size_t oi = 0; oi < MAX_OVERRIDES; ++oi) { if (override_dirs [oi]) { std::unique_ptr override_file {utils.path_combine (override_dirs [oi], name)}; @@ -317,7 +253,7 @@ AndroidSystem::monodroid_get_system_property_from_overrides ([[maybe_unused]] co return result; } } -#endif +#endif // def DEBUG return 0; } @@ -524,7 +460,7 @@ AndroidSystem::get_gref_gc_threshold () return static_cast ((max_gref_count * 90LL) / 100LL); } -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) void AndroidSystem::setup_environment (const char *name, const char *value) { @@ -547,11 +483,6 @@ AndroidSystem::setup_environment (const char *name, const char *value) void AndroidSystem::setup_environment_from_override_file (const char *path) { -#if WINDOWS - using read_count_type = unsigned int; -#else - using read_count_type = size_t; -#endif monodroid_stat_t sbuf; if (utils.monodroid_stat (path, &sbuf) < 0) { log_warn (LOG_DEFAULT, "Failed to stat the environment override file %s: %s", path, strerror (errno)); @@ -570,7 +501,7 @@ AndroidSystem::setup_environment_from_override_file (const char *path) auto buf = std::make_unique (file_size); do { - auto read_count = static_cast(file_size - nread); + auto read_count = static_cast(file_size - nread); r = read (fd, buf.get () + nread, read_count); if (r > 0) nread += static_cast(r); @@ -635,7 +566,7 @@ AndroidSystem::setup_environment_from_override_file (const char *path) data_size -= data_width; } } -#endif // DEBUG || !ANDROID +#endif // DEBUG void AndroidSystem::setup_environment () @@ -655,12 +586,7 @@ AndroidSystem::setup_environment () break; case 'i': -#if !defined (NET) - aotMode = MonoAotMode::MONO_AOT_MODE_LAST; - aot_mode_last_is_interpreter = true; -#else // defined (NET) aotMode = MonoAotMode::MONO_AOT_MODE_INTERP_ONLY; -#endif // !defined (NET) break; default: @@ -704,7 +630,7 @@ AndroidSystem::setup_environment () if (setenv (var_name, var_value, 1) < 0) log_warn (LOG_DEFAULT, "Failed to set environment variable: %s", strerror (errno)); } -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) // TODO: for debug read from file in the override directory named `environment` for (size_t oi = 0; oi < MAX_OVERRIDES; oi++) { std::unique_ptr env_override_file {utils.path_combine (override_dirs [oi], OVERRIDE_ENVIRONMENT_FILE_NAME)}; @@ -712,7 +638,7 @@ AndroidSystem::setup_environment () setup_environment_from_override_file (env_override_file.get ()); } } -#endif +#endif // def DEBUG } void @@ -734,66 +660,5 @@ AndroidSystem::setup_process_args (jstring_array_wrapper &runtimeApks) monodroid_dirent_t* AndroidSystem::readdir (monodroid_dir_t *dir) { -#if defined (WINDOWS) - return readdir_windows (dir); -#else return ::readdir (dir); -#endif -} - -#if defined (WINDOWS) -struct _wdirent* -AndroidSystem::readdir_windows (_WDIR *dirp) -{ - std::lock_guard lock (readdir_mutex); - errno = 0; - struct _wdirent *entry = _wreaddir (dirp); - - if (entry == nullptr && errno != 0) - return nullptr; - - return entry; -} - -// Returns the directory in which this library was loaded from -char* -AndroidSystem::get_libmonoandroid_directory_path () -{ - wchar_t module_path[MAX_PATH]; - HMODULE module = nullptr; - - if (libmonoandroid_directory_path != nullptr) - return libmonoandroid_directory_path; - - DWORD flags = GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; - const wchar_t *dir_path = reinterpret_cast(&libmonoandroid_directory_path); - BOOL retval = GetModuleHandleExW (flags, dir_path, &module); - if (!retval) - return nullptr; - - GetModuleFileNameW (module, module_path, sizeof (module_path) / sizeof (module_path[0])); - PathRemoveFileSpecW (module_path); - libmonoandroid_directory_path = utils.utf16_to_utf8 (module_path); - return libmonoandroid_directory_path; } - -int -AndroidSystem::setenv (const char *name, const char *value, [[maybe_unused]] int overwrite) -{ - wchar_t *wname = utils.utf8_to_utf16 (name); - wchar_t *wvalue = utils.utf8_to_utf16 (value); - - BOOL result = SetEnvironmentVariableW (wname, wvalue); - free (wname); - free (wvalue); - - return result ? 0 : -1; -} - -int -AndroidSystem::symlink (const char *target, const char *linkpath) -{ - return utils.file_copy (target, linkpath); -} -#else -#endif diff --git a/src/monodroid/jni/android-system.hh b/src/monodroid/jni/android-system.hh index 54f0bdd32b9..145309ba08d 100644 --- a/src/monodroid/jni/android-system.hh +++ b/src/monodroid/jni/android-system.hh @@ -7,9 +7,7 @@ #include #include -#ifdef ANDROID #include -#endif #include "util.hh" #include "cppcompat.hh" @@ -20,11 +18,6 @@ #include -#if !defined (ANDROID) -constexpr uint32_t PROP_NAME_MAX = 32; -constexpr uint32_t PROP_VALUE_MAX = 92; -#endif - constexpr size_t PROPERTY_VALUE_BUFFER_LEN = PROP_VALUE_MAX + 1; namespace xamarin::android { @@ -34,22 +27,18 @@ namespace xamarin::android { namespace xamarin::android::internal { -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) struct BundledProperty; -#endif +#endif // def DEBUG class AndroidSystem : public BasicAndroidSystem { private: -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) static constexpr char OVERRIDE_ENVIRONMENT_FILE_NAME[] = "environment"; static constexpr uint32_t OVERRIDE_ENVIRONMENT_FILE_HEADER_SIZE = 22; static BundledProperty *bundled_properties; -#endif -#if defined (WINDOWS) - static std::mutex readdir_mutex; - static char *libmonoandroid_directory_path; -#endif +#endif // def DEBUG public: void setup_environment (); @@ -76,9 +65,6 @@ namespace xamarin::android::internal max_gref_count = get_max_gref_count_from_system (); } -#if defined (WINDOWS) - int setenv (const char *name, const char *value, int overwrite); -#endif bool is_assembly_preload_enabled () const { return application_config.uses_assembly_preload; @@ -101,22 +87,7 @@ namespace xamarin::android::internal bool is_interpreter_enabled () const { -#if !defined (NET) - // HACK! See below - return get_mono_aot_mode () == MonoAotMode::MONO_AOT_MODE_LAST && is_aot_mode_last_really_interpreter_mode (); -#else // defined (NET) return get_mono_aot_mode () == MonoAotMode::MONO_AOT_MODE_INTERP_ONLY; -#endif // !defined (NET) - } - - // Hack, see comment for `aot_mode_last_is_interpreter` at the bottom of the class declaration - bool is_aot_mode_last_really_interpreter_mode () const - { -#if !defined(NET) - return aot_mode_last_is_interpreter; -#else // defined (NET) - return false; -#endif // !defined (NET) } void set_running_in_emulator (bool yesno) @@ -125,52 +96,29 @@ namespace xamarin::android::internal } private: -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) void add_system_property (const char *name, const char *value); void setup_environment (const char *name, const char *value); void setup_environment_from_override_file (const char *path); BundledProperty* lookup_system_property (const char *name); -#endif +#endif // def DEBUG const char* lookup_system_property (const char *name, size_t &value_len); long get_max_gref_count_from_system (); void setup_process_args_apk (const char *apk, size_t index, size_t apk_count, void *user_data); int _monodroid__system_property_get (const char *name, char *sp_value, size_t sp_value_len); -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) size_t _monodroid_get_system_property_from_file (const char *path, char **value); -#endif +#endif // def DEBUG bool get_full_dso_path (const char *base_dir, const char *dso_path, dynamic_local_string& path); void* load_dso_from_specified_dirs (const char **directories, size_t num_entries, const char *dso_name, unsigned int dl_flags); void* load_dso_from_app_lib_dirs (const char *name, unsigned int dl_flags); void* load_dso_from_override_dirs (const char *name, unsigned int dl_flags); bool get_existing_dso_path_on_disk (const char *base_dir, const char *dso_name, dynamic_local_string& path); -#if defined (WINDOWS) - struct _wdirent* readdir_windows (_WDIR *dirp); - char* get_libmonoandroid_directory_path (); - int symlink (const char *target, const char *linkpath); - -#endif // WINDOWS - -#if !defined (ANDROID) - void monodroid_strreplace (char *buffer, char old_char, char new_char); -#endif // !ANDROID private: long max_gref_count = 0; MonoAotMode aotMode = MonoAotMode::MONO_AOT_MODE_NONE; bool running_in_emulator = false; - -#if !defined (NET) - // This is a hack because of the way Mono currently switches the full interpreter (no JIT) mode. In Mono - // **internal** headers there's an AOT mode macro, `MONO_EE_MODE_INTERP`, whose value is exactly the same as - // MonoAotMode::MONO_AOT_MODE_LAST. However, we use `MonoAotMode::MONO_AOT_MODE_LAST` as a sentinel to indicate - // that we want to use the default Mono AOT/JIT mode and so we can't "overload" it to mean something else for - // the sake of using Mono's internal functionality. Until Mono makes `MONO_EE_MODE_INTERP` part of the public - // `MonoAotMode` enum and its value is not in conflict with the sentinel, we will use this hack. - // - // See also: https://github.com/mono/mono/issues/18893 - // - bool aot_mode_last_is_interpreter = false; -#endif // !defined (NET) }; } #endif // !__ANDROID_SYSTEM_H diff --git a/src/monodroid/jni/basic-android-system.hh b/src/monodroid/jni/basic-android-system.hh index a12ba47fa1d..194ff7472de 100644 --- a/src/monodroid/jni/basic-android-system.hh +++ b/src/monodroid/jni/basic-android-system.hh @@ -39,14 +39,6 @@ namespace xamarin::android::internal static constexpr char SYSTEM_LIB_PATH[] = "/system/lib64"; #elif ANDROID static constexpr char SYSTEM_LIB_PATH[] = "/system/lib"; -#elif LINUX_FLATPAK - static constexpr char SYSTEM_LIB_PATH[] = "/app/lib/mono"; -#elif defined (__linux__) || defined (__linux) - static constexpr char SYSTEM_LIB_PATH[] = "/usr/lib"; -#elif APPLE_OS_X - static constexpr char SYSTEM_LIB_PATH[] = "/Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/xamarin.android/xbuild/Xamarin/Android/lib/host-Darwin"; -#elif WINDOWS - static const char *SYSTEM_LIB_PATH; #else static constexpr char SYSTEM_LIB_PATH[] = ""; #endif diff --git a/src/monodroid/jni/basic-utilities.cc b/src/monodroid/jni/basic-utilities.cc index adf67f7a9c1..6a94a643c8e 100644 --- a/src/monodroid/jni/basic-utilities.cc +++ b/src/monodroid/jni/basic-utilities.cc @@ -2,11 +2,6 @@ #include #include -#ifdef WINDOWS -#include -#include -#endif - #include "basic-utilities.hh" #include "logger.hh" #include "cpp-util.hh" @@ -38,15 +33,9 @@ BasicUtilities::path_combine (const char *path1, const char *path2) void BasicUtilities::create_public_directory (const char *dir) { -#ifndef WINDOWS mode_t m = umask (0); mkdir (dir, 0777); umask (m); -#else - wchar_t *buffer = utf8_to_utf16 (dir); - _wmkdir (buffer); - free (buffer); -#endif } int @@ -59,12 +48,8 @@ BasicUtilities::create_directory (const char *pathname, mode_t mode) errno = EINVAL; return -1; } -#ifdef WINDOWS - int oldumask; -#else - mode_t oldumask; -#endif - oldumask = umask (022); + + mode_t oldumask = umask (022); std::unique_ptr path {strdup_new (pathname)}; int rv, ret = 0; for (char *d = path.get (); d != nullptr && *d; ++d) { @@ -91,7 +76,6 @@ BasicUtilities::create_directory (const char *pathname, mode_t mode) void BasicUtilities::set_world_accessable ([[maybe_unused]] const char *path) { -#ifdef ANDROID int r; do r = chmod (path, 0664); @@ -99,13 +83,11 @@ BasicUtilities::set_world_accessable ([[maybe_unused]] const char *path) if (r == -1) log_error (LOG_DEFAULT, "chmod(\"%s\", 0664) failed: %s", path, strerror (errno)); -#endif } void BasicUtilities::set_user_executable ([[maybe_unused]] const char *path) { -#ifdef ANDROID int r; do { r = chmod (path, S_IRUSR | S_IWUSR | S_IXUSR); @@ -113,7 +95,6 @@ BasicUtilities::set_user_executable ([[maybe_unused]] const char *path) if (r == -1) log_error (LOG_DEFAULT, "chmod(\"%s\") failed: %s", path, strerror (errno)); -#endif } bool @@ -184,34 +165,18 @@ BasicUtilities::is_path_rooted (const char *path) { if (path == nullptr) return false; -#ifdef WINDOWS - LPCWSTR wpath = utf8_to_utf16 (path); - bool ret = !PathIsRelativeW (wpath); - free (const_cast (reinterpret_cast (wpath))); - return ret; -#else + return path [0] == MONODROID_PATH_SEPARATOR_CHAR; -#endif } FILE * BasicUtilities::monodroid_fopen (const char *filename, const char *mode) { - FILE *ret; -#ifndef WINDOWS /* On Unix, both path and system calls are all assumed * to be UTF-8 compliant. */ - ret = fopen (filename, mode); -#else - // Convert the path and mode to a UTF-16 and then use the wide variant of fopen - wchar_t *wpath = utf8_to_utf16 (filename); - wchar_t *wmode = utf8_to_utf16 (mode); - - ret = _wfopen (wpath, wmode); - free (wpath); - free (wmode); -#endif // ndef WINDOWS + FILE *ret = fopen (filename, mode); + if (ret == nullptr) { log_error (LOG_DEFAULT, "fopen failed for file %s: %s", filename, strerror (errno)); return nullptr; @@ -223,53 +188,25 @@ BasicUtilities::monodroid_fopen (const char *filename, const char *mode) int BasicUtilities::monodroid_stat (const char *path, monodroid_stat_t *s) { - int result; - -#ifndef WINDOWS - result = stat (path, s); -#else - wchar_t *wpath = utf8_to_utf16 (path); - result = _wstat (wpath, s); - free (wpath); -#endif - - return result; + return stat (path, s); } monodroid_dir_t* BasicUtilities::monodroid_opendir (const char *filename) { -#ifndef WINDOWS return opendir (filename); -#else - wchar_t *wfilename = utf8_to_utf16 (filename); - monodroid_dir_t *result = _wopendir (wfilename); - free (wfilename); - return result; -#endif } int BasicUtilities::monodroid_closedir (monodroid_dir_t *dirp) { -#ifndef WINDOWS return closedir (dirp); -#else - return _wclosedir (dirp); -#endif } int BasicUtilities::monodroid_dirent_hasextension (monodroid_dirent_t *e, const char *extension) { -#ifndef WINDOWS return ends_with_slow (e->d_name, extension); -#else - char *mb_dname = utf16_to_utf8 (e->d_name); - int result = ends_with_slow (mb_dname, extension); - free (mb_dname); - return result; -#endif } void diff --git a/src/monodroid/jni/basic-utilities.hh b/src/monodroid/jni/basic-utilities.hh index d7b67d83014..b84507768ac 100644 --- a/src/monodroid/jni/basic-utilities.hh +++ b/src/monodroid/jni/basic-utilities.hh @@ -240,20 +240,7 @@ namespace xamarin::android return ret; } -#if defined (WINDOWS) - /* Those two conversion functions are only properly implemented on Windows - * because that's the only place where they should be useful. - */ - char *utf16_to_utf8 (const wchar_t *widestr) - { - return ::utf16_to_utf8 (widestr); - } - wchar_t *utf8_to_utf16 (const char *mbstr) - { - return ::utf8_to_utf16 (mbstr); - } -#endif // def WINDOWS bool is_path_rooted (const char *path); template @@ -286,11 +273,7 @@ namespace xamarin::android int make_directory (const char *path, [[maybe_unused]] mode_t mode) { -#if WINDOWS - return mkdir (path); -#else return mkdir (path, mode); -#endif } private: diff --git a/src/monodroid/jni/build-info.hh b/src/monodroid/jni/build-info.hh index b91c9e9d0aa..2c903ab92d0 100644 --- a/src/monodroid/jni/build-info.hh +++ b/src/monodroid/jni/build-info.hh @@ -1,9 +1,7 @@ #if !defined (__BUILD_INFO_HH) #define __BUILD_INFO_HH -#if defined (ANDROID) #include -#endif // def ANDROID namespace xamarin::android::internal { diff --git a/src/monodroid/jni/cpp-util.hh b/src/monodroid/jni/cpp-util.hh index eac76f0625e..aadc8d04acb 100644 --- a/src/monodroid/jni/cpp-util.hh +++ b/src/monodroid/jni/cpp-util.hh @@ -9,11 +9,7 @@ #include -#if defined (ANDROID) #include -#else -#include -#endif #include "cppcompat.hh" #include "platform-compat.hh" @@ -25,12 +21,7 @@ do_abort_unless (const char* fmt, ...) va_list ap; va_start (ap, fmt); -#if defined (ANDROID) __android_log_vprint (ANDROID_LOG_FATAL, "monodroid", fmt, ap); -#else // def ANDROID - vfprintf (stderr, fmt, ap); - fprintf (stderr, "\n"); -#endif // ndef ANDROID va_end (ap); xamarin::android::Helpers::abort_application (); @@ -84,26 +75,8 @@ namespace xamarin::android char _elems[Size]{}; }; - // MinGW 9 on the CI build bots has a bug in the gcc compiler which causes builds to fail with: - // - // error G713F753E: ‘constexpr auto xamarin::android::concat_const(const char (&)[Length]...) [with long long unsigned int ...Length = {15, 7, 5}]’ called in a constant expression - // ... - // /usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/include/c++/array:94:12: note: ‘struct std::array’ has no user-provided default constructor - // struct array - // ^~~~~ - // /usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/include/c++/array:110:56: note: and the implicitly-defined constructor does not initialize ‘char std::array::_M_elems [17]’ - // typename _AT_Type::_Type _M_elems; - // ^~~~~~~~ - // - // thus we need to use this workaround here - // -#if defined (__MINGW32__) && __GNUC__ < 10 - template - using char_array = helper_char_array; -#else template using char_array = std::array; -#endif template constexpr auto concat_const (const char (&...parts)[Length]) diff --git a/src/monodroid/jni/cppcompat.hh b/src/monodroid/jni/cppcompat.hh index 1f2c7047b37..50b452fb06b 100644 --- a/src/monodroid/jni/cppcompat.hh +++ b/src/monodroid/jni/cppcompat.hh @@ -6,20 +6,6 @@ #undef HAVE_WORKING_MUTEX -// On desktop builds we can include the actual C++ standard library files which declare type traits -// as well as the `lock_guard` and `mutex` classes. However, some versions of MinGW, even though -// they have the required files, do not declare `mutex` because the `gthreads` feature is not -// enabled. Thus the complicated `#if` below. -#if !defined (ANDROID) && (!defined (WINDOWS) || (defined (WINDOWS) && defined (_GLIBCXX_HAS_GTHREADS))) -#define HAVE_WORKING_MUTEX 1 -#endif - -// We can't use on Android because it requires linking libc++ into the rutime, see below. -#if !defined (ANDROID) -#include -#include // Also declares `lock_guard` even if it doesn't declare `mutex` -#endif - // Android NDK currently provides a build of libc++ which we cannot link into Xamarin.Android runtime because it would // expose libc++ symbols which would conflict with a version of libc++ potentially included in a mixed // native/Xamarin.Android application. @@ -32,7 +18,6 @@ // we can remove this file. namespace std { -#if defined (ANDROID) template class lock_guard { @@ -58,9 +43,7 @@ namespace std private: mutex_type &_mutex; }; -#endif // !def ANDROID -#if !defined (HAVE_WORKING_MUTEX) class mutex { public: @@ -79,7 +62,6 @@ namespace std private: pthread_mutex_t _pmutex = PTHREAD_MUTEX_INITIALIZER; }; -#endif // !def HAVE_WORKING_MUTEX } #endif diff --git a/src/monodroid/jni/cpu-arch-detect.cc b/src/monodroid/jni/cpu-arch-detect.cc index d5d63ebc58e..8418501ece7 100644 --- a/src/monodroid/jni/cpu-arch-detect.cc +++ b/src/monodroid/jni/cpu-arch-detect.cc @@ -1,18 +1,9 @@ #include #include -#if __APPLE__ -#include -#include -#include -#elif _WIN32 -#include -#endif - #include "cpp-util.hh" #include "cpu-arch.hh" -#if __ANDROID__ #define BUF_SIZE 512 #if __arm__ @@ -42,7 +33,6 @@ detect_houdini () return find_in_maps ("libhoudini"); } #endif -#endif // __ANDROID__ static unsigned char is_64_bit () @@ -50,42 +40,6 @@ is_64_bit () return sizeof (char*) == 8; } -static int -get_built_for_cpu_windows ([[maybe_unused]] unsigned short *built_for_cpu) -{ -#if _WIN32 -#if _M_AMD64 || _M_X64 - *built_for_cpu = CPU_KIND_X86_64; -#elif _M_IX86 - *built_for_cpu = CPU_KIND_X86; -#elif _M_ARM - *built_for_cpu = CPU_KIND_ARM; -#else - *built_for_cpu = CPU_KIND_UNKNOWN; -#endif - return 1; -#else - return 0; -#endif -} - -static int -get_built_for_cpu_apple ([[maybe_unused]] unsigned short *built_for_cpu) -{ -#if __APPLE__ -#if __x86_64__ - *built_for_cpu = CPU_KIND_X86_64; -#elif __i386__ - *built_for_cpu = CPU_KIND_X86; -#else - *built_for_cpu = CPU_KIND_UNKNOWN; -#endif - return 1; -#else - return 0; -#endif -} - static int get_built_for_cpu_android ([[maybe_unused]] unsigned short *built_for_cpu) { @@ -111,78 +65,12 @@ get_built_for_cpu_android ([[maybe_unused]] unsigned short *built_for_cpu) static void get_built_for_cpu (unsigned short *built_for_cpu) { - if (get_built_for_cpu_windows (built_for_cpu)) - return; - - if (get_built_for_cpu_apple (built_for_cpu)) - return; - if (get_built_for_cpu_android (built_for_cpu)) return; *built_for_cpu = CPU_KIND_UNKNOWN; } -static int -get_running_on_cpu_windows ([[maybe_unused]] unsigned short *running_on_cpu) -{ -#if _WIN32 - SYSTEM_INFO si; - - GetSystemInfo (&si); - switch (si.wProcessorArchitecture) { - case PROCESSOR_ARCHITECTURE_AMD64: - *running_on_cpu = CPU_KIND_X86_64; - break; - - case PROCESSOR_ARCHITECTURE_ARM: - *running_on_cpu = CPU_KIND_ARM; - break; - - case PROCESSOR_ARCHITECTURE_INTEL: - *running_on_cpu = CPU_KIND_X86; - break; - - default: - *running_on_cpu = CPU_KIND_UNKNOWN; - break; - } - - return 1; -#else - return 0; -#endif -} - -static int -get_running_on_cpu_apple ([[maybe_unused]] unsigned short *running_on_cpu) -{ -#if __APPLE__ - cpu_type_t cputype; - size_t length; - - length = sizeof (cputype); - sysctlbyname ("hw.cputype", &cputype, &length, nullptr, 0); - switch (cputype) { - case CPU_TYPE_X86: - *running_on_cpu = CPU_KIND_X86; - break; - - case CPU_TYPE_X86_64: - *running_on_cpu = CPU_KIND_X86_64; - break; - - default: - *running_on_cpu = CPU_KIND_UNKNOWN; - break; - } - - return 1; -#else - return 0; -#endif -} - static int get_running_on_cpu_android ([[maybe_unused]] unsigned short *running_on_cpu) { @@ -213,12 +101,6 @@ get_running_on_cpu_android ([[maybe_unused]] unsigned short *running_on_cpu) static void get_running_on_cpu (unsigned short *running_on_cpu) { - if (get_running_on_cpu_windows (running_on_cpu)) - return; - - if (get_running_on_cpu_apple (running_on_cpu)) - return; - if (get_running_on_cpu_android (running_on_cpu)) return; diff --git a/src/monodroid/jni/cpu-arch.hh b/src/monodroid/jni/cpu-arch.hh index 527a1e1e29e..29c210d47f4 100644 --- a/src/monodroid/jni/cpu-arch.hh +++ b/src/monodroid/jni/cpu-arch.hh @@ -10,8 +10,5 @@ #define CPU_KIND_X86 ((unsigned short)4) #define CPU_KIND_X86_64 ((unsigned short)5) -#if !defined(NET) -MONO_API -#endif // def NET void _monodroid_detect_cpu_and_architecture (unsigned short *built_for_cpu, unsigned short *running_on_cpu, unsigned char *is64bit); #endif // ndef NET diff --git a/src/monodroid/jni/debug-app-helper.cc b/src/monodroid/jni/debug-app-helper.cc index e79c62b238d..6303d0fe324 100644 --- a/src/monodroid/jni/debug-app-helper.cc +++ b/src/monodroid/jni/debug-app-helper.cc @@ -6,9 +6,7 @@ #include #include #include -#ifdef ANDROID #include -#endif #include "basic-android-system.hh" #include "basic-utilities.hh" @@ -38,23 +36,6 @@ bool maybe_load_library (const char *path); __android_log_vprint ((_level_), (_tag_), (_format_), (_args_)); \ va_end ((_args_)); -#ifndef ANDROID -#define ANDROID_LOG_INFO 1 -#define ANDROID_LOG_WARN 2 -#define ANDROID_LOG_ERROR 3 -#define ANDROID_LOG_FATAL 4 -#define ANDROID_LOG_DEBUG 5 - -static void -__android_log_vprint (int prio, const char* tag, const char* fmt, va_list ap) -{ - printf ("%d [%s] ", prio, tag); - vprintf (fmt, ap); - putchar ('\n'); - fflush (stdout); -} -#endif - static constexpr char TAG[] = "debug-app-helper"; unsigned int log_categories = LOG_DEFAULT | LOG_ASSEMBLY; @@ -95,7 +76,6 @@ Java_mono_android_DebugRuntime_init (JNIEnv *env, [[maybe_unused]] jclass klass, } } -#if defined (ANDROID) static void copy_file_to_internal_location (char *to_dir, char *from_dir, char *file) { @@ -130,12 +110,6 @@ copy_file_to_internal_location (char *to_dir, char *from_dir, char *file) delete[] from_file; delete[] to_file; } -#else /* !defined (ANDROID) */ -static void -copy_file_to_internal_location ([[maybe_unused]] char *to_dir, [[maybe_unused]] char *from_dir, [[maybe_unused]] char* file) -{ -} -#endif /* defined (ANDROID) */ static void copy_native_libraries_to_internal_location () @@ -162,15 +136,8 @@ copy_native_libraries_to_internal_location () while ((e = readdir (dir)) != nullptr) { log_warn (LOG_DEFAULT, "checking file: `%s`", e->d_name); if (utils.monodroid_dirent_hasextension (e, ".so")) { -#if WINDOWS - char *file_name = utils.utf16_to_utf8 (e->d_name); -#else /* def WINDOWS */ char *file_name = e->d_name; -#endif /* ndef WINDOWS */ copy_file_to_internal_location (androidSystem.get_primary_override_dir (), dir_path, file_name); -#if WINDOWS - free (file_name); -#endif /* def WINDOWS */ } } utils.monodroid_closedir (dir); @@ -255,11 +222,6 @@ get_libmonosgen_path () return libmonoso; delete[] libmonoso; -#ifdef WINDOWS - if (runtime_exists (get_libmonoandroid_directory_path (), libmonoso)) - return libmonoso; -#endif - if (runtime_exists (BasicAndroidSystem::SYSTEM_LIB_PATH, libmonoso)) return libmonoso; log_fatal (LOG_DEFAULT, "Cannot find '%s'. Looked in the following locations:", SharedConstants::MONO_SGEN_SO); diff --git a/src/monodroid/jni/debug.cc b/src/monodroid/jni/debug.cc index 3b911106a99..9fd128afa23 100644 --- a/src/monodroid/jni/debug.cc +++ b/src/monodroid/jni/debug.cc @@ -10,14 +10,12 @@ #include #include -#ifndef WINDOWS #include #include #include #include #include #include -#endif #include #include @@ -28,13 +26,7 @@ #include -#ifdef ANDROID #include -#endif - -#if defined (APPLE_OS_X) -#include -#endif // def APPLE_OX_X #include "java-interop-util.h" @@ -140,7 +132,7 @@ Debug::load_profiler_from_handle (void *dso_handle, const char *desc, const char return false; } -#if defined (DEBUG) && !defined (WINDOWS) +#if defined (DEBUG) void Debug::set_debugger_log_level (const char *level) { @@ -528,8 +520,6 @@ Debug::process_cmd (int fd, char *cmd) return false; } -#if !defined (WINDOWS) - void Debug::start_debugging (void) { @@ -585,10 +575,6 @@ Debug::start_profiling () monodroid_profiler_load (androidSystem.get_runtime_libdir (), profiler_description, nullptr); } -#endif // !def WINDOWS - -#ifdef ANDROID -#ifdef DEBUG static const char *soft_breakpoint_kernel_list[] = { "2.6.32.21-g1e30168", nullptr }; @@ -628,18 +614,6 @@ Debug::enable_soft_breakpoints (void) delete[] value; return ret; } -#endif /* DEBUG */ -#else /* !defined (ANDROID) */ -#if defined (DEBUG) && !defined (WINDOWS) -#ifndef enable_soft_breakpoints -[[maybe_unused]] bool -Debug::enable_soft_breakpoints (void) -{ - return false; -} -#endif /* DEBUG */ -#endif // enable_soft_breakpoints -#endif /* defined (ANDROID) */ // TODO: this is less than ideal. We can't use std::function or std::bind beause we // don't have the C++ stdlib on Android (well, we do but including it would make the diff --git a/src/monodroid/jni/debug.hh b/src/monodroid/jni/debug.hh index a5e596e8608..7d2fb7aa51b 100644 --- a/src/monodroid/jni/debug.hh +++ b/src/monodroid/jni/debug.hh @@ -53,7 +53,7 @@ namespace xamarin::android bool load_profiler (void *handle, const char *desc, const char *symbol); bool load_profiler_from_handle (void *dso_handle, const char *desc, const char *name); -#if !defined (WINDOWS) && defined (DEBUG) +#if defined (DEBUG) public: bool enable_soft_breakpoints (); void start_debugging_and_profiling (); diff --git a/src/monodroid/jni/embedded-assemblies-zip.cc b/src/monodroid/jni/embedded-assemblies-zip.cc index f7be28a631e..c6b68efda64 100644 --- a/src/monodroid/jni/embedded-assemblies-zip.cc +++ b/src/monodroid/jni/embedded-assemblies-zip.cc @@ -19,20 +19,12 @@ using namespace xamarin::android::internal; // // warning: conversion from ‘size_t’ {aka ‘long long unsigned int’} to ‘unsigned int’ may change value [-Wconversion] // -#if defined (WINDOWS) -using read_count_type = unsigned int; -#else using read_count_type = size_t; -#endif force_inline bool EmbeddedAssemblies::is_debug_file (dynamic_local_string const& name) noexcept { - return utils.ends_with (name, ".pdb") -#if !defined (NET) - || utils.ends_with (name, ".mdb") -#endif - ; + return utils.ends_with (name, ".pdb"); } force_inline bool @@ -65,7 +57,6 @@ EmbeddedAssemblies::zip_load_entry_common (size_t entry_index, std::vector c continue; } -#if !defined(NET) - if (utils.ends_with (entry_name, ".config")) { - char *assembly_name = strdup (basename (entry_name.get ())); - // Remove '.config' suffix - *strrchr (assembly_name, '.') = '\0'; - - md_mmap_info map_info = md_mmap_apk_file (state.apk_fd, state.data_offset, state.file_size, entry_name.get ()); - mono_register_config_for_assembly (assembly_name, (const char*)map_info.area); - - continue; - } -#endif // ndef NET - if (!utils.ends_with (entry_name, SharedConstants::DLL_EXTENSION)) continue; diff --git a/src/monodroid/jni/embedded-assemblies.cc b/src/monodroid/jni/embedded-assemblies.cc index 82b7607f437..5a3ffb5a608 100644 --- a/src/monodroid/jni/embedded-assemblies.cc +++ b/src/monodroid/jni/embedded-assemblies.cc @@ -1,8 +1,6 @@ #include -#if !defined (__MINGW32__) || (defined (__MINGW32__) && __GNUC__ >= 10) #include -#endif // ndef MINGW32 || def MINGW32 && GNUC >= 10 #include #include #include @@ -84,7 +82,7 @@ EmbeddedAssemblies::set_assembly_data_and_size (uint8_t* source_assembly_data, u force_inline void EmbeddedAssemblies::get_assembly_data (uint8_t *data, uint32_t data_size, [[maybe_unused]] const char *name, uint8_t*& assembly_data, uint32_t& assembly_data_size) noexcept { -#if defined (ANDROID) && defined (HAVE_LZ4) && defined (RELEASE) +#if defined (HAVE_LZ4) && defined (RELEASE) auto header = reinterpret_cast(data); if (header->magic == COMPRESSED_DATA_MAGIC) { if (XA_UNLIKELY (compressed_assemblies.descriptors == nullptr)) { @@ -275,10 +273,6 @@ EmbeddedAssemblies::load_bundled_assembly ( return nullptr; } -#if !defined (NET) - // In dotnet the call is a no-op - mono_config_for_assembly (image); -#endif return a; } @@ -322,7 +316,6 @@ EmbeddedAssemblies::individual_assemblies_open_from_bundles (dynamic_local_strin force_inline const AssemblyStoreHashEntry* EmbeddedAssemblies::find_assembly_store_entry ([[maybe_unused]] hash_t hash, [[maybe_unused]] const AssemblyStoreHashEntry *entries, [[maybe_unused]] size_t entry_count) noexcept { -#if !defined (__MINGW32__) || (defined (__MINGW32__) && __GNUC__ >= 10) hash_t entry_hash; const AssemblyStoreHashEntry *ret = nullptr; @@ -344,7 +337,6 @@ EmbeddedAssemblies::find_assembly_store_entry ([[maybe_unused]] hash_t hash, [[m return ret; } } -#endif // ndef __MINGW32__ || (def __MINGW32__ && __GNUC__ >= 10) return nullptr; } @@ -397,17 +389,6 @@ EmbeddedAssemblies::assembly_store_open_from_bundles (dynamic_local_stringdebug_data_offset != 0) { assembly_runtime_info.debug_info_data = rd.data_start + bba->debug_data_offset; } -#if !defined (NET) - if (bba->config_data_size != 0) { - assembly_runtime_info.config_data = rd.data_start + bba->config_data_offset; - - // Mono takes ownership of the pointers - mono_register_config_for_assembly ( - utils.string_concat (name.get (), ".dll"), - utils.strdup_new (reinterpret_cast(assembly_runtime_info.config_data)) - ); - } -#endif // NET log_debug ( LOG_ASSEMBLY, @@ -452,9 +433,6 @@ EmbeddedAssemblies::assembly_store_open_from_bundles (dynamic_local_string force_inline const Entry* @@ -591,7 +550,7 @@ EmbeddedAssemblies::binary_search (const Key *key, const Entry *base, size_t nme return nullptr; } -#if defined (RELEASE) && defined (ANDROID) +#if defined (RELEASE) force_inline const TypeMapModuleEntry* EmbeddedAssemblies::binary_search (uint32_t key, const TypeMapModuleEntry *arr, uint32_t n) noexcept { @@ -610,9 +569,9 @@ EmbeddedAssemblies::binary_search (uint32_t key, const TypeMapModuleEntry *arr, return arr[right].type_token_id == key ? &arr[right] : nullptr; } -#endif // def RELEASE && def ANDROID +#endif // def RELEASE -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) force_inline int EmbeddedAssemblies::compare_type_name (const char *type_name, const TypeMapEntry *entry) noexcept { @@ -708,14 +667,11 @@ EmbeddedAssemblies::typemap_java_to_managed (hash_t hash, const MonoString *java return nullptr; } -#if defined (NET) // MonoVM in dotnet runtime doesn't use the `domain` parameter passed to `mono_type_get_object` (since AppDomains // are gone in NET 6+), in fact, the function `mono_type_get_object` calls (`mono_type_get_object_checked`) itself // calls `mono_get_root_domain`. Thus, we can save on a one function call here by passing `nullptr` constexpr MonoDomain *domain = nullptr; -#else - MonoDomain *domain = utils.get_current_domain (); -#endif + MonoReflectionType *ret = mono_type_get_object (domain, mono_class_get_type (klass)); if (ret == nullptr) { log_warn (LOG_ASSEMBLY, "typemap: unable to instantiate managed type with token ID %u in assembly '%s', corresponding to Java type '%s'", java_entry->type_token_id, module->assembly_name, to_utf8 (java_type_name).get ()); @@ -759,7 +715,7 @@ EmbeddedAssemblies::typemap_java_to_managed (MonoString *java_type) noexcept return ret; } -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) force_inline const TypeMapEntry* EmbeddedAssemblies::typemap_managed_to_java (const char *managed_type_name) noexcept { @@ -941,7 +897,7 @@ EmbeddedAssemblies::gather_bundled_assemblies_from_apk (const char* apk, monodro zip_load_entries (fd, apk, should_register); } -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) ssize_t EmbeddedAssemblies::do_read (int fd, void *buf, size_t count) { ssize_t ret; @@ -965,14 +921,8 @@ bool EmbeddedAssemblies::typemap_read_header ([[maybe_unused]] int dir_fd, const char *file_type, const char *dir_path, const char *file_path, uint32_t expected_magic, H &header, size_t &file_size, int &fd) { struct stat sbuf; - int res; + int res = fstatat (dir_fd, file_path, &sbuf, 0); -#if __ANDROID_API__ < 21 - std::unique_ptr full_file_path {utils.path_combine (dir_path, file_path)}; - res = stat (full_file_path.get (), &sbuf); -#else - res = fstatat (dir_fd, file_path, &sbuf, 0); -#endif if (res < 0) { log_error (LOG_ASSEMBLY, "typemap: failed to stat %s file '%s/%s': %s", file_type, dir_path, file_path, strerror (errno)); return false; @@ -984,11 +934,7 @@ EmbeddedAssemblies::typemap_read_header ([[maybe_unused]] int dir_fd, const char return false; } -#if __ANDROID_API__ < 21 - fd = open (full_file_path.get (), O_RDONLY); -#else fd = openat (dir_fd, file_path, O_RDONLY); -#endif if (fd < 0) { log_error (LOG_ASSEMBLY, "typemap: failed to open %s file %s/%s for reading: %s", file_type, dir_path, file_path, strerror (errno)); return false; @@ -1189,12 +1135,7 @@ EmbeddedAssemblies::try_load_typemaps_from_directory (const char *path) return; } - int dir_fd; -#if __ANDROID_API__ < 21 - dir_fd = -1; -#else - dir_fd = dirfd (dir); -#endif + int dir_fd = dirfd (dir); constexpr char index_name[] = "typemap.index"; diff --git a/src/monodroid/jni/embedded-assemblies.hh b/src/monodroid/jni/embedded-assemblies.hh index 4b4c3324dae..fc767cc9439 100644 --- a/src/monodroid/jni/embedded-assemblies.hh +++ b/src/monodroid/jni/embedded-assemblies.hh @@ -14,9 +14,7 @@ #include #include -#if defined (NET) #include -#endif #include "strings.hh" #include "xamarin-app.hh" @@ -40,7 +38,7 @@ namespace xamarin::android::internal { struct TypeMappingInfo; #endif -#if defined (RELEASE) && defined (ANDROID) +#if defined (RELEASE) #define STATIC_IN_ANDROID_RELEASE static #else #define STATIC_IN_ANDROID_RELEASE @@ -56,10 +54,7 @@ namespace xamarin::android::internal { template concept LoaderData = requires (T a) { - requires std::same_as -#if defined (NET) - || std::same_as -#endif + requires std::same_as || std::same_as ; }; #else @@ -102,8 +97,7 @@ namespace xamarin::android::internal { static constexpr auto assembly_store_common_file_name = concat_const ("/", assembly_store_prefix, assembly_store_extension); static constexpr auto assembly_store_arch_file_name = concat_const ("/", assembly_store_prefix, ".", SharedConstants::android_abi, assembly_store_extension); - -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) static constexpr char override_typemap_entry_name[] = ".__override__"; #endif @@ -112,20 +106,19 @@ namespace xamarin::android::internal { using monodroid_should_register = bool (*)(const char *filename); public: -#if defined (RELEASE) && defined (ANDROID) +#if defined (RELEASE) EmbeddedAssemblies () noexcept {} -#endif // def RELEASE && def ANDROID +#endif // def RELEASE -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) void try_load_typemaps_from_directory (const char *path); #endif STATIC_IN_ANDROID_RELEASE const char* typemap_managed_to_java (MonoReflectionType *type, const uint8_t *mvid) noexcept; void install_preload_hooks_for_appdomains (); -#if defined (NET) void install_preload_hooks_for_alc (); -#endif // def NET + STATIC_IN_ANDROID_RELEASE MonoReflectionType* typemap_java_to_managed (MonoString *java_type) noexcept; /* returns current number of *all* assemblies found from all invocations */ @@ -148,7 +141,6 @@ namespace xamarin::android::internal { void set_assemblies_prefix (const char *prefix); -#if defined (NET) void get_runtime_config_blob (const char *& area, uint32_t& size) const { area = static_cast(runtime_config_blob_mmap.area); @@ -161,7 +153,6 @@ namespace xamarin::android::internal { { return application_config.have_runtime_config_blob && runtime_config_blob_mmap.area != nullptr; } -#endif bool keep_scanning () const noexcept { @@ -205,7 +196,7 @@ namespace xamarin::android::internal { TLoaderData loader_data, bool ref_only) noexcept; -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) template bool typemap_read_header (int dir_fd, const char *file_type, const char *dir_path, const char *file_path, uint32_t expected_magic, H &header, size_t &file_size, int &fd); std::unique_ptr typemap_load_index (int dir_fd, const char *dir_path, const char *index_path); @@ -214,15 +205,12 @@ namespace xamarin::android::internal { bool typemap_load_file (BinaryTypeMapHeader &header, const char *dir_path, const char *file_path, int file_fd, TypeMap &module); static ssize_t do_read (int fd, void *buf, size_t count); const TypeMapEntry *typemap_managed_to_java (const char *managed_type_name) noexcept; -#endif // DEBUG || !ANDROID +#endif // DEBUG static md_mmap_info md_mmap_apk_file (int fd, uint32_t offset, size_t size, const char* filename); static MonoAssembly* open_from_bundles_full (MonoAssemblyName *aname, char **assemblies_path, void *user_data); -#if defined (NET) static MonoAssembly* open_from_bundles (MonoAssemblyLoadContextGCHandle alc_gchandle, MonoAssemblyName *aname, char **assemblies_path, void *user_data, MonoError *error); -#else // def NET - static MonoAssembly* open_from_bundles_refonly (MonoAssemblyName *aname, char **assemblies_path, void *user_data); -#endif // ndef NET + void set_assembly_data_and_size (uint8_t* source_assembly_data, uint32_t source_assembly_data_size, uint8_t*& dest_assembly_data, uint32_t& dest_assembly_data_size) noexcept; void get_assembly_data (uint8_t *data, uint32_t data_size, const char *name, uint8_t*& assembly_data, uint32_t& assembly_data_size) noexcept; void get_assembly_data (XamarinAndroidBundledAssembly const& e, uint8_t*& assembly_data, uint32_t& assembly_data_size) noexcept; @@ -280,9 +268,7 @@ namespace xamarin::android::internal { { return number_of_mapped_assembly_stores == application_config.number_of_assembly_store_files -#if defined (NET) && ((application_config.have_runtime_config_blob && runtime_config_blob_found) || !application_config.have_runtime_config_blob) -#endif // NET ; } @@ -296,7 +282,7 @@ namespace xamarin::android::internal { template static const Entry* binary_search (const Key *key, const Entry *base, size_t nmemb, size_t extra_size = 0) noexcept; -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) static int compare_type_name (const char *type_name, const TypeMapEntry *entry) noexcept; #else static int compare_mvid (const uint8_t *mvid, const TypeMapModule *module) noexcept; @@ -318,17 +304,15 @@ namespace xamarin::android::internal { size_t bundled_assembly_index = 0; size_t number_of_found_assemblies = 0; -#if defined (DEBUG) || !defined (ANDROID) +#if defined (DEBUG) TypeMappingInfo *java_to_managed_maps; TypeMappingInfo *managed_to_java_maps; TypeMap *type_maps; size_t type_map_count; -#endif // DEBUG || !ANDROID +#endif // DEBUG const char *assemblies_prefix_override = nullptr; -#if defined (NET) md_mmap_info runtime_config_blob_mmap{}; bool runtime_config_blob_found = false; -#endif // def NET uint32_t number_of_mapped_assembly_stores = 0; bool need_to_scan_more_apks = true; @@ -338,8 +322,4 @@ namespace xamarin::android::internal { }; } -#if !defined (NET) -MONO_API int monodroid_embedded_assemblies_set_assemblies_prefix (const char *prefix); -#endif // ndef NET - #endif /* INC_MONODROID_EMBEDDED_ASSEMBLIES_H */ diff --git a/src/monodroid/jni/globals.cc b/src/monodroid/jni/globals.cc index 697ef2d037c..eb1a2c87fe4 100644 --- a/src/monodroid/jni/globals.cc +++ b/src/monodroid/jni/globals.cc @@ -9,7 +9,5 @@ OSBridge osBridge; EmbeddedAssemblies embeddedAssemblies; MonodroidRuntime monodroidRuntime; Timing *timing = nullptr; -#ifndef ANDROID -DesignerAssemblies designerAssemblies; -#endif + Debug debug; diff --git a/src/monodroid/jni/globals.hh b/src/monodroid/jni/globals.hh index e163ffc2e00..17c9034a562 100644 --- a/src/monodroid/jni/globals.hh +++ b/src/monodroid/jni/globals.hh @@ -19,8 +19,4 @@ extern xamarin::android::internal::EmbeddedAssemblies embeddedAssemblies; extern xamarin::android::internal::MonodroidRuntime monodroidRuntime; extern xamarin::android::Timing *timing; -#ifndef ANDROID -extern xamarin::android::internal::DesignerAssemblies designerAssemblies; -#endif - #endif // !__GLOBALS_H diff --git a/src/monodroid/jni/logger.cc b/src/monodroid/jni/logger.cc index 7edd748b424..1f19af64a11 100644 --- a/src/monodroid/jni/logger.cc +++ b/src/monodroid/jni/logger.cc @@ -5,9 +5,7 @@ #include #include -#ifdef ANDROID #include -#endif #include "logger.hh" @@ -51,23 +49,6 @@ static const char* log_names[] = { // ffs(value) returns index of lowest bit set in `value` #define CATEGORY_NAME(value) (value == 0 ? log_names [0] : log_names [ffs (value)]) -#ifndef ANDROID -static void -__android_log_vprint (int prio, const char* tag, const char* fmt, va_list ap) -{ - printf ("%d [%s] ", prio, tag); - vprintf (fmt, ap); - putchar ('\n'); - fflush (stdout); -} - -static void -__android_log_write (int prio, const char* tag, const char* message) -{ - printf ("%d [%s] %s\n", prio, tag, message); -} -#endif - unsigned int log_categories = LOG_NONE; unsigned int log_timing_categories; int gc_spew_enabled; @@ -149,10 +130,6 @@ init_logging_categories (char*& mono_log_mask, char*& mono_log_level) { mono_log_mask = nullptr; mono_log_level = nullptr; - -#if !ANDROID - log_categories = LOG_DEFAULT; -#endif log_timing_categories = LOG_TIMING_DEFAULT; dynamic_local_string value; @@ -269,7 +246,7 @@ init_logging_categories (char*& mono_log_mask, char*& mono_log_level) continue; } -#if !defined (WINDOWS) && defined (DEBUG) +#if defined (DEBUG) constexpr char DEBUGGER_LOG_LEVEL[] = "debugger-log-level="; constexpr size_t DEBUGGER_LOG_LEVEL_LEN = sizeof (DEBUGGER_LOG_LEVEL) - 1; if (param.starts_with (DEBUGGER_LOG_LEVEL)) { diff --git a/src/monodroid/jni/logger.hh b/src/monodroid/jni/logger.hh index 2f65333751f..81951615025 100644 --- a/src/monodroid/jni/logger.hh +++ b/src/monodroid/jni/logger.hh @@ -3,20 +3,6 @@ #include "java-interop-logger.h" -#ifndef ANDROID -typedef enum android_LogPriority { - ANDROID_LOG_UNKNOWN = 0, - ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */ - ANDROID_LOG_VERBOSE, - ANDROID_LOG_DEBUG, - ANDROID_LOG_INFO, - ANDROID_LOG_WARN, - ANDROID_LOG_ERROR, - ANDROID_LOG_FATAL, - ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */ -} android_LogPriority; -#endif - void init_logging_categories (char*& mono_log_mask, char*& mono_log_level); void init_reference_logging (const char *override_dir); diff --git a/src/monodroid/jni/mkbundle-api.h b/src/monodroid/jni/mkbundle-api.h deleted file mode 100644 index 586f5d26273..00000000000 --- a/src/monodroid/jni/mkbundle-api.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __MKBUNDLE_API_H -#define __MKBUNDLE_API_H - -#ifdef __cplusplus -using namespace xamarin::android; -#endif - -typedef struct BundleMonoAPI -{ - void (*mono_register_bundled_assemblies) (const MonoBundledAssembly **assemblies); - void (*mono_register_config_for_assembly) (const char* assembly_name, const char* config_xml); - void (*mono_jit_set_aot_mode) (int mode); - void (*mono_aot_register_module) (void** aot_info); - void (*mono_config_parse_memory) (const char *buffer); - void (*mono_register_machine_config) (const char *config_xml); -} BundleMonoAPI; - -#if ANDROID -#include -#include - -#ifdef __cplusplus -[[maybe_unused]] -#endif -static void -mkbundle_log_error (const char *format, ...) -{ - va_list ap; - - va_start (ap, format); - __android_log_vprint (ANDROID_LOG_ERROR, "mkbundle", format, ap); - va_end (ap); -} -#endif // ANDROID -#endif // __MKBUNDLE_API_H diff --git a/src/monodroid/jni/mono-image-loader.hh b/src/monodroid/jni/mono-image-loader.hh index 87bcbc2ed3a..3a23c077c51 100644 --- a/src/monodroid/jni/mono-image-loader.hh +++ b/src/monodroid/jni/mono-image-loader.hh @@ -6,9 +6,7 @@ #include #include -#if defined (NET) #include -#endif #include #include "platform-compat.hh" @@ -17,7 +15,7 @@ #include "search.hh" #include "strings.hh" -#if defined (RELEASE) && defined (ANDROID) && defined (NET) +#if defined (RELEASE) #define USE_CACHE 1 #endif @@ -52,7 +50,6 @@ namespace xamarin::android::internal { } #endif // def USE_CACHE -#if defined (NET) force_inline static MonoImage* load (dynamic_local_string const& name, MonoAssemblyLoadContextGCHandle alc_gchandle, hash_t name_hash, uint8_t *assembly_data, uint32_t assembly_data_size) noexcept { MonoImageOpenStatus status; @@ -72,7 +69,6 @@ namespace xamarin::android::internal { { return load (name, alc_gchandle, xxhash::hash (name.get (), name.length ()), assembly_data, assembly_data_size); } -#endif // def NET force_inline static MonoImage* load (dynamic_local_string const& name, bool ref_only, hash_t name_hash, uint8_t *assembly_data, uint32_t assembly_data_size) noexcept { @@ -129,7 +125,7 @@ namespace xamarin::android::internal { // support for unloadable Assembly Load Contexts) and the actual write operation to the destination is // atomic assembly_image_cache[index] = image; -#endif // def RELEASE && def ANDROID && def NET +#endif // def USE_CACHE return image; } diff --git a/src/monodroid/jni/monodroid-glue-designer.cc b/src/monodroid/jni/monodroid-glue-designer.cc deleted file mode 100644 index 8e8d6ab4cba..00000000000 --- a/src/monodroid/jni/monodroid-glue-designer.cc +++ /dev/null @@ -1,147 +0,0 @@ -// -// Android designer support code, not used on devices -// -#include "globals.hh" -#include "mono_android_Runtime.h" -#include "monodroid-glue-internal.hh" - -using namespace xamarin::android::internal; - -// DO NOT USE ON NORMAL X.A -// This function only works with the custom TypeManager embedded with the designer process. -force_inline static void -reinitialize_android_runtime_type_manager (JNIEnv *env) -{ - jclass typeManager = env->FindClass ("mono/android/TypeManager"); - env->UnregisterNatives (typeManager); - - jmethodID resetRegistration = env->GetStaticMethodID (typeManager, "resetRegistration", "()V"); - env->CallStaticVoidMethod (typeManager, resetRegistration); - - env->DeleteLocalRef (typeManager); -} - -inline void -MonodroidRuntime::shutdown_android_runtime (MonoDomain *domain) -{ - MonoClass *runtime = get_android_runtime_class (domain); - MonoMethod *method = mono_class_get_method_from_name (runtime, "Exit", 0); - - utils.monodroid_runtime_invoke (domain, method, nullptr, nullptr, nullptr); -} - -inline jint -MonodroidRuntime::Java_mono_android_Runtime_createNewContextWithData (JNIEnv *env, jclass klass, jobjectArray runtimeApksJava, jobjectArray assembliesJava, - jobjectArray assembliesBytes, jobjectArray assembliesPaths, jobject loader, jboolean force_preload_assemblies) -{ - log_info (LOG_DEFAULT, "CREATING NEW CONTEXT"); - reinitialize_android_runtime_type_manager (env); - MonoDomain *root_domain = mono_get_root_domain (); - mono_jit_thread_attach (root_domain); - - jstring_array_wrapper runtimeApks (env, runtimeApksJava); - jstring_array_wrapper assemblies (env, assembliesJava); - jstring_array_wrapper assembliePaths (env, assembliesPaths); - MonoDomain *domain = create_and_initialize_domain (env, klass, runtimeApks, assemblies, assembliesBytes, assembliePaths, loader, /*is_root_domain:*/ false, force_preload_assemblies, /* have_split_apks */ false); - mono_domain_set (domain, FALSE); - int domain_id = mono_domain_get_id (domain); - current_context_id = domain_id; - log_info (LOG_DEFAULT, "Created new context with id %d\n", domain_id); - return domain_id; -} - -inline void -MonodroidRuntime::Java_mono_android_Runtime_switchToContext (JNIEnv *env, jint contextID) -{ - log_info (LOG_DEFAULT, "SWITCHING CONTEXT"); - MonoDomain *domain = mono_domain_get_by_id ((int)contextID); - if (current_context_id != (int)contextID) { - mono_domain_set (domain, TRUE); - // Reinitialize TypeManager so that its JNI handle goes into the right domain - reinitialize_android_runtime_type_manager (env); - } - current_context_id = (int)contextID; -} - -inline void -MonodroidRuntime::Java_mono_android_Runtime_destroyContexts (JNIEnv *env, jintArray array) -{ - MonoDomain *root_domain = mono_get_root_domain (); - mono_jit_thread_attach (root_domain); - current_context_id = -1; - - jint *contextIDs = env->GetIntArrayElements (array, nullptr); - jsize count = env->GetArrayLength (array); - - log_info (LOG_DEFAULT, "Cleaning %d domains", count); - - for (jsize i = 0; i < count; i++) { - int domain_id = contextIDs[i]; - MonoDomain *domain = mono_domain_get_by_id (domain_id); - - if (domain == nullptr) - continue; - log_info (LOG_DEFAULT, "Shutting down domain `%d'", contextIDs[i]); - shutdown_android_runtime (domain); - osBridge.remove_monodroid_domain (domain); - designerAssemblies.clear_for_domain (domain); - } - osBridge.on_destroy_contexts (); - for (jsize i = 0; i < count; i++) { - int domain_id = contextIDs[i]; - MonoDomain *domain = mono_domain_get_by_id (domain_id); - - if (domain == nullptr) - continue; - log_info (LOG_DEFAULT, "Unloading domain `%d'", contextIDs[i]); - mono_domain_unload (domain); - } - env->ReleaseIntArrayElements (array, contextIDs, JNI_ABORT); - - reinitialize_android_runtime_type_manager (env); - - log_info (LOG_DEFAULT, "All domain cleaned up"); -} - -JNIEXPORT jint -JNICALL Java_mono_android_Runtime_createNewContextWithData (JNIEnv *env, jclass klass, jobjectArray runtimeApksJava, jobjectArray assembliesJava, jobjectArray assembliesBytes, jobjectArray assembliesPaths, jobject loader, jboolean force_preload_assemblies) -{ - return monodroidRuntime.Java_mono_android_Runtime_createNewContextWithData ( - env, - klass, - runtimeApksJava, - assembliesJava, - assembliesBytes, - assembliesPaths, - loader, - force_preload_assemblies - ); -} - -/* !DO NOT REMOVE! Used by older versions of the Android Designer (pre-16.4) */ -JNIEXPORT jint -JNICALL Java_mono_android_Runtime_createNewContext (JNIEnv *env, jclass klass, jobjectArray runtimeApksJava, jobjectArray assembliesJava, jobject loader) -{ - return monodroidRuntime.Java_mono_android_Runtime_createNewContextWithData ( - env, - klass, - runtimeApksJava, - assembliesJava, - nullptr, // assembliesBytes - nullptr, // assembliesPaths - loader, - false // force_preload_assemblies - ); -} - -JNIEXPORT void -JNICALL Java_mono_android_Runtime_switchToContext (JNIEnv *env, [[maybe_unused]] jclass klass, jint contextID) -{ - monodroidRuntime.Java_mono_android_Runtime_switchToContext (env, contextID); -} - -JNIEXPORT void -JNICALL Java_mono_android_Runtime_destroyContexts (JNIEnv *env, [[maybe_unused]] jclass klass, jintArray array) -{ - monodroidRuntime.Java_mono_android_Runtime_destroyContexts (env, array); -} diff --git a/src/monodroid/jni/monodroid-glue-internal.hh b/src/monodroid/jni/monodroid-glue-internal.hh index def9a263218..9d4cbeca7cc 100644 --- a/src/monodroid/jni/monodroid-glue-internal.hh +++ b/src/monodroid/jni/monodroid-glue-internal.hh @@ -13,7 +13,6 @@ #include #include -#if defined (NET) // NDEBUG causes robin_map.h not to include which, in turn, prevents indirect inclusion of . // conflicts with our std::mutex definition in cppcompat.hh #if !defined (NDEBUG) @@ -38,16 +37,12 @@ #undef NDEBUG_UNDEFINE #endif -//#include #include #include -#endif -#if defined (NET) // See https://github.com/dotnet/runtime/pull/67024 // See https://github.com/xamarin/xamarin-android/issues/6935 extern mono_bool mono_opt_aot_lazy_assembly_load; -#endif // def NET namespace xamarin::android::internal { @@ -68,7 +63,6 @@ namespace xamarin::android::internal class MonodroidRuntime { -#if defined (NET) using pinvoke_api_map = tsl::robin_map< std::string, void*, @@ -90,11 +84,8 @@ namespace xamarin::android::internal using load_assemblies_context_type = MonoAssemblyLoadContextGCHandle; static constexpr pinvoke_library_map::size_type LIBRARY_MAP_INITIAL_BUCKET_COUNT = 1; -#else // def NET - using load_assemblies_context_type = MonoDomain*; -#endif // ndef NET -#if defined (DEBUG) && !defined (WINDOWS) +#if defined (DEBUG) struct RuntimeOptions { bool debug = false; int loglevel = 0; @@ -135,20 +126,12 @@ namespace xamarin::android::internal bool marshalMethodsEnabled; }; -#if defined (NET) using jnienv_initialize_fn = void (*) (JnienvInitializeArgs*); using jnienv_register_jni_natives_fn = void (*)(const jchar *typeName_ptr, int32_t typeName_len, jclass jniClass, const jchar *methods_ptr, int32_t methods_len); -#endif private: static constexpr char base_apk_name[] = "/base.apk"; static constexpr size_t SMALL_STRING_PARSE_BUFFER_LEN = 50; - static constexpr bool is_running_on_desktop = -#if ANDROID - false; -#else - true; -#endif static constexpr char mono_component_debugger_name[] = "libmono-component-debugger.so"; static constexpr hash_t mono_component_debugger_hash = xxhash::hash (mono_component_debugger_name); @@ -159,16 +142,6 @@ namespace xamarin::android::internal static constexpr char mono_component_diagnostics_tracing_name[] = "libmono-component-diagnostics_tracing.so"; static constexpr hash_t mono_component_diagnostics_tracing_hash = xxhash::hash (mono_component_diagnostics_tracing_name); -#if !defined (NET) -#define MAKE_API_DSO_NAME(_ext_) "libxa-internal-api." # _ext_ -#if defined (WINDOWS) - static constexpr char API_DSO_NAME[] = MAKE_API_DSO_NAME (dll); -#elif defined (APPLE_OS_X) - static constexpr char API_DSO_NAME[] = MAKE_API_DSO_NAME (dylib); -#else // !defined(WINDOWS) && !defined(APPLE_OS_X) - static constexpr char API_DSO_NAME[] = MAKE_API_DSO_NAME (so); -#endif // defined(WINDOWS) -#endif // ndef NET public: static constexpr int XA_LOG_COUNTERS = MONO_COUNTER_JIT | MONO_COUNTER_METADATA | MONO_COUNTER_GC | MONO_COUNTER_GENERICS | MONO_COUNTER_INTERP; @@ -178,13 +151,7 @@ namespace xamarin::android::internal jstring runtimeNativeLibDir, jobjectArray appDirs, jint localDateTimeOffset, jobject loader, jobjectArray assembliesJava, jint apiLevel, jboolean isEmulator, jboolean haveSplitApks); -#if !defined (ANDROID) - jint Java_mono_android_Runtime_createNewContextWithData (JNIEnv *env, jclass klass, jobjectArray runtimeApksJava, jobjectArray assembliesJava, - jobjectArray assembliesBytes, jobjectArray assembliesPaths, jobject loader, jboolean force_preload_assemblies); - void Java_mono_android_Runtime_switchToContext (JNIEnv *env, jint contextID); - void Java_mono_android_Runtime_destroyContexts (JNIEnv *env, jintArray array); - void shutdown_android_runtime (MonoDomain *domain); -#endif + jint Java_JNI_OnLoad (JavaVM *vm, void *reserved); static bool is_startup_in_progress () noexcept @@ -217,52 +184,19 @@ namespace xamarin::android::internal monodroid_gdb_wait = yes_no; } -#if defined (NET) void propagate_uncaught_exception (JNIEnv *env, jobject javaThread, jthrowable javaException); -#else // def NET - void propagate_uncaught_exception (MonoDomain *domain, JNIEnv *env, jobject javaThread, jthrowable javaException); - - FILE *get_counters () const - { - return counters; - } - - // The reason we don't use the C++ overload feature here is that there appears to be an issue in clang++ that - // comes with the Android NDK. The issue is that for calls like: - // - // char *s = "something"; - // dump_counters ("My string: %s", s); - // - // the compiler will resolve the overload taking `va_list` instead of the one with the ellipsis, thus causing - // `vfprintf` to segfault while trying to perform a `strlen` on `args`. - // - // The issue appears to stem from the fact that `va_list` in the NDK is a typedef to `__builtin_va_list` which - // in turn is internally defined by clang to be `char*` - // - // Desktop builds (using both clang++ and g++) do NOT appear to have this issue, so it might be a problem in the - // NDK. More investigation would be required, but for now lets work around the issue by not overloading the - // function - void dump_counters (const char *format, ...); - void dump_counters_v (const char *format, va_list args); -#endif // ndef NET - char* get_java_class_name_for_TypeManager (jclass klass); private: -#if defined (ANDROID) static void mono_log_handler (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data); static void mono_log_standard_streams_handler (const char *str, mono_bool is_stdout); // A reference to unique_ptr is not the best practice ever, but it's faster this way void setup_mono_tracing (std::unique_ptr const& mono_log_mask, bool have_log_assembly, bool have_log_gc); void install_logging_handlers (); -#endif // def ANDROID unsigned int convert_dl_flags (int flags); -#if defined (WINDOWS) || defined (APPLE_OS_X) - static const char* get_my_location (bool remove_file_name = true); -#endif // defined(WINDOWS) || defined(APPLE_OS_X) -#if defined (NET) + static void cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data); static void* load_library_symbol (const char *library_name, const char *symbol_name, void **dso_handle = nullptr) noexcept; static void* load_library_entry (std::string const& library_name, std::string const& entrypoint_name, pinvoke_api_map_ptr api_map) noexcept; @@ -271,41 +205,29 @@ namespace xamarin::android::internal static PinvokeEntry* find_pinvoke_address (hash_t hash, const PinvokeEntry *entries, size_t entry_count) noexcept; static void* handle_other_pinvoke_request (const char *library_name, hash_t library_name_hash, const char *entrypoint_name, hash_t entrypoint_name_hash) noexcept; static void* monodroid_pinvoke_override (const char *library_name, const char *entrypoint_name); -#endif // def NET static void* monodroid_dlopen_ignore_component_or_load (hash_t hash, const char *name, int flags, char **err) noexcept; static void* monodroid_dlopen (const char *name, int flags, char **err) noexcept; static void* monodroid_dlopen (const char *name, int flags, char **err, void *user_data) noexcept; static void* monodroid_dlsym (void *handle, const char *name, char **err, void *user_data); static void* monodroid_dlopen_log_and_return (void *handle, char **err, const char *full_name, bool free_memory, bool need_api_init = false); static DSOCacheEntry* find_dso_cache_entry (hash_t hash) noexcept; -#if !defined (NET) - static void init_internal_api_dso (void *handle); -#endif // ndef NET + int LocalRefsAreIndirect (JNIEnv *env, jclass runtimeClass, int version); void create_xdg_directory (jstring_wrapper& home, size_t home_len, const char *relativePath, size_t relative_path_len, const char *environmentVariableName); void create_xdg_directories_and_environment (jstring_wrapper &homeDir); - void disable_external_signal_handlers (); void lookup_bridge_info (MonoClass *klass, const OSBridge::MonoJavaGCBridgeType *type, OSBridge::MonoJavaGCBridgeInfo *info); -#if defined (NET) void lookup_bridge_info (MonoImage *image, const OSBridge::MonoJavaGCBridgeType *type, OSBridge::MonoJavaGCBridgeInfo *info); -#else // def NET - void lookup_bridge_info (MonoDomain *domain, MonoImage *image, const OSBridge::MonoJavaGCBridgeType *type, OSBridge::MonoJavaGCBridgeInfo *info); -#endif // ndef NET + void load_assembly (MonoDomain *domain, jstring_wrapper &assembly); -#if defined (NET) void load_assembly (MonoAssemblyLoadContextGCHandle alc_handle, jstring_wrapper &assembly); -#endif // ndef NET + void load_assemblies (load_assemblies_context_type ctx, bool preload, jstring_array_wrapper &assemblies); void set_debug_options (); void parse_gdb_options (); void mono_runtime_init (dynamic_local_string& runtime_args); -#if defined (NET) void init_android_runtime (JNIEnv *env, jclass runtimeClass, jobject loader); -#else //def NET - void init_android_runtime (MonoDomain *domain, JNIEnv *env, jclass runtimeClass, jobject loader); - void setup_bundled_app (const char *dso_name); -#endif // ndef NET + void set_environment_variable_for_directory (const char *name, jstring_wrapper &value, bool createDirectory, mode_t mode); void set_environment_variable_for_directory (const char *name, jstring_wrapper &value) @@ -318,18 +240,14 @@ namespace xamarin::android::internal set_environment_variable_for_directory (name, value, false, 0); } -#if defined (NET) static void monodroid_unhandled_exception (MonoObject *java_exception); MonoClass* get_android_runtime_class (); -#else // def NET - MonoClass* get_android_runtime_class (MonoDomain *domain); -#endif - MonoDomain* create_domain (JNIEnv *env, jstring_array_wrapper &runtimeApks, bool is_root_domain, bool have_split_apks); + + MonoDomain* create_domain (jstring_array_wrapper &runtimeApks, bool have_split_apks) noexcept; MonoDomain* create_and_initialize_domain (JNIEnv* env, jclass runtimeClass, jstring_array_wrapper &runtimeApks, jstring_array_wrapper &assemblies, jobjectArray assembliesBytes, jstring_array_wrapper &assembliesPaths, - jobject loader, bool is_root_domain, bool force_preload_assemblies, - bool have_split_apks); + jobject loader, bool have_split_apks) noexcept; void gather_bundled_assemblies (jstring_array_wrapper &runtimeApks, size_t *out_user_assemblies_count, bool have_split_apks); static bool should_register_file (const char *filename); @@ -342,15 +260,14 @@ namespace xamarin::android::internal static void jit_done (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo); static void thread_start (MonoProfiler *prof, uintptr_t tid); static void thread_end (MonoProfiler *prof, uintptr_t tid); -#if !defined (RELEASE) || !defined (ANDROID) +#if !defined (RELEASE) static MonoReflectionType* typemap_java_to_managed (MonoString *java_type_name) noexcept; static const char* typemap_managed_to_java (MonoReflectionType *type, const uint8_t *mvid) noexcept; -#endif // !def RELEASE || !def ANDROID +#endif // !def RELEASE -#if defined (NET) static void monodroid_debugger_unhandled_exception (MonoException *ex); -#if defined (RELEASE) && defined (ANDROID) +#if defined (RELEASE) static const char* get_method_name (uint32_t mono_image_index, uint32_t method_token) noexcept; static const char* get_class_name (uint32_t class_index) noexcept; @@ -358,17 +275,13 @@ namespace xamarin::android::internal static void get_function_pointer (uint32_t mono_image_index, uint32_t class_index, uint32_t method_token, void*& target_ptr) noexcept; static void get_function_pointer_at_startup (uint32_t mono_image_index, uint32_t class_token, uint32_t method_token, void*& target_ptr) noexcept; static void get_function_pointer_at_runtime (uint32_t mono_image_index, uint32_t class_token, uint32_t method_token, void*& target_ptr) noexcept; -#endif // def RELEASE && def ANDROID -#endif // def NET +#endif // def RELEASE #if defined (DEBUG) void set_debug_env_vars (void); - -#if !defined (WINDOWS) bool parse_runtime_args (dynamic_local_string &runtime_args, RuntimeOptions *options); int monodroid_debug_connect (int sock, struct sockaddr_in addr); int monodroid_debug_accept (int sock, struct sockaddr_in addr); -#endif // !WINDOWS #endif // DEBUG #if !defined (RELEASE) @@ -385,9 +298,6 @@ namespace xamarin::android::internal timing_period jit_time; FILE *jit_log; MonoProfilerHandle profiler_handle; -#if !defined (NET) - FILE *counters; -#endif // ndef NET /* * If set, monodroid will spin in a loop until the debugger breaks the wait by @@ -403,10 +313,7 @@ namespace xamarin::android::internal int current_context_id = -1; static bool startup_in_progress; -#if defined (NET) -#if defined (ANDROID) jnienv_register_jni_natives_fn jnienv_register_jni_natives = nullptr; -#endif MonoAssemblyLoadContextGCHandle default_alc = nullptr; static std::mutex pinvoke_map_write_lock; @@ -417,10 +324,6 @@ namespace xamarin::android::internal static void *system_native_library_handle; static void *system_security_cryptography_native_android_library_handle; static void *system_io_compression_native_library_handle; -#else // def NET - static std::mutex api_init_lock; - static void *api_dso_handle; -#endif // !def NET static std::mutex dso_handle_write_lock; }; } diff --git a/src/monodroid/jni/monodroid-glue.cc b/src/monodroid/jni/monodroid-glue.cc index d50c2c73d3a..88f42242e1a 100644 --- a/src/monodroid/jni/monodroid-glue.cc +++ b/src/monodroid/jni/monodroid-glue.cc @@ -9,12 +9,7 @@ #include #include #include -#if !defined (__MINGW32__) || (defined (__MINGW32__) && __GNUC__ >= 10) #include -#endif // ndef MINGW32 || def MINGW32 && GNUC >= 10 -#if defined (APPLE_OS_X) -#include -#endif // def APPLE_OX_X #include #include @@ -34,13 +29,11 @@ #include #include -#if defined (NET) #include -#endif #include "mono_android_Runtime.h" -#if defined (DEBUG) && !defined (WINDOWS) +#if defined (DEBUG) #include #include #include @@ -51,21 +44,8 @@ #include #endif -#if defined (APPLE_OS_X) -#include -#endif // defined(APPLE_OS_X) - -#ifndef WINDOWS #include #include -#else -#include -#include -#include -#include -#include -#include -#endif #include #include @@ -80,20 +60,16 @@ #include "debug.hh" #include "embedded-assemblies.hh" #include "monodroid-glue.hh" -#include "mkbundle-api.h" #include "monodroid-glue-internal.hh" #include "globals.hh" #include "xamarin-app.hh" #include "timing.hh" -#include "xa-internal-api-impl.hh" #include "build-info.hh" #include "monovm-properties.hh" #include "startup-aware-lock.hh" #include "timing-internal.hh" -#ifndef WINDOWS #include "xamarin_getifaddrs.h" -#endif #include "cpp-util.hh" #include "strings.hh" @@ -104,17 +80,6 @@ using namespace microsoft::java_interop; using namespace xamarin::android; using namespace xamarin::android::internal; -// This is below the above because we don't want to modify the header with our internal -// implementation details as it would prevent mkbundle from working -#include "mkbundle-api.h" - -#if !defined (NET) -#include "config.include" -#include "machine.config.include" - -std::mutex MonodroidRuntime::api_init_lock; -void *MonodroidRuntime::api_dso_handle = nullptr; -#else // ndef NET std::mutex MonodroidRuntime::pinvoke_map_write_lock; MonoCoreRuntimeProperties MonodroidRuntime::monovm_core_properties = { @@ -124,119 +89,15 @@ MonoCoreRuntimeProperties MonodroidRuntime::monovm_core_properties = { .pinvoke_override = &MonodroidRuntime::monodroid_pinvoke_override }; -#endif // def NET - std::mutex MonodroidRuntime::dso_handle_write_lock; bool MonodroidRuntime::startup_in_progress = true; -#ifdef WINDOWS -static const char* get_xamarin_android_msbuild_path (void); -const char *BasicAndroidSystem::SYSTEM_LIB_PATH = get_xamarin_android_msbuild_path(); - -/* Set of Windows-specific utility/reimplementation of Unix functions */ - -static char *msbuild_folder_path = nullptr; - -static const char* -get_xamarin_android_msbuild_path (void) -{ - const char *suffix = "MSBuild\\Xamarin\\Android"; - char *base_path = nullptr; - wchar_t *buffer = nullptr; - - if (msbuild_folder_path != nullptr) - return msbuild_folder_path; - - // Get the base path for 'Program Files' on Windows - if (!SUCCEEDED (SHGetKnownFolderPath (FOLDERID_ProgramFilesX86, 0, nullptr, &buffer))) { - if (buffer != nullptr) - CoTaskMemFree (buffer); - // returns current directory if a global one couldn't be found - return "."; - } - - // Compute the final path - base_path = utils.utf16_to_utf8 (buffer); - if (base_path == nullptr) { - log_fatal (LOG_DEFAULT, "Failed to convert UTF-16 to UTF-8 in %s", __PRETTY_FUNCTION__); - Helpers::abort_application (); - } - CoTaskMemFree (buffer); - msbuild_folder_path = utils.path_combine (base_path, suffix); - free (base_path); - - return msbuild_folder_path; -} - -static int -setenv(const char *name, const char *value, int overwrite) -{ - return androidSystem.setenv (name, value, overwrite); -} -#endif // def WINDOWS - -#if !defined (NET) -typedef void* (*mono_mkbundle_init_ptr) (void (*)(const MonoBundledAssembly **), void (*)(const char* assembly_name, const char* config_xml),void (*) (int mode)); -mono_mkbundle_init_ptr mono_mkbundle_init; - -typedef void (*mono_mkbundle_initialize_mono_api_ptr) (const BundleMonoAPI *info); -mono_mkbundle_initialize_mono_api_ptr mono_mkbundle_initialize_mono_api; - -void -MonodroidRuntime::setup_bundled_app (const char *dso_name) -{ - if (!application_config.is_a_bundled_app) - return; - - static unsigned int dlopen_flags = JAVA_INTEROP_LIB_LOAD_LOCALLY; - void *libapp = nullptr; - - if (androidSystem.is_embedded_dso_mode_enabled ()) { - log_info (LOG_DEFAULT, "bundle app: embedded DSO mode"); - libapp = androidSystem.load_dso_from_any_directories (dso_name, dlopen_flags); - } else { - log_info (LOG_DEFAULT, "bundle app: normal mode"); - dynamic_local_string bundle_path; - if (!androidSystem.get_full_dso_path_on_disk (dso_name, bundle_path)) { - log_info (LOG_DEFAULT, "bundle %s not found on filesystem", dso_name); - return; - } - log_info (LOG_BUNDLE, "Attempting to load bundled app from %s", bundle_path.get ()); - libapp = androidSystem.load_dso (bundle_path.get (), dlopen_flags, true); - } - - if (libapp == nullptr) { - log_info (LOG_DEFAULT, "No libapp!"); - if (!androidSystem.is_embedded_dso_mode_enabled ()) { - log_fatal (LOG_BUNDLE, "bundled app initialization error"); - Helpers::abort_application (); - } else { - log_info (LOG_BUNDLE, "bundled app not found in the APK, ignoring."); - return; - } - } - - mono_mkbundle_initialize_mono_api = reinterpret_cast (java_interop_lib_symbol (libapp, "initialize_mono_api", nullptr)); - if (mono_mkbundle_initialize_mono_api == nullptr) - log_error (LOG_BUNDLE, "Missing initialize_mono_api in the application"); - - mono_mkbundle_init = reinterpret_cast (java_interop_lib_symbol (libapp, "mono_mkbundle_init", nullptr)); - if (mono_mkbundle_init == nullptr) - log_error (LOG_BUNDLE, "Missing mono_mkbundle_init in the application"); - log_info (LOG_BUNDLE, "Bundled app loaded: %s", dso_name); -} -#endif - void MonodroidRuntime::thread_start ([[maybe_unused]] MonoProfiler *prof, [[maybe_unused]] uintptr_t tid) { JNIEnv* env; - int r; -#ifdef PLATFORM_ANDROID - r = osBridge.get_jvm ()->AttachCurrentThread (&env, nullptr); -#else // ndef PLATFORM_ANDROID - r = osBridge.get_jvm ()->AttachCurrentThread (reinterpret_cast(&env), nullptr); -#endif // ndef PLATFORM_ANDROID + int r = osBridge.get_jvm ()->AttachCurrentThread (&env, nullptr); + if (r != JNI_OK) { #if DEBUG log_fatal (LOG_DEFAULT, "ERROR: Unable to attach current thread to the Java VM!"); @@ -298,21 +159,6 @@ MonoAssembly* MonodroidRuntime::open_from_update_dir (MonoAssemblyName *aname, [[maybe_unused]] char **assemblies_path, [[maybe_unused]] void *user_data) { MonoAssembly *result = nullptr; - -#ifndef ANDROID - // First check if there are any in-memory assemblies - if (designerAssemblies.has_assemblies ()) { - MonoDomain *domain = mono_domain_get (); - result = designerAssemblies.try_load_assembly (domain, aname); - if (result != nullptr) { - log_debug (LOG_ASSEMBLY, "Loaded assembly %s from memory in domain %d", mono_assembly_name_get_name (aname), mono_domain_get_id (domain)); - return result; - } - log_debug (LOG_ASSEMBLY, "No in-memory data found for assembly %s", mono_assembly_name_get_name (aname)); - } else { - log_debug (LOG_ASSEMBLY, "No in-memory assemblies detected", mono_assembly_name_get_name (aname)); - } -#endif const char *override_dir; bool found = false; @@ -409,7 +255,7 @@ MonodroidRuntime::should_register_file ([[maybe_unused]] const char *filename) inline void MonodroidRuntime::gather_bundled_assemblies (jstring_array_wrapper &runtimeApks, size_t *out_user_assemblies_count, bool have_split_apks) { -#if defined(DEBUG) || !defined (ANDROID) +#if defined(DEBUG) if (application_config.instant_run_enabled) { for (size_t i = 0; i < AndroidSystem::MAX_OVERRIDES; ++i) { const char *p = androidSystem.get_override_dir (i); @@ -456,7 +302,7 @@ MonodroidRuntime::gather_bundled_assemblies (jstring_array_wrapper &runtimeApks, embeddedAssemblies.ensure_valid_assembly_stores (); } -#if defined (DEBUG) && !defined (WINDOWS) +#if defined (DEBUG) int MonodroidRuntime::monodroid_debug_connect (int sock, struct sockaddr_in addr) { @@ -578,7 +424,7 @@ MonodroidRuntime::parse_gdb_options () } } -#if defined (DEBUG) && !defined (WINDOWS) +#if defined (DEBUG) bool MonodroidRuntime::parse_runtime_args (dynamic_local_string &runtime_args, RuntimeOptions *options) { @@ -697,7 +543,7 @@ MonodroidRuntime::set_debug_options (void) void MonodroidRuntime::mono_runtime_init ([[maybe_unused]] dynamic_local_string& runtime_args) { -#if defined (DEBUG) && !defined (WINDOWS) +#if defined (DEBUG) RuntimeOptions options{}; int64_t cur_time; @@ -854,24 +700,6 @@ MonodroidRuntime::mono_runtime_init ([[maybe_unused]] dynamic_local_string(mono_jit_set_aot_mode), - .mono_aot_register_module = mono_aot_register_module, - .mono_config_parse_memory = mono_config_parse_memory, - .mono_register_machine_config = reinterpret_cast(mono_register_machine_config), - }; - - /* The initialization function copies the struct */ - mono_mkbundle_initialize_mono_api (&bundle_mono_api); - } - - if (mono_mkbundle_init) - mono_mkbundle_init (mono_register_bundled_assemblies, mono_register_config_for_assembly, reinterpret_cast(mono_jit_set_aot_mode)); -#endif // ndef NET /* * Assembly preload hooks are invoked in _reverse_ registration order. * Looking for assemblies from the update dir takes precedence over @@ -882,12 +710,11 @@ MonodroidRuntime::mono_runtime_init ([[maybe_unused]] dynamic_local_string(const_cast(args->runtimeconfig.data.data)), args->runtimeconfig.data.data_len); -#endif // ndef WINDOWS } -#endif // def NET MonoDomain* -MonodroidRuntime::create_domain (JNIEnv *env, jstring_array_wrapper &runtimeApks, bool is_root_domain, bool have_split_apks) +MonodroidRuntime::create_domain (jstring_array_wrapper &runtimeApks, bool have_split_apks) noexcept { size_t user_assemblies_count = 0; -#if defined (NET) - constexpr bool have_mono_mkbundle_init = false; -#else // def NET - bool have_mono_mkbundle_init = mono_mkbundle_init != nullptr; -#endif // ndef NET gather_bundled_assemblies (runtimeApks, &user_assemblies_count, have_split_apks); -#if defined (NET) size_t blob_time_index; if (XA_UNLIKELY (FastTiming::enabled ())) { blob_time_index = internal_timing->start_event (TimingEventKind::RuntimeConfigBlob); @@ -928,9 +746,8 @@ MonodroidRuntime::create_domain (JNIEnv *env, jstring_array_wrapper &runtimeApks if (XA_UNLIKELY (FastTiming::enabled ())) { internal_timing->end_event (blob_time_index); } -#endif // def NET - if (!have_mono_mkbundle_init && user_assemblies_count == 0 && androidSystem.count_override_assemblies () == 0 && !is_running_on_desktop) { + if (user_assemblies_count == 0 && androidSystem.count_override_assemblies () == 0) { #if defined (DEBUG) log_fatal (LOG_DEFAULT, "No assemblies found in '%s' or '%s'. Assuming this is part of Fast Deployment. Exiting...", androidSystem.get_override_dir (0), @@ -944,52 +761,7 @@ MonodroidRuntime::create_domain (JNIEnv *env, jstring_array_wrapper &runtimeApks Helpers::abort_application (); } - MonoDomain *domain; -#if !defined (NET) - if (is_root_domain) { -#endif // ndef NET - domain = mono_jit_init_version (const_cast ("RootDomain"), const_cast ("mobile")); -#if !defined (NET) - } else { - MonoDomain* root_domain = mono_get_root_domain (); - - constexpr char DOMAIN_NAME[] = "MonoAndroidDomain"; - constexpr size_t DOMAIN_NAME_LENGTH = sizeof(DOMAIN_NAME) - 1; - constexpr size_t DOMAIN_NAME_TOTAL_SIZE = DOMAIN_NAME_LENGTH + SharedConstants::MAX_INTEGER_DIGIT_COUNT_BASE10; - - static_local_string domain_name (DOMAIN_NAME_TOTAL_SIZE); - domain_name.append (DOMAIN_NAME); - domain_name.append (android_api_level); - - domain = utils.monodroid_create_appdomain (root_domain, domain_name.get (), /*shadow_copy:*/ 1, /*shadow_directory:*/ androidSystem.get_override_dir (0)); - } -#endif // ndef NET - - if constexpr (is_running_on_desktop) { - if (is_root_domain) { - c_unique_ptr corlib_error_message_guard {const_cast(mono_check_corlib_version ())}; - char *corlib_error_message = corlib_error_message_guard.get (); - - if (corlib_error_message == nullptr) { - if (!androidSystem.monodroid_get_system_property ("xamarin.studio.fakefaultycorliberrormessage", &corlib_error_message)) { - corlib_error_message = nullptr; - } - } - if (corlib_error_message != nullptr) { - jclass ex_klass = env->FindClass ("mono/android/MonoRuntimeException"); - env->ThrowNew (ex_klass, corlib_error_message); - return nullptr; - } - - // Load a basic environment for the RootDomain if run on desktop so that we can unload - // and reload most assemblies including Mono.Android itself - MonoAssemblyName *aname = mono_assembly_name_new ("System"); - mono_assembly_load_full (aname, nullptr, nullptr, 0); - mono_assembly_name_free (aname); - } - } - - return domain; + return mono_jit_init_version (const_cast ("RootDomain"), const_cast ("mobile")); } inline int @@ -1027,7 +799,6 @@ MonodroidRuntime::lookup_bridge_info (MonoClass *klass, const OSBridge::MonoJava } } -#if defined (NET) force_inline void MonodroidRuntime::lookup_bridge_info (MonoImage *image, const OSBridge::MonoJavaGCBridgeType *type, OSBridge::MonoJavaGCBridgeInfo *info) { @@ -1037,37 +808,20 @@ MonodroidRuntime::lookup_bridge_info (MonoImage *image, const OSBridge::MonoJava info ); } -#else // def NET -force_inline void -MonodroidRuntime::lookup_bridge_info (MonoDomain *domain, MonoImage *image, const OSBridge::MonoJavaGCBridgeType *type, OSBridge::MonoJavaGCBridgeInfo *info) -{ - lookup_bridge_info ( - utils.monodroid_get_class_from_image (domain, image, type->_namespace, type->_typename), - type, - info - ); -} -#endif // ndef NET -#if defined (NET) void MonodroidRuntime::monodroid_debugger_unhandled_exception (MonoException *ex) { mono_debugger_agent_unhandled_exception (ex); } -#endif void -MonodroidRuntime::init_android_runtime ( -#if !defined (NET) - MonoDomain *domain, -#endif // ndef NET - JNIEnv *env, jclass runtimeClass, jobject loader) +MonodroidRuntime::init_android_runtime (JNIEnv *env, jclass runtimeClass, jobject loader) { constexpr char icall_typemap_java_to_managed[] = "Java.Interop.TypeManager::monodroid_typemap_java_to_managed"; constexpr char icall_typemap_managed_to_java[] = "Android.Runtime.JNIEnv::monodroid_typemap_managed_to_java"; -#if defined (RELEASE) && defined (ANDROID) +#if defined (RELEASE) // The reason for these using is that otherwise the compiler will complain about not being // able to cast overloaded methods to const void* pointers. using j2mFn = MonoReflectionType* (*)(MonoString *java_type); @@ -1078,12 +832,10 @@ MonodroidRuntime::init_android_runtime ( #else mono_add_internal_call (icall_typemap_java_to_managed, reinterpret_cast(typemap_java_to_managed)); mono_add_internal_call (icall_typemap_managed_to_java, reinterpret_cast(typemap_managed_to_java)); -#endif // def RELEASE && def ANDROID +#endif // def RELEASE -#if defined (NET) mono_add_internal_call ("Android.Runtime.RuntimeNativeMethods::monodroid_debugger_unhandled_exception", reinterpret_cast (monodroid_debugger_unhandled_exception)); mono_add_internal_call ("Android.Runtime.RuntimeNativeMethods::monodroid_unhandled_exception", reinterpret_cast(monodroid_unhandled_exception)); -#endif // def NET struct JnienvInitializeArgs init = {}; init.javaVm = osBridge.get_jvm (); @@ -1092,7 +844,7 @@ MonodroidRuntime::init_android_runtime ( init.version = env->GetVersion (); init.androidSdkVersion = android_api_level; init.localRefsAreIndirect = LocalRefsAreIndirect (env, runtimeClass, init.androidSdkVersion); - init.isRunningOnDesktop = is_running_on_desktop ? 1 : 0; + init.isRunningOnDesktop = 0; init.brokenExceptionTransitions = application_config.broken_exception_transitions ? 1 : 0; init.packageNamingPolicy = static_cast(application_config.package_naming_policy); init.boundExceptionType = application_config.bound_exception_type; @@ -1109,58 +861,28 @@ MonodroidRuntime::init_android_runtime ( Class_getName = env->GetMethodID (init.grefClass, "getName", "()Ljava/lang/String;"); init.Class_forName = env->GetStaticMethodID (init.grefClass, "forName", "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;"); - MonoAssembly *mono_android_assembly; - -#if defined (NET) - mono_android_assembly = utils.monodroid_load_assembly (default_alc, SharedConstants::MONO_ANDROID_ASSEMBLY_NAME); -#else // def NET - mono_android_assembly = utils.monodroid_load_assembly (domain, SharedConstants::MONO_ANDROID_ASSEMBLY_NAME); -#endif // ndef NET + MonoAssembly *mono_android_assembly = utils.monodroid_load_assembly (default_alc, SharedConstants::MONO_ANDROID_ASSEMBLY_NAME); MonoImage *mono_android_assembly_image = mono_assembly_get_image (mono_android_assembly); uint32_t i = 0; for ( ; i < OSBridge::NUM_XA_GC_BRIDGE_TYPES; ++i) { lookup_bridge_info ( -#if !defined (NET) - domain, -#endif // ndef NET mono_android_assembly_image, &osBridge.get_java_gc_bridge_type (i), &osBridge.get_java_gc_bridge_info (i) ); } - MonoClass *runtime; - MonoMethod *method; - - if constexpr (is_running_on_desktop) { -#if defined (NET) - runtime = mono_class_from_name (mono_android_assembly_image, SharedConstants::ANDROID_RUNTIME_NS_NAME, SharedConstants::JNIENVINIT_CLASS_NAME); -#else - runtime = utils.monodroid_get_class_from_image (domain, mono_android_assembly_image, SharedConstants::ANDROID_RUNTIME_NS_NAME, SharedConstants::JNIENVINIT_CLASS_NAME); -#endif // def NET - method = mono_class_get_method_from_name (runtime, "Initialize", 1); - } else { - runtime = mono_class_get (mono_android_assembly_image, application_config.android_runtime_jnienv_class_token); - method = mono_get_method (mono_android_assembly_image, application_config.jnienv_initialize_method_token, runtime); - } + MonoClass *runtime = mono_class_get (mono_android_assembly_image, application_config.android_runtime_jnienv_class_token); + MonoMethod *method = mono_get_method (mono_android_assembly_image, application_config.jnienv_initialize_method_token, runtime);; abort_unless (runtime != nullptr, "INTERNAL ERROR: unable to find the Android.Runtime.JNIEnvInit class!"); abort_unless (method != nullptr, "INTERNAL ERROR: Unable to find the Android.Runtime.JNIEnvInit.Initialize method!"); - MonoAssembly *ji_assm; -#if defined (NET) - ji_assm = utils.monodroid_load_assembly (default_alc, SharedConstants::JAVA_INTEROP_ASSEMBLY_NAME); -#else // def NET - ji_assm = utils.monodroid_load_assembly (domain, SharedConstants::JAVA_INTEROP_ASSEMBLY_NAME); -#endif // ndef NET - - MonoImage *ji_image = mono_assembly_get_image (ji_assm); + MonoAssembly *ji_assm = utils.monodroid_load_assembly (default_alc, SharedConstants::JAVA_INTEROP_ASSEMBLY_NAME); + MonoImage *ji_image = mono_assembly_get_image (ji_assm); for ( ; i < OSBridge::NUM_XA_GC_BRIDGE_TYPES + OSBridge::NUM_JI_GC_BRIDGE_TYPES; ++i) { lookup_bridge_info ( -#if !defined (NET) - domain, -#endif // ndef NET ji_image, &osBridge.get_java_gc_bridge_type (i), &osBridge.get_java_gc_bridge_info (i) @@ -1171,15 +893,9 @@ MonodroidRuntime::init_android_runtime ( /* If running on desktop, we may be swapping in a new Mono.Android image when calling this * so always make sure we have the freshest handle to the method. */ - if (registerType == nullptr || is_running_on_desktop) { - if constexpr (is_running_on_desktop) { - registerType = mono_class_get_method_from_name (runtime, "RegisterJniNatives", 5); - } else { - registerType = mono_get_method (mono_android_assembly_image, application_config.jnienv_registerjninatives_method_token, runtime); -#if defined (NET) && defined (ANDROID) - jnienv_register_jni_natives = reinterpret_cast(mono_method_get_unmanaged_callers_only_ftnptr (registerType, &error)); -#endif // def NET && def ANDROID - } + if (registerType == nullptr) { + registerType = mono_get_method (mono_android_assembly_image, application_config.jnienv_registerjninatives_method_token, runtime); + jnienv_register_jni_natives = reinterpret_cast(mono_method_get_unmanaged_callers_only_ftnptr (registerType, &error)); } abort_unless (registerType != nullptr, "INTERNAL ERROR: Unable to find Android.Runtime.JNIEnvInit.RegisterJniNatives! %s", mono_error_get_message (&error)); @@ -1199,7 +915,6 @@ MonodroidRuntime::init_android_runtime ( native_to_managed_index = internal_timing->start_event (TimingEventKind::NativeToManagedTransition); } -#if defined (NET) && defined (ANDROID) auto initialize = reinterpret_cast (mono_method_get_unmanaged_callers_only_ftnptr (method, &error)); if (initialize == nullptr) { log_fatal (LOG_DEFAULT, "Failed to get pointer to Initialize. Mono error: %s", mono_error_get_message (&error)); @@ -1211,20 +926,12 @@ MonodroidRuntime::init_android_runtime ( mono_error_get_message (&error) ); initialize (&init); -#else // def NET && def ANDROID - void *args [] = { - &init, - }; - - utils.monodroid_runtime_invoke (domain, method, nullptr, args, nullptr); -#endif // ndef NET && ndef ANDROID if (XA_UNLIKELY (FastTiming::enabled ())) { internal_timing->end_event (native_to_managed_index); } } -#if defined (NET) MonoClass* MonodroidRuntime::get_android_runtime_class () { @@ -1232,29 +939,11 @@ MonodroidRuntime::get_android_runtime_class () MonoImage *image = mono_assembly_get_image (assm); return mono_class_from_name (image, SharedConstants::ANDROID_RUNTIME_NS_NAME, SharedConstants::JNIENV_CLASS_NAME); } -#else // def NET -MonoClass* -MonodroidRuntime::get_android_runtime_class (MonoDomain *domain) -{ - MonoAssembly *assm = utils.monodroid_load_assembly (domain, SharedConstants::MONO_ANDROID_ASSEMBLY_NAME); - MonoImage *image = mono_assembly_get_image (assm); - return utils.monodroid_get_class_from_image (domain, image, SharedConstants::ANDROID_RUNTIME_NS_NAME, SharedConstants::JNIENV_CLASS_NAME); -} -#endif // ndef NET inline void -MonodroidRuntime::propagate_uncaught_exception ( -#if !defined (NET) - MonoDomain *domain, -#endif // ndef NET - JNIEnv *env, jobject javaThread, jthrowable javaException) +MonodroidRuntime::propagate_uncaught_exception (JNIEnv *env, jobject javaThread, jthrowable javaException) { - MonoClass *runtime; -#if defined (NET) - runtime = get_android_runtime_class (); -#else - runtime = get_android_runtime_class (domain); -#endif + MonoClass *runtime = get_android_runtime_class (); MonoMethod *method = mono_class_get_method_from_name (runtime, "PropagateUncaughtException", 3); void* args[] = { @@ -1262,11 +951,7 @@ MonodroidRuntime::propagate_uncaught_exception ( &javaThread, &javaException, }; -#if defined (NET) mono_runtime_invoke (method, nullptr, args, nullptr); -#else // def NET - utils.monodroid_runtime_invoke (domain, method, nullptr, args, nullptr); -#endif // ndef NET } #if DEBUG @@ -1289,60 +974,9 @@ MonodroidRuntime::convert_dl_flags (int flags) return lflags; } -#if !defined (NET) -force_inline void -MonodroidRuntime::init_internal_api_dso (void *handle) -{ - if (handle == nullptr) { - log_fatal (LOG_DEFAULT, "Internal API library is required"); - Helpers::abort_application (); - } - - // There's a very, very small chance of a race condition here, but it should be acceptable and we can save some time - // by not acquiring the lock on Android systems which don't have the dlopen bug we worked around in - // https://github.com/xamarin/xamarin-android/pull/4914 - // - // The race condition will exist only on systems with the above dynamic loader bug and would become a problem only - // if an application were loading managed assemblies with p/invokes very quickly from different threads. All in all, - // not a very likely scenario. - // - if (handle == api_dso_handle) { - log_debug (LOG_DEFAULT, "Internal API library already loaded, initialization not necessary"); - return; - } - - std::lock_guard lock (api_init_lock); - if (api_dso_handle != nullptr) { - auto api_shutdown = reinterpret_cast (java_interop_lib_symbol (api_dso_handle, MonoAndroidInternalCalls::SHUTDOWN_FUNCTION_NAME, nullptr)); - if (api_shutdown == nullptr) { - // We COULD ignore this situation, but if the function is missing it means we messed something up and thus - // it *is* a fatal error. - log_fatal (LOG_DEFAULT, "Unable to properly close Internal API library, shutdown function '%s' not found in the module", MonoAndroidInternalCalls::SHUTDOWN_FUNCTION_NAME); - Helpers::abort_application (); - } - api_shutdown (); - } - - api_dso_handle = handle; - auto api = new MonoAndroidInternalCalls_Impl (); - auto api_init = reinterpret_cast(java_interop_lib_symbol (handle, MonoAndroidInternalCalls::INIT_FUNCTION_NAME, nullptr)); - if (api_init == nullptr) { - log_fatal (LOG_DEFAULT, "Unable to initialize Internal API library, init function '%s' not found in the module", MonoAndroidInternalCalls::INIT_FUNCTION_NAME); - Helpers::abort_application (); - } - - log_debug (LOG_DEFAULT, "Initializing Internal API library %p", handle); - if (!api_init (api)) { - log_fatal (LOG_DEFAULT, "Failed to initialize Internal API library"); - Helpers::abort_application (); - } -} -#endif // ndef NET - force_inline DSOCacheEntry* MonodroidRuntime::find_dso_cache_entry ([[maybe_unused]] hash_t hash) noexcept { -#if !defined (__MINGW32__) || (defined (__MINGW32__) && __GNUC__ >= 10) hash_t entry_hash; DSOCacheEntry *ret = nullptr; size_t entry_count = application_config.number_of_dso_cache_entries; @@ -1362,7 +996,6 @@ MonodroidRuntime::find_dso_cache_entry ([[maybe_unused]] hash_t hash) noexcept return ret; } } -#endif // ndef MINGW32 || def MINGW32 && GNUC >= 10 return nullptr; } @@ -1377,19 +1010,12 @@ MonodroidRuntime::monodroid_dlopen_log_and_return (void *handle, char **err, con delete[] full_name; } -#if !defined (NET) - if (!need_api_init) - return handle; - init_internal_api_dso (handle); -#endif // ndef NET - return handle; } force_inline void* MonodroidRuntime::monodroid_dlopen_ignore_component_or_load ([[maybe_unused]] hash_t name_hash, const char *name, int flags, char **err) noexcept { -#if defined (NET) if (startup_in_progress) { auto ignore_component = [&](const char *label, MonoComponent component) -> bool { if ((application_config.mono_components_mask & component) != component) { @@ -1420,7 +1046,7 @@ MonodroidRuntime::monodroid_dlopen_ignore_component_or_load ([[maybe_unused]] ha break; } } -#endif + unsigned int dl_flags = monodroidRuntime.convert_dl_flags (flags); void * handle = androidSystem.load_dso_from_any_directories (name, dl_flags); if (handle != nullptr) { @@ -1466,117 +1092,12 @@ MonodroidRuntime::monodroid_dlopen (const char *name, int flags, char **err) noe void* MonodroidRuntime::monodroid_dlopen (const char *name, int flags, char **err, [[maybe_unused]] void *user_data) noexcept { - void *h = nullptr; - -#if defined (NET) if (name == nullptr) { log_warn (LOG_ASSEMBLY, "monodroid_dlopen got a null name. This is not supported in NET+"); return nullptr; } -#else // def NET - unsigned int dl_flags = monodroidRuntime.convert_dl_flags (flags); - - bool libmonodroid_fallback = false; - bool name_is_full_path = false; - bool name_needs_free = false; - /* name is nullptr when we're P/Invoking __Internal, so remap to libxa-internal-api */ - if (name == nullptr || strstr (name, "xa-internal-api") != nullptr) { -#if defined (WINDOWS) - char *tmp_name = nullptr; - - auto probe_dll_at = [&](const char *the_path) -> bool { - if (the_path == nullptr) { - return false; - } - - const char *last_sep = strrchr (the_path, MONODROID_PATH_SEPARATOR_CHAR); - if (last_sep != nullptr) { - char *dir = utils.strdup_new (the_path, last_sep - the_path); - if (dir == nullptr) { - return false; - } - - tmp_name = utils.string_concat (dir, MONODROID_PATH_SEPARATOR, API_DSO_NAME); - delete[] dir; - if (!utils.file_exists (tmp_name)) { - delete[] tmp_name; - tmp_name = nullptr; - return false; - } - - return true; - } - - return false; - }; - - // - // First try to see if it exists at the path pointed to by `name`. With p/invokes, currently (Sep 2020), we can't - // really trust the path since it consists of *some* directory path + p/invoke library name and it does not - // point to the location where the native library is. However, we still need to check the location first, should - // it point to the right place in the future. - // - // Context: https://github.com/mono/mono/issues/20295#issuecomment-679271621 - // - bool found = probe_dll_at (name); - if (!found) { - // Next lets try the location of the XA runtime DLL, libxa-internal-api.dll should be next to it. - const char *path = get_my_location (false); - found = probe_dll_at (path); // lgtm [cpp/unguardednullreturndereference] probe_dll_at checks whether the passed pointer is nullptr - if (path != nullptr) { - free (reinterpret_cast(const_cast(path))); - } - - if (!found) { - log_warn (LOG_DEFAULT, "Failed to locate %s, using file name without the path", API_DSO_NAME); - name = API_DSO_NAME; - } else { - name = tmp_name; - name_is_full_path = true; - name_needs_free = true; - } - } -#else // ndef WINDOWS - name = API_DSO_NAME; -#endif // WINDOWS - libmonodroid_fallback = true; - } - if (!name_is_full_path) { - // h = androidSystem.load_dso_from_any_directories (name, dl_flags); - h = monodroid_dlopen (name, flags, err); - if (h != nullptr) { - return h; // already logged by monodroid_dlopen - } - } - - if (h != nullptr) { - return monodroid_dlopen_log_and_return (h, err, name, name_needs_free, libmonodroid_fallback); - } - - if (libmonodroid_fallback) { - const char *full_name; - if (name_is_full_path) { - full_name = name; - } else { - if (name_needs_free) { - delete[] name; - } - full_name = utils.path_combine (AndroidSystem::SYSTEM_LIB_PATH, API_DSO_NAME); - name_needs_free = true; - } - h = androidSystem.load_dso (full_name, dl_flags, false); - return monodroid_dlopen_log_and_return (h, err, full_name, name_needs_free, true); - } -#endif // ndef NET - - h = monodroid_dlopen (name, flags, err); -#if !defined (NET) - if (name_needs_free) { - delete[] name; - } -#endif // ndef NET - return h; + return monodroid_dlopen (name, flags, err); } void* @@ -1688,7 +1209,6 @@ MonodroidRuntime::set_trace_options (void) mono_jit_set_trace_options (value.get ()); } -#if defined (NET) inline void MonodroidRuntime::set_profile_options () { @@ -1751,133 +1271,7 @@ MonodroidRuntime::set_profile_options () log_warn (LOG_DEFAULT, "Initializing profiler with options: %s", value.get ()); debug.monodroid_profiler_load (androidSystem.get_runtime_libdir (), value.get (), output_path.get ()); } -#else // def NET -inline void -MonodroidRuntime::set_profile_options () -{ - // We want to avoid dynamic allocation, thus let’s create a buffer that can take both the property value and a - // path without allocation - dynamic_local_string value; - { - dynamic_local_string prop_value; - if (androidSystem.monodroid_get_system_property (Debug::DEBUG_MONO_PROFILE_PROPERTY, prop_value) == 0) - return; - - value.assign (prop_value.get (), prop_value.length ()); - } - - constexpr char OUTPUT_ARG[] = "output="; - constexpr size_t OUTPUT_ARG_LEN = sizeof(OUTPUT_ARG) - 1; - - ssize_t colon_idx = value.index_of (':'); - size_t start_index = colon_idx < 0 ? 0 : static_cast(colon_idx + 1); - dynamic_local_string output_path; - bool have_output_arg = false; - string_segment param; - - while (value.next_token (start_index, ',', param)) { - dynamic_local_string temp; - temp.assign (param.start (), param.length ()); - if (!param.starts_with (OUTPUT_ARG) || param.length () == OUTPUT_ARG_LEN) { - continue; - } - - output_path.assign (param.start () + OUTPUT_ARG_LEN, param.length () - OUTPUT_ARG_LEN); - have_output_arg = true; - break; - } - - if (!have_output_arg) { - constexpr char MLPD_EXT[] = "mlpd"; - constexpr char AOT_EXT[] = "aotprofile"; - constexpr char COV_EXT[] = "xml"; - constexpr char LOG_PREFIX[] = "log:"; - constexpr size_t LOG_PREFIX_LENGTH = sizeof(LOG_PREFIX) - 1; - constexpr char AOT_PREFIX[] = "aot:"; - constexpr size_t AOT_PREFIX_LENGTH = sizeof(AOT_PREFIX) - 1; - constexpr char DEFAULT_PREFIX[] = "default:"; - constexpr size_t DEFAULT_PREFIX_LENGTH = sizeof(DEFAULT_PREFIX) - 1; - constexpr char COVERAGE_PREFIX[] = "coverage:"; - constexpr size_t COVERAGE_PREFIX_LENGTH = sizeof(COVERAGE_PREFIX) - 1; - constexpr char PROFILE_FILE_NAME_PREFIX[] = "profile."; - - size_t length_adjust = colon_idx >= 1 ? 0 : 1; - - output_path - .assign_c (androidSystem.get_override_dir (0)) - .append (MONODROID_PATH_SEPARATOR) - .append (PROFILE_FILE_NAME_PREFIX); - - if (value.starts_with (LOG_PREFIX, LOG_PREFIX_LENGTH - length_adjust)) { - output_path.append (MLPD_EXT); - } else if (value.starts_with (AOT_PREFIX, AOT_PREFIX_LENGTH - length_adjust)) { - output_path.append (AOT_EXT); - } else if (value.starts_with (DEFAULT_PREFIX, DEFAULT_PREFIX_LENGTH - length_adjust)) { - output_path.append (MLPD_EXT); - } else if (value.starts_with (COVERAGE_PREFIX, COVERAGE_PREFIX_LENGTH - length_adjust)) { - output_path.append (COV_EXT); - } else { - size_t len = colon_idx < 0 ? value.length () : static_cast(colon_idx + 1); - output_path.append (value.get (), len); - } - - if (colon_idx < 0) - value.append (":"); - else - value.append (","); - value - .append (OUTPUT_ARG) - .append (output_path.get (), output_path.length ()); - } - - /* - * libmono-profiler-log.so profiler won't overwrite existing files. - * Remove it For Great Justice^H^H^H to preserve my sanity! - */ - unlink (output_path.get ()); - - log_warn (LOG_DEFAULT, "Initializing profiler with options: %s", value.get ()); - debug.monodroid_profiler_load (androidSystem.get_runtime_libdir (), value.get (), output_path.get ()); -} -#endif // ndef NET - -/* -Disable LLVM signal handlers. - -This happens when RenderScript needs to be compiled. See https://bugzilla.xamarin.com/show_bug.cgi?id=18016 - -This happens only on first run of the app. LLVM is used to compiled the RenderScript scripts. LLVM, been -a nice and smart library installs a ton of signal handlers and don't chain at all, completely breaking us. -This is a hack to set llvm::DisablePrettyStackTrace to true and avoid this source of signal handlers. - -As of Android 5.0 (API 21) the symbol no longer exists in libLLVM.so and stack pretty printing is an opt-in -instead of an opt-out feature. LLVM change which removed the symbol is at - -https://github.com/llvm/llvm-project/commit/c10ca903243f97cbc8014f20c64f1318a57a2936 - -*/ -void -MonodroidRuntime::disable_external_signal_handlers (void) -{ -#if !defined (NET) - if (android_api_level >= 21) { - return; - } - - void *llvm = androidSystem.load_dso ("libLLVM.so", JAVA_INTEROP_LIB_LOAD_GLOBALLY, TRUE); - if (llvm) { - bool *disable_signals = reinterpret_cast (java_interop_lib_symbol (llvm, "_ZN4llvm23DisablePrettyStackTraceE", nullptr)); - if (disable_signals) { - *disable_signals = true; - log_info (LOG_DEFAULT, "Disabled LLVM signal trapping"); - } - //MUST NOT dlclose to ensure we don't lose the hack - } -#endif // ndef NET -} - -#if defined (NET) inline void MonodroidRuntime::load_assembly (MonoAssemblyLoadContextGCHandle alc_handle, jstring_wrapper &assembly) { @@ -1910,7 +1304,6 @@ MonodroidRuntime::load_assembly (MonoAssemblyLoadContextGCHandle alc_handle, jst internal_timing->add_more_info (total_time_index, more_info); } } -#endif // NET inline void MonodroidRuntime::load_assembly (MonoDomain *domain, jstring_wrapper &assembly) @@ -1927,21 +1320,13 @@ MonodroidRuntime::load_assembly (MonoDomain *domain, jstring_wrapper &assembly) } MonoAssemblyName *aname = mono_assembly_name_new (assm_name); - -#ifndef ANDROID - if (designerAssemblies.has_assemblies () && designerAssemblies.try_load_assembly (domain, aname) != nullptr) { - log_debug (LOG_ASSEMBLY, "Dynamically opened assembly %s", mono_assembly_name_get_name (aname)); - } else -#endif - { - MonoDomain *current = utils.get_current_domain (); - if (domain != current) { - mono_domain_set (domain, FALSE); - mono_assembly_load_full (aname, NULL, NULL, 0); - mono_domain_set (current, FALSE); - } else { - mono_assembly_load_full (aname, NULL, NULL, 0); - } + MonoDomain *current = utils.get_current_domain (); + if (domain != current) { + mono_domain_set (domain, FALSE); + mono_assembly_load_full (aname, NULL, NULL, 0); + mono_domain_set (current, FALSE); + } else { + mono_assembly_load_full (aname, NULL, NULL, 0); } mono_assembly_name_free (aname); @@ -1993,57 +1378,34 @@ monodroid_Mono_UnhandledException_internal ([[maybe_unused]] MonoException *ex) MonoDomain* MonodroidRuntime::create_and_initialize_domain (JNIEnv* env, jclass runtimeClass, jstring_array_wrapper &runtimeApks, jstring_array_wrapper &assemblies, [[maybe_unused]] jobjectArray assembliesBytes, - [[maybe_unused]] jstring_array_wrapper &assembliesPaths, jobject loader, bool is_root_domain, - bool force_preload_assemblies, bool have_split_apks) + [[maybe_unused]] jstring_array_wrapper &assembliesPaths, jobject loader, + bool have_split_apks) noexcept { - MonoDomain* domain = create_domain (env, runtimeApks, is_root_domain, have_split_apks); -#if defined (ANDROID) - // Asserting this on desktop apparently breaks a Designer test + MonoDomain* domain = create_domain (runtimeApks, have_split_apks); abort_unless (domain != nullptr, "Failed to create AppDomain"); -#endif - // When running on desktop, the root domain is only a dummy so don't initialize it - if constexpr (is_running_on_desktop) { - if (is_root_domain) { - return domain; - } - } - -#if defined (NET) default_alc = mono_alc_get_default_gchandle (); abort_unless (default_alc != nullptr, "Default AssemblyLoadContext not found"); embeddedAssemblies.install_preload_hooks_for_alc (); log_debug (LOG_ASSEMBLY, "ALC hooks installed"); -#endif // def NET -#ifndef ANDROID - if (assembliesBytes != nullptr && domain != nullptr) - designerAssemblies.add_or_update_from_java (domain, env, assemblies, assembliesBytes, assembliesPaths); -#endif - bool preload = (androidSystem.is_assembly_preload_enabled () || (is_running_on_desktop && force_preload_assemblies)); + bool preload = androidSystem.is_assembly_preload_enabled (); -#if defined (NET) load_assemblies (default_alc, preload, assemblies); init_android_runtime (env, runtimeClass, loader); -#else // def NET - load_assemblies (domain, preload, assemblies); - init_android_runtime (domain, env, runtimeClass, loader); -#endif // ndef NET osBridge.add_monodroid_domain (domain); return domain; } -#if defined (NET) void MonodroidRuntime::monodroid_unhandled_exception (MonoObject *java_exception) { mono_unhandled_exception (java_exception); } -#endif // def NET -#if !defined (RELEASE) || !defined (ANDROID) +#if !defined (RELEASE) MonoReflectionType* MonodroidRuntime::typemap_java_to_managed (MonoString *java_type_name) noexcept { @@ -2055,50 +1417,8 @@ MonodroidRuntime::typemap_managed_to_java (MonoReflectionType *type, const uint8 { return embeddedAssemblies.typemap_managed_to_java (type, mvid); } -#endif // !def RELEASE || !def ANDROID - -#if defined (WINDOWS) -const char* -MonodroidRuntime::get_my_location (bool remove_file_name) -{ - HMODULE hm = NULL; - - DWORD handle_flags = GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; - if (GetModuleHandleExW (handle_flags, (LPCWSTR) &get_xamarin_android_msbuild_path, &hm) == 0) { - int ret = GetLastError (); - log_warn (LOG_DEFAULT, "Unable to get HANDLE to `libmono-android.debug.dll`; GetModuleHandleExW returned %d\n", ret); - return nullptr; - } - - WCHAR path[MAX_PATH * 2]; - if (GetModuleFileNameW (hm, path, sizeof(path)) == 0) { - int ret = GetLastError (); - log_warn (LOG_DEFAULT, "Unable to get filename to `libmono-android.debug.dll`; GetModuleFileNameW returned %d\n", ret); - return nullptr; - } - - if (remove_file_name) - PathRemoveFileSpecW (path); - - return utils.utf16_to_utf8 (path); -} -#elif defined (APPLE_OS_X) -const char* -MonodroidRuntime::get_my_location (bool remove_file_name) -{ - Dl_info info; - if (dladdr (reinterpret_cast(&MonodroidRuntime::get_my_location), &info) == 0) { - log_warn (LOG_DEFAULT, "Could not lookup library containing `MonodroidRuntime::get_my_location()`; dladdr failed: %s", dlerror ()); - return nullptr; - } - - if (remove_file_name) - return utils.strdup_new (dirname (const_cast(info.dli_fname))); - return utils.strdup_new (info.dli_fname); -} -#endif // defined(WINDOWS) +#endif // !def RELEASE -#if defined (ANDROID) force_inline void MonodroidRuntime::setup_mono_tracing (std::unique_ptr const& mono_log_mask, bool have_log_assembly, bool have_log_gc) { @@ -2183,8 +1503,6 @@ MonodroidRuntime::install_logging_handlers () mono_trace_set_printerr_handler (mono_log_standard_streams_handler); } -#endif // def ANDROID - inline void MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass klass, jstring lang, jobjectArray runtimeApksJava, jstring runtimeNativeLibDir, jobjectArray appDirs, jint localDateTimeOffset, @@ -2211,7 +1529,6 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl jstring_array_wrapper applicationDirs (env, appDirs); jstring_wrapper &home = applicationDirs[SharedConstants::APP_DIRS_FILES_DIR_INDEX]; -#if defined (NET) mono_opt_aot_lazy_assembly_load = application_config.aot_lazy_load ? TRUE : FALSE; { @@ -2229,7 +1546,6 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl const_cast(monovm_props.property_values ()) ); } -#endif // def NET android_api_level = apiLevel; androidSystem.detect_embedded_dso_mode (applicationDirs); @@ -2249,8 +1565,6 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl create_xdg_directories_and_environment (home); androidSystem.set_primary_override_dir (home); - disable_external_signal_handlers (); - jstring_array_wrapper runtimeApks (env, runtimeApksJava); androidSystem.setup_app_library_directories (runtimeApks, applicationDirs, haveSplitApks); @@ -2262,11 +1576,6 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl set_debug_env_vars (); #endif -#if !defined (NET) - setup_bundled_app ("libmonodroid_bundle_app.so"); -#endif - -#if defined (ANDROID) bool have_log_assembly = (log_categories & LOG_ASSEMBLY) != 0; bool have_log_gc = (log_categories & LOG_GC) != 0; @@ -2277,11 +1586,7 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl } setup_mono_tracing (mono_log_mask, have_log_assembly, have_log_gc); - -#if defined (NET) install_logging_handlers (); -#endif // def NET -#endif if (runtimeNativeLibDir != nullptr) { jstr = runtimeNativeLibDir; @@ -2290,83 +1595,26 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl } androidSystem.setup_process_args (runtimeApks); -#if !defined (NET) - // JIT stats based on perf counters are disabled in dotnet/mono - if (XA_UNLIKELY (FastTiming::enabled () && !FastTiming::is_bare_mode ())) { - mono_counters_enable (static_cast(XA_LOG_COUNTERS)); - - dynamic_local_string counters_path; - utils.path_combine (counters_path, androidSystem.get_override_dir (0), "counters.txt"); - log_info_nocheck (LOG_TIMING, "counters path: %s", counters_path.get ()); - counters = utils.monodroid_fopen (counters_path.get (), "a"); - utils.set_world_accessable (counters_path.get ()); - } - - void *dso_handle = nullptr; -#if defined (WINDOWS) || defined (APPLE_OS_X) - const char *my_location = get_my_location (); - if (my_location != nullptr) { - std::unique_ptr dso_path {utils.path_combine (my_location, API_DSO_NAME)}; - log_info (LOG_DEFAULT, "Attempting to load %s", dso_path.get ()); - dso_handle = java_interop_lib_load (dso_path.get (), JAVA_INTEROP_LIB_LOAD_GLOBALLY, nullptr); -#if defined (APPLE_OS_X) - delete[] my_location; -#else // !defined(APPLE_OS_X) - free (static_cast(const_cast(my_location))); // JI allocates with `calloc` -#endif // defined(APPLE_OS_X) - } - - if (dso_handle == nullptr) { - log_info (LOG_DEFAULT, "Attempting to load %s with \"bare\" dlopen", API_DSO_NAME); - dso_handle = java_interop_lib_load (API_DSO_NAME, JAVA_INTEROP_LIB_LOAD_GLOBALLY, nullptr); - } -#endif // defined(WINDOWS) || defined(APPLE_OS_X) - if (dso_handle == nullptr) - dso_handle = androidSystem.load_dso_from_any_directories (API_DSO_NAME, JAVA_INTEROP_LIB_LOAD_GLOBALLY); - - init_internal_api_dso (dso_handle); -#endif // ndef NET mono_dl_fallback_register (monodroid_dlopen, monodroid_dlsym, nullptr, nullptr); set_profile_options (); set_trace_options (); -#if defined (DEBUG) && !defined (WINDOWS) +#if defined (DEBUG) debug.start_debugging_and_profiling (); #endif -#if !defined (NET) - mono_config_parse_memory (reinterpret_cast (monodroid_config)); - mono_register_machine_config (reinterpret_cast (monodroid_machine_config)); -#endif // ndef NET log_info (LOG_DEFAULT, "Probing for Mono AOT mode\n"); MonoAotMode mode = MonoAotMode::MONO_AOT_MODE_NONE; if (androidSystem.is_mono_aot_enabled ()) { mode = androidSystem.get_mono_aot_mode (); -#if !defined (NET) - if (mode == MonoAotMode::MONO_AOT_MODE_LAST) { - // Hack. See comments in android-system.hh - if (!androidSystem.is_interpreter_enabled ()) { - mode = MonoAotMode::MONO_AOT_MODE_NONE; - } - } - - if (mode != MonoAotMode::MONO_AOT_MODE_NONE) { - if (mode != MonoAotMode::MONO_AOT_MODE_LAST) { - log_info (LOG_DEFAULT, "Enabling AOT mode in Mono"); - } else { - log_info (LOG_DEFAULT, "Enabling Mono Interpreter"); - } - } -#else // defined (NET) if (mode != MonoAotMode::MONO_AOT_MODE_INTERP_ONLY) { log_info (LOG_DEFAULT, "Enabling AOT mode in Mono"); } else { log_info (LOG_DEFAULT, "Enabling Mono Interpreter"); } -#endif // !defined (NET) } mono_jit_set_aot_mode (mode); @@ -2401,18 +1649,7 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl jstring_array_wrapper assemblies (env, assembliesJava); jstring_array_wrapper assembliesPaths (env); /* the first assembly is used to initialize the AppDomain name */ - create_and_initialize_domain (env, klass, runtimeApks, assemblies, nullptr, assembliesPaths, loader, /*is_root_domain:*/ true, /*force_preload_assemblies:*/ false, haveSplitApks); - -#if defined (ANDROID) && !defined (NET) - // Mono from mono/mono has a bug which requires us to install the handlers after `mono_init_jit_version` is called - install_logging_handlers (); -#endif // def ANDROID && ndef NET - - // Install our dummy exception handler on Desktop - if constexpr (is_running_on_desktop) { - mono_add_internal_call ("System.Diagnostics.Debugger::Mono_UnhandledException_internal(System.Exception)", - reinterpret_cast (monodroid_Mono_UnhandledException_internal)); - } + create_and_initialize_domain (env, klass, runtimeApks, assemblies, nullptr, assembliesPaths, loader, haveSplitApks); if (XA_UNLIKELY (utils.should_log (LOG_DEFAULT))) { log_info_nocheck ( @@ -2424,52 +1661,20 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl BuildInfo::date ); -#if defined (ANDROID) log_info_nocheck (LOG_DEFAULT, "NDK version: %s; API level: %s", BuildInfo::ndk_version, BuildInfo::ndk_api_level); log_info_nocheck (LOG_DEFAULT, "MonoVM version: %s", mono_get_runtime_build_info ()); -#endif // def ANDROID } if (XA_UNLIKELY (FastTiming::enabled ())) { internal_timing->end_event (total_time_index); -#if !defined (NET) - dump_counters ("## Runtime.init: end"); -#endif // ndef NET } -#if defined (RELEASE) && defined (ANDROID) && defined (NET) +#if defined (RELEASE) xamarin_app_init (get_function_pointer_at_runtime); -#endif // def RELEASE && def ANDROID && def NET +#endif // def RELEASE startup_in_progress = false; } -#if !defined (NET) -void -MonodroidRuntime::dump_counters (const char *format, ...) -{ - if (counters == nullptr) - return; - - va_list args; - va_start (args, format); - dump_counters_v (format, args); - va_end (args); -} - -void -MonodroidRuntime::dump_counters_v (const char *format, va_list args) -{ - if (counters == nullptr) - return; - - fprintf (counters, "\n"); - vfprintf (counters, format, args); - fprintf (counters, "\n"); - - mono_counters_dump (MonodroidRuntime::XA_LOG_COUNTERS, counters); -} -#endif // ndef NET - JNIEXPORT jint JNICALL JNI_OnLoad (JavaVM *vm, void *reserved) { @@ -2535,38 +1740,9 @@ MonodroidRuntime::Java_mono_android_Runtime_register (JNIEnv *env, jstring manag int methods_len = env->GetStringLength (methods); const jchar *methods_ptr = env->GetStringChars (methods, nullptr); -#if !defined (NET) || !defined (ANDROID) - void *args[] = { - &managedType_ptr, - &managedType_len, - &nativeClass, - &methods_ptr, - &methods_len, - }; - MonoMethod *register_jni_natives = registerType; -#endif // ndef NET || ndef ANDROID - -#if !defined (NET) - MonoDomain *domain = utils.get_current_domain (/* attach_thread_if_needed */ false); - mono_jit_thread_attach (domain); - // Refresh current domain as it might have been modified by the above call - domain = mono_domain_get (); - - if constexpr (is_running_on_desktop) { - MonoClass *runtime = utils.monodroid_get_class_from_name (domain, SharedConstants::MONO_ANDROID_ASSEMBLY_NAME, SharedConstants::ANDROID_RUNTIME_NS_NAME, SharedConstants::JNIENVINIT_CLASS_NAME); - register_jni_natives = mono_class_get_method_from_name (runtime, "RegisterJniNatives", 5); - } - - utils.monodroid_runtime_invoke (domain, register_jni_natives, nullptr, args, nullptr); -#else // ndef NET mono_jit_thread_attach (nullptr); // There's just one domain in .net - -#if !defined (ANDROID) - mono_runtime_invoke (register_jni_natives, nullptr, args, nullptr); -#else jnienv_register_jni_natives (managedType_ptr, managedType_len, nativeClass, methods_ptr, methods_len); -#endif // ndef ANDROID -#endif // def NET + env->ReleaseStringChars (methods, methods_ptr); env->ReleaseStringChars (managedType, managedType_ptr); @@ -2580,9 +1756,6 @@ MonodroidRuntime::Java_mono_android_Runtime_register (JNIEnv *env, jstring manag env->ReleaseStringUTFChars (managedType, mt_ptr); internal_timing->add_more_info (total_time_index, type); -#if !defined (NET) - dump_counters ("## Runtime.register: type=%s\n", type.get ()); -#endif } } @@ -2644,10 +1817,5 @@ get_jnienv (void) JNIEXPORT void JNICALL Java_mono_android_Runtime_propagateUncaughtException (JNIEnv *env, [[maybe_unused]] jclass klass, jobject javaThread, jthrowable javaException) { -#if defined (NET) monodroidRuntime.propagate_uncaught_exception (env, javaThread, javaException); -#else // def NET - MonoDomain *domain = utils.get_current_domain (); - monodroidRuntime.propagate_uncaught_exception (domain, env, javaThread, javaException); -#endif // ndef NET } diff --git a/src/monodroid/jni/xa-internal-api-impl.hh b/src/monodroid/jni/xa-internal-api-impl.hh deleted file mode 100644 index 51df4b41a1a..00000000000 --- a/src/monodroid/jni/xa-internal-api-impl.hh +++ /dev/null @@ -1,54 +0,0 @@ -// Dear Emacs, this is a -*- C++ -*- header -#ifndef __XA_INTERNAL_API_IMPL_HH -#define __XA_INTERNAL_API_IMPL_HH - -#include "xa-internal-api.hh" - -namespace xamarin::android::internal -{ - class MonoAndroidInternalCalls_Impl final : public MonoAndroidInternalCalls - { - public: - virtual mono_bool monodroid_get_network_interface_up_state (const char *ifname, mono_bool *is_up) final override; - virtual mono_bool monodroid_get_network_interface_supports_multicast (const char *ifname, mono_bool *supports_multicast) final override; - virtual int monodroid_get_dns_servers (void **dns_servers_array) final override; - virtual int monodroid_getifaddrs (_monodroid_ifaddrs **ifap) final override; - virtual void monodroid_freeifaddrs (_monodroid_ifaddrs *ifa) final override; - virtual void monodroid_detect_cpu_and_architecture (unsigned short *built_for_cpu, unsigned short *running_on_cpu, unsigned char *is64bit) final override; - virtual unsigned int monodroid_get_log_categories () final override; - virtual void monodroid_log (LogLevel level, LogCategories category, const char *message) final override; - virtual int monodroid_get_system_property (const char *name, char **value) final override; - virtual int monodroid_max_gref_get () final override; - virtual int monodroid_gref_get () final override; - virtual void monodroid_gref_log (const char *message) final override; - virtual int monodroid_gref_log_new (jobject curHandle, char curType, jobject newHandle, char newType, const char *threadName, int threadId, const char *from, int from_writable) final override; - virtual void monodroid_gref_log_delete (jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) final override; - virtual int monodroid_weak_gref_get () final override; - virtual void monodroid_weak_gref_new (jobject curHandle, char curType, jobject newHandle, char newType, const char *threadName, int threadId, const char *from, int from_writable) final override; - virtual void monodroid_weak_gref_delete (jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) final override; - virtual void monodroid_lref_log_new (int lrefc, jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) final override; - virtual void monodroid_lref_log_delete (int lrefc, jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) final override; - virtual void monodroid_gc_wait_for_bridge_processing () final override; - virtual int monodroid_get_android_api_level () final override; - virtual void monodroid_clear_gdb_wait () final override; - virtual void* monodroid_get_identity_hash_code (JNIEnv *env, void *v) final override; - virtual void* monodroid_timezone_get_default_id () final override; - virtual void dump_counters (const char *format, va_list args) final override; - virtual int monodroid_embedded_assemblies_set_assemblies_prefix (const char *prefix) final override; - virtual managed_timing_sequence* monodroid_timing_start (const char *message) final override; - virtual void monodroid_timing_stop (managed_timing_sequence *sequence, const char *message) final override; - virtual void monodroid_strfreev (char **str_array) final override; - virtual char** monodroid_strsplit (const char *str, const char *delimiter, size_t max_tokens) final override; - virtual char* monodroid_strdup_printf (const char *format, va_list args) final override; - virtual char* monodroid_TypeManager_get_java_class_name (jclass klass) final override; - virtual void monodroid_store_package_name (const char *name) final override; - virtual int monodroid_get_namespaced_system_property (const char *name, char **value) final override; - virtual FILE* monodroid_fopen (const char* filename, const char* mode) final override; - virtual int send_uninterrupted (int fd, void *buf, int len) final override; - virtual int recv_uninterrupted (int fd, void *buf, int len) final override; - virtual void set_world_accessable (const char *path) final override; - virtual void create_public_directory (const char *dir) final override; - virtual char* path_combine (const char *path1, const char *path2) final override; - }; -} -#endif // __XA_INTERNAL_API_IMPL_HH diff --git a/src/monodroid/jni/xa-internal-api.cc b/src/monodroid/jni/xa-internal-api.cc deleted file mode 100644 index df1349c35c7..00000000000 --- a/src/monodroid/jni/xa-internal-api.cc +++ /dev/null @@ -1,347 +0,0 @@ -#ifdef WINDOWS -#include -#include -#include -#include -#include -#include -#endif // defined(WINDOWS) - -#include "globals.hh" -#include "xa-internal-api-impl.hh" - -#if defined (WINDOWS) -#define WINDOWS_UNUSED_ARG [[maybe_unused]] -#else -#define WINDOWS_UNUSED_ARG -#endif - -using namespace xamarin::android; -using namespace xamarin::android::internal; - -void _monodroid_detect_cpu_and_architecture (unsigned short *built_for_cpu, unsigned short *running_on_cpu, unsigned char *is64bit); -mono_bool _monodroid_get_network_interface_up_state (const char *ifname, mono_bool *is_up); -mono_bool _monodroid_get_network_interface_supports_multicast (const char *ifname, mono_bool *supports_multicast); -int _monodroid_get_dns_servers (void **dns_servers_array); -int _monodroid_getifaddrs (struct _monodroid_ifaddrs **ifap); -void _monodroid_freeifaddrs (struct _monodroid_ifaddrs *ifa); - -mono_bool -MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_up_state (WINDOWS_UNUSED_ARG const char *ifname, WINDOWS_UNUSED_ARG mono_bool *is_up) -{ -#ifdef WINDOWS - return FALSE; -#else // !defined(WINDOWS) - return ::_monodroid_get_network_interface_up_state (ifname, is_up); -#endif // defined(WINDOWS) -} - -mono_bool -MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_supports_multicast (WINDOWS_UNUSED_ARG const char *ifname, WINDOWS_UNUSED_ARG mono_bool *supports_multicast) -{ -#ifdef WINDOWS - return FALSE; -#else // !defined(WINDOWS) - return ::_monodroid_get_network_interface_supports_multicast (ifname, supports_multicast); -#endif // defined(WINDOWS) -} - -int -MonoAndroidInternalCalls_Impl::monodroid_get_dns_servers (WINDOWS_UNUSED_ARG void **dns_servers_array) -{ -#ifdef WINDOWS - return FALSE; -#else // !defined(WINDOWS) - return ::_monodroid_get_dns_servers (dns_servers_array); -#endif // defined(WINDOWS) -} - -int -MonoAndroidInternalCalls_Impl::monodroid_getifaddrs (WINDOWS_UNUSED_ARG struct _monodroid_ifaddrs **ifap) -{ -#ifdef WINDOWS - return -1; -#else // !defined(WINDOWS) - return ::_monodroid_getifaddrs (ifap); -#endif // defined(WINDOWS) -} - -void -MonoAndroidInternalCalls_Impl::monodroid_freeifaddrs (WINDOWS_UNUSED_ARG struct _monodroid_ifaddrs *ifa) -{ -#ifndef WINDOWS - ::_monodroid_freeifaddrs (ifa); -#endif // defined(WINDOWS) -} - -void -MonoAndroidInternalCalls_Impl::monodroid_detect_cpu_and_architecture (unsigned short *built_for_cpu, unsigned short *running_on_cpu, unsigned char *is64bit) -{ - ::_monodroid_detect_cpu_and_architecture (built_for_cpu, running_on_cpu, is64bit); -} - -unsigned int -MonoAndroidInternalCalls_Impl::monodroid_get_log_categories () -{ - return log_categories; -} - -void -MonoAndroidInternalCalls_Impl::monodroid_log (LogLevel level, LogCategories category, const char *message) -{ - switch (level) { - case LogLevel::Verbose: - case LogLevel::Debug: - log_debug_nocheck (category, message); - break; - - case LogLevel::Info: - log_info_nocheck (category, message); - break; - - case LogLevel::Warn: - case LogLevel::Silent: // warn is always printed - log_warn (category, message); - break; - - case LogLevel::Error: - log_error (category, message); - break; - - case LogLevel::Fatal: - log_fatal (category, message); - break; - - default: - case LogLevel::Unknown: - case LogLevel::Default: - log_info_nocheck (category, message); - break; - } -} - -int -MonoAndroidInternalCalls_Impl::monodroid_get_system_property (const char *name, char **value) -{ - return androidSystem.monodroid_get_system_property (name, value); -} - -int -MonoAndroidInternalCalls_Impl::monodroid_max_gref_get () -{ - return static_cast(androidSystem.get_max_gref_count ()); -} - -int -MonoAndroidInternalCalls_Impl::monodroid_gref_get () -{ - return osBridge.get_gc_gref_count (); -} - -int -MonoAndroidInternalCalls_Impl::monodroid_weak_gref_get () -{ - return osBridge.get_gc_weak_gref_count (); -} - -void -MonoAndroidInternalCalls_Impl::monodroid_gref_log (const char *message) -{ - osBridge._monodroid_gref_log (message); -} - -int -MonoAndroidInternalCalls_Impl::monodroid_gref_log_new (jobject curHandle, char curType, jobject newHandle, char newType, const char *threadName, int threadId, const char *from, int from_writable) -{ - return osBridge._monodroid_gref_log_new (curHandle, curType, newHandle, newType, threadName, threadId, from, from_writable); -} - -void -MonoAndroidInternalCalls_Impl::monodroid_gref_log_delete (jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) -{ - osBridge._monodroid_gref_log_delete (handle, type, threadName, threadId, from, from_writable); -} - -void -MonoAndroidInternalCalls_Impl::monodroid_weak_gref_new (jobject curHandle, char curType, jobject newHandle, char newType, const char *threadName, int threadId, const char *from, int from_writable) -{ - osBridge._monodroid_weak_gref_new (curHandle, curType, newHandle, newType, threadName, threadId, from, from_writable); -} - -void -MonoAndroidInternalCalls_Impl::monodroid_weak_gref_delete (jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) -{ - osBridge._monodroid_weak_gref_delete (handle, type, threadName, threadId, from, from_writable); -} - -void -MonoAndroidInternalCalls_Impl::monodroid_lref_log_new (int lrefc, jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) -{ - osBridge._monodroid_lref_log_new (lrefc, handle, type, threadName, threadId, from, from_writable); -} - -void -MonoAndroidInternalCalls_Impl::monodroid_lref_log_delete (int lrefc, jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) -{ - osBridge._monodroid_lref_log_delete (lrefc, handle, type, threadName, threadId, from, from_writable); -} - -void -MonoAndroidInternalCalls_Impl::monodroid_gc_wait_for_bridge_processing () -{ - mono_gc_wait_for_bridge_processing (); -} - -int -MonoAndroidInternalCalls_Impl::monodroid_get_android_api_level () -{ - return monodroidRuntime.get_android_api_level (); -} - -void -MonoAndroidInternalCalls_Impl::monodroid_clear_gdb_wait () -{ - monodroidRuntime.set_monodroid_gdb_wait (false); -} - -void* -MonoAndroidInternalCalls_Impl::monodroid_get_identity_hash_code (JNIEnv *env, void *v) -{ - intptr_t rv = env->CallStaticIntMethod (monodroidRuntime.get_java_class_System (), monodroidRuntime.get_java_class_method_System_identityHashCode (), v); - return (void*) rv; -} - -void* -MonoAndroidInternalCalls_Impl::monodroid_timezone_get_default_id () -{ - JNIEnv *env = osBridge.ensure_jnienv (); - jmethodID getDefault = env->GetStaticMethodID (monodroidRuntime.get_java_class_TimeZone (), "getDefault", "()Ljava/util/TimeZone;"); - jmethodID getID = env->GetMethodID (monodroidRuntime.get_java_class_TimeZone (), "getID", "()Ljava/lang/String;"); - jobject d = env->CallStaticObjectMethod (monodroidRuntime.get_java_class_TimeZone (), getDefault); - jstring id = reinterpret_cast (env->CallObjectMethod (d, getID)); - const char *mutf8 = env->GetStringUTFChars (id, nullptr); - char *def_id = strdup (mutf8); - - env->ReleaseStringUTFChars (id, mutf8); - env->DeleteLocalRef (id); - env->DeleteLocalRef (d); - - return def_id; -} - -void -MonoAndroidInternalCalls_Impl::dump_counters (const char *format, va_list args) -{ - monodroidRuntime.dump_counters_v (format, args); -} - -int -MonoAndroidInternalCalls_Impl::monodroid_embedded_assemblies_set_assemblies_prefix (const char *prefix) -{ - embeddedAssemblies.set_assemblies_prefix (prefix); - return 0; -} - -managed_timing_sequence* -MonoAndroidInternalCalls_Impl::monodroid_timing_start (const char *message) -{ - if (timing == nullptr) - return nullptr; - - managed_timing_sequence *ret = timing->get_available_sequence (); - if (message != nullptr) { - log_write (LOG_TIMING, LogLevel::Info, message); - } - ret->period.mark_start (); - - return ret; -} - -void -MonoAndroidInternalCalls_Impl::monodroid_timing_stop (managed_timing_sequence *sequence, const char *message) -{ - static constexpr const char DEFAULT_MESSAGE[] = "Managed Timing"; - - if (sequence == nullptr) - return; - - sequence->period.mark_end (); - Timing::info (sequence->period, message == nullptr ? DEFAULT_MESSAGE : message); - timing->release_sequence (sequence); -} - -void -MonoAndroidInternalCalls_Impl::monodroid_strfreev (char **str_array) -{ - utils.monodroid_strfreev (str_array); -} - -char** -MonoAndroidInternalCalls_Impl::monodroid_strsplit (const char *str, const char *delimiter, size_t max_tokens) -{ - return utils.monodroid_strsplit (str, delimiter, max_tokens); -} - -char* -MonoAndroidInternalCalls_Impl::monodroid_strdup_printf (const char *format, va_list args) -{ - return utils.monodroid_strdup_vprintf (format, args); -} - -char* -MonoAndroidInternalCalls_Impl::monodroid_TypeManager_get_java_class_name (jclass klass) -{ - return monodroidRuntime.get_java_class_name_for_TypeManager (klass); -} - -void -MonoAndroidInternalCalls_Impl::monodroid_store_package_name (const char *name) -{ - utils.monodroid_store_package_name (name); -} - -int -MonoAndroidInternalCalls_Impl::monodroid_get_namespaced_system_property (const char *name, char **value) -{ - return static_cast(androidSystem.monodroid_get_system_property (name, value)); -} - -FILE* -MonoAndroidInternalCalls_Impl::monodroid_fopen (const char* filename, const char* mode) -{ - return utils.monodroid_fopen (filename, mode); -} - -int -MonoAndroidInternalCalls_Impl::send_uninterrupted (int fd, void *buf, int len) -{ - if (len < 0) - len = 0; - return utils.send_uninterrupted (fd, buf, static_cast(len)); -} - -int -MonoAndroidInternalCalls_Impl::recv_uninterrupted (int fd, void *buf, int len) -{ - if (len < 0) - len = 0; - return static_cast(utils.recv_uninterrupted (fd, buf, static_cast(len))); -} - -void -MonoAndroidInternalCalls_Impl::set_world_accessable (const char *path) -{ - utils.set_world_accessable (path); -} - -void -MonoAndroidInternalCalls_Impl::create_public_directory (const char *dir) -{ - utils.create_public_directory (dir); -} - -char* -MonoAndroidInternalCalls_Impl::path_combine (const char *path1, const char *path2) -{ - return utils.path_combine (path1, path2); -} diff --git a/src/monodroid/jni/xa-internal-api.hh b/src/monodroid/jni/xa-internal-api.hh deleted file mode 100644 index 8569161a686..00000000000 --- a/src/monodroid/jni/xa-internal-api.hh +++ /dev/null @@ -1,72 +0,0 @@ -// Dear Emacs, this is a -*- C++ -*- header -#ifndef __XA_INTERNAL_API_HH -#define __XA_INTERNAL_API_HH - -#include -#include -#include - -#include "monodroid.h" -#include "logger.hh" -#include "timing.hh" -#include "xamarin_getifaddrs.h" - -namespace xamarin::android -{ - class MonoAndroidInternalCalls - { - public: - static constexpr char INIT_FUNCTION_NAME[] = "_monodroid_init_internal_api"; - static constexpr char SHUTDOWN_FUNCTION_NAME[] = "_monodroid_shutdown_internal_api"; - - // To shush compiler warnings - virtual ~MonoAndroidInternalCalls () - {} - - public: - virtual mono_bool monodroid_get_network_interface_up_state (const char *ifname, mono_bool *is_up) = 0; - virtual mono_bool monodroid_get_network_interface_supports_multicast (const char *ifname, mono_bool *supports_multicast) = 0; - virtual int monodroid_get_dns_servers (void **dns_servers_array) = 0; - virtual int monodroid_getifaddrs (_monodroid_ifaddrs **ifap) = 0; - virtual void monodroid_freeifaddrs (_monodroid_ifaddrs *ifa) = 0; - virtual void monodroid_detect_cpu_and_architecture (unsigned short *built_for_cpu, unsigned short *running_on_cpu, unsigned char *is64bit) = 0; - virtual unsigned int monodroid_get_log_categories () = 0; - virtual void monodroid_log (LogLevel level, LogCategories category, const char *message) = 0; - virtual int monodroid_get_system_property (const char *name, char **value) = 0; - virtual int monodroid_max_gref_get () = 0; - virtual int monodroid_gref_get () = 0; - virtual void monodroid_gref_log (const char *message) = 0; - virtual int monodroid_gref_log_new (jobject curHandle, char curType, jobject newHandle, char newType, const char *threadName, int threadId, const char *from, int from_writable) = 0; - virtual void monodroid_gref_log_delete (jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) = 0; - virtual int monodroid_weak_gref_get () = 0; - virtual void monodroid_weak_gref_new (jobject curHandle, char curType, jobject newHandle, char newType, const char *threadName, int threadId, const char *from, int from_writable) = 0; - virtual void monodroid_weak_gref_delete (jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) = 0; - virtual void monodroid_lref_log_new (int lrefc, jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) = 0; - virtual void monodroid_lref_log_delete (int lrefc, jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) = 0; - virtual void monodroid_gc_wait_for_bridge_processing () = 0; - virtual int monodroid_get_android_api_level () = 0; - virtual void monodroid_clear_gdb_wait () = 0; - virtual void* monodroid_get_identity_hash_code (JNIEnv *env, void *v) = 0; - virtual void* monodroid_timezone_get_default_id () = 0; - virtual void dump_counters (const char *format, va_list args) = 0; - virtual int monodroid_embedded_assemblies_set_assemblies_prefix (const char *prefix) = 0; - virtual managed_timing_sequence* monodroid_timing_start (const char *message) = 0; - virtual void monodroid_timing_stop (managed_timing_sequence *sequence, const char *message) = 0; - virtual void monodroid_strfreev (char **str_array) = 0; - virtual char** monodroid_strsplit (const char *str, const char *delimiter, size_t max_tokens) = 0; - virtual char* monodroid_strdup_printf (const char *format, va_list args) = 0; - virtual char* monodroid_TypeManager_get_java_class_name (jclass klass) = 0; - virtual void monodroid_store_package_name (const char *name) = 0; - virtual int monodroid_get_namespaced_system_property (const char *name, char **value) = 0; - virtual FILE* monodroid_fopen (const char* filename, const char* mode) = 0; - virtual int send_uninterrupted (int fd, void *buf, int len) = 0; - virtual int recv_uninterrupted (int fd, void *buf, int len) = 0; - virtual void set_world_accessable (const char *path) = 0; - virtual void create_public_directory (const char *dir) = 0; - virtual char* path_combine (const char *path1, const char *path2) = 0; - }; - - typedef bool (*external_api_init_fn) (MonoAndroidInternalCalls *api); - typedef void (*external_api_shutdown_fn) (); -} -#endif // __XA_INTERNAL_API_HH diff --git a/src/monodroid/monodroid.targets b/src/monodroid/monodroid.targets index d157bb0a0f8..f52b2bbcb8c 100644 --- a/src/monodroid/monodroid.targets +++ b/src/monodroid/monodroid.targets @@ -20,7 +20,7 @@ + DependsOnTargets="_GenerateIncludeFiles;_ConfigureRuntimes;_BuildAndroidRuntimes;_BuildAndroidAnalyzerRuntimes;_CopyToPackDirs"> <_ConfigureRuntimesInputs Include="CMakeLists.txt" /> <_ConfigureRuntimesInputs Include="..\..\build-tools\scripts\Ndk.targets" /> - <_ConfigureRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(IntermediateOutputPath)\%(Identity)-Debug\CMakeCache.txt')" /> <_ConfigureRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(IntermediateOutputPath)\%(AndroidRID)-Debug\CMakeCache.txt')" /> - <_ConfigureRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(IntermediateOutputPath)\%(Identity)-Release\CMakeCache.txt')" /> <_ConfigureRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(IntermediateOutputPath)\%(AndroidRID)-Release\CMakeCache.txt')" /> - <_ConfigureRuntimesOutputs Include="@(_HostRuntime->'$(IntermediateOutputPath)%(OutputDirectory)-Debug\CMakeCache.txt')" /> - <_ConfigureRuntimesOutputs Include="@(_HostRuntime->'$(IntermediateOutputPath)%(OutputDirectory)-Release\CMakeCache.txt')" /> @@ -92,29 +88,19 @@ - <_BuildAndroidRuntimesInputs Include="@(AndroidSupportedTargetJitAbi->'$(IntermediateOutputPath)\%(Identity)-Debug\CMakeCache.txt')" /> <_BuildAndroidRuntimesInputs Include="@(AndroidSupportedTargetJitAbi->'$(IntermediateOutputPath)\%(AndroidRID)-Debug\CMakeCache.txt')" /> - <_BuildAndroidRuntimesInputs Include="@(AndroidSupportedTargetJitAbi->'$(IntermediateOutputPath)\%(Identity)-Release\CMakeCache.txt')" /> <_BuildAndroidRuntimesInputs Include="@(AndroidSupportedTargetJitAbi->'$(IntermediateOutputPath)\%(AndroidRID)-Release\CMakeCache.txt')" /> <_BuildAndroidRuntimesInputs Include="@(_MonoDroidSources)" /> <_BuildAndroidRuntimesInputs Include="..\..\build-tools\scripts\Ndk.targets" /> - <_BuildAndroidRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(Identity)\libmono-android.debug.so')" /> <_BuildAndroidRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(AndroidRID)\libmono-android.debug.so')" /> - <_BuildAndroidRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(Identity)\libmono-android.release.so')" /> <_BuildAndroidRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(AndroidRID)\libmono-android.release.so')" /> - <_BuildAndroidRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(Identity)\Debug\libxamarin-app.so')" /> <_BuildAndroidRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(AndroidRID)\Debug\libxamarin-app.so')" /> - <_BuildAndroidRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(Identity)\Release\libxamarin-app.so')" /> <_BuildAndroidRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(AndroidRID)\Release\libxamarin-app.so')" /> - <_BuildAndroidAnalyzerRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(Identity)\libmono-android-checked+ubsan.debug.so')" /> <_BuildAndroidAnalyzerRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(AndroidRID)\libmono-android-checked+ubsan.debug.so')" /> - <_BuildAndroidAnalyzerRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(Identity)\libmono-android-checked+asan.debug.so')" /> <_BuildAndroidAnalyzerRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(AndroidRID)\libmono-android-checked+asan.debug.so')" /> - <_BuildAndroidAnalyzerRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(Identity)\libmono-android-checked+asan.release.so')" /> <_BuildAndroidAnalyzerRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(AndroidRID)\libmono-android-checked+asan.release.so')" /> - <_BuildAndroidAnalyzerRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(Identity)\libmono-android-checked+ubsan.release.so')" /> <_BuildAndroidAnalyzerRuntimesOutputs Include="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(AndroidRID)\libmono-android-checked+ubsan.release.so')" /> @@ -123,21 +109,11 @@ DependsOnTargets="_BuildAndroidRuntimesInputs" Inputs="@(_BuildAndroidRuntimesInputs)" Outputs="@(_BuildAndroidRuntimesOutputs)"> - - - - - - - - - - - - - - - <_BuildHostRuntimesInputs Include="@(_HostRuntime->'$(IntermediateOutputPath)%(OutputDirectory)-Debug\CMakeCache.txt')" /> - <_BuildHostRuntimesInputs Include="@(_HostRuntime->'$(IntermediateOutputPath)%(OutputDirectory)-Release\CMakeCache.txt')" /> - <_BuildHostRuntimesInputs Include="@(_MonoDroidSources)" /> - <_BuildHostRuntimesOutputs Include="@(_HostRuntime->'$(OutputPath)%(OutputDirectory)\libmono-android.debug.%(NativeLibraryExtension)')" /> - <_BuildHostRuntimesOutputs Include="@(_HostRuntime->'$(OutputPath)%(OutputDirectory)\libmono-android.release.%(NativeLibraryExtension)')" /> - <_BuildHostRuntimesOutputs Include="@(_HostRuntime->'$(OutputPath)%(OutputDirectory)\libxamarin-app.%(NativeLibraryExtension)')" /> - - - - - - - - - - - - - - - - - - - + + + + - - - - - <_OutputDebugPath Include="$(OutputPath)%(_HostRuntime.OutputDirectory)\libmono-android.debug.d.%(_HostRuntime.NativeLibraryExtension)" /> - <_OutputDebugStripPath Include="$(OutputPath)%(_HostRuntime.OutputDirectory)\libmono-android.debug.%(_HostRuntime.NativeLibraryExtension)" /> - <_OutputReleasePath Include="$(OutputPath)%(_HostRuntime.OutputDirectory)\libmono-android.release.d.%(_HostRuntime.NativeLibraryExtension)" /> - <_OutputReleaseStripPath Include="$(OutputPath)%(_HostRuntime.OutputDirectory)\libmono-android.release.%(_HostRuntime.NativeLibraryExtension)" /> - + DependsOnTargets="_BuildAndroidRuntimes"> <_CompileCommandsDir Include="$(IntermediateOutputPath)%(AndroidSupportedTargetJitAbi.Identity)-Debug"> %(AndroidSupportedTargetJitAbi.Identity)-Debug @@ -279,14 +184,6 @@ <_CompileCommandsDir Include="$(IntermediateOutputPath)%(AndroidSupportedTargetJitAbi.Identity)-Release"> %(AndroidSupportedTargetJitAbi.Identity)-Release - - - <_CompileCommandsDir Include="$(IntermediateOutputPath)%(_HostRuntime.OutputDirectory)-Debug" Condition=" '%(_HostRuntime.Identity)' != 'host-mxe-Win64' And '%(_HostRuntime.Identity)' != 'host-mxe-Win32' "> - %(_HostRuntime.OutputDirectory)-Debug - - <_CompileCommandsDir Include="$(IntermediateOutputPath)%(_HostRuntime.OutputDirectory)-Release" Condition=" '%(_HostRuntime.Identity)' != 'host-mxe-Win64' And '%(_HostRuntime.Identity)' != 'host-mxe-Win32' "> - %(_HostRuntime.OutputDirectory)-Release - diff --git a/src/sqlite-xamarin/sqlite-xamarin.targets b/src/sqlite-xamarin/sqlite-xamarin.targets index b7998a9eebe..761618a6a93 100644 --- a/src/sqlite-xamarin/sqlite-xamarin.targets +++ b/src/sqlite-xamarin/sqlite-xamarin.targets @@ -17,7 +17,7 @@ <_ConfigureSqliteCommands Include="@(AndroidSupportedTargetJitAbi)"> $(CmakePath) - $(_CmakeAndroidFlags) -DANDROID_NATIVE_API_LEVEL=%(AndroidSupportedTargetJitAbi.ApiLevel) -DANDROID_PLATFORM=android-%(AndroidSupportedTargetJitAbi.ApiLevel) -DANDROID_ABI=%(AndroidSupportedTargetJitAbi.Identity) -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="$(OutputPath)%(AndroidSupportedTargetJitAbi.Identity)" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$(OutputPath)%(AndroidSupportedTargetJitAbi.Identity)" -DCMAKE_BUILD_TYPE=$(Configuration) -DSQLITE_SOURCE_DIR="$(SqliteSourceFullPath)" -DSQLITE_LIBRARY_NAME="$(_SqliteBaseLibName)" -DSQLITE_OUTPUT_DIR="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(Identity)')" $(MSBuildThisFileDirectory) + $(_CmakeAndroidFlags) -DANDROID_NATIVE_API_LEVEL=%(AndroidSupportedTargetJitAbi.ApiLevelNET) -DANDROID_PLATFORM=android-%(AndroidSupportedTargetJitAbi.ApiLevelNET) -DANDROID_ABI=%(AndroidSupportedTargetJitAbi.Identity) -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="$(OutputPath)%(AndroidSupportedTargetJitAbi.Identity)" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$(OutputPath)%(AndroidSupportedTargetJitAbi.Identity)" -DCMAKE_BUILD_TYPE=$(Configuration) -DSQLITE_SOURCE_DIR="$(SqliteSourceFullPath)" -DSQLITE_LIBRARY_NAME="$(_SqliteBaseLibName)" -DSQLITE_OUTPUT_DIR="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(Identity)')" $(MSBuildThisFileDirectory) $(IntermediateOutputPath)%(AndroidSupportedTargetJitAbi.Identity)-$(Configuration) diff --git a/tools/xabuild/xabuild.csproj b/tools/xabuild/xabuild.csproj index cfc40557a26..def9cee99ad 100644 --- a/tools/xabuild/xabuild.csproj +++ b/tools/xabuild/xabuild.csproj @@ -45,6 +45,5 @@ - - \ No newline at end of file + From 73b57e13a7d40846f1382bd2cdcf84e860533597 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Mon, 20 Feb 2023 16:51:19 +0100 Subject: [PATCH 02/10] Remove classic stuff from the installers and fix the build --- .../installers/create-installers.targets | 39 ------------------- .../Xamarin.Android.Build.Tasks.targets | 22 +++++++++++ tools/xabuild/xabuild.csproj | 1 + 3 files changed, 23 insertions(+), 39 deletions(-) diff --git a/build-tools/installers/create-installers.targets b/build-tools/installers/create-installers.targets index 3e589147ceb..e914a5f7e5c 100644 --- a/build-tools/installers/create-installers.targets +++ b/build-tools/installers/create-installers.targets @@ -206,35 +206,6 @@ <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)java-interop.jar" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)java-source-utils.jar" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)LayoutBinding.cs" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmono-android.debug.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmono-android-checked+asan.debug.so')" ExcludeFromAndroidNETSdk="true" Condition=" '$(EnableNativeAnalyzers)' == 'true' " /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmono-android-checked+ubsan.debug.so')" ExcludeFromAndroidNETSdk="true" Condition=" '$(EnableNativeAnalyzers)' == 'true' " /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmono-android.release.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmono-android-checked+asan.release.so')" ExcludeFromAndroidNETSdk="true" Condition=" '$(EnableNativeAnalyzers)' == 'true' " /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmono-android-checked+ubsan.release.so')" ExcludeFromAndroidNETSdk="true" Condition=" '$(EnableNativeAnalyzers)' == 'true' " /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libxa-internal-api.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libxa-internal-api-checked+asan.so')" ExcludeFromAndroidNETSdk="true" Condition=" '$(EnableNativeAnalyzers)' == 'true' " /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libxa-internal-api-checked+ubsan.so')" ExcludeFromAndroidNETSdk="true" Condition=" '$(EnableNativeAnalyzers)' == 'true' " /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmono-btls-shared.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmono-btls-shared.d.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmono-profiler-aot.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmono-profiler-log.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmono-native.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmono-native.d.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libMonoPosixHelper.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libMonoPosixHelper.d.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmonosgen-2.0.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libmonosgen-2.0.d.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libsqlite3_xamarin.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libxamarin-debug-app-helper.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libxamarin-debug-app-helper-checked+asan.so')" ExcludeFromAndroidNETSdk="true" Condition=" '$(EnableNativeAnalyzers)' == 'true' " /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\libxamarin-debug-app-helper-checked+ubsan.so')" ExcludeFromAndroidNETSdk="true" Condition=" '$(EnableNativeAnalyzers)' == 'true' " /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\interpreter-%(Identity)\libmono-btls-shared.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\interpreter-%(Identity)\libmono-profiler-aot.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\interpreter-%(Identity)\libmono-profiler-log.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\interpreter-%(Identity)\libmono-native.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\interpreter-%(Identity)\libMonoPosixHelper.so')" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\interpreter-%(Identity)\libmonosgen-2.0.so')" ExcludeFromAndroidNETSdk="true" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libZipSharp.dll" /> <_MSBuildFiles Include="@(_LocalizationLanguages->'$(MicrosoftAndroidSdkOutDir)%(Identity)\libZipSharp.resources.dll')" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libZipSharp.pdb" /> @@ -249,7 +220,6 @@ <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Microsoft.Android.Build.BaseTasks.pdb" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)mkbundle.exe" ExcludeFromAndroidNETSdk="true" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)mkbundle.pdb" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)mkbundle-api.h" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)mono-symbolicate.exe" ExcludeFromAndroidNETSdk="true" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)mono-symbolicate.pdb" ExcludeFromAndroidNETSdk="true" /> <_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Mono.CompilerServices.SymbolWriter.dll" /> @@ -385,15 +355,6 @@ <_MSBuildFilesUnix Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\mono.config" /> <_MSBuildFilesUnix Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\mono-symbolicate" ExcludeFromAndroidNETSdk="true" /> <_MSBuildFilesUnixSignAndHarden Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\aapt2" /> - <_MSBuildFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)lib\host-$(HostOS)\libmono-android.debug.$(LibExtension)" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)lib\host-$(HostOS)\libmono-android.release.$(LibExtension)" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)lib\host-$(HostOS)\libmono-native.$(LibExtension)" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)lib\host-$(HostOS)\libmono-profiler-aot.$(LibExtension)" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)lib\host-$(HostOS)\libmono-profiler-log.$(LibExtension)" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)lib\host-$(HostOS)\libMonoPosixHelper.$(LibExtension)" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)lib\host-$(HostOS)\libmonosgen-2.0.$(LibExtension)" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)lib\host-$(HostOS)\libxamarin-app.$(LibExtension)" ExcludeFromAndroidNETSdk="true" /> - <_MSBuildFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)lib\host-$(HostOS)\libxa-internal-api.$(LibExtension)" ExcludeFromAndroidNETSdk="true" /> <_MSBuildFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)libZipSharpNative.$(LibExtension)" /> <_MSBuildFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)libMono.Unix.$(LibExtension)" /> diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets index 922902a4552..fa92d1bee28 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets @@ -404,4 +404,26 @@ SkipUnchangedFiles="True" /> + + + + + + + diff --git a/tools/xabuild/xabuild.csproj b/tools/xabuild/xabuild.csproj index def9cee99ad..ed600389fb4 100644 --- a/tools/xabuild/xabuild.csproj +++ b/tools/xabuild/xabuild.csproj @@ -45,5 +45,6 @@ + From 05f1d0a3b700b87b24268b404c5b427f4cdf40f6 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Mon, 20 Feb 2023 17:53:22 +0100 Subject: [PATCH 03/10] Don't try to package desktop dlls (for designer) --- build-tools/installers/create-installers.targets | 6 ------ 1 file changed, 6 deletions(-) diff --git a/build-tools/installers/create-installers.targets b/build-tools/installers/create-installers.targets index e914a5f7e5c..3dad7e4c3c8 100644 --- a/build-tools/installers/create-installers.targets +++ b/build-tools/installers/create-installers.targets @@ -331,12 +331,6 @@ <_MSBuildFilesWin Include="$(MicrosoftAndroidSdkOutDir)binutils\bin\x86_64-linux-android-as.cmd" /> <_MSBuildFilesWin Include="$(MicrosoftAndroidSdkOutDir)binutils\bin\x86_64-linux-android-ld.cmd" /> <_MSBuildFilesWin Include="$(MicrosoftAndroidSdkOutDir)binutils\bin\x86_64-linux-android-strip.cmd" /> - <_MSBuildLibHostFilesWin Include="$(MicrosoftAndroidSdkOutDir)lib\host-mxe-Win64\libmono-android.debug.dll" Condition=" '$(HostOS)' != 'Windows' " /> - <_MSBuildLibHostFilesWin Include="$(MicrosoftAndroidSdkOutDir)lib\host-mxe-Win64\libmono-android.release.dll" Condition=" '$(HostOS)' != 'Windows' " /> - <_MSBuildLibHostFilesWin Include="$(MicrosoftAndroidSdkOutDir)lib\host-mxe-Win64\libMonoPosixHelper.dll" /> - <_MSBuildLibHostFilesWin Include="$(MicrosoftAndroidSdkOutDir)lib\host-mxe-Win64\libmonosgen-2.0.dll" /> - <_MSBuildLibHostFilesWin Include="$(MicrosoftAndroidSdkOutDir)lib\host-mxe-Win64\libxamarin-app.dll" Condition=" '$(HostOS)' != 'Windows' " /> - <_MSBuildLibHostFilesWin Include="$(MicrosoftAndroidSdkOutDir)lib\host-mxe-Win64\libxa-internal-api.dll" Condition=" '$(HostOS)' != 'Windows' " /> <_MSBuildFilesUnixSignAndHarden> From a95d91394001d36f26b170334906167f6b70de6b Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Mon, 20 Feb 2023 21:21:35 +0100 Subject: [PATCH 04/10] See whether this fixes the Windows build --- build-tools/installers/create-installers.targets | 1 - 1 file changed, 1 deletion(-) diff --git a/build-tools/installers/create-installers.targets b/build-tools/installers/create-installers.targets index 3dad7e4c3c8..78a4776753a 100644 --- a/build-tools/installers/create-installers.targets +++ b/build-tools/installers/create-installers.targets @@ -158,7 +158,6 @@ <_LegacyJIFiles Include="$(LegacyMSBuildSrcDir)jit-times.pdb" /> <_LegacyJIFiles Include="$(LegacyMSBuildSrcDir)jnimarshalmethod-gen.exe" /> <_LegacyJIFiles Include="$(LegacyMSBuildSrcDir)jnimarshalmethod-gen.pdb" /> - <_LegacyJIFiles Include="$(LegacyMSBuildSrcDir)Java.Interop.dll.config" /> <_LegacyJIFiles Include="$(LegacyMSBuildSrcDir)Java.Runtime.Environment.dll" /> <_LegacyJIFiles Include="$(LegacyMSBuildSrcDir)Java.Runtime.Environment.pdb" /> <_LegacyJIFiles Include="$(LegacyMSBuildSrcDir)Java.Runtime.Environment.dll.config" Condition=" '$(HostOS)' != 'Windows' " /> From 56f9e28ad019ce745287bcb8c91b3dae41e14a32 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Tue, 21 Feb 2023 10:52:19 +0100 Subject: [PATCH 05/10] Update and remove tests - Minimum NDK level is 21 now - Don't run classic MSBuild smoke tests on Windows --- build-tools/automation/yaml-templates/build-windows.yaml | 7 ------- .../Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/build-tools/automation/yaml-templates/build-windows.yaml b/build-tools/automation/yaml-templates/build-windows.yaml index 4de0eb8b73c..7f41f63de37 100644 --- a/build-tools/automation/yaml-templates/build-windows.yaml +++ b/build-tools/automation/yaml-templates/build-windows.yaml @@ -114,13 +114,6 @@ stages: - template: install-apkdiff.yaml - - template: run-nunit-tests.yaml - parameters: - testRunTitle: Smoke MSBuild Tests - Windows Build Tree - testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\net472\Xamarin.Android.Build.Tests.dll - testResultsFile: TestResult-SmokeMSBuildTests-WinBuildTree-$(XA.Build.Configuration).xml - nunitConsoleExtraArgs: --where "cat == SmokeTests" - - template: run-nunit-tests.yaml parameters: useDotNet: true diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs index e1530c07b0c..75989fd3105 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs @@ -42,7 +42,7 @@ public void TestNdkUtil () Assert.IsTrue (ndk.ValidateNdkPlatform (arch, enableLLVM: false)); Assert.AreEqual (0, errors.Count, "NdkTools.ValidateNdkPlatform should not have returned false."); int level = ndk.GetMinimumApiLevelFor (arch); - int expected = 19; + int expected = 21; Assert.AreEqual (expected, level, $"Min Api Level for {arch} should be {expected}."); var compilerNoQuotes = ndk.GetToolPath (NdkToolKind.CompilerC, arch, level); Assert.AreEqual (0, errors.Count, "NdkTools.GetToolPath should not have errored."); From c054a008d5ec26c75c8f721ec4fafa2e19d39dd4 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Tue, 21 Feb 2023 20:15:25 +0100 Subject: [PATCH 06/10] Remove BCL tests --- build-tools/automation/azure-pipelines.yaml | 68 --------------------- 1 file changed, 68 deletions(-) diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 6b76827abd1..f03552a6f8f 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -770,74 +770,6 @@ stages: - template: yaml-templates/fail-on-issue.yaml -- stage: bcl_tests - displayName: BCL Emulator Tests - dependsOn: mac_build - # Disabled on .NET release branches - condition: and(succeeded(), eq(variables.IsRelOrTargetingRel, 'False'), or(eq(variables['RunAllTests'], true), contains(dependencies.mac_build.outputs['mac_build_create_installers.TestConditions.TestAreas'], 'BCL'))) - jobs: - # Check - "Xamarin.Android (macOS > Tests > BCL (Emulator))" - - job: mac_bcl_tests - displayName: macOS > Tests > BCL (Emulator) - pool: - vmImage: $(HostedMacImage) - timeoutInMinutes: 180 - workspace: - clean: all - steps: - - template: yaml-templates/setup-test-environment.yaml - parameters: - provisionatorChannel: ${{ parameters.provisionatorChannel }} - - - template: yaml-templates/run-xaprepare.yaml - parameters: - displayName: install emulator - arguments: --s=EmulatorTestDependencies - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: $(TestAssembliesArtifactName) - downloadPath: $(System.DefaultWorkingDirectory)/bin/$(XA.Build.Configuration) - - - task: MSBuild@1 - displayName: build remap-assembly-ref.csproj - inputs: - solution: build-tools/remap-assembly-ref/remap-assembly-ref.csproj - configuration: $(XA.Build.Configuration) - msbuildArguments: /restore /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/remap-assembly-ref.binlog - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Xamarin.Android.Bcl-Tests - project: tests/BCL-Tests/Xamarin.Android.Bcl-Tests/Xamarin.Android.Bcl-Tests.csproj - testResultsFiles: TestResult-Xamarin.Android.Bcl_Tests.nunit-$(XA.Build.Configuration).xml - artifactSource: bin/Test$(XA.Build.Configuration)/Xamarin.Android.Bcl_Tests-Signed.apk - artifactFolder: Default - - - task: PublishTestResults@2 - displayName: publish Xamarin.Android.Bcl-Tests-XUnit results - inputs: - testResultsFormat: NUnit - testResultsFiles: TestResult-Xamarin.Android.Bcl_Tests.xunit-$(XA.Build.Configuration).xml - testRunTitle: Xamarin.Android.Bcl-Tests-NUnit - - - task: MSBuild@1 - displayName: shut down emulator - inputs: - solution: tests/BCL-Tests/Xamarin.Android.Bcl-Tests/Xamarin.Android.Bcl-Tests.csproj - configuration: $(XA.Build.Configuration) - msbuildArguments: >- - /t:AcquireAndroidTarget,ReleaseAndroidTarget - /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog - condition: always() - - - template: yaml-templates/upload-results.yaml - parameters: - artifactName: Test Results - BCL With Emulator - macOS - - - template: yaml-templates/fail-on-issue.yaml - - stage: dotnet_prepare_release displayName: Prepare .NET Release dependsOn: From 9c91ff836e8d5301f8023b0b10d5429068aa40b1 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Tue, 21 Feb 2023 21:53:55 +0100 Subject: [PATCH 07/10] Remove more classic tests --- build-tools/automation/azure-pipelines.yaml | 202 -------------------- 1 file changed, 202 deletions(-) diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index f03552a6f8f..7c3658ea84c 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -99,208 +99,6 @@ stages: displayName: Smoke Tests dependsOn: mac_build jobs: - # Check - "Xamarin.Android (macOS > Tests > APKs Classic)" - - job: mac_apk_tests_legacy - displayName: macOS > Tests > APKs Classic - # Disabled on .NET release branches - condition: and(succeeded(), eq(variables.IsRelOrTargetingRel, 'False')) - pool: - vmImage: $(HostedMacImage) - timeoutInMinutes: 180 - workspace: - clean: all - variables: - ApkTestConfiguration: Release - steps: - - template: yaml-templates/setup-test-environment.yaml - parameters: - configuration: $(ApkTestConfiguration) - provisionatorChannel: ${{ parameters.provisionatorChannel }} - - - template: yaml-templates/run-xaprepare.yaml - parameters: - displayName: install emulator - arguments: --s=EmulatorTestDependencies - - - template: yaml-templates/run-dotnet-preview.yaml - parameters: - project: Xamarin.Android.sln - arguments: -t:PrepareJavaInterop -c $(XA.Build.Configuration) -m:1 -v:n - displayName: prepare java.interop $(XA.Build.Configuration) - continueOnError: false - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(ApkTestConfiguration) - testName: Xamarin.Android.JcwGen_Tests - project: tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj - testResultsFiles: TestResult-Xamarin.Android.JcwGen_Tests-$(ApkTestConfiguration).xml - artifactSource: bin/Test$(ApkTestConfiguration)/Xamarin.Android.JcwGen_Tests-Signed.apk - artifactFolder: Default - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(ApkTestConfiguration) - testName: Xamarin.Android.JcwGen_Tests_FastDev - project: tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj - testResultsFiles: TestResult-Xamarin.Android.JcwGen_Tests-$(ApkTestConfiguration).xml - artifactSource: bin/Test$(ApkTestConfiguration)/Xamarin.Android.JcwGen_Tests-Signed.apk - artifactFolder: FastDev_Assemblies_Dexes - extraBuildArgs: /p:AndroidFastDeploymentType=Assemblies:Dexes - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(ApkTestConfiguration) - testName: Xamarin.Android.Locale_Tests - project: tests/locales/Xamarin.Android.Locale-Tests/Xamarin.Android.Locale-Tests.csproj - testResultsFiles: TestResult-Xamarin.Android.Locale_Tests-$(ApkTestConfiguration).xml - artifactSource: bin/Test$(ApkTestConfiguration)/Xamarin.Android.Locale_Tests-Signed.apk - artifactFolder: Default - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(ApkTestConfiguration) - testName: Xamarin.Android.Locale_Tests-Aot - project: tests/locales/Xamarin.Android.Locale-Tests/Xamarin.Android.Locale-Tests.csproj - testResultsFiles: TestResult-Xamarin.Android.Locale_Tests-$(ApkTestConfiguration)-Aot.xml - extraBuildArgs: /p:AotAssemblies=True - artifactSource: bin/Test$(ApkTestConfiguration)/Xamarin.Android.Locale_Tests-Signed.apk - artifactFolder: Aot - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(ApkTestConfiguration) - testName: Xamarin.Android.Locale_Tests-Profiled-Aot - project: tests/locales/Xamarin.Android.Locale-Tests/Xamarin.Android.Locale-Tests.csproj - testResultsFiles: TestResult-Xamarin.Android.Locale_Tests-$(ApkTestConfiguration)-Profiled-Aot.xml - extraBuildArgs: /p:AotAssemblies=True /p:AndroidEnableProfiledAot=true - artifactSource: bin/Test$(ApkTestConfiguration)/Xamarin.Android.Locale_Tests-Signed.apk - artifactFolder: Profiled-Aot - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(ApkTestConfiguration) - testName: Xamarin.Android.EmbeddedDSO_Test - project: tests/EmbeddedDSOs/EmbeddedDSO/EmbeddedDSO.csproj - testResultsFiles: TestResult-Xamarin.Android.EmbeddedDSO_Test.nunit-$(ApkTestConfiguration).xml - artifactSource: bin/Test$(ApkTestConfiguration)/Xamarin.Android.EmbeddedDSO_Test-Signed.apk - artifactFolder: Default - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(ApkTestConfiguration) - testName: Xamarin.Forms-Performance-Integration - project: tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj - testResultsFiles: TestResult-apkdiff-Xamarin.Forms_Performance_Integration-Signed-$(ApkTestConfiguration).xml - artifactSource: bin/Test$(ApkTestConfiguration)/Xamarin.Forms_Performance_Integration-Signed.apk - artifactFolder: Default - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(ApkTestConfiguration) - testName: Xamarin.Forms-Performance-Integration-Aot - project: tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj - testResultsFiles: TestResult-apkdiff-Xamarin.Forms_Performance_Integration-Signed-$(ApkTestConfiguration)-Aot.xml - extraBuildArgs: /p:AotAssemblies=true - artifactSource: bin/Test$(ApkTestConfiguration)/Xamarin.Forms_Performance_Integration-Signed.apk - artifactFolder: Aot - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(ApkTestConfiguration) - testName: Xamarin.Forms-Performance-Integration-Profiled-Aot - project: tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj - testResultsFiles: TestResult-apkdiff-Xamarin.Forms_Performance_Integration-Signed-$(ApkTestConfiguration)-Profiled-Aot.xml - extraBuildArgs: /p:AotAssemblies=True /p:AndroidEnableProfiledAot=true - artifactSource: bin/Test$(ApkTestConfiguration)/Xamarin.Forms_Performance_Integration-Signed.apk - artifactFolder: Profiled-Aot - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(ApkTestConfiguration) - testName: Xamarin.Forms-Performance-Integration-Bundle - project: tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj - testResultsFiles: TestResult-apkdiff-Xamarin.Forms_Performance_Integration-Signed-$(ApkTestConfiguration)-Bundle.xml - extraBuildArgs: /p:BundleAssemblies=true - artifactSource: bin/Test$(ApkTestConfiguration)/Xamarin.Forms_Performance_Integration-Signed.apk - artifactFolder: Bundle - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(ApkTestConfiguration) - testName: VSAndroidApp - project: samples/VSAndroidAppProxy.csproj - testResultsFiles: TestResult-apkdiff-com.companyname.vsandroidapp-Signed-$(ApkTestConfiguration).xml - artifactSource: bin/Test$(ApkTestConfiguration)/com.companyname.vsandroidapp-Signed.apk - artifactFolder: Default - - - task: MSBuild@1 - displayName: shut down emulator - inputs: - solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj - configuration: $(ApkTestConfiguration) - msbuildArguments: >- - /t:AcquireAndroidTarget,ReleaseAndroidTarget - /bl:$(System.DefaultWorkingDirectory)/bin/Test$(ApkTestConfiguration)/shutdown-emulator.binlog - condition: always() - - - template: yaml-templates/upload-results.yaml - parameters: - configuration: $(ApkTestConfiguration) - artifactName: Test Results - APKs Legacy - macOS - - # Plots: Utilize command-line utility built here to send plot information contained in CSV files to AppInsights - - task: MSBuild@1 - displayName: build plots-to-appinsights - inputs: - solution: build-tools/plots-to-appinsights/ProcessPlotCSVFile.csproj - configuration: $(ApkTestConfiguration) - msbuildArguments: >- - /restore - /t:Build - /v:normal - /bl:$(System.DefaultWorkingDirectory)/bin/Test$(ApkTestConfiguration)/plots-to-appinsights.binlog - continueOnError: true - condition: and(succeeded(), or(eq(variables['Build.Reason'], 'IndividualCI'), eq(variables['Build.Reason'], 'Manual'))) - - # Process Plot CSV files and send results to AppInsights - # XamarinAndroidMetrics: https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/64e11c84-c922-4ffd-bea9-67ab39354edd/resourceGroups/XamarinMetrics/providers/microsoft.insights/components/XamarinAndroidMetrics/overview - # UNDONE: Need plot definitions for the following files: - # TestResult-Xamarin.Android.EmbeddedDSO_Test-times.csv - - - template: yaml-templates/plots-to-appinsights.yaml - parameters: - condition: and(succeeded(), or(eq(variables['Build.Reason'], 'IndividualCI'), eq(variables['Build.Reason'], 'Manual'))) - configuration: $(ApkTestConfiguration) - plotGroup: Test times - plotTitle: Runtime merged - plotPathAndFilename: $(System.DefaultWorkingDirectory)/TestResult-Mono.Android_Tests-times.csv - - - template: yaml-templates/plots-to-appinsights.yaml - parameters: - condition: and(succeeded(), or(eq(variables['Build.Reason'], 'IndividualCI'), eq(variables['Build.Reason'], 'Manual'))) - configuration: $(ApkTestConfiguration) - plotGroup: Test times - plotTitle: Jcw - plotPathAndFilename: $(System.DefaultWorkingDirectory)/TestResult-Xamarin.Android.JcwGen_Tests-times.csv - - - template: yaml-templates/plots-to-appinsights.yaml - parameters: - condition: and(succeeded(), or(eq(variables['Build.Reason'], 'IndividualCI'), eq(variables['Build.Reason'], 'Manual'))) - configuration: $(ApkTestConfiguration) - plotGroup: Test times - plotTitle: Locale - plotPathAndFilename: $(System.DefaultWorkingDirectory)/TestResult-Xamarin.Android.Locale_Tests-times.csv - - - template: yaml-templates/plots-to-appinsights.yaml - parameters: - condition: and(succeeded(), or(eq(variables['Build.Reason'], 'IndividualCI'), eq(variables['Build.Reason'], 'Manual'))) - configuration: $(ApkTestConfiguration) - plotGroup: Test times - plotTitle: Xamarin.Forms app startup - plotPathAndFilename: $(System.DefaultWorkingDirectory)/TestResult-Xamarin.Forms_Test-times.csv - - - template: yaml-templates/fail-on-issue.yaml # Check - "Xamarin.Android (macOS > Tests > APKs .NET)" - job: mac_apk_tests_net From 6cd61f101c1adfe5969c155f99f083d221b45224 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Fri, 24 Feb 2023 11:40:53 +0100 Subject: [PATCH 08/10] Fix --- tests/api-compatibility/acceptable-breakages-v8.0.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/api-compatibility/acceptable-breakages-v8.0.txt b/tests/api-compatibility/acceptable-breakages-v8.0.txt index d5b7d8a96fb..4df3c70db2f 100644 --- a/tests/api-compatibility/acceptable-breakages-v8.0.txt +++ b/tests/api-compatibility/acceptable-breakages-v8.0.txt @@ -76,3 +76,4 @@ CannotAddAbstractMembers : Member 'public Java.Net.SocketAddress Java.Nio.Channe CannotAddAbstractMembers : Member 'public Java.Net.SocketAddress Java.Nio.Channels.ServerSocketChannel.LocalAddress.get()' is abstract in the implementation but is missing in the contract. CannotAddAbstractMembers : Member 'public Java.Net.SocketAddress Java.Nio.Channels.SocketChannel.LocalAddress' is abstract in the implementation but is missing in the contract. CannotAddAbstractMembers : Member 'public Java.Net.SocketAddress Java.Nio.Channels.SocketChannel.LocalAddress.get()' is abstract in the implementation but is missing in the contract. +CannotRemoveAttribute : Attribute 'Android.Runtime.RegisterAttribute' exists on 'Java.Lang.JavaSystem.LoadLibrary(System.String)' in the contract but not the implementation. From d30cd08484df7e76898721bdf6ff4910f97c0cbd Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Tue, 28 Feb 2023 11:26:32 +0100 Subject: [PATCH 09/10] Remove BCL test again, after merge from main --- build-tools/automation/azure-pipelines.yaml | 69 --------------------- 1 file changed, 69 deletions(-) diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 84db6354913..f8cc8ffbdf0 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -446,75 +446,6 @@ stages: stageCondition: and(succeeded(), or(eq(variables['RunAllTests'], true), contains(dependencies.mac_build.outputs['mac_build_create_installers.TestConditions.TestAreas'], 'MSBuildDevice'))) nunit_categories: '& cat != DotNetIgnore & cat != HybridAOT & cat != MkBundle & cat != MonoSymbolicate & cat != PackagesConfig & cat != StaticProject & cat != SystemApplication' -- stage: bcl_tests - displayName: BCL Emulator Tests - dependsOn: mac_build - # Disabled on .NET release branches - condition: and(succeeded(), eq(variables.IsRelOrTargetingRel, 'False'), or(eq(variables['RunAllTests'], true), contains(dependencies.mac_build.outputs['mac_build_create_installers.TestConditions.TestAreas'], 'BCL'))) - jobs: - # Check - "Xamarin.Android (macOS > Tests > BCL (Emulator))" - - job: mac_bcl_tests - displayName: macOS > Tests > BCL (Emulator) - pool: - vmImage: $(HostedMacImage) - timeoutInMinutes: 180 - workspace: - clean: all - steps: - - template: yaml-templates/setup-test-environment.yaml - parameters: - provisionatorChannel: ${{ parameters.provisionatorChannel }} - - - template: yaml-templates/run-xaprepare.yaml - parameters: - displayName: install emulator - arguments: --s=EmulatorTestDependencies - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: $(TestAssembliesArtifactName) - downloadPath: $(System.DefaultWorkingDirectory)/bin/$(XA.Build.Configuration) - - - task: MSBuild@1 - displayName: build remap-assembly-ref.csproj - inputs: - solution: build-tools/remap-assembly-ref/remap-assembly-ref.csproj - configuration: $(XA.Build.Configuration) - msbuildArguments: /restore /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/remap-assembly-ref.binlog - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Xamarin.Android.Bcl-Tests - project: tests/BCL-Tests/Xamarin.Android.Bcl-Tests/Xamarin.Android.Bcl-Tests.csproj - testResultsFiles: TestResult-Xamarin.Android.Bcl_Tests.nunit-$(XA.Build.Configuration).xml - artifactSource: bin/Test$(XA.Build.Configuration)/Xamarin.Android.Bcl_Tests-Signed.apk - artifactFolder: Default - useDotNet: false - - - task: PublishTestResults@2 - displayName: publish Xamarin.Android.Bcl-Tests-XUnit results - inputs: - testResultsFormat: NUnit - testResultsFiles: TestResult-Xamarin.Android.Bcl_Tests.xunit-$(XA.Build.Configuration).xml - testRunTitle: Xamarin.Android.Bcl-Tests-NUnit - - - task: MSBuild@1 - displayName: shut down emulator - inputs: - solution: tests/BCL-Tests/Xamarin.Android.Bcl-Tests/Xamarin.Android.Bcl-Tests.csproj - configuration: $(XA.Build.Configuration) - msbuildArguments: >- - /t:AcquireAndroidTarget,ReleaseAndroidTarget - /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog - condition: always() - - - template: yaml-templates/upload-results.yaml - parameters: - artifactName: Test Results - BCL With Emulator - macOS - - - template: yaml-templates/fail-on-issue.yaml - - stage: dotnet_prepare_release displayName: Prepare .NET Release dependsOn: From 4dbe22a35851686cde588f31725daa64ce5a4295 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Wed, 15 Mar 2023 15:27:05 +0100 Subject: [PATCH 10/10] Fixup after merge --- src/monodroid/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monodroid/CMakeLists.txt b/src/monodroid/CMakeLists.txt index 3a5e6590ca7..1ed6694e993 100644 --- a/src/monodroid/CMakeLists.txt +++ b/src/monodroid/CMakeLists.txt @@ -716,7 +716,7 @@ target_link_libraries( ${LINK_LIBS} xamarin-app ) -if(ANDROID AND ENABLE_NET) +if(ANDROID) add_library( c SHARED ${XAMARIN_STUB_LIB_SOURCES}