-
Notifications
You must be signed in to change notification settings - Fork 548
[dotnet] Add support for generating a binary version of runtimeconfig.json. Fixes #11745. #11887
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
Changes from all commits
8798580
ff4ef4e
30870b4
06d65d6
7a307d0
f255cc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,8 @@ | |
|
|
||
| #include <TargetConditionals.h> | ||
| #include <pthread.h> | ||
| #include <sys/mman.h> | ||
| #include <sys/stat.h> | ||
|
|
||
| #if !DOTNET && TARGET_OS_OSX | ||
| #define LEGACY_XAMARIN_MAC 1 | ||
|
|
@@ -392,11 +394,48 @@ | |
|
|
||
| #if DOTNET | ||
|
|
||
| static void | ||
| xamarin_runtime_config_cleanup (MonovmRuntimeConfigArguments *args, void *user_data) | ||
| { | ||
| free ((char *) args->runtimeconfig.name.path); | ||
| free (args); | ||
| } | ||
|
|
||
| static void | ||
| xamarin_initialize_runtime_config () | ||
| { | ||
| if (xamarin_runtime_configuration_name == NULL) { | ||
| LOG (PRODUCT ": No runtime config file provided at build time.\n"); | ||
| return; | ||
| } | ||
|
|
||
| const char *app_path = xamarin_get_bundle_path (); | ||
| char path [1024]; | ||
| if (!xamarin_locate_assembly_resource_for_root (app_path, NULL, xamarin_runtime_configuration_name, path, sizeof (path))) { | ||
| LOG (PRODUCT ": Could not locate the runtime config file '%s' in the app bundle: %s\n", xamarin_runtime_configuration_name, app_path); | ||
| return; | ||
| } | ||
|
|
||
| MonovmRuntimeConfigArguments *args = (MonovmRuntimeConfigArguments *) calloc (sizeof (MonovmRuntimeConfigArguments), 1); | ||
| args->kind = 0; // Path of runtimeconfig.blob | ||
| args->runtimeconfig.name.path = strdup (path); | ||
|
|
||
| int rv = monovm_runtimeconfig_initialize (args, xamarin_runtime_config_cleanup, NULL); | ||
| if (rv != 0) { | ||
| LOG_MONOVM (PRODUCT ": Failed to load the runtime config file %s: %i\n", path, rv); | ||
| return; | ||
| } | ||
|
|
||
| LOG_MONOVM (PRODUCT ": Loaded the runtime config file %s\n", path); | ||
| } | ||
|
|
||
| bool | ||
| xamarin_bridge_vm_initialize (int propertyCount, const char **propertyKeys, const char **propertyValues) | ||
| { | ||
| int rv; | ||
|
|
||
| xamarin_initialize_runtime_config (); | ||
|
|
||
| rv = monovm_initialize (propertyCount, propertyKeys, propertyValues); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does not this call reset the values of the config file ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the values we pass to the task here: list the values we will later pass to This is documented here: https://github.com/dotnet/runtime/blob/01b7e73cd378145264a7cb7a09365b41ed42b240/docs/design/mono/mobile-runtimeconfig-json.md#design-overview |
||
|
|
||
| LOG_MONOVM (stderr, "xamarin_vm_initialize (%i, %p, %p): rv: %i\n", propertyCount, propertyKeys, propertyValues, rv); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| TOP=../../.. | ||
|
|
||
| include $(TOP)/Make.config | ||
|
|
||
| build: | ||
| $(DOTNET6) build /bl $(MSBULD_VERBOSITY) | ||
|
|
||
| run: | ||
| $(DOTNET6) build /bl $(MSBUILD_VERBOSITY) /t:Run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might also check here if
$(GenerateRuntimeConfigurationFiles)istrue?If a user sets it to
falsein their project, I think the*.runtimeconfig.jsonfile would not be created:https://github.com/dotnet/sdk/blob/415f1b90e14ddbbcfd6e2cb2d91b27e72db54db0/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L238
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm yeah, good point, maybe we could even warn that some features won't work in that case.