Skip to content

Allow publishing AndroidSampleApp with R2R using in-build crossgen2 #112547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libraries/externals.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
<RuntimeFiles Include="@(HostPolicyFile)" Condition="Exists('@(HostPolicyFile)')" />
<RuntimeFiles Include="@(_HostSymbols)" Condition="Exists('@(_HostSymbols)')" IsNative="true" />
<!-- CoreRun is not used for testing anymore, but we still use it for benchmarking and profiling -->
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\corerun*" />
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\PDB\corerun*" />
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\corerun*" Condition="'$(TargetsAndroid)' != 'true'" />
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\PDB\corerun*" Condition="'$(TargetsAndroid)' != 'true'" />
<!-- Include cDAC reader library
TODO: [cdac] Remove once cdacreader is added to shipping shared framework -->
<RuntimeFiles Include="$(CoreCLRArtifactsPath)\*cdacreader*" />
Expand Down
15 changes: 15 additions & 0 deletions src/mono/msbuild/android/build/AndroidBuild.InTree.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,19 @@
</ItemGroup>
<Message Text="Used runtime pack: %(ResolvedRuntimePack.PackageDirectory)" Importance="high" />
</Target>

<!-- Override the ResolveReadyToRunCompilers target to use the in-build crossgen2.
This needs to be imported after SDK targets, so any project requiring this should set AfterMicrosoftNETSdkTargets -->
<Target Name="ResolveReadyToRunCompilers" Condition="'$(PublishReadyToRun)' == true" DependsOnTargets="ResolveRuntimeFilesFromLocalBuild">
<PropertyGroup>
<Crossgen2Path>$([MSBuild]::NormalizePath('$(Crossgen2InBuildDir)', 'crossgen2$(ExeSuffix)'))</Crossgen2Path>
</PropertyGroup>

<ItemGroup>
<Crossgen2Tool Include="$(Crossgen2Path)"
TargetArch="$(TargetArchitecture)"
TargetOS="linux"
PerfmapFormatVersion="$(PublishReadyToRunPerfmapFormatVersion)"/>
</ItemGroup>
</Target>
</Project>
9 changes: 6 additions & 3 deletions src/mono/sample/Android/AndroidSampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
</ItemGroup>

<Import Project="$(MonoProjectRoot)\msbuild\android\build\AndroidBuild.props" />
<Import Project="$(MonoProjectRoot)\msbuild\android\build\AndroidBuild.InTree.targets" />
<PropertyGroup>
<!-- Import after SDK targets in order to override R2R-related targets in the SDK -->
<AfterMicrosoftNETSdkTargets>$(MonoProjectRoot)\msbuild\android\build\AndroidBuild.InTree.targets</AfterMicrosoftNETSdkTargets>
</PropertyGroup>

<Target Name="RunAppBundle"
Condition="'$(ArchiveTests)' != 'true' and '$(DeployAndRun)' == 'true'"
Expand All @@ -34,8 +37,8 @@
<Exec Command="$(RepoDotnet) xharness android test --package-name=net.dot.HelloAndroid --instrumentation=net.dot.MonoRunner --app=$(AndroidBundleDir)/bin/HelloAndroid.apk --expected-exit-code=42 --output-directory=$(AndroidBundleDir)/log" />
</Target>

<Target Name="CopySampleAppToHelixTestDir"
Condition="'$(ArchiveTests)' == 'true'"
<Target Name="CopySampleAppToHelixTestDir"
Condition="'$(ArchiveTests)' == 'true'"
AfterTargets="_AfterAndroidBuild"
DependsOnTargets="$(AndroidBuildDependsOn)" >
<PropertyGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/mono/sample/Android/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ AOT_WITH_LIBRARY_FILES=false
INTERP=false
DEPLOY_AND_RUN?=true
RUNTIME_FLAVOR?=Mono
R2R?=false
R2R_COMPOSITE?=false

#If DIAGNOSTIC_PORTS is enabled, @(RuntimeComponents) must also include 'diagnostics_tracing'.
#If @(RuntimeComponents) includes 'diagnostics_tracing', DIAGNOSTIC_PORTS is optional.
Expand Down Expand Up @@ -48,6 +50,8 @@ run: appbuilder
/p:RunActivity=false \
'/p:DiagnosticPorts="$(DIAGNOSTIC_PORTS)"' \
/p:RuntimeFlavor=$(RUNTIME_FLAVOR) \
/p:PublishReadyToRun=$(R2R) \
/p:PublishReadyToRunComposite=$(R2R_COMPOSITE) \
/bl
clean:
rm -rf $(REPO_DIR)/artifacts/bin/AndroidSampleApp
Expand Down
Loading