From 14d26c6e4cc8bdbb720d3ec6dd3aea5ffe2560ed Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Thu, 7 Sep 2023 14:54:22 +0200 Subject: [PATCH 1/5] Always use runtime components as MSBuild items --- docs/design/mono/diagnostics-tracing.md | 47 +++++++++++++-- .../System.Diagnostics.Tracing.Tests.csproj | 7 ++- src/libraries/sendtohelix-mobile.targets | 3 + .../msbuild/android/build/AndroidBuild.props | 8 +++ .../android/build/AndroidBuild.targets | 37 +++++------- .../apple/build/AppleBuild.LocalBuild.props | 4 +- src/mono/msbuild/apple/build/AppleBuild.props | 8 +++ .../msbuild/apple/build/AppleBuild.targets | 42 ++++++-------- .../msbuild/apple/data/Directory.Build.props | 8 +-- .../apple/data/Directory.Build.targets | 2 +- .../apple/data/ProxyProjectForAOTOnHelix.proj | 7 ++- src/mono/msbuild/common/MonoSharedBuild.props | 26 +++++++++ .../common}/RuntimeComponentManifest.targets | 0 ...oft.NET.Runtime.LibraryBuilder.Sdk.pkgproj | 2 + .../Sdk/Sdk.targets.in | 1 + ...rosoft.NET.Runtime.MonoTargets.Sdk.pkgproj | 2 +- .../sample/Android/AndroidSampleApp.csproj | 13 ++--- src/mono/sample/Android/Makefile | 9 +-- src/mono/sample/iOS/Makefile | 12 +--- src/mono/sample/iOS/Program.csproj | 6 +- .../AndroidAppBuilder/AndroidAppBuilder.cs | 2 +- src/tasks/AndroidAppBuilder/ApkBuilder.cs | 57 +++++-------------- .../AndroidAppBuilder/Templates/monodroid.c | 2 +- src/tasks/AppleAppBuilder/AppleAppBuilder.cs | 20 ++----- .../Templates/runtime-librarymode.m | 2 +- src/tasks/AppleAppBuilder/Templates/runtime.m | 2 +- src/tasks/AppleAppBuilder/Xcode.cs | 29 +++------- ...d.Device_Emulator.Aot_Profiled.Test.csproj | 5 +- src/tests/build.proj | 8 ++- 29 files changed, 194 insertions(+), 177 deletions(-) create mode 100644 src/mono/msbuild/common/MonoSharedBuild.props rename src/mono/{nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk => msbuild/common}/RuntimeComponentManifest.targets (100%) diff --git a/docs/design/mono/diagnostics-tracing.md b/docs/design/mono/diagnostics-tracing.md index 9b5632c433fd77..9d1f668871caef 100644 --- a/docs/design/mono/diagnostics-tracing.md +++ b/docs/design/mono/diagnostics-tracing.md @@ -33,11 +33,11 @@ Depending on platform, there are different recommended and supported ways to inc ### Android -Android is build using dynamic component support, meaning that components are included as shared objects and runtime will try to load them from the same location as `libmonosgen-2.0.so`. If runtime fails to load component, it will be disabled, if it successfully loads the component at runtime, it will be enabled and used. Enabling/disabling components is then a matter of including/excluding the needed shared library files in the APK (in same folder as `libmonosgen-2.0.so`). The same runtime build can be used to support any combination of components. +Android is built using dynamic component support, meaning that components are included as shared objects and runtime will try to load them from the same location as `libmonosgen-2.0.so`. If runtime fails to load component, it will be disabled, if it successfully loads the component at runtime, it will be enabled and used. Enabling/disabling components is then a matter of including/excluding the needed shared library files in the APK (in same folder as `libmonosgen-2.0.so`). The same runtime build can be used to support any combination of components. -If `AndroidAppBuilderTask` is used, there is a msbuild property, `RuntimeComponents` that can be used to include specific components in the generated application. By default, its empty, meaning all components will be disabled, using a `*` will enabled all components and by specify individual components, only those will be enabled. Enabling tracing would look like this, `RuntimeComponents="diagnostics_tracing"`, more components can be enabled by separating them with `;`. +Android runtime pack has the following runtime components included: `debugger`, `hot_reload`, `diagnostics_tracing`, `marshal-ilgen`. -Android runtime pack have the following component libraries included. For default scenarios, the dynamic versions should be used together with `libmonosgen-2.0.so`, but runtime pack also includes static versions of the components that can be used if runtime is built statically using `libmonosgen-2.0.a`. In case of static linking, using `libmono-component-*-stub-static.a` library will disable the component, using `libmono-component-*-static.a` will enable it. +For default scenarios, the dynamic versions should be used together with `libmonosgen-2.0.so`, but runtime pack also includes static versions of the components that can be used if runtime is built statically using `libmonosgen-2.0.a`. In case of static linking, using `libmono-component-*-stub-static.a` library will disable the component, using `libmono-component-*-static.a` will enable it. ``` libmono-component-diagnostics_tracing.so @@ -45,13 +45,15 @@ libmono-component-diagnostics_tracing-static.a libmono-component-diagnostics_tracing-stub-static.a ``` +In order to enable the `diagnostic tracing` runtime component in your build, please take a look at [Enabling runtime components](#enabling-runtime-components) section. + ### iOS -iOS is build using static component support, meaning that components are included as static libraries that needs to be linked together with `libmonosgen-2.0.a` to produce final application. Static components come in two flavors, the component library, and a stub library. Linking the component library will enable the component in final application, while linking the stub library disables the component. Depending on linked component flavors it is possible to create a build that enables specific components while disabling others. All components needs to be linked in (using component or stub library) or there will be unresolved symbols in `libmonosgen-2.0.a`. +iOS is built using static component support, meaning that components are included as static libraries that needs to be linked together with `libmonosgen-2.0.a` to produce final application. Static components come in two flavors, the component library, and a stub library. Linking the component library will enable the component in final application, while linking the stub library disables the component. Depending on linked component flavors it is possible to create a build that enables specific components while disabling others. All components needs to be linked in (using component or stub library) or there will be unresolved symbols in `libmonosgen-2.0.a`. -If `AppleAppBuilderTask` is used, there is a msbuild property, `RuntimeComponents` that can be used to include specific components in the build application. By default, its empty, meaning all components will be disabled, using a `*` will enabled all components and by specify individual components, only those will be enabled. Enabling tracing would look like this, `RuntimeComponents="diagnostics_tracing"`, more components can be enabled by separating them with `;`. +iOS runtime pack has the following runtime components included: `debugger`, `hot_reload`, `diagnostics_tracing`, `marshal-ilgen`. -iOS runtime pack have the following component libraries included. Using `libmono-component-*-stub-static.a` library will disable the component, using `libmono-component-*-static.a` will enable it. +Using `libmono-component-*-stub-static.a` library will disable the component, using `libmono-component-*-static.a` will enable it. ``` libmono-component-diagnostics_tracing-static.a @@ -60,6 +62,39 @@ libmono-component-diagnostics_tracing-stub-static.a NOTE, running on iOS simulator offers some additional capabilities, so runtime pack for iOS includes shared as well as static library builds, like the Android use case described above. +In order to enable the `diagnostic tracing` runtime component in your build, please take a look at [Enabling runtime components](#enabling-runtime-components) section. + +### Enabling runtime components + +When using `AndroidAppBuilderTask` to target `Android`, or `AppleAppBuilderTask` to target `iOS` platforms, there is a MSBuild item: `RuntimeComponents` that can be used to include specific components in the generated application. By default, its empty, meaning all components will be disabled. +To enable a single component (eg: `diagnostic tracing`), by adding the following to your project file: +```xml + + + +``` +will enable only that runtime component. + +On the other hand, if it is desired to include all components, there are two options: +1. Manually, include all supported components manually via: +```xml + + + + + + +``` +2. Automatically, use provided MSBuild property that includes all the supported components for you, in the following way: + - Import `AndroidBuild.props/targets` in your project file (the file can be found [here](../../../src/mono/msbuild/android/build/AndroidBuild.targets)) + - Set `UseAllRuntimeComponents` MSBuild property to `true` via: + - By adding: `-p:UseAllRuntimeComponents=true` to your build command, or + - By adding the following in your project file: + ```xml + + true + + ``` ## Install diagnostic client tooling ``` diff --git a/src/libraries/System.Diagnostics.Tracing/tests/System.Diagnostics.Tracing.Tests.csproj b/src/libraries/System.Diagnostics.Tracing/tests/System.Diagnostics.Tracing.Tests.csproj index a650b53c7975c8..03b6eb9890a22e 100644 --- a/src/libraries/System.Diagnostics.Tracing/tests/System.Diagnostics.Tracing.Tests.csproj +++ b/src/libraries/System.Diagnostics.Tracing/tests/System.Diagnostics.Tracing.Tests.csproj @@ -5,9 +5,10 @@ true true - - diagnostics_tracing;marshal-ilgen - + + + + diff --git a/src/libraries/sendtohelix-mobile.targets b/src/libraries/sendtohelix-mobile.targets index 8bc9b527ac7d9d..6ad05011487a1e 100644 --- a/src/libraries/sendtohelix-mobile.targets +++ b/src/libraries/sendtohelix-mobile.targets @@ -58,6 +58,7 @@ <_XHarnessAppleCustomCommand Condition="'$(NeedsiOSSDK)' == 'true'"> source build-apple-app.sh + <_RuntimeComponentManifestDir>$([MSBuild]::NormalizeDirectory('$(MonoArtifactsPath)', 'build')) @@ -66,6 +67,8 @@ + linux <_IsLibraryMode Condition="'$(UseNativeAOTRuntime)' != 'true' and '$(NativeLib)' != ''">true + <_ReadRuntimeComponentsManifest Condition="'$(UseNativeAOTRuntime)' != 'true'">_MonoReadAvailableComponentsManifest Publish + $(_ReadRuntimeComponentsManifest); _InitializeCommonProperties; _BeforeAndroidBuild; _AndroidResolveReferences; @@ -21,5 +23,11 @@ _AndroidGenerateAppBundle; _AfterAndroidBuild + + + <_CommonTargetsDir Condition="'$(_CommonTargetsDir)' == ''">$(MSBuildThisFileDirectory)..\..\common\ + + + \ No newline at end of file diff --git a/src/mono/msbuild/android/build/AndroidBuild.targets b/src/mono/msbuild/android/build/AndroidBuild.targets index 99a226aafc603a..e9d70c0ef55018 100644 --- a/src/mono/msbuild/android/build/AndroidBuild.targets +++ b/src/mono/msbuild/android/build/AndroidBuild.targets @@ -41,16 +41,12 @@ <_MonoHeaderPath>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include', 'mono-2.0')) - - - <_RuntimeComponentList Include="$(RuntimeComponents)" /> - <_RuntimeComponentList Include="marshal-ilgen" KeepDuplicates="false"/> + + + + - - @(_RuntimeComponentList) - - <_CommonLinkerArgs Include="-l:libz.so" /> <_CommonLinkerArgs Include="-l:liblog.so" /> @@ -58,23 +54,16 @@ <_CommonLinkerArgs Include="-l:libm.so" /> <_CommonLinkerArgs Include="--build-id=sha1" /> - - - - - - <_UsedComponents - Condition="'$(RuntimeComponents)' != '' and '$(RuntimeComponents)' != '*'" - Include="$(RuntimeComponents)" /> + + + + - <_RuntimeLibraries - Include="$(AndroidBuildDir)\*-stub-static.a" /> - <_RuntimeLibraries - Include="$(AndroidBuildDir)\*.a" - Exclude="$(AndroidBuildDir)\*-static.a" /> + <_RuntimeLibraries Include="$(AndroidBuildDir)\*.a" Exclude="$(AndroidBuildDir)\libmono-component-*.a" /> + <_RuntimeLibraries Include="$(AndroidBuildDir)\libmono-component-*-stub-static.a" /> + <_RuntimeLibraries Condition="'@(RuntimeComponents)' != ''" Remove="$(AndroidBuildDir)\libmono-component-%(RuntimeComponents.Identity)-stub-static.a" /> + <_RuntimeLibraries Condition="'@(RuntimeComponents)' != ''" Include="$(AndroidBuildDir)\libmono-component-%(RuntimeComponents.Identity)-static.a" /> - <_RuntimeLibraries Remove="$(AndroidBuildDir)\libmono-component-%(_UsedComponents.Identity)-stub-static.a" /> - <_RuntimeLibraries Include="$(AndroidBuildDir)\libmono-component-%(_UsedComponents.Identity)-static.a" /> @@ -283,7 +272,7 @@ NativeDependencies="@(_NativeDependencies)" OutputDir="$(AndroidBundleDir)" ProjectName="$(AssemblyName)" - RuntimeComponents="$(RuntimeComponents)" + RuntimeComponents="@(RuntimeComponents)" RuntimeIdentifier="$(RuntimeIdentifier)" StripDebugSymbols="False"> diff --git a/src/mono/msbuild/apple/build/AppleBuild.LocalBuild.props b/src/mono/msbuild/apple/build/AppleBuild.LocalBuild.props index 1b26d384c4b995..8fe589c70e94fc 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.LocalBuild.props +++ b/src/mono/msbuild/apple/build/AppleBuild.LocalBuild.props @@ -19,7 +19,6 @@ $(AppleBuildSupportDir) - directory which has all the tasks, targets, and runtimepack --> - @@ -84,4 +83,7 @@ $([MSBuild]::NormalizePath('$(MonoTargetsTasksDir)', 'MonoTargetsTasks.dll')) + + + diff --git a/src/mono/msbuild/apple/build/AppleBuild.props b/src/mono/msbuild/apple/build/AppleBuild.props index 860ab8c6976aff..30d102bcf70c1c 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.props +++ b/src/mono/msbuild/apple/build/AppleBuild.props @@ -24,9 +24,11 @@ <_AotCompileTargetName Condition="'$(UseNativeAOTRuntime)' == 'true'">_AppleNativeAotCompile <_AotCompileTargetName Condition="'$(UseNativeAOTRuntime)' != 'true'">_AppleAotCompile ComputeIlcCompileInputs;SetupOSSpecificProps;PrepareForILLink + <_ReadRuntimeComponentsManifest Condition="'$(UseNativeAOTRuntime)' != 'true'">_MonoReadAvailableComponentsManifest Publish + $(_ReadRuntimeComponentsManifest); _InitializeCommonProperties; _BeforeAppleBuild; _AppleResolveReferences; @@ -37,5 +39,11 @@ _AppleGenerateAppBundle; _AfterAppleBuild + + + <_CommonTargetsDir Condition="'$(_CommonTargetsDir)' == ''">$(MSBuildThisFileDirectory)..\..\common\ + + + \ No newline at end of file diff --git a/src/mono/msbuild/apple/build/AppleBuild.targets b/src/mono/msbuild/apple/build/AppleBuild.targets index 936bb275516e16..f8da6b476fa324 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.targets +++ b/src/mono/msbuild/apple/build/AppleBuild.targets @@ -58,9 +58,11 @@ $(AssemblyName) - - marshal-ilgen - + + + + + @@ -106,47 +108,37 @@ - - - true - + - - + - + - + - + - - @(RuntimeComponentList) - - - - - - <_UsedComponents - Condition="'$(RuntimeComponents)' != '' and '$(RuntimeComponents)' != '*'" - Include="$(RuntimeComponents)" /> + + + + <_RuntimeLibraries Include="$(AppleBuildDir)\*.a" Exclude="$(AppleBuildDir)\libmono-component-*.a" /> <_RuntimeLibraries Include="$(AppleBuildDir)\libmono-component-*-stub-static.a" /> - <_RuntimeLibraries Remove="$(AppleBuildDir)\libmono-component-%(_UsedComponents.Identity)-stub-static.a" /> - <_RuntimeLibraries Include="$(AppleBuildDir)\libmono-component-%(_UsedComponents.Identity)-static.a" /> + <_RuntimeLibraries Condition="'@(RuntimeComponents)' != ''" Remove="$(AppleBuildDir)\libmono-component-%(RuntimeComponents.Identity)-stub-static.a" /> + <_RuntimeLibraries Condition="'@(RuntimeComponents)' != ''" Include="$(AppleBuildDir)\libmono-component-%(RuntimeComponents.Identity)-static.a" /> @@ -325,7 +317,7 @@ Optimized="$(Optimized)" OutputDirectory="$(AppleBundleDir)" ProjectName="$(AppName)" - RuntimeComponents="$(RuntimeComponents)" + RuntimeComponents="@(RuntimeComponents)" StripSymbolTable="$(StripDebugSymbols)" TargetOS="$(TargetOS)" UseConsoleUITemplate="$(UseConsoleUITemplate)" diff --git a/src/mono/msbuild/apple/data/Directory.Build.props b/src/mono/msbuild/apple/data/Directory.Build.props index d86cea231468b3..8e1cebe431fe3d 100644 --- a/src/mono/msbuild/apple/data/Directory.Build.props +++ b/src/mono/msbuild/apple/data/Directory.Build.props @@ -2,17 +2,17 @@ $(HELIX_CORRELATION_PAYLOAD)\build\ <_AppleTargetsDir>$(AppleBuildSupportDir)\apple\ - <_LibraryTargetsDir>$(AppleBuildSupportDir)\common\ + <_CommonTargetsDir>$(AppleBuildSupportDir)\common\ <_AppleTargetsDir Condition="'$(_AppleTargetsDir)' == '' and '$(RuntimeSrcDir)' != ''">$(RuntimeSrcDir)\src\mono\msbuild\apple\build\ <_AppleTargetsDir Condition="'$(_AppleTargetsDir)' != ''">$([MSBuild]::EnsureTrailingSlash($(_AppleTargetsDir))) - <_LibraryTargetsDir Condition="'$(_LibraryTargetsDir)' == '' and '$(RuntimeSrcDir)' != ''">$(RuntimeSrcDir)\src\mono\msbuild\common\ - <_LibraryTargetsDir Condition="'$(_LibraryTargetsDir)' != ''">$([MSBuild]::EnsureTrailingSlash($(_LibraryTargetsDir))) + <_CommonTargetsDir Condition="'$(_CommonTargetsDir)' == '' and '$(RuntimeSrcDir)' != ''">$(RuntimeSrcDir)\src\mono\msbuild\common\ + <_CommonTargetsDir Condition="'$(_CommonTargetsDir)' != ''">$([MSBuild]::EnsureTrailingSlash($(_CommonTargetsDir))) - + PrepareForAppleBuild;$(AppleBuildDependsOn) diff --git a/src/mono/msbuild/apple/data/Directory.Build.targets b/src/mono/msbuild/apple/data/Directory.Build.targets index 329f06b80dee2f..59ea9bc47ba208 100644 --- a/src/mono/msbuild/apple/data/Directory.Build.targets +++ b/src/mono/msbuild/apple/data/Directory.Build.targets @@ -14,6 +14,6 @@ - + diff --git a/src/mono/msbuild/apple/data/ProxyProjectForAOTOnHelix.proj b/src/mono/msbuild/apple/data/ProxyProjectForAOTOnHelix.proj index 37be991b09c922..1bdf85d6403b15 100644 --- a/src/mono/msbuild/apple/data/ProxyProjectForAOTOnHelix.proj +++ b/src/mono/msbuild/apple/data/ProxyProjectForAOTOnHelix.proj @@ -53,9 +53,14 @@ - diagnostics_tracing;marshal-ilgen 127.0.0.1:9000,nosuspend,listen + + + + + + + + false + + <_RuntimeComponentManifestDir Condition="'$(_RuntimeComponentManifestDir)' == '' and '$(BuildTestsOn)' != 'helix' and '$(MonoArtifactsPath)' != ''">$([MSBuild]::NormalizePath('$(MonoArtifactsPath)', 'build')) + <_RuntimeComponentManifestDir Condition="'$(_RuntimeComponentManifestDir)' == '' and '$(BuildTestsOn)' != 'helix' and '$(RuntimeBinDir)' != ''">$([MSBuild]::NormalizePath('$(RuntimeBinDir)', 'build')) + <_RuntimeComponentManifestDir Condition="'$(_RuntimeComponentManifestDir)' == '' and '$(MicrosoftNetCoreAppRuntimePackRidDir)' != ''">$([MSBuild]::NormalizePath('$(MicrosoftNetCoreAppRuntimePackRidDir)', 'build')) + <_RuntimeComponentManifestDir>$([MSBuild]::EnsureTrailingSlash('$(_RuntimeComponentManifestDir)')) + <_MonoRuntimeComponentManifestJsonFilePath Condition="'$(_MonoRuntimeComponentManifestJsonFilePath)' == '' and '$(_RuntimeComponentManifestDir)' != ''">$(_RuntimeComponentManifestDir)RuntimeComponentManifest.json + + + + + <_MonoRuntimeComponentSharedLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + <_MonoRuntimeComponentStaticLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + <_MonoRuntimeComponentLinking ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + <_MonoRuntimeAvailableComponents ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + + + \ No newline at end of file diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets b/src/mono/msbuild/common/RuntimeComponentManifest.targets similarity index 100% rename from src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets rename to src/mono/msbuild/common/RuntimeComponentManifest.targets diff --git a/src/mono/nuget/Microsoft.NET.Runtime.LibraryBuilder.Sdk/Microsoft.NET.Runtime.LibraryBuilder.Sdk.pkgproj b/src/mono/nuget/Microsoft.NET.Runtime.LibraryBuilder.Sdk/Microsoft.NET.Runtime.LibraryBuilder.Sdk.pkgproj index f01678f86f6ded..8839ca2e1c7890 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.LibraryBuilder.Sdk/Microsoft.NET.Runtime.LibraryBuilder.Sdk.pkgproj +++ b/src/mono/nuget/Microsoft.NET.Runtime.LibraryBuilder.Sdk/Microsoft.NET.Runtime.LibraryBuilder.Sdk.pkgproj @@ -16,6 +16,8 @@ + + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.LibraryBuilder.Sdk/Sdk/Sdk.targets.in b/src/mono/nuget/Microsoft.NET.Runtime.LibraryBuilder.Sdk/Sdk/Sdk.targets.in index dbe8e157a0026e..633a0414b80d16 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.LibraryBuilder.Sdk/Sdk/Sdk.targets.in +++ b/src/mono/nuget/Microsoft.NET.Runtime.LibraryBuilder.Sdk/Sdk/Sdk.targets.in @@ -10,6 +10,7 @@ $(_TasksDir)LibraryBuilder.dll $(_TasksDir)MobileBuildTasks.dll + <_CommonTargetsDir>$(MSBuildThisFileDirectory) diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj index 8d9e3dea06baf8..f2db3fcf82d2d1 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj @@ -13,7 +13,7 @@ - + diff --git a/src/mono/sample/Android/AndroidSampleApp.csproj b/src/mono/sample/Android/AndroidSampleApp.csproj index c5316052559933..6e0d76f4919ad9 100644 --- a/src/mono/sample/Android/AndroidSampleApp.csproj +++ b/src/mono/sample/Android/AndroidSampleApp.csproj @@ -10,6 +10,10 @@ false + + + + @@ -46,14 +50,9 @@ - <_RuntimeComponentList Include="$(RuntimeComponents)" /> - <_RuntimeComponentList Include="marshal-ilgen" KeepDuplicates="false"/> + - - @(_RuntimeComponentList) - - <_AotOutputType>Library <_AotLibraryFormat>So @@ -116,7 +115,7 @@ MonoRuntimeHeaders="$(MicrosoftNetCoreAppRuntimePackDir)runtimes\android-$(TargetArchitecture)\native\include\mono-2.0" OutputDir="$(ApkDir)" ProjectName="HelloAndroid" - RuntimeComponents="$(RuntimeComponents)" + RuntimeComponents="@(RuntimeComponents)" RuntimeIdentifier="$(RuntimeIdentifier)" StripDebugSymbols="$(StripDebugSymbols)"> diff --git a/src/mono/sample/Android/Makefile b/src/mono/sample/Android/Makefile index 7c741f0c96b835..6fe6205e3148dd 100644 --- a/src/mono/sample/Android/Makefile +++ b/src/mono/sample/Android/Makefile @@ -7,15 +7,13 @@ AOT_WITH_LIBRARY_FILES=false INTERP=false DEPLOY_AND_RUN?=true -#If DIAGNOSTIC_PORTS is enabled, RUNTIME_COMPONENTS must also be enabled. -#If RUNTIME_COMPONENTS is enabled, DIAGNOSTIC_PORTS is optional. -#If RUNTIME_COMPONENTS is enabled, DIAGNOSTIC_PORTS is disabled, use DOTNET_DiagnosticPorts when launching application to enable diagnostics. -#RUNTIME_COMPONENTS=marshal-ilgen;diagnostics_tracing +#If DIAGNOSTIC_PORTS is enabled, @(RuntimeComponents) must also include 'diagnostics_tracing'. +#If @(RuntimeComponents) includes 'diagnostics_tracing', DIAGNOSTIC_PORTS is optional. +#If @(RuntimeComponents) includes 'diagnostics_tracing', DIAGNOSTIC_PORTS is disabled, use DOTNET_DiagnosticPorts when launching application to enable diagnostics. #DIAGNOSTIC_PORTS=10.0.2.2:9000,nosuspend #DIAGNOSTIC_PORTS=10.0.2.2:9000,suspend #DIAGNOSTIC_PORTS=$(DOTNET_DiagnosticPorts) - all: runtimepack run runtimepack: @@ -33,7 +31,6 @@ run: /p:MonoForceInterpreter=$(INTERP) \ /p:UseLLVM=$(USE_LLVM) \ /p:RunActivity=false \ - '/p:RuntimeComponents="$(RUNTIME_COMPONENTS)"' \ '/p:DiagnosticPorts="$(DIAGNOSTIC_PORTS)"' clean: rm -rf ../../../../artifacts/bin/AndroidSampleApp diff --git a/src/mono/sample/iOS/Makefile b/src/mono/sample/iOS/Makefile index 9c55609d72382b..60887e9b7abc6c 100644 --- a/src/mono/sample/iOS/Makefile +++ b/src/mono/sample/iOS/Makefile @@ -8,10 +8,9 @@ APP_SANDBOX?=false STRIP_DEBUG_SYMBOLS?=false # only used when measuring SOD via build-appbundle make target HYBRID_GLOBALIZATION?=false -#If DIAGNOSTIC_PORTS is enabled, RUNTIME_COMPONENTS must also be enabled. -#If RUNTIME_COMPONENTS is enabled, DIAGNOSTIC_PORTS is optional. -#If RUNTIME_COMPONENTS is enabled, DIAGNOSTIC_PORTS is disabled, use DOTNET_DiagnosticPorts when launching application to enable diagnostics. -#RUNTIME_COMPONENTS=marshal-ilgen;diagnostics_tracing +#If DIAGNOSTIC_PORTS is enabled, @(RuntimeComponents) must also include 'diagnostics_tracing'. +#If @(RuntimeComponents) includes 'diagnostics_tracing', DIAGNOSTIC_PORTS is optional. +#If @(RuntimeComponents) includes 'diagnostics_tracing', DIAGNOSTIC_PORTS is disabled, use DOTNET_DiagnosticPorts when launching application to enable diagnostics. #DIAGNOSTIC_PORTS=127.0.0.1:9000,nosuspend #DIAGNOSTIC_PORTS=127.0.0.1:9000,suspend #DIAGNOSTIC_PORTS=$(DOTNET_DiagnosticPorts) @@ -45,7 +44,6 @@ run: clean appbuilder /p:TargetArchitecture=$(MONO_ARCH) \ /p:MonoEnableLLVM=$(USE_LLVM) \ /p:DeployAndRun=$(DEPLOY_AND_RUN) \ - '/p:RuntimeComponents="$(RUNTIME_COMPONENTS)"' \ '/p:DiagnosticPorts="$(DIAGNOSTIC_PORTS)"' \ /bl @@ -57,7 +55,6 @@ run-sim: clean appbuilder /p:MonoEnableLLVM=$(USE_LLVM) \ /p:MonoForceInterpreter=false \ /p:DeployAndRun=$(DEPLOY_AND_RUN) \ - '/p:RuntimeComponents="$(RUNTIME_COMPONENTS)"' \ '/p:DiagnosticPorts="$(DIAGNOSTIC_PORTS)"' \ /bl @@ -69,7 +66,6 @@ run-sim-interp: clean appbuilder /p:MonoEnableLLVM=$(USE_LLVM) \ /p:MonoForceInterpreter=true \ /p:DeployAndRun=$(DEPLOY_AND_RUN) \ - '/p:RuntimeComponents="$(RUNTIME_COMPONENTS)"' \ '/p:DiagnosticPorts="$(DIAGNOSTIC_PORTS)"' \ /bl @@ -82,7 +78,6 @@ run-catalyst: clean appbuilder /p:MonoForceInterpreter=false \ /p:DeployAndRun=$(DEPLOY_AND_RUN) \ /p:EnableAppSandbox=$(APP_SANDBOX) \ - '/p:RuntimeComponents="$(RUNTIME_COMPONENTS)"' \ /bl run-catalyst-interp: clean appbuilder @@ -94,7 +89,6 @@ run-catalyst-interp: clean appbuilder /p:MonoForceInterpreter=true \ /p:DeployAndRun=$(DEPLOY_AND_RUN) \ /p:EnableAppSandbox=$(APP_SANDBOX) \ - '/p:RuntimeComponents="$(RUNTIME_COMPONENTS)"' \ /bl clean: diff --git a/src/mono/sample/iOS/Program.csproj b/src/mono/sample/iOS/Program.csproj index f7b0306ba23c1d..647976dfc5c178 100644 --- a/src/mono/sample/iOS/Program.csproj +++ b/src/mono/sample/iOS/Program.csproj @@ -26,13 +26,17 @@ Publish + + + + - + diff --git a/src/tasks/AndroidAppBuilder/AndroidAppBuilder.cs b/src/tasks/AndroidAppBuilder/AndroidAppBuilder.cs index ddbbe5bc64d195..626a6d2b191705 100644 --- a/src/tasks/AndroidAppBuilder/AndroidAppBuilder.cs +++ b/src/tasks/AndroidAppBuilder/AndroidAppBuilder.cs @@ -66,7 +66,7 @@ public class AndroidAppBuilderTask : Task /// /// List of enabled runtime components /// - public string? RuntimeComponents { get; set; } = ""!; + public string[] RuntimeComponents { get; set; } = Array.Empty(); /// /// Diagnostic ports configuration string diff --git a/src/tasks/AndroidAppBuilder/ApkBuilder.cs b/src/tasks/AndroidAppBuilder/ApkBuilder.cs index 98188fdbe919c6..50d52ecb998a69 100644 --- a/src/tasks/AndroidAppBuilder/ApkBuilder.cs +++ b/src/tasks/AndroidAppBuilder/ApkBuilder.cs @@ -35,7 +35,7 @@ public partial class ApkBuilder public bool InvariantGlobalization { get; set; } public bool EnableRuntimeLogging { get; set; } public bool StaticLinkedRuntime { get; set; } - public string? RuntimeComponents { get; set; } + public string[] RuntimeComponents { get; set; } = Array.Empty(); public string? DiagnosticPorts { get; set; } public bool IsLibraryMode { get; set; } public ITaskItem[] Assemblies { get; set; } = Array.Empty(); @@ -98,19 +98,9 @@ public ApkBuilder(TaskLoggingHelper logger) throw new InvalidOperationException("Interpreter and AOT cannot be enabled at the same time"); } - if (!string.IsNullOrEmpty(DiagnosticPorts)) + if (!string.IsNullOrEmpty(DiagnosticPorts) && !Array.Exists(RuntimeComponents, runtimeComponent => string.Equals(runtimeComponent, "diagnostics_tracing", StringComparison.OrdinalIgnoreCase))) { - bool validDiagnosticsConfig = false; - - if (string.IsNullOrEmpty(RuntimeComponents)) - validDiagnosticsConfig = false; - else if (RuntimeComponents.Equals("*", StringComparison.OrdinalIgnoreCase)) - validDiagnosticsConfig = true; - else if (RuntimeComponents.Contains("diagnostics_tracing", StringComparison.OrdinalIgnoreCase)) - validDiagnosticsConfig = true; - - if (!validDiagnosticsConfig) - throw new ArgumentException("Using DiagnosticPorts require diagnostics_tracing runtime component."); + throw new ArgumentException("Using DiagnosticPorts requires diagnostics_tracing runtime component."); } // Try to get the latest build-tools version if not specified @@ -278,34 +268,19 @@ public ApkBuilder(TaskLoggingHelper logger) if (StaticLinkedRuntime) { string[] staticComponentStubLibs = Directory.GetFiles(AppDir, "libmono-component-*-stub-static.a"); - bool staticLinkAllComponents = false; - string[] staticLinkedComponents = Array.Empty(); - - if (!string.IsNullOrEmpty(RuntimeComponents) && RuntimeComponents.Equals("*", StringComparison.OrdinalIgnoreCase)) - staticLinkAllComponents = true; - else if (!string.IsNullOrEmpty(RuntimeComponents)) - staticLinkedComponents = RuntimeComponents.Split(";"); // by default, component stubs will be linked and depending on how mono runtime has been build, // stubs can disable or dynamic load components. foreach (string staticComponentStubLib in staticComponentStubLibs) { string componentLibToLink = staticComponentStubLib; - if (staticLinkAllComponents) + foreach (string runtimeComponent in RuntimeComponents) { - // static link component. - componentLibToLink = componentLibToLink.Replace("-stub-static.a", "-static.a", StringComparison.OrdinalIgnoreCase); - } - else - { - foreach (string staticLinkedComponent in staticLinkedComponents) + if (componentLibToLink.Contains(runtimeComponent, StringComparison.OrdinalIgnoreCase)) { - if (componentLibToLink.Contains(staticLinkedComponent, StringComparison.OrdinalIgnoreCase)) - { - // static link component. - componentLibToLink = componentLibToLink.Replace("-stub-static.a", "-static.a", StringComparison.OrdinalIgnoreCase); - break; - } + // static link component. + componentLibToLink = componentLibToLink.Replace("-stub-static.a", "-static.a", StringComparison.OrdinalIgnoreCase); + break; } } @@ -461,13 +436,6 @@ public ApkBuilder(TaskLoggingHelper logger) } // add all *.so files to lib/%abi%/ - string[] dynamicLinkedComponents = Array.Empty(); - bool dynamicLinkAllComponents = false; - if (!StaticLinkedRuntime && !string.IsNullOrEmpty(RuntimeComponents) && RuntimeComponents.Equals("*", StringComparison.OrdinalIgnoreCase)) - dynamicLinkAllComponents = true; - if (!string.IsNullOrEmpty(RuntimeComponents) && !StaticLinkedRuntime) - dynamicLinkedComponents = RuntimeComponents.Split(";"); - Directory.CreateDirectory(Path.Combine(OutputDir, "lib", abi)); foreach (var dynamicLib in dynamicLibs) { @@ -485,18 +453,19 @@ public ApkBuilder(TaskLoggingHelper logger) if (dynamicLibName.Contains("libmono-component-", StringComparison.OrdinalIgnoreCase)) { - bool includeComponent = dynamicLinkAllComponents; - if (!StaticLinkedRuntime && !includeComponent) + bool includeComponent = false; + if (!StaticLinkedRuntime) { - foreach (string dynamicLinkedComponent in dynamicLinkedComponents) + foreach (string runtimeComponent in RuntimeComponents) { - if (dynamicLibName.Contains(dynamicLinkedComponent, StringComparison.OrdinalIgnoreCase)) + if (dynamicLibName.Contains(runtimeComponent, StringComparison.OrdinalIgnoreCase)) { includeComponent = true; break; } } } + if (!includeComponent) { // make sure dynamic component is not included in package. diff --git a/src/tasks/AndroidAppBuilder/Templates/monodroid.c b/src/tasks/AndroidAppBuilder/Templates/monodroid.c index 109b0bd18736e4..d139109f7b0a90 100644 --- a/src/tasks/AndroidAppBuilder/Templates/monodroid.c +++ b/src/tasks/AndroidAppBuilder/Templates/monodroid.c @@ -234,7 +234,7 @@ mono_droid_runtime_init (const char* executable, int managed_argc, char* managed // build using DiagnosticPorts property in AndroidAppBuilder // or set DOTNET_DiagnosticPorts env via adb, xharness when undefined. - // NOTE, using DOTNET_DiagnosticPorts requires app build using AndroidAppBuilder and RuntimeComponents=diagnostics_tracing + // NOTE, using DOTNET_DiagnosticPorts requires app build using AndroidAppBuilder and RuntimeComponents to include 'diagnostics_tracing' component #ifdef DIAGNOSTIC_PORTS setenv ("DOTNET_DiagnosticPorts", DIAGNOSTIC_PORTS, true); #endif diff --git a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs index 5315533105a0a2..617f82dae07729 100644 --- a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs +++ b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs @@ -140,7 +140,7 @@ public string TargetOS /// /// List of enabled runtime components /// - public string? RuntimeComponents { get; set; } = ""!; + public string[] RuntimeComponents { get; set; } = Array.Empty(); /// /// Diagnostic ports configuration string @@ -207,8 +207,8 @@ public void ValidateRuntimeSelection() if (ForceAOT) throw new ArgumentException($"Property \"{nameof(ForceAOT)}\" is not supported with NativeAOT runtime and will be ignored."); - if (!string.IsNullOrEmpty(RuntimeComponents)) - throw new ArgumentException($"Property \"{nameof(RuntimeComponents)}\" is not supported with NativeAOT runtime and will be ignored."); + if (RuntimeComponents.Length > 0) + throw new ArgumentException($"Item \"{nameof(RuntimeComponents)}\" is not supported with NativeAOT runtime and will be ignored."); if (!string.IsNullOrEmpty(DiagnosticPorts)) throw new ArgumentException($"Property \"{nameof(DiagnosticPorts)}\" is not supported with NativeAOT runtime and will be ignored."); @@ -294,19 +294,9 @@ public override bool Execute() } } - if (!string.IsNullOrEmpty(DiagnosticPorts)) + if (!string.IsNullOrEmpty(DiagnosticPorts) && !Array.Exists(RuntimeComponents, runtimeComponent => string.Equals(runtimeComponent, "diagnostics_tracing", StringComparison.OrdinalIgnoreCase))) { - bool validDiagnosticsConfig = false; - - if (string.IsNullOrEmpty(RuntimeComponents)) - validDiagnosticsConfig = false; - else if (RuntimeComponents.Equals("*", StringComparison.OrdinalIgnoreCase)) - validDiagnosticsConfig = true; - else if (RuntimeComponents.Contains("diagnostics_tracing", StringComparison.OrdinalIgnoreCase)) - validDiagnosticsConfig = true; - - if (!validDiagnosticsConfig) - throw new ArgumentException("Using DiagnosticPorts require diagnostics_tracing runtime component."); + throw new ArgumentException("Using DiagnosticPorts requires diagnostics_tracing runtime component."); } if (EnableAppSandbox && (string.IsNullOrEmpty(DevTeamProvisioning) || DevTeamProvisioning == "-")) diff --git a/src/tasks/AppleAppBuilder/Templates/runtime-librarymode.m b/src/tasks/AppleAppBuilder/Templates/runtime-librarymode.m index b3efb76186f138..066d92c2463f7a 100644 --- a/src/tasks/AppleAppBuilder/Templates/runtime-librarymode.m +++ b/src/tasks/AppleAppBuilder/Templates/runtime-librarymode.m @@ -66,7 +66,7 @@ int invoke_netlibrary_entrypoints (void) // build using DiagnosticPorts property in AppleAppBuilder // or set DOTNET_DiagnosticPorts env via mlaunch, xharness when undefined. - // NOTE, using DOTNET_DiagnosticPorts requires app build using AppleAppBuilder and RuntimeComponents=diagnostics_tracing + // NOTE, using DOTNET_DiagnosticPorts requires app build using AppleAppBuilder and RuntimeComponents to include 'diagnostics_tracing' component #ifdef DIAGNOSTIC_PORTS setenv ("DOTNET_DiagnosticPorts", DIAGNOSTIC_PORTS, true); #endif diff --git a/src/tasks/AppleAppBuilder/Templates/runtime.m b/src/tasks/AppleAppBuilder/Templates/runtime.m index d577f06a3a1def..4a60f33f5d7d20 100644 --- a/src/tasks/AppleAppBuilder/Templates/runtime.m +++ b/src/tasks/AppleAppBuilder/Templates/runtime.m @@ -272,7 +272,7 @@ static bool is_pinvoke_override_library (const char* libraryName) // build using DiagnosticPorts property in AppleAppBuilder // or set DOTNET_DiagnosticPorts env via mlaunch, xharness when undefined. - // NOTE, using DOTNET_DiagnosticPorts requires app build using AppleAppBuilder and RuntimeComponents=diagnostics_tracing + // NOTE, using DOTNET_DiagnosticPorts requires app build using AppleAppBuilder and RuntimeComponents to include 'diagnostics_tracing' component #ifdef DIAGNOSTIC_PORTS setenv ("DOTNET_DiagnosticPorts", DIAGNOSTIC_PORTS, true); #endif diff --git a/src/tasks/AppleAppBuilder/Xcode.cs b/src/tasks/AppleAppBuilder/Xcode.cs index 0e05d9168423e0..867bb2cec15c4e 100644 --- a/src/tasks/AppleAppBuilder/Xcode.cs +++ b/src/tasks/AppleAppBuilder/Xcode.cs @@ -188,7 +188,7 @@ public string GenerateXCode( bool enableRuntimeLogging, bool enableAppSandbox, string? diagnosticPorts, - string? runtimeComponents = null, + IEnumerable runtimeComponents, string? nativeMainSource = null, bool useNativeAOTRuntime = false, bool isLibraryMode = false) @@ -252,7 +252,7 @@ public string GenerateCMake( bool enableRuntimeLogging, bool enableAppSandbox, string? diagnosticPorts, - string? runtimeComponents = null, + IEnumerable runtimeComponents, string? nativeMainSource = null, bool useNativeAOTRuntime = false, bool isLibraryMode = false) @@ -337,34 +337,19 @@ public string GenerateCMake( { string[] allComponentLibs = Directory.GetFiles(workspace, "libmono-component-*-static.a"); string[] staticComponentStubLibs = Directory.GetFiles(workspace, "libmono-component-*-stub-static.a"); - bool staticLinkAllComponents = false; - string[] staticLinkedComponents = Array.Empty(); - - if (!string.IsNullOrEmpty(runtimeComponents) && runtimeComponents.Equals("*", StringComparison.OrdinalIgnoreCase)) - staticLinkAllComponents = true; - else if (!string.IsNullOrEmpty(runtimeComponents)) - staticLinkedComponents = runtimeComponents.Split(";"); // by default, component stubs will be linked and depending on how mono runtime has been build, // stubs can disable or dynamic load components. foreach (string staticComponentStubLib in staticComponentStubLibs) { string componentLibToLink = staticComponentStubLib; - if (staticLinkAllComponents) - { - // static link component. - componentLibToLink = componentLibToLink.Replace("-stub-static.a", "-static.a", StringComparison.OrdinalIgnoreCase); - } - else + foreach (string runtimeComponent in runtimeComponents) { - foreach (string staticLinkedComponent in staticLinkedComponents) + if (componentLibToLink.Contains(runtimeComponent, StringComparison.OrdinalIgnoreCase)) { - if (componentLibToLink.Contains(staticLinkedComponent, StringComparison.OrdinalIgnoreCase)) - { - // static link component. - componentLibToLink = componentLibToLink.Replace("-stub-static.a", "-static.a", StringComparison.OrdinalIgnoreCase); - break; - } + // static link component. + componentLibToLink = componentLibToLink.Replace("-stub-static.a", "-static.a", StringComparison.OrdinalIgnoreCase); + break; } } diff --git a/src/tests/FunctionalTests/Android/Device_Emulator/AOT_PROFILED/Android.Device_Emulator.Aot_Profiled.Test.csproj b/src/tests/FunctionalTests/Android/Device_Emulator/AOT_PROFILED/Android.Device_Emulator.Aot_Profiled.Test.csproj index aaaf9e924f4262..4394c46be87867 100644 --- a/src/tests/FunctionalTests/Android/Device_Emulator/AOT_PROFILED/Android.Device_Emulator.Aot_Profiled.Test.csproj +++ b/src/tests/FunctionalTests/Android/Device_Emulator/AOT_PROFILED/Android.Device_Emulator.Aot_Profiled.Test.csproj @@ -13,10 +13,13 @@ - + + + + diff --git a/src/tests/build.proj b/src/tests/build.proj index 5bbe4b6d828532..a9314100a4e8d4 100644 --- a/src/tests/build.proj +++ b/src/tests/build.proj @@ -195,7 +195,6 @@ $(BuildDir)\apk $(XUnitTestBinBase)$(CategoryWithSlash)\$(Category).apk False - diagnostics_tracing;marshal-ilgen 127.0.0.1:9000,nosuspend,listen True $(ArtifactsBinDir)microsoft.netcore.app.runtime.android-$(TargetArchitecture)\$(Configuration)\runtimes\android-$(TargetArchitecture)\ @@ -207,6 +206,11 @@ true + + + + + @@ -247,7 +251,7 @@ MonoRuntimeHeaders="$(MicrosoftNetCoreAppRuntimePackDir)/native/include/mono-2.0" OutputDir="$(AppDir)" ProjectName="$(Category)" - RuntimeComponents="$(RuntimeComponents)" + RuntimeComponents="@(RuntimeComponents)" RuntimeIdentifier="$(RuntimeIdentifier)" StripDebugSymbols="$(StripDebugSymbols)"> From 88bc9277d6245864642f19e6f902987b183fcbf2 Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Tue, 17 Oct 2023 14:44:39 +0200 Subject: [PATCH 2/5] Addressing PR feedback --- .../System.Diagnostics.Tracing.Tests.csproj | 4 +- .../msbuild/android/build/AndroidBuild.props | 6 +-- .../android/build/AndroidBuild.targets | 8 ++-- src/mono/msbuild/apple/build/AppleBuild.props | 6 +-- .../msbuild/apple/build/AppleBuild.targets | 8 ++-- src/mono/msbuild/common/MonoSharedBuild.props | 44 +++++++++---------- .../sample/Android/AndroidSampleApp.csproj | 2 +- src/mono/sample/Android/Makefile | 2 +- src/mono/sample/iOS/Makefile | 2 +- src/mono/sample/iOS/Program.csproj | 2 +- src/tasks/AndroidAppBuilder/ApkBuilder.cs | 2 +- src/tasks/AppleAppBuilder/AppleAppBuilder.cs | 2 +- ...d.Device_Emulator.Aot_Profiled.Test.csproj | 2 +- 13 files changed, 43 insertions(+), 47 deletions(-) diff --git a/src/libraries/System.Diagnostics.Tracing/tests/System.Diagnostics.Tracing.Tests.csproj b/src/libraries/System.Diagnostics.Tracing/tests/System.Diagnostics.Tracing.Tests.csproj index 03b6eb9890a22e..8c5a0b086946fb 100644 --- a/src/libraries/System.Diagnostics.Tracing/tests/System.Diagnostics.Tracing.Tests.csproj +++ b/src/libraries/System.Diagnostics.Tracing/tests/System.Diagnostics.Tracing.Tests.csproj @@ -6,8 +6,8 @@ true - - + + diff --git a/src/mono/msbuild/android/build/AndroidBuild.props b/src/mono/msbuild/android/build/AndroidBuild.props index 2b3a6200092eef..03237e1fbf2154 100644 --- a/src/mono/msbuild/android/build/AndroidBuild.props +++ b/src/mono/msbuild/android/build/AndroidBuild.props @@ -9,11 +9,11 @@ <_HostOS Condition="'$(_HostOS)' == ''">linux <_IsLibraryMode Condition="'$(UseNativeAOTRuntime)' != 'true' and '$(NativeLib)' != ''">true - <_ReadRuntimeComponentsManifest Condition="'$(UseNativeAOTRuntime)' != 'true'">_MonoReadAvailableComponentsManifest + <_ReadRuntimeComponentsManifestTargetName Condition="'$(UseNativeAOTRuntime)' != 'true'">_MonoReadAvailableComponentsManifest Publish - $(_ReadRuntimeComponentsManifest); + $(_ReadRuntimeComponentsManifestTargetName); _InitializeCommonProperties; _BeforeAndroidBuild; _AndroidResolveReferences; @@ -25,7 +25,7 @@ - <_CommonTargetsDir Condition="'$(_CommonTargetsDir)' == ''">$(MSBuildThisFileDirectory)..\..\common\ + <_CommonTargetsDir Condition="'$(_CommonTargetsDir)' == ''">$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), '..', '..', 'common')) diff --git a/src/mono/msbuild/android/build/AndroidBuild.targets b/src/mono/msbuild/android/build/AndroidBuild.targets index e9d70c0ef55018..686bebbaa98d05 100644 --- a/src/mono/msbuild/android/build/AndroidBuild.targets +++ b/src/mono/msbuild/android/build/AndroidBuild.targets @@ -55,15 +55,13 @@ <_CommonLinkerArgs Include="--build-id=sha1" /> - - - - <_RuntimeLibraries Include="$(AndroidBuildDir)\*.a" Exclude="$(AndroidBuildDir)\libmono-component-*.a" /> + <_RuntimeLibraries Include="$(AndroidBuildDir)\libmono-component-*-stub-static.a" /> + <_RuntimeLibraries Condition="'@(RuntimeComponents)' != ''" Remove="$(AndroidBuildDir)\libmono-component-%(RuntimeComponents.Identity)-stub-static.a" /> <_RuntimeLibraries Condition="'@(RuntimeComponents)' != ''" Include="$(AndroidBuildDir)\libmono-component-%(RuntimeComponents.Identity)-static.a" /> - + diff --git a/src/mono/msbuild/apple/build/AppleBuild.props b/src/mono/msbuild/apple/build/AppleBuild.props index 30d102bcf70c1c..2e166cc10efedb 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.props +++ b/src/mono/msbuild/apple/build/AppleBuild.props @@ -24,11 +24,11 @@ <_AotCompileTargetName Condition="'$(UseNativeAOTRuntime)' == 'true'">_AppleNativeAotCompile <_AotCompileTargetName Condition="'$(UseNativeAOTRuntime)' != 'true'">_AppleAotCompile ComputeIlcCompileInputs;SetupOSSpecificProps;PrepareForILLink - <_ReadRuntimeComponentsManifest Condition="'$(UseNativeAOTRuntime)' != 'true'">_MonoReadAvailableComponentsManifest + <_ReadRuntimeComponentsManifestTargetName Condition="'$(UseNativeAOTRuntime)' != 'true'">_MonoReadAvailableComponentsManifest Publish - $(_ReadRuntimeComponentsManifest); + $(_ReadRuntimeComponentsManifestTargetName); _InitializeCommonProperties; _BeforeAppleBuild; _AppleResolveReferences; @@ -41,7 +41,7 @@ - <_CommonTargetsDir Condition="'$(_CommonTargetsDir)' == ''">$(MSBuildThisFileDirectory)..\..\common\ + <_CommonTargetsDir Condition="'$(_CommonTargetsDir)' == ''">$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), '..', '..', 'common')) diff --git a/src/mono/msbuild/apple/build/AppleBuild.targets b/src/mono/msbuild/apple/build/AppleBuild.targets index f8da6b476fa324..6629acfa5bcf8f 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.targets +++ b/src/mono/msbuild/apple/build/AppleBuild.targets @@ -129,16 +129,14 @@ - - - - - <_RuntimeLibraries Include="$(AppleBuildDir)\*.a" Exclude="$(AppleBuildDir)\libmono-component-*.a" /> + <_RuntimeLibraries Include="$(AppleBuildDir)\libmono-component-*-stub-static.a" /> + <_RuntimeLibraries Condition="'@(RuntimeComponents)' != ''" Remove="$(AppleBuildDir)\libmono-component-%(RuntimeComponents.Identity)-stub-static.a" /> <_RuntimeLibraries Condition="'@(RuntimeComponents)' != ''" Include="$(AppleBuildDir)\libmono-component-%(RuntimeComponents.Identity)-static.a" /> + diff --git a/src/mono/msbuild/common/MonoSharedBuild.props b/src/mono/msbuild/common/MonoSharedBuild.props index c5cd21f164813d..0124b52c2ef866 100644 --- a/src/mono/msbuild/common/MonoSharedBuild.props +++ b/src/mono/msbuild/common/MonoSharedBuild.props @@ -1,26 +1,26 @@ - - false - - <_RuntimeComponentManifestDir Condition="'$(_RuntimeComponentManifestDir)' == '' and '$(BuildTestsOn)' != 'helix' and '$(MonoArtifactsPath)' != ''">$([MSBuild]::NormalizePath('$(MonoArtifactsPath)', 'build')) - <_RuntimeComponentManifestDir Condition="'$(_RuntimeComponentManifestDir)' == '' and '$(BuildTestsOn)' != 'helix' and '$(RuntimeBinDir)' != ''">$([MSBuild]::NormalizePath('$(RuntimeBinDir)', 'build')) - <_RuntimeComponentManifestDir Condition="'$(_RuntimeComponentManifestDir)' == '' and '$(MicrosoftNetCoreAppRuntimePackRidDir)' != ''">$([MSBuild]::NormalizePath('$(MicrosoftNetCoreAppRuntimePackRidDir)', 'build')) - <_RuntimeComponentManifestDir>$([MSBuild]::EnsureTrailingSlash('$(_RuntimeComponentManifestDir)')) - <_MonoRuntimeComponentManifestJsonFilePath Condition="'$(_MonoRuntimeComponentManifestJsonFilePath)' == '' and '$(_RuntimeComponentManifestDir)' != ''">$(_RuntimeComponentManifestDir)RuntimeComponentManifest.json - + + false + + <_RuntimeComponentManifestDir Condition="'$(_RuntimeComponentManifestDir)' == '' and '$(BuildTestsOn)' != 'helix' and '$(MonoArtifactsPath)' != ''">$([MSBuild]::NormalizePath('$(MonoArtifactsPath)', 'build')) + <_RuntimeComponentManifestDir Condition="'$(_RuntimeComponentManifestDir)' == '' and '$(BuildTestsOn)' != 'helix' and '$(RuntimeBinDir)' != ''">$([MSBuild]::NormalizePath('$(RuntimeBinDir)', 'build')) + <_RuntimeComponentManifestDir Condition="'$(_RuntimeComponentManifestDir)' == '' and '$(MicrosoftNetCoreAppRuntimePackRidDir)' != ''">$([MSBuild]::NormalizePath('$(MicrosoftNetCoreAppRuntimePackRidDir)', 'build')) + <_RuntimeComponentManifestDir>$([MSBuild]::EnsureTrailingSlash('$(_RuntimeComponentManifestDir)')) + <_MonoRuntimeComponentManifestJsonFilePath Condition="'$(_MonoRuntimeComponentManifestJsonFilePath)' == '' and '$(_RuntimeComponentManifestDir)' != ''">$(_RuntimeComponentManifestDir)RuntimeComponentManifest.json + - - - <_MonoRuntimeComponentSharedLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> - <_MonoRuntimeComponentStaticLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> - <_MonoRuntimeComponentLinking ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> - <_MonoRuntimeAvailableComponents ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> - + + + <_MonoRuntimeComponentSharedLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + <_MonoRuntimeComponentStaticLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + <_MonoRuntimeComponentLinking ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + <_MonoRuntimeAvailableComponents ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + \ No newline at end of file diff --git a/src/mono/sample/Android/AndroidSampleApp.csproj b/src/mono/sample/Android/AndroidSampleApp.csproj index 6e0d76f4919ad9..7fb665824e5bea 100644 --- a/src/mono/sample/Android/AndroidSampleApp.csproj +++ b/src/mono/sample/Android/AndroidSampleApp.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/mono/sample/Android/Makefile b/src/mono/sample/Android/Makefile index 6fe6205e3148dd..64f5e13a5e89a6 100644 --- a/src/mono/sample/Android/Makefile +++ b/src/mono/sample/Android/Makefile @@ -9,7 +9,7 @@ DEPLOY_AND_RUN?=true #If DIAGNOSTIC_PORTS is enabled, @(RuntimeComponents) must also include 'diagnostics_tracing'. #If @(RuntimeComponents) includes 'diagnostics_tracing', DIAGNOSTIC_PORTS is optional. -#If @(RuntimeComponents) includes 'diagnostics_tracing', DIAGNOSTIC_PORTS is disabled, use DOTNET_DiagnosticPorts when launching application to enable diagnostics. +#If @(RuntimeComponents) includes 'diagnostics_tracing', and DIAGNOSTIC_PORTS is disabled, then use DOTNET_DiagnosticPorts when launching application to enable diagnostics. #DIAGNOSTIC_PORTS=10.0.2.2:9000,nosuspend #DIAGNOSTIC_PORTS=10.0.2.2:9000,suspend #DIAGNOSTIC_PORTS=$(DOTNET_DiagnosticPorts) diff --git a/src/mono/sample/iOS/Makefile b/src/mono/sample/iOS/Makefile index 60887e9b7abc6c..e3c8320dcd96e3 100644 --- a/src/mono/sample/iOS/Makefile +++ b/src/mono/sample/iOS/Makefile @@ -10,7 +10,7 @@ HYBRID_GLOBALIZATION?=false #If DIAGNOSTIC_PORTS is enabled, @(RuntimeComponents) must also include 'diagnostics_tracing'. #If @(RuntimeComponents) includes 'diagnostics_tracing', DIAGNOSTIC_PORTS is optional. -#If @(RuntimeComponents) includes 'diagnostics_tracing', DIAGNOSTIC_PORTS is disabled, use DOTNET_DiagnosticPorts when launching application to enable diagnostics. +#If @(RuntimeComponents) includes 'diagnostics_tracing', and DIAGNOSTIC_PORTS is disabled, then use DOTNET_DiagnosticPorts when launching application to enable diagnostics. #DIAGNOSTIC_PORTS=127.0.0.1:9000,nosuspend #DIAGNOSTIC_PORTS=127.0.0.1:9000,suspend #DIAGNOSTIC_PORTS=$(DOTNET_DiagnosticPorts) diff --git a/src/mono/sample/iOS/Program.csproj b/src/mono/sample/iOS/Program.csproj index 647976dfc5c178..ad1fa59aa6f906 100644 --- a/src/mono/sample/iOS/Program.csproj +++ b/src/mono/sample/iOS/Program.csproj @@ -27,7 +27,7 @@ - + diff --git a/src/tasks/AndroidAppBuilder/ApkBuilder.cs b/src/tasks/AndroidAppBuilder/ApkBuilder.cs index 50d52ecb998a69..6498af18155d53 100644 --- a/src/tasks/AndroidAppBuilder/ApkBuilder.cs +++ b/src/tasks/AndroidAppBuilder/ApkBuilder.cs @@ -100,7 +100,7 @@ public ApkBuilder(TaskLoggingHelper logger) if (!string.IsNullOrEmpty(DiagnosticPorts) && !Array.Exists(RuntimeComponents, runtimeComponent => string.Equals(runtimeComponent, "diagnostics_tracing", StringComparison.OrdinalIgnoreCase))) { - throw new ArgumentException("Using DiagnosticPorts requires diagnostics_tracing runtime component."); + throw new ArgumentException($"Using DiagnosticPorts requires diagnostics_tracing runtime component, which was not included in 'RuntimeComponents' item group. @RuntimeComponents: '{string.Join(", ", RuntimeComponents)}'"); } // Try to get the latest build-tools version if not specified diff --git a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs index 617f82dae07729..0e16db616d62e8 100644 --- a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs +++ b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs @@ -296,7 +296,7 @@ public override bool Execute() if (!string.IsNullOrEmpty(DiagnosticPorts) && !Array.Exists(RuntimeComponents, runtimeComponent => string.Equals(runtimeComponent, "diagnostics_tracing", StringComparison.OrdinalIgnoreCase))) { - throw new ArgumentException("Using DiagnosticPorts requires diagnostics_tracing runtime component."); + throw new ArgumentException($"Using DiagnosticPorts requires diagnostics_tracing runtime component, which was not included in 'RuntimeComponents' item group. @RuntimeComponents: '{string.Join(", ", RuntimeComponents)}'"); } if (EnableAppSandbox && (string.IsNullOrEmpty(DevTeamProvisioning) || DevTeamProvisioning == "-")) diff --git a/src/tests/FunctionalTests/Android/Device_Emulator/AOT_PROFILED/Android.Device_Emulator.Aot_Profiled.Test.csproj b/src/tests/FunctionalTests/Android/Device_Emulator/AOT_PROFILED/Android.Device_Emulator.Aot_Profiled.Test.csproj index 4394c46be87867..e1c153ea053acd 100644 --- a/src/tests/FunctionalTests/Android/Device_Emulator/AOT_PROFILED/Android.Device_Emulator.Aot_Profiled.Test.csproj +++ b/src/tests/FunctionalTests/Android/Device_Emulator/AOT_PROFILED/Android.Device_Emulator.Aot_Profiled.Test.csproj @@ -17,7 +17,7 @@ - + From e337b6a431f6f4cb7665ee5e430ef0a0947e1770 Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Tue, 17 Oct 2023 15:09:18 +0200 Subject: [PATCH 3/5] Renaming MonoSharedBuild.props into CommonMobileBuild.props --- src/mono/msbuild/android/build/AndroidBuild.props | 2 +- src/mono/msbuild/apple/build/AppleBuild.props | 2 +- .../common/{MonoSharedBuild.props => CommonMobileBuild.props} | 0 .../Microsoft.NET.Runtime.LibraryBuilder.Sdk.pkgproj | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename src/mono/msbuild/common/{MonoSharedBuild.props => CommonMobileBuild.props} (100%) diff --git a/src/mono/msbuild/android/build/AndroidBuild.props b/src/mono/msbuild/android/build/AndroidBuild.props index 03237e1fbf2154..9263ef8a7c82d2 100644 --- a/src/mono/msbuild/android/build/AndroidBuild.props +++ b/src/mono/msbuild/android/build/AndroidBuild.props @@ -28,6 +28,6 @@ <_CommonTargetsDir Condition="'$(_CommonTargetsDir)' == ''">$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), '..', '..', 'common')) - + \ No newline at end of file diff --git a/src/mono/msbuild/apple/build/AppleBuild.props b/src/mono/msbuild/apple/build/AppleBuild.props index 2e166cc10efedb..211b35e7004e1a 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.props +++ b/src/mono/msbuild/apple/build/AppleBuild.props @@ -44,6 +44,6 @@ <_CommonTargetsDir Condition="'$(_CommonTargetsDir)' == ''">$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), '..', '..', 'common')) - + \ No newline at end of file diff --git a/src/mono/msbuild/common/MonoSharedBuild.props b/src/mono/msbuild/common/CommonMobileBuild.props similarity index 100% rename from src/mono/msbuild/common/MonoSharedBuild.props rename to src/mono/msbuild/common/CommonMobileBuild.props diff --git a/src/mono/nuget/Microsoft.NET.Runtime.LibraryBuilder.Sdk/Microsoft.NET.Runtime.LibraryBuilder.Sdk.pkgproj b/src/mono/nuget/Microsoft.NET.Runtime.LibraryBuilder.Sdk/Microsoft.NET.Runtime.LibraryBuilder.Sdk.pkgproj index 8839ca2e1c7890..81017a4279a17d 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.LibraryBuilder.Sdk/Microsoft.NET.Runtime.LibraryBuilder.Sdk.pkgproj +++ b/src/mono/nuget/Microsoft.NET.Runtime.LibraryBuilder.Sdk/Microsoft.NET.Runtime.LibraryBuilder.Sdk.pkgproj @@ -16,7 +16,7 @@ - + From 946644f373a702465675b45987c8984867143ce3 Mon Sep 17 00:00:00 2001 From: Ivan Povazan <55002338+ivanpovazan@users.noreply.github.com> Date: Tue, 17 Oct 2023 18:17:23 +0200 Subject: [PATCH 4/5] Formatting: whitespace Co-authored-by: Ankit Jain --- src/mono/msbuild/android/build/AndroidBuild.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/msbuild/android/build/AndroidBuild.targets b/src/mono/msbuild/android/build/AndroidBuild.targets index 686bebbaa98d05..2aedc442f59352 100644 --- a/src/mono/msbuild/android/build/AndroidBuild.targets +++ b/src/mono/msbuild/android/build/AndroidBuild.targets @@ -42,7 +42,7 @@ - + From 2e96e4f8de72e3f7a8c4d46424067aaea7d180a9 Mon Sep 17 00:00:00 2001 From: Ivan Povazan <55002338+ivanpovazan@users.noreply.github.com> Date: Tue, 17 Oct 2023 18:17:42 +0200 Subject: [PATCH 5/5] Formatting: whitespace Co-authored-by: Ankit Jain --- src/mono/msbuild/android/build/AndroidBuild.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/msbuild/android/build/AndroidBuild.targets b/src/mono/msbuild/android/build/AndroidBuild.targets index 2aedc442f59352..917aed88506697 100644 --- a/src/mono/msbuild/android/build/AndroidBuild.targets +++ b/src/mono/msbuild/android/build/AndroidBuild.targets @@ -44,7 +44,7 @@ - +