Skip to content
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

CLR hosting #9572

Merged
merged 143 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
1cf9e25
Enable static linking with libc++
grendello Nov 26, 2024
dae8f4d
Remove C++ ABI compatibility sources
grendello Nov 26, 2024
b27665f
Update apkdesc files
grendello Nov 26, 2024
baa8378
Playing around with some ideas
grendello Oct 31, 2024
b2ac780
More consistent use of std::string_view + remove unused code
grendello Nov 4, 2024
66b192a
Making EmbeddedAssemblies a static type
grendello Nov 7, 2024
e8ff385
More move to static, more cleanup
grendello Nov 13, 2024
20ddba5
MonodroidRuntime is static now
grendello Nov 13, 2024
2721778
Buglets fixed
grendello Nov 14, 2024
d8814a5
Trying to find out why AppContext.GetData doesn't appear to work
grendello Nov 21, 2024
5d230ee
Cleanup
grendello Nov 21, 2024
c822af5
Lengths and offsets...
grendello Nov 25, 2024
01f8460
Cleanup
grendello Nov 26, 2024
2b9bd9c
Start using std::format and std::string_view string literals
grendello Nov 26, 2024
b8599c0
A bit less of reinterpret_cast<>
grendello Nov 26, 2024
633f993
Conversion to std::format continues
grendello Nov 27, 2024
55587b6
More std::format
grendello Nov 27, 2024
793eecf
Friendlier, no need to use `std::format` directly in log_* anymore
grendello Nov 28, 2024
3b538c3
Cleanup
grendello Nov 29, 2024
e6d3224
Cleanup
grendello Nov 29, 2024
847e385
Update apkdesc files
grendello Nov 29, 2024
c63300a
std::format doesn't like null pointers when printing strings
grendello Nov 29, 2024
3b87eb9
Beginnings of CLR hosting
grendello Dec 2, 2024
8ec22aa
Address feedback
grendello Dec 3, 2024
8a08bc1
First packaging steps + Java startup code changes
grendello Dec 3, 2024
1d05f4c
Build deps + application config for CLR
grendello Dec 3, 2024
1147b73
Moving on: logging + timing
grendello Dec 4, 2024
16cf5a1
Beginnings of initialization code
grendello Dec 4, 2024
3227bcb
More environment work
grendello Dec 5, 2024
9456f80
Enable static linking with libc++
grendello Nov 26, 2024
c8511c4
Remove C++ ABI compatibility sources
grendello Nov 26, 2024
6adc16a
Update apkdesc files
grendello Nov 26, 2024
0be5634
Playing around with some ideas
grendello Oct 31, 2024
9e0d730
More consistent use of std::string_view + remove unused code
grendello Nov 4, 2024
c5f82c8
Making EmbeddedAssemblies a static type
grendello Nov 7, 2024
7db34e4
More move to static, more cleanup
grendello Nov 13, 2024
0bbc9db
MonodroidRuntime is static now
grendello Nov 13, 2024
5678421
Buglets fixed
grendello Nov 14, 2024
44d4e55
Trying to find out why AppContext.GetData doesn't appear to work
grendello Nov 21, 2024
118b664
Cleanup
grendello Nov 21, 2024
ecf77d8
Lengths and offsets...
grendello Nov 25, 2024
76cfa0d
Cleanup
grendello Nov 26, 2024
f4b9cdb
Start using std::format and std::string_view string literals
grendello Nov 26, 2024
3938562
A bit less of reinterpret_cast<>
grendello Nov 26, 2024
6fe8dfc
Conversion to std::format continues
grendello Nov 27, 2024
8e0aae5
More std::format
grendello Nov 27, 2024
bb9fcff
Friendlier, no need to use `std::format` directly in log_* anymore
grendello Nov 28, 2024
25ea6dd
Cleanup
grendello Nov 29, 2024
29e2369
Update apkdesc files
grendello Nov 29, 2024
d35774a
std::format doesn't like null pointers when printing strings
grendello Nov 29, 2024
95bfbcb
Address feedback
grendello Dec 3, 2024
96c6564
Add the CoreCLR runtime falvor
grendello Jan 10, 2025
38f0b6d
New src/native layout
grendello Jan 13, 2025
8e62329
Reorg continued
grendello Jan 13, 2025
b58563c
Build appears to be working
grendello Jan 14, 2025
8cc8b4f
Properly resolve library stubs from runtime packs
grendello Jan 14, 2025
59810bf
Fix java runtime jar inclusion
grendello Jan 14, 2025
ed7e277
Recreate @(ResolvedRuntimePack) item group
grendello Jan 14, 2025
8be8b21
Double-check if a nuget package is indeed our runtime pack
grendello Jan 15, 2025
c68c2ea
Don't package runtime stubs
grendello Jan 15, 2025
946febe
Not needed
grendello Jan 15, 2025
07d211f
Update to match `main`
grendello Jan 16, 2025
3d3fe80
Remove unnecessary sources
grendello Jan 16, 2025
1b11015
Import changes from https://github.com/dotnet/android/pull/9686/
grendello Jan 16, 2025
fc00b03
Mono -> MonoVM
grendello Jan 16, 2025
73a5437
Fixes
grendello Jan 16, 2025
f69d006
Fixes and workarounds to make CoreCLR build happen
grendello Jan 16, 2025
956e24f
Hack to be able to use CoreCLR runtime pack we created
grendello Jan 17, 2025
a7f2f3a
Fake CoreCLR runtime pack works. Next step: use correct CoreCLR inste…
grendello Jan 17, 2025
8a2da86
Add support for local version of CoreCLR runtime pack
grendello Jan 20, 2025
915c0db
Support for CoreCLR in xaprepare
grendello Jan 21, 2025
d4012bc
Limit CoreCLR builds to android-arm64 for now
grendello Jan 21, 2025
ef8257d
Build tweaks to make progress easier
grendello Jan 21, 2025
f9478ef
A couple more hacks
grendello Jan 21, 2025
5851e45
Fix JCW generation for CoreCLR
grendello Jan 22, 2025
f93a1af
A handful of fixlets
grendello Jan 22, 2025
f0b4254
Fix JCW again
grendello Jan 22, 2025
ac65631
Revert "Fix JCW again", trying to figure out what's actually broken
grendello Jan 22, 2025
94ebcbb
Add some temporary logging
grendello Jan 22, 2025
6533e58
Runtime config properties now stored in libxamarin-app.so
grendello Jan 23, 2025
552b6c4
[WIP] Unicode strings support
grendello Jan 27, 2025
5fab337
More elegant solution to managing same strings with different encodings
grendello Jan 28, 2025
a8fc7df
Add a missing variable
grendello Jan 28, 2025
a7d384f
One step closer
grendello Jan 28, 2025
cc3e528
More work towards assembly store support in CLR
grendello Jan 29, 2025
d373f92
Assembly stores support for CLR done
grendello Jan 30, 2025
9dd56b6
On the road to first managed call
grendello Jan 31, 2025
1d03a76
Hook into some error logging in CLR
grendello Jan 31, 2025
ffe325d
Package CoreCLR JIT library
grendello Feb 3, 2025
aa8bee7
CoreCLR android runtime packs are available now. Adjust.
grendello Feb 4, 2025
74147ef
Two special assemblies
grendello Feb 4, 2025
701d16d
p/invoke override support
grendello Feb 4, 2025
e0fce17
Oops, kind of need this one
grendello Feb 5, 2025
3c34b2b
Notes + logging
grendello Feb 5, 2025
15778ad
Remove a number of hacks, now that runtime packs are available
grendello Feb 6, 2025
e9bd6c5
One more hack gone
grendello Feb 6, 2025
d1f6999
Sync CoreCLR host with the latest native changes in main
grendello Feb 10, 2025
6b55c39
Create an LlvmIrStringVariable instance when adding a string variable
grendello Feb 10, 2025
4fdd003
Let's try this
grendello Feb 10, 2025
64495ae
"Namespace" LLVM IR strings"
grendello Feb 11, 2025
a6af727
Fix string constant options
grendello Feb 11, 2025
9d6836c
Hello world now runs.
grendello Feb 12, 2025
ee6195f
WIP for CoreCLR typemaps
grendello Feb 13, 2025
3abcc6d
More CoreCLR typemap work
grendello Feb 13, 2025
5574c31
Share more code between MonoVM and CoreCLR hosts
grendello Feb 14, 2025
93dd85e
Fix package manager registration for CoreCLR
grendello Feb 14, 2025
092b131
Fix pinvoke generator
grendello Feb 14, 2025
39d3759
Update notes
grendello Feb 14, 2025
9a3ad92
Post-merge fixups
grendello Feb 14, 2025
eff1edd
Type map implementation for CLR
grendello Feb 17, 2025
f45e45a
MAUI hello world works now
grendello Feb 18, 2025
d059b3e
Fix Windows build?
jonpryor Feb 19, 2025
5b79113
Add missing parentheses
grendello Feb 19, 2025
235440b
Some cleanup
grendello Feb 19, 2025
947a608
Changes
grendello Feb 20, 2025
23c3d39
Fix after rebase
grendello Feb 21, 2025
6b87268
Typemaps use type token ids again
grendello Feb 21, 2025
9f5d911
Fix after rebase
grendello Feb 21, 2025
dece52f
[WIP] Broken, tbc on Monday
grendello Feb 21, 2025
69a6713
Use a local CoreCLR runtime build, if requested and present
grendello Feb 24, 2025
cea7432
Forget me not
grendello Feb 24, 2025
5f66199
[WIP] runtime pack library dirs discovery
grendello Feb 24, 2025
a61d1ea
Use discovered runtime pack native lib dirs
grendello Feb 24, 2025
cc0be44
Fix build on CoreCLR after `main` rebase
grendello Feb 24, 2025
630eeeb
Add some logs and update structure layout
grendello Feb 24, 2025
6e1c6c3
Cleanup
grendello Feb 24, 2025
04d4170
Updates to work with the latest dotnet/runtime changes
grendello Feb 25, 2025
b835667
Make build using local CLR work
grendello Feb 25, 2025
8d4e35c
Fix after rebase
grendello Feb 25, 2025
7ea447d
No-compression MAUI hack
grendello Feb 25, 2025
ce4e595
Disable native build until up-to-date runtime packs are available
grendello Feb 26, 2025
d4cc649
Let's see if this works
grendello Feb 26, 2025
656614a
FastDev needs the parameters too
grendello Feb 26, 2025
f19135a
Fix after rebase
grendello Feb 26, 2025
0a11c7f
One more fixup
grendello Feb 26, 2025
d5dec28
Revert "Bump to dotnet/sdk/main@d3d96bc671 10.0.100-preview.3.25126.7…
grendello Feb 27, 2025
07edabc
Temporarily disable a CoreCLR test and try to fix NativeAOT builds
grendello Feb 27, 2025
2122ecb
Neither assembly store nor assemblies are used with NativeAOT
grendello Feb 27, 2025
35ae830
Reapply "Bump to dotnet/sdk/main@d3d96bc671 10.0.100-preview.3.25126.…
grendello Feb 27, 2025
73d0588
Let's try this
grendello Feb 27, 2025
8cc1f89
Revert "Let's try this"
grendello Feb 28, 2025
473814d
Take two
grendello Feb 28, 2025
e911841
Fix indentation.
jonpryor Feb 28, 2025
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
42 changes: 42 additions & 0 deletions CLR-Host-Notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Notes

## Potential optimizations

* https://github.com/dotnet/runtime/blob/9b24fb60a19f62620ca1fc5e4eb2e3ae0b3b086d/src/coreclr/binder/assemblybindercommon.cpp#L844-L889
* Managed C++ assemblies aren't available on Unix, no point in looking for them
* `candidates[]` is `WCHAR*`, while `ProbeAppBundle` takes UTF-8 - no point in doing the
conversion here
* Host contract
* It might make sense to pass strings as Unicode to host and back, to avoid conversions.
p/invoke names for instance, can be Unicode. So can be the assembly names. Native library
names should be UTF-8, but we can generate lookup tables for those at application build time
(e.g. indexed by an xxHash of the Unicode version of the name) - no conversion at run time.
* We need declarations of all he possible HRESULT errors (`S_OK` etc)

## Stuff that should be changed

### Logging
Currently, most of the messages logged by the runtime end up in `/dev/null` (either because they
are disabled in release build or because they log to stdio which doesn't work on Android).

Logcat is the only way to get information from remote devices, especially via Google Play Console.

We should log to logcat:

+ C++ exception messages
+ abort() messages / fatal errors
+ warnings
+ errors

A subsystem should be added which will provide a single function that will do actual output, implementation of which
will be specific to the platform. API should allow specification of severity, the actual message, and possibly a flag
to indicate whether the process should be aborted (the decision might also be based on the severity). Severity should
be shared between all targets, which then can (if needed) translate it to the target platform's value(s), if any.

### Process termination
Runtime currently calls `abort()` in several places. This should probably become part of the host contract instead.
Being part of the contract, the target platform could implement process termination on `abort()` in a uniform way
(includes platform-specific logging, preparation etc)

## Issues and workarounds

11 changes: 11 additions & 0 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,15 @@
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="NativeAOT" />
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="CoreCLR" />
</ItemGroup>

<!-- Whenever there's a need to use a locally built CoreCLR, both .NET for Android and the
application(s) must be built with the same runtime. This property should point to the CoreCLR
artifact directory in its repository checkout:

{PATH_TO_DOTNET_RUNTIME_REPO}/artifacts/bin/microsoft.netcore.app.runtime.android-{ARCH}/{CONFIG}

<PropertyGroup>
<CLRLocalRuntimePath></CLRLocalRuntimePath>
</PropertyGroup>
-->
</Project>
2 changes: 1 addition & 1 deletion Xamarin.Android.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Tools.Diagnost
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Tools.Cecil", "external\Java.Interop\src\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil.csproj", "{D48EE8D0-0A0A-4493-AEF5-DAF5F8CF86AD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "native", "src\native\native-mono.csproj", "{53EE4C57-1C03-405A-8243-8DA539546C88}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "native-mono", "src\native\native-mono.csproj", "{53EE4C57-1C03-405A-8243-8DA539546C88}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{CAB438D8-B0F5-4AF0-BEBD-9E2ADBD7B483}"
EndProject
Expand Down
2 changes: 1 addition & 1 deletion build-tools/create-packs/Microsoft.Android.Runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ projects that use the Microsoft.Android framework in .NET 6+.
<_AndroidRuntimePackAssets Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libunwind_xamarin.a" />
</ItemGroup>

<ItemGroup Condition=" '$(AndroidRuntime)' == 'CoreCLR' ">
<ItemGroup Condition=" '$(AndroidRuntime)' != 'NativeAOT' ">
<!-- TODO: the Exists() checks must go away once we build CoreCLR host for all the targets -->
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libc.so') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libc.so" />
<_AndroidRuntimePackAssets Condition=" Exists('$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libdl.so') " Include="$(NativeRuntimeOutputRootDir)$(_RuntimeFlavorDirName)\$(AndroidRID)\libdl.so" />
Expand Down
16 changes: 4 additions & 12 deletions build-tools/installers/create-installers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)java_runtime_fastdev_net6.jar" ExcludeFromLegacy="true" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)java_runtime_net6.dex" ExcludeFromLegacy="true" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)java_runtime_fastdev_net6.dex" ExcludeFromLegacy="true" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)java_runtime_clr.jar" ExcludeFromLegacy="true" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)java_runtime_fastdev_clr.jar" ExcludeFromLegacy="true" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)java_runtime_clr.dex" ExcludeFromLegacy="true" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)java_runtime_fastdev_clr.dex" ExcludeFromLegacy="true" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)manifestmerger.jar" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)proguard-android.txt" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)protobuf-net.dll" />
Expand Down Expand Up @@ -175,18 +179,6 @@
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)K4os.Compression.LZ4.dll" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)ELFSharp.dll" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)ManifestOverlays\Timing.xml" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm64\libc.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm64\libm.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm\libc.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm\libm.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x64\libc.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x64\libm.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x86\libc.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x86\libm.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)dsostubs\android-arm64\libarchive-dso-stub.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)dsostubs\android-arm\libarchive-dso-stub.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)dsostubs\android-x64\libarchive-dso-stub.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)dsostubs\android-x86\libarchive-dso-stub.so" />
</ItemGroup>
<ItemGroup>
<_MSBuildTargetsSrcFiles Include="$(MSBuildTargetsSrcDir)\Xamarin.Android.AvailableItems.targets" />
Expand Down
93 changes: 62 additions & 31 deletions build-tools/scripts/generate-pinvoke-tables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
MY_DIR="$(dirname $0)"
HOST="$(uname | tr A-Z a-z)"

NATIVE_DIR="${MY_DIR}/../../src/native/mono"
MONODROID_SOURCE_DIR="${NATIVE_DIR}/pinvoke-override"
GENERATOR_SOURCE="${MONODROID_SOURCE_DIR}/generate-pinvoke-tables.cc"
GENERATOR_BINARY="${MONODROID_SOURCE_DIR}/generate-pinvoke-tables"
TARGET_FILE="${MONODROID_SOURCE_DIR}/pinvoke-tables.include"
NATIVE_DIR="${MY_DIR}/../../src/native"
MONODROID_SOURCE_DIR="${NATIVE_DIR}/mono/pinvoke-override"
MONODROID_INCLUDE_DIR="${NATIVE_DIR}/mono/shared"
CLR_SOURCE_DIR="${NATIVE_DIR}/clr/host"
CLR_INCLUDE_DIR="${NATIVE_DIR}/clr/include/shared"
GENERATOR_SOURCE="generate-pinvoke-tables.cc"
GENERATOR_BINARY="generate-pinvoke-tables"
TARGET_FILE="pinvoke-tables.include"
GENERATED_FILE="${TARGET_FILE}.generated"
DIFF_FILE="${TARGET_FILE}.diff"
EXTERNAL_DIR="${MY_DIR}/../../external/"
Expand Down Expand Up @@ -64,33 +67,61 @@ case ${HOST} in
*) die Unsupported OS ;;
esac

${COMPILER} -O2 -std=c++20 -I${EXTERNAL_DIR} -I${EXTERNAL_DIR}/constexpr-xxh3 -I${NATIVE_DIR}/shared -I${NATIVE_DIR}/../common/include "${GENERATOR_SOURCE}" -o "${GENERATOR_BINARY}"
"${GENERATOR_BINARY}" "${GENERATED_FILE}"

FILES_DIFFER="no"
cmp "${GENERATED_FILE}" "${TARGET_FILE}" > /dev/null 2>&1 || FILES_DIFFER="yes"

RETVAL=0
if [ "${TEST_ONLY}" == "no" ]; then
if [ "${FILES_DIFFER}" == "yes" ]; then
mv "${GENERATED_FILE}" "${TARGET_FILE}"
else
rm "${GENERATED_FILE}"
fi
else
if [ "${FILES_DIFFER}" == "yes" ]; then
echo "Generated p/invokes table file differs from the current one"
diff -U3 -Narp "${TARGET_FILE}" "${GENERATED_FILE}" > "${DIFF_FILE}"

echo "Diff file saved in: ${DIFF_FILE}"
echo "------ DIFF START ------"
cat "${DIFF_FILE}"
echo "------ DIFF END ------"
echo
RETVAL=1
function generate()
{
local SOURCE_DIR="${1}"
local INCLUDE_DIR="${2}"
local SOURCE="${SOURCE_DIR}/${GENERATOR_SOURCE}"
local BINARY="${SOURCE_DIR}/${GENERATOR_BINARY}"
local RESULT="${SOURCE_DIR}/${GENERATED_FILE}"
local TARGET="${SOURCE_DIR}/${TARGET_FILE}"
local DIFF="${SOURCE_DIR}/${DIFF_FILE}"

${COMPILER} -O2 -std=c++20 -I${EXTERNAL_DIR} -I${EXTERNAL_DIR}/constexpr-xxh3 -I${INCLUDE_DIR} -I${NATIVE_DIR}/common/include "${SOURCE}" -o "${BINARY}"
"${BINARY}" "${RESULT}"

FILES_DIFFER="no"
cmp "${RESULT}" "${TARGET}" > /dev/null 2>&1 || FILES_DIFFER="yes"

if [ "${TEST_ONLY}" == "no" ]; then
if [ "${FILES_DIFFER}" == "yes" ]; then
mv "${RESULT}" "${TARGET}"
else
rm "${RESULT}"
fi
else
echo Generated file is identical to the current one
if [ "${FILES_DIFFER}" == "yes" ]; then
echo "Generated p/invokes table file differs from the current one"
diff -U3 -Narp "${TARGET}" "${RESULT}" > "${DIFF}"

echo "Diff file saved in: ${DIFF}"
echo "------ DIFF START ------"
cat "${DIFF}"
echo "------ DIFF END ------"
echo
RETVAL=1
else
echo Generated file is identical to the current one
fi
fi
fi
}

RETVAL=0
cat <<EOF
**
** Generating for MonoVM
**
EOF
generate "${MONODROID_SOURCE_DIR}" "${MONODROID_INCLUDE_DIR}"

cat <<EOF

--------------------------------------

**
** Generating for CoreCLR
**
EOF
generate "${CLR_SOURCE_DIR}" "${CLR_INCLUDE_DIR}"

exit ${RETVAL}
5 changes: 5 additions & 0 deletions build-tools/scripts/xa_build_configuration.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ set(NETCORE_APP_RUNTIME_DIR_ARM "@NETCORE_APP_RUNTIME_ANDROID_ARM@")
set(NETCORE_APP_RUNTIME_DIR_ARM64 "@NETCORE_APP_RUNTIME_ANDROID_ARM64@")
set(NETCORE_APP_RUNTIME_DIR_X86 "@NETCORE_APP_RUNTIME_ANDROID_X86@")
set(NETCORE_APP_RUNTIME_DIR_X86_64 "@NETCORE_APP_RUNTIME_ANDROID_X86_64@")

set(CORECLR_APP_RUNTIME_DIR_ARM "@CORECLR_APP_RUNTIME_ANDROID_ARM@")
set(CORECLR_APP_RUNTIME_DIR_ARM64 "@CORECLR_APP_RUNTIME_ANDROID_ARM64@")
set(CORECLR_APP_RUNTIME_DIR_X86 "@CORECLR_APP_RUNTIME_ANDROID_X86@")
set(CORECLR_APP_RUNTIME_DIR_X86_64 "@CORECLR_APP_RUNTIME_ANDROID_X86_64@")
23 changes: 22 additions & 1 deletion build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,18 @@ public static partial class Paths
public static string OpenJDKInstallDir => GetCachedPath (ref openJDKInstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), Defaults.JdkFolder));
public static string OpenJDKCacheDir => GetCachedPath (ref openJDKCacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory));

// .NET 6
// .NET 6+
public static string NetcoreAppRuntimeAndroidARM => GetCachedPath (ref netcoreAppRuntimeAndroidARM, () => GetNetcoreAppRuntimePath (ctx, "arm"));
public static string NetcoreAppRuntimeAndroidARM64 => GetCachedPath (ref netcoreAppRuntimeAndroidARM64, () => GetNetcoreAppRuntimePath (ctx, "arm64"));
public static string NetcoreAppRuntimeAndroidX86 => GetCachedPath (ref netcoreAppRuntimeAndroidX86, () => GetNetcoreAppRuntimePath (ctx, "x86"));
public static string NetcoreAppRuntimeAndroidX86_64 => GetCachedPath (ref netcoreAppRuntimeAndroidX86_64, () => GetNetcoreAppRuntimePath (ctx, "x64"));

// CoreCLR
public static string CoreClrAppRuntimeAndroidARM => GetCachedPath (ref coreclrAppRuntimeAndroidARM, () => GetCoreClrAppRuntimePath (ctx, "arm"));
public static string CoreClrAppRuntimeAndroidARM64 => GetCachedPath (ref coreclrAppRuntimeAndroidARM64, () => GetCoreClrAppRuntimePath (ctx, "arm64"));
public static string CoreClrAppRuntimeAndroidX86 => GetCachedPath (ref coreclrAppRuntimeAndroidX86, () => GetCoreClrAppRuntimePath (ctx, "x86"));
public static string CoreClrAppRuntimeAndroidX86_64 => GetCachedPath (ref coreclrAppRuntimeAndroidX86_64, () => GetCoreClrAppRuntimePath (ctx, "x64"));

public static string MicrosoftNETWorkloadMonoPackageDir => Path.Combine (
XAPackagesDir,
$"microsoft.net.workload.mono.toolchain.{{0}}.manifest-{ctx.Properties.GetRequiredValue (KnownProperties.DotNetMonoManifestVersionBand)}",
Expand Down Expand Up @@ -242,6 +248,17 @@ static string GetNetcoreAppRuntimePath (Context ctx, string androidTarget)
);
}

static string GetCoreClrAppRuntimePath (Context ctx, string androidTarget)
{
return Path.Combine (
XAPackagesDir,
$"microsoft.netcore.app.runtime.android-{androidTarget}",
ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftNETCoreAppRefPackageVersion),
"runtimes",
$"android-{androidTarget}"
);
}

static string EnsureAndroidToolchainBinDirectories ()
{
if (androidToolchainBinDirectory != null)
Expand Down Expand Up @@ -278,6 +295,10 @@ static string GetCachedPath (ref string? variable, Func<string> creator)
static string? netcoreAppRuntimeAndroidARM64;
static string? netcoreAppRuntimeAndroidX86;
static string? netcoreAppRuntimeAndroidX86_64;
static string? coreclrAppRuntimeAndroidARM;
static string? coreclrAppRuntimeAndroidARM64;
static string? coreclrAppRuntimeAndroidX86;
static string? coreclrAppRuntimeAndroidX86_64;
}
}
}
16 changes: 13 additions & 3 deletions build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ GeneratedFile Get_Cmake_XA_Build_Configuration (Context context)
{ "@NETCORE_APP_RUNTIME_ANDROID_ARM64@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidARM64) },
{ "@NETCORE_APP_RUNTIME_ANDROID_X86@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidX86) },
{ "@NETCORE_APP_RUNTIME_ANDROID_X86_64@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidX86_64) },

{ "@CORECLR_APP_RUNTIME_ANDROID_ARM@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidARM) },
{ "@CORECLR_APP_RUNTIME_ANDROID_ARM64@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidARM64) },
{ "@CORECLR_APP_RUNTIME_ANDROID_X86@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidX86) },
{ "@CORECLR_APP_RUNTIME_ANDROID_X86_64@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidX86_64) },
};

return new GeneratedPlaceholdersFile (
Expand All @@ -107,7 +112,7 @@ GeneratedFile Get_Cmake_XA_Build_Configuration (Context context)
);
}

GeneratedFile Get_Cmake_Presets (Context context)
GeneratedFile GetCmakePresetsCommon (Context context, string sourcesDir)
{
const string OutputFileName = "CMakePresets.json";

Expand All @@ -126,11 +131,16 @@ GeneratedFile Get_Cmake_Presets (Context context)

return new GeneratedPlaceholdersFile (
replacements,
Path.Combine (Configurables.Paths.NativeSourcesDir, $"{OutputFileName}.in"),
Path.Combine (Configurables.Paths.NativeSourcesDir, OutputFileName)
Path.Combine (sourcesDir, $"{OutputFileName}.in"),
Path.Combine (sourcesDir, OutputFileName)
);
}

GeneratedFile Get_Cmake_Presets (Context context)
{
return GetCmakePresetsCommon (context, Configurables.Paths.NativeSourcesDir);
}

GeneratedFile Get_Configuration_Generated_Props (Context context)
{
const string OutputFileName = "Configuration.Generated.props";
Expand Down
2 changes: 2 additions & 0 deletions build-tools/xaprepare/xaprepare/package-download.proj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Otherwise, $(MicrosoftNETCoreAppRefPackageVersion) from eng/Versions.props will
<PackageDownload Include="Microsoft.NETCore.App.Runtime.Mono.android-arm64" Version="[$(DotNetRuntimePacksVersion)]" />
<PackageDownload Include="Microsoft.NETCore.App.Runtime.Mono.android-x86" Version="[$(DotNetRuntimePacksVersion)]" />
<PackageDownload Include="Microsoft.NETCore.App.Runtime.Mono.android-x64" Version="[$(DotNetRuntimePacksVersion)]" />
<PackageDownload Include="Microsoft.NETCore.App.Runtime.android-arm64" Version="[$(DotNetRuntimePacksVersion)]" />
<PackageDownload Include="Microsoft.NETCore.App.Runtime.android-x64" Version="[$(DotNetRuntimePacksVersion)]" />
<PackageDownload Include="Microsoft.NET.Workload.Mono.ToolChain.Current.Manifest-$(DotNetMonoManifestVersionBand)" Version="[$(DotNetRuntimePacksVersion)]" />
<PackageDownload Include="Microsoft.NET.Workload.Mono.ToolChain.net6.Manifest-$(DotNetMonoManifestVersionBand)" Version="[$(DotNetRuntimePacksVersion)]" />
<PackageDownload Include="Microsoft.NET.Workload.Mono.ToolChain.net7.Manifest-$(DotNetMonoManifestVersionBand)" Version="[$(DotNetRuntimePacksVersion)]" />
Expand Down
11 changes: 11 additions & 0 deletions src-ThirdParty/dotnet/runtime/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
The header files in this directory are verbatim copies taken from the
https://github.com/dotnet/runtime/ repository.

They can be found in the following locations in the repository:

src/native/corehost/host_runtime_contract.h
src/coreclr/hosts/inc/coreclrhost.h

and they MUST be in sync with the current version of the runtime being
used. They don't have to come from the same version, but their content
must be ABI and API compatible with it.
Loading
Loading