[runtime] Add support for finding assemblies in an RID-specific subdirectory.

This commit is contained in:
Rolf Bjarne Kvinge 2021-05-25 21:43:50 +02:00
Родитель 5275220e71
Коммит 87de6ea653
2 изменённых файлов: 55 добавлений и 2 удалений

Просмотреть файл

@ -6,6 +6,8 @@
*
*/
#include <TargetConditionals.h>
#ifdef MONOTOUCH
#if TARGET_OS_WATCH
#define PRODUCT "Xamarin.WatchOS"
@ -43,4 +45,45 @@
#define ARCH_SUBDIR
#else
#error Either MONOTOUCH or MONOMAC must be defined.
#endif
#endif
// Set RuntimeIdentifier defines
#if TARGET_OS_MACCATALYST
#define RUNTIMEIDENTIFIER_PLATFORM "maccatalyst"
#elif TARGET_OS_IOS
#if TARGET_OS_SIMULATOR
#define RUNTIMEIDENTIFIER_PLATFORM "iossimulator"
#else
#define RUNTIMEIDENTIFIER_PLATFORM "ios"
#endif
#elif TARGET_OS_TV
#if TARGET_OS_SIMULATOR
#define RUNTIMEIDENTIFIER_PLATFORM "tvossimulator"
#else
#define RUNTIMEIDENTIFIER_PLATFORM "tvos"
#endif
#elif TARGET_OS_WATCH
#if TARGET_OS_SIMULATOR
#define RUNTIMEIDENTIFIER_PLATFORM "watchossimulator"
#else
#define RUNTIMEIDENTIFIER_PLATFORM "watchos"
#endif
#elif TARGET_OS_OSX
#define RUNTIMEIDENTIFIER_PLATFORM "osx"
#else
#error Unknown platform
#endif
#if defined (__aarch64__)
#define RUNTIMEIDENTIFIER_ARCHITECTURE "arm64"
#elif defined (__x86_64__)
#define RUNTIMEIDENTIFIER_ARCHITECTURE "x64"
#elif defined (__i386__)
#define RUNTIMEIDENTIFIER_ARCHITECTURE "x86"
#elif defined (__arm__)
#define RUNTIMEIDENTIFIER_ARCHITECTURE "arm"
#else
#error Unknown architecture
#endif
#define RUNTIMEIDENTIFIER RUNTIMEIDENTIFIER_PLATFORM "-" RUNTIMEIDENTIFIER_ARCHITECTURE

Просмотреть файл

@ -2478,7 +2478,7 @@ xamarin_vprintf (const char *format, va_list args)
*
* The platform assembly (Xamarin.[iOS|TVOS|WatchOS].dll) and any assemblies
* the platform assembly references (mscorlib.dll, System.dll) may be in a
* pointer-size subdirectory (ARCH_SUBDIR).
* pointer-size subdirectory (ARCH_SUBDIR), or an RID-specific subdirectory.
*
* AOT data files will have an arch-specific infix.
*/
@ -2536,6 +2536,16 @@ xamarin_locate_assembly_resource_for_root (const char *root, const char *culture
}
#endif // !MONOMAC
#if DOTNET
// RID-specific subdirectory
if (snprintf (path, pathlen, "%s/.xamarin/%s/%s", root, RUNTIMEIDENTIFIER, resource) < 0) {
LOG (PRODUCT ": Failed to construct path for resource: %s (5): %s", resource, strerror (errno));
return false;
} else if (xamarin_file_exists (path)) {
return true;
}
#endif
// just the file, no extensions, etc.
if (snprintf (path, pathlen, "%s/%s", root, resource) < 0) {
LOG (PRODUCT ": Failed to construct path for resource: %s (6): %s", resource, strerror (errno));