Skip to content

Commit 564f130

Browse files
committed
Begin migration from #8800
1 parent 86fcf16 commit 564f130

34 files changed

+1472
-142
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@
2828
[submodule "external/constexpr-xxh3"]
2929
path = external/constexpr-xxh3
3030
url = https://github.com/chys87/constexpr-xxh3.git
31+
[submodule "external/libunwind"]
32+
path = external/libunwind
33+
url = https://github.com/libunwind/libunwind.git
34+
branch = master

Configuration.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
<IgnoreMaxMonoVersion Condition=" '$(IgnoreMaxMonoVersion)' == '' ">True</IgnoreMaxMonoVersion>
105105
<OpenTKSourceDirectory>$(MSBuildThisFileDirectory)external\opentk</OpenTKSourceDirectory>
106106
<SqliteSourceDirectory Condition=" '$(SqliteSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\sqlite</SqliteSourceDirectory>
107+
<LibUnwindSourceDirectory Condition=" '$(LibUnwindSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\libunwind</LibUnwindSourceDirectory>
108+
<LibUnwindGeneratedHeadersDirectory Condition=" '$(LibUnwindGeneratedHeadersDirectory)' == '' ">$(BootstrapOutputDirectory)\libunwind</LibUnwindGeneratedHeadersDirectory>
107109
<XamarinAndroidSourcePath>$(MSBuildThisFileDirectory)</XamarinAndroidSourcePath>
108110
<ThirdPartySourcePath>$(MSBuildThisFileDirectory)src-ThirdParty\</ThirdPartySourcePath>
109111
<AllSupported32BitTargetAndroidAbis>armeabi-v7a;x86</AllSupported32BitTargetAndroidAbis>
@@ -144,6 +146,8 @@
144146
<JavaInteropFullPath>$([System.IO.Path]::GetFullPath ('$(JavaInteropSourceDirectory)'))</JavaInteropFullPath>
145147
<MonoSourceFullPath>$([System.IO.Path]::GetFullPath ('$(MonoSourceDirectory)'))</MonoSourceFullPath>
146148
<SqliteSourceFullPath>$([System.IO.Path]::GetFullPath ('$(SqliteSourceDirectory)'))</SqliteSourceFullPath>
149+
<LibUnwindSourceFullPath>$([System.IO.Path]::GetFullPath ('$(LibUnwindSourceDirectory)'))</LibUnwindSourceFullPath>
150+
<LibUnwindGeneratedHeadersFullPath>$([System.IO.Path]::GetFullPath ('$(LibUnwindGeneratedHeadersDirectory)'))</LibUnwindGeneratedHeadersFullPath>
147151
<OpenTKSourceFullPath>$([System.IO.Path]::GetFullPath ('$(OpenTKSourceDirectory)'))</OpenTKSourceFullPath>
148152
<JavaInteropTargetFrameworkVersion>net8.0</JavaInteropTargetFrameworkVersion>
149153
</PropertyGroup>

Xamarin.Android.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Tools.Diagnost
4747
EndProject
4848
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}"
4949
EndProject
50+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "libunwind", "src\libunwind-xamarin\libunwind-xamarin.csproj", "{F8E4961B-C427-47F9-92D6-0BEB5B76B3D7}"
51+
EndProject
5052
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "monodroid", "src\monodroid\monodroid.csproj", "{53EE4C57-1C03-405A-8243-8DA539546C88}"
5153
EndProject
5254
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{CAB438D8-B0F5-4AF0-BEBD-9E2ADBD7B483}"

build-tools/cmake/xa_common.cmake

Lines changed: 143 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,143 @@
1-
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12)
1+
set(CMAKE_CXX_STANDARD 20)
2+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3+
set(CMAKE_CXX_EXTENSIONS OFF)
4+
5+
set(CMAKE_C_STANDARD 11)
6+
set(CMAKE_C_STANDARD_REQUIRED ON)
7+
set(CMAKE_C_EXTENSIONS OFF)
8+
9+
include("${CMAKE_ANDROID_NDK}/build/cmake/abis.cmake")
10+
11+
if(CMAKE_BUILD_TYPE STREQUAL Debug)
12+
set(DEBUG_BUILD True)
13+
else()
14+
set(DEBUG_BUILD False)
15+
endif()
16+
17+
set(XA_NO_INLINE "$ENV{XA_NO_INLINE}")
18+
if(XA_NO_INLINE)
19+
set(DONT_INLINE_DEFAULT ON)
20+
else()
21+
set(DONT_INLINE_DEFAULT OFF)
22+
endif()
23+
24+
set(XA_NO_STRIP "$ENV{XA_NO_STRIP}")
25+
if(XA_NO_STRIP OR DEBUG_BUILD)
26+
set(STRIP_DEBUG_DEFAULT OFF)
27+
endif()
28+
29+
option(ENABLE_CLANG_ASAN "Enable the clang AddressSanitizer support" OFF)
30+
option(ENABLE_CLANG_UBSAN "Enable the clang UndefinedBehaviorSanitizer support" OFF)
31+
32+
if(ENABLE_CLANG_ASAN OR ENABLE_CLANG_UBSAN)
33+
set(STRIP_DEBUG_DEFAULT OFF)
34+
set(ANALYZERS_ENABLED ON)
35+
else()
36+
if(NOT XA_NO_STRIP)
37+
set(STRIP_DEBUG_DEFAULT ON)
38+
endif()
39+
set(ANALYZERS_ENABLED OFF)
40+
endif()
41+
42+
option(COMPILER_DIAG_COLOR "Show compiler diagnostics/errors in color" ON)
43+
option(STRIP_DEBUG "Strip debugging information when linking" ${STRIP_DEBUG_DEFAULT})
44+
option(DISABLE_DEBUG "Disable the built-in debugging code" OFF)
45+
option(USE_CCACHE "Use ccache, if found, to speed up recompilation" ON)
46+
option(DONT_INLINE "Do not inline any functions which are usually inlined, to get better stack traces" ${DONT_INLINE_DEFAULT})
47+
48+
if(USE_CCACHE)
49+
if(CMAKE_CXX_COMPILER MATCHES "/ccache/")
50+
message(STATUS "ccache: compiler already uses ccache")
51+
else()
52+
find_program(CCACHE ccache)
53+
if(CCACHE)
54+
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE}")
55+
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE}")
56+
message(STATUS "ccache: compiler will be lauched with ${CCACHE}")
57+
endif()
58+
endif()
59+
endif()
60+
61+
if(ANDROID_STL STREQUAL none)
62+
set(USES_LIBSTDCPP False)
63+
else()
64+
set(USES_LIBSTDCPP True)
65+
endif()
66+
67+
#
68+
# General config
69+
#
70+
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
71+
set(IS_LINUX True)
72+
else()
73+
set(IS_LINUX False)
74+
endif()
75+
76+
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
77+
set(IS_MACOS True)
78+
else()
79+
set(IS_MACOS False)
80+
endif()
81+
82+
set(XA_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../bin/Build${XA_BUILD_CONFIGURATION}")
83+
include("${XA_BUILD_DIR}/xa_build_configuration.cmake")
84+
85+
#
86+
# Paths
87+
#
88+
if(ANDROID_ABI MATCHES "^arm64-v8a")
89+
set(NET_RUNTIME_DIR "${NETCORE_APP_RUNTIME_DIR_ARM64}")
90+
set(TOOLCHAIN_TRIPLE "${NDK_ABI_arm64-v8a_TRIPLE}")
91+
elseif(ANDROID_ABI MATCHES "^armeabi-v7a")
92+
set(NET_RUNTIME_DIR "${NETCORE_APP_RUNTIME_DIR_ARM}")
93+
set(TOOLCHAIN_TRIPLE "${NDK_ABI_armeabi-v7a_TRIPLE}")
94+
elseif(ANDROID_ABI MATCHES "^x86_64")
95+
set(NET_RUNTIME_DIR "${NETCORE_APP_RUNTIME_DIR_X86_64}")
96+
set(TOOLCHAIN_TRIPLE "${NDK_ABI_x86_64_TRIPLE}")
97+
elseif(ANDROID_ABI MATCHES "^x86")
98+
set(NET_RUNTIME_DIR "${NETCORE_APP_RUNTIME_DIR_X86}")
99+
set(TOOLCHAIN_TRIPLE "${NDK_ABI_x86_TRIPLE}")
100+
else()
101+
message(FATAL "${ANDROID_ABI} is not supported for .NET 6+ builds")
102+
endif()
103+
104+
file(REAL_PATH "../../" REPO_ROOT_DIR)
105+
set(EXTERNAL_DIR "${REPO_ROOT_DIR}/external")
106+
set(JAVA_INTEROP_SRC_PATH "${EXTERNAL_DIR}/Java.Interop/src/java-interop")
107+
set(SHARED_SOURCES_DIR "${REPO_ROOT_DIR}/src/native/shared")
108+
set(TRACING_SOURCES_DIR "${REPO_ROOT_DIR}/src/native/tracing")
109+
#
110+
# Include directories
111+
#
112+
include_directories(SYSTEM ${CMAKE_SYSROOT}/usr/include/c++/v1/)
113+
include_directories(SYSTEM "${NET_RUNTIME_DIR}/native/include/mono-2.0")
114+
include_directories("${JAVA_INTEROP_SRC_PATH}")
115+
include_directories("${SHARED_SOURCES_DIR}")
116+
include_directories("${TRACING_SOURCES_DIR}")
117+
118+
#
119+
# Compiler defines
120+
#
121+
add_compile_definitions(XA_VERSION="${XA_VERSION}")
122+
add_compile_definitions(_REENTRANT)
123+
add_compile_definitions(PLATFORM_ANDROID)
124+
125+
if(DEBUG_BUILD AND NOT DISABLE_DEBUG)
126+
add_compile_definitions(DEBUG)
127+
endif()
128+
129+
if(ANDROID_ABI MATCHES "^(arm64-v8a|x86_64)")
130+
add_compile_definitions(ANDROID64)
131+
endif()
132+
133+
if (ANDROID_NDK_MAJOR LESS 20)
134+
add_compile_definitions(__ANDROID_API_Q__=29)
135+
endif()
136+
137+
#
138+
# Shared sources
139+
#
140+
set(XA_SHARED_SOURCES
141+
${SHARED_SOURCES_DIR}/helpers.cc
142+
${SHARED_SOURCES_DIR}/new_delete.cc
143+
)

build-tools/cmake/xa_macros.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ function(xa_common_prepare)
200200
-fstack-protector-strong
201201
-fstrict-return
202202
-fno-strict-aliasing
203-
-ffunction-sections
203+
-fno-function-sections
204+
-fno-data-sections
204205
-funswitch-loops
205206
-Wa,-noexecstack
206207
-fPIC
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12)
2+
3+
#
4+
# Read product version
5+
#
6+
file(STRINGS "../../Directory.Build.props" XA_PRODUCT_VERSION_XML REGEX "^[ \t]*<ProductVersion>(.*)</ProductVersion>")
7+
string(REGEX REPLACE "^[ \t]*<ProductVersion>(.*)</ProductVersion>" "\\1" XA_VERSION "${XA_PRODUCT_VERSION_XML}")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<_CmakeAndroidFlags>--debug-output -GNinja -DCMAKE_MAKE_PROGRAM="$(NinjaPath)" -DXA_BUILD_CONFIGURATION=$(Configuration) -DXA_LIB_TOP_DIR=$(MicrosoftAndroidSdkOutDir) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DMONO_PATH="$(MonoSourceFullPath)" -DANDROID_STL="none" -DANDROID_CPP_FEATURES="no-rtti no-exceptions" -DANDROID_TOOLCHAIN=clang -DCMAKE_TOOLCHAIN_FILE="$(AndroidNdkDirectory)/build/cmake/android.toolchain.cmake" -DANDROID_NDK=$(AndroidNdkDirectory)</_CmakeAndroidFlags>
5+
</PropertyGroup>
6+
</Project>

build-tools/scripts/generate-pinvoke-tables.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ TARGET_FILE="${MONODROID_SOURCE_DIR}/pinvoke-tables.include"
99
GENERATED_FILE="${TARGET_FILE}.generated"
1010
DIFF_FILE="${TARGET_FILE}.diff"
1111
EXTERNAL_DIR="${MY_DIR}/../../external/"
12+
NATIVE_DIR="${MY_DIR}/../../src/native"
1213

1314
function die()
1415
{
@@ -63,7 +64,7 @@ case ${HOST} in
6364
*) die Unsupported OS ;;
6465
esac
6566

66-
${COMPILER} -O2 -std=c++20 -I${EXTERNAL_DIR} -I${EXTERNAL_DIR}/constexpr-xxh3 "${GENERATOR_SOURCE}" -o "${GENERATOR_BINARY}"
67+
${COMPILER} -O2 -std=c++20 -I${EXTERNAL_DIR} -I${EXTERNAL_DIR}/constexpr-xxh3 -I${NATIVE_DIR}/shared "${GENERATOR_SOURCE}" -o "${GENERATOR_BINARY}"
6768
"${GENERATOR_BINARY}" "${GENERATED_FILE}"
6869

6970
FILES_DIFFER="no"

external/libunwind

Submodule libunwind added at 3705bae

src/Mono.Android/Android.Runtime/RuntimeNativeMethods.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,23 @@
66

77
namespace Android.Runtime
88
{
9+
// Values must be identical to those in src/monodroid/jni/monodroid-glue-internal.hh
10+
[Flags]
11+
enum TraceKind : uint
12+
{
13+
Java = 0x01,
14+
Managed = 0x02,
15+
Native = 0x04,
16+
Signals = 0x08,
17+
18+
All = Java | Managed | Native | Signals,
19+
}
20+
921
internal static class RuntimeNativeMethods
1022
{
23+
[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
24+
internal extern static void monodroid_log_traces (TraceKind kind, string first_line);
25+
1126
[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
1227
internal extern static void monodroid_log (LogLevel level, LogCategories category, string message);
1328

0 commit comments

Comments
 (0)