Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c2b3fb0

Browse files
committedOct 31, 2024
Better FastDev handling
1 parent d445dd7 commit c2b3fb0

File tree

9 files changed

+46
-24
lines changed

9 files changed

+46
-24
lines changed
 

‎src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public class GeneratePackageManagerJava : AndroidTask
7474
public string AndroidSequencePointsMode { get; set; }
7575
public bool EnableSGenConcurrent { get; set; }
7676
public string? CustomBundleConfigFile { get; set; }
77+
public bool FastDevEnabled { get; set; }
7778

7879
bool _Debug {
7980
get {
@@ -314,6 +315,7 @@ void AddEnvironment ()
314315
JniRemappingReplacementMethodIndexEntryCount = jniRemappingNativeCodeInfo == null ? 0 : jniRemappingNativeCodeInfo.ReplacementMethodIndexEntryCount,
315316
MarshalMethodsEnabled = EnableMarshalMethods,
316317
IgnoreSplitConfigs = ShouldIgnoreSplitConfigs (),
318+
FastDevEnabled = FastDevEnabled,
317319
};
318320
LLVMIR.LlvmIrModule appConfigModule = appConfigAsmGen.Construct ();
319321

‎src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/EnvironmentHelper.cs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public sealed class ApplicationConfig
4646
public bool broken_exception_transitions;
4747
public bool jni_add_native_method_registration_attribute_present;
4848
public bool have_runtime_config_blob;
49+
public bool fastdev_enabled;
4950
public bool marshal_methods_enabled;
5051
public bool ignore_split_configs;
5152
public byte bound_stream_io_exception_type;
@@ -65,7 +66,7 @@ public sealed class ApplicationConfig
6566
public string android_package_name = String.Empty;
6667
}
6768

68-
const uint ApplicationConfigFieldCount = 24;
69+
const uint ApplicationConfigFieldCount = 25;
6970

7071
const string ApplicationConfigSymbolName = "application_config";
7172
const string AppEnvironmentVariablesSymbolName = "app_environment_variables";
@@ -239,87 +240,92 @@ static ApplicationConfig ReadApplicationConfig (EnvironmentFile envFile)
239240
ret.have_runtime_config_blob = ConvertFieldToBool ("have_runtime_config_blob", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
240241
break;
241242

242-
case 7: // marshal_methods_enabled: bool / .byte
243+
case 7: // fastdev_enabled: bool / .byte
244+
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
245+
ret.fastdev_enabled = ConvertFieldToBool ("fastdev_enabled", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
246+
break;
247+
248+
case 8: // marshal_methods_enabled: bool / .byte
243249
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
244250
ret.marshal_methods_enabled = ConvertFieldToBool ("marshal_methods_enabled", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
245251
break;
246252

247-
case 8: // ignore_split_configs: bool / .byte
253+
case 9: // ignore_split_configs: bool / .byte
248254
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
249255
ret.ignore_split_configs = ConvertFieldToBool ("ignore_split_configs", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
250256
break;
251257

252-
case 9: // bound_stream_io_exception_type: byte / .byte
258+
case 10: // bound_stream_io_exception_type: byte / .byte
253259
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
254260
ret.bound_stream_io_exception_type = ConvertFieldToByte ("bound_stream_io_exception_type", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
255261
break;
256262

257-
case 10: // package_naming_policy: uint32_t / .word | .long
263+
case 11: // package_naming_policy: uint32_t / .word | .long
258264
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
259265
ret.package_naming_policy = ConvertFieldToUInt32 ("package_naming_policy", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
260266
break;
261267

262-
case 11: // environment_variable_count: uint32_t / .word | .long
268+
case 12: // environment_variable_count: uint32_t / .word | .long
263269
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
264270
ret.environment_variable_count = ConvertFieldToUInt32 ("environment_variable_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
265271
break;
266272

267-
case 12: // system_property_count: uint32_t / .word | .long
273+
case 13: // system_property_count: uint32_t / .word | .long
268274
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
269275
ret.system_property_count = ConvertFieldToUInt32 ("system_property_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
270276
break;
271277

272-
case 13: // number_of_assemblies_in_apk: uint32_t / .word | .long
278+
case 14: // number_of_assemblies_in_apk: uint32_t / .word | .long
273279
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
274280
ret.number_of_assemblies_in_apk = ConvertFieldToUInt32 ("number_of_assemblies_in_apk", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
275281
break;
276282

277-
case 14: // number_of_assembly_store_files: uint32_t / .word | .long
283+
case 15: // number_of_assembly_store_files: uint32_t / .word | .long
278284
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
279285
ret.number_of_assembly_store_files = ConvertFieldToUInt32 ("number_of_assembly_store_files", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
280286
break;
281287

282-
case 15: // number_of_dso_cache_entries: uint32_t / .word | .long
288+
case 16: // number_of_dso_cache_entries: uint32_t / .word | .long
283289
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
284290
ret.number_of_dso_cache_entries = ConvertFieldToUInt32 ("number_of_dso_cache_entries", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
285291
break;
286292

287-
case 16: // number_of_aot_cache_entries: uint32_t / .word | .long
293+
case 17: // number_of_aot_cache_entries: uint32_t / .word | .long
288294
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
289295
ret.number_of_aot_cache_entries = ConvertFieldToUInt32 ("number_of_aot_cache_entries", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
290296
break;
291297

292-
case 17: // android_runtime_jnienv_class_token: uint32_t / .word | .long
298+
case 18: // android_runtime_jnienv_class_token: uint32_t / .word | .long
293299
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
294300
ret.android_runtime_jnienv_class_token = ConvertFieldToUInt32 ("android_runtime_jnienv_class_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
295301
break;
296302

297-
case 18: // jnienv_initialize_method_token: uint32_t / .word | .long
303+
case 19: // jnienv_initialize_method_token: uint32_t / .word | .long
298304
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
299305
ret.jnienv_initialize_method_token = ConvertFieldToUInt32 ("jnienv_initialize_method_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
300306
break;
301307

302-
case 19: // jnienv_registerjninatives_method_token: uint32_t / .word | .long
308+
case 20: // jnienv_registerjninatives_method_token: uint32_t / .word | .long
303309
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
304310
ret.jnienv_registerjninatives_method_token = ConvertFieldToUInt32 ("jnienv_registerjninatives_method_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
305311
break;
306312

307-
case 20: // jni_remapping_replacement_type_count: uint32_t / .word | .long
313+
case 21: // jni_remapping_replacement_type_count: uint32_t / .word | .long
308314
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
309315
ret.jni_remapping_replacement_type_count = ConvertFieldToUInt32 ("jni_remapping_replacement_type_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
310316
break;
311317

312-
case 21: // jni_remapping_replacement_method_index_entry_count: uint32_t / .word | .long
318+
case 22: // jni_remapping_replacement_method_index_entry_count: uint32_t / .word | .long
313319
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
314320
ret.jni_remapping_replacement_method_index_entry_count = ConvertFieldToUInt32 ("jni_remapping_replacement_method_index_entry_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
315321
break;
316322

317-
case 22: // mono_components_mask: uint32_t / .word | .long
323+
case 23: // mono_components_mask: uint32_t / .word | .long
318324
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
319325
ret.mono_components_mask = ConvertFieldToUInt32 ("mono_components_mask", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
320326
break;
321327

322-
case 23: // android_package_name: string / [pointer type]
328+
case 24: // android_package_name: string / [pointer type]
323329
Assert.IsTrue (expectedPointerTypes.Contains (field [0]), $"Unexpected pointer field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
324330
pointers.Add (field [1].Trim ());
325331
break;

‎src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ sealed class ApplicationConfig
3131
public bool broken_exception_transitions;
3232
public bool jni_add_native_method_registration_attribute_present;
3333
public bool have_runtime_config_blob;
34+
public bool fastdev_enabled;
3435
public bool marshal_methods_enabled;
3536
public bool ignore_split_configs;
3637
public byte bound_stream_io_exception_type;

‎src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ sealed class XamarinAndroidBundledAssembly
186186
public List<ITaskItem> NativeLibraries { get; set; }
187187
public bool MarshalMethodsEnabled { get; set; }
188188
public bool IgnoreSplitConfigs { get; set; }
189+
public bool FastDevEnabled { get; set; }
189190

190191
public ApplicationConfigNativeAssemblyGenerator (IDictionary<string, string> environmentVariables, IDictionary<string, string> systemProperties, TaskLoggingHelper log)
191192
: base (log)
@@ -225,6 +226,7 @@ protected override void Construct (LlvmIrModule module)
225226
broken_exception_transitions = BrokenExceptionTransitions,
226227
jni_add_native_method_registration_attribute_present = JniAddNativeMethodRegistrationAttributePresent,
227228
have_runtime_config_blob = HaveRuntimeConfigBlob,
229+
fastdev_enabled = FastDevEnabled,
228230
marshal_methods_enabled = MarshalMethodsEnabled,
229231
ignore_split_configs = IgnoreSplitConfigs,
230232
bound_stream_io_exception_type = (byte)BoundExceptionType,

‎src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!--
1+
<!--
22
***********************************************************************************************
33
Xamarin.Android.Common.targets
44
@@ -161,6 +161,8 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
161161
<EmbedAssembliesIntoApk Condition=" '$(EmbedAssembliesIntoApk)' == '' And '$(Optimize)' != 'True' And '$(_XASupportsFastDev)' == 'True' ">False</EmbedAssembliesIntoApk>
162162
<EmbedAssembliesIntoApk Condition=" '$(_XASupportsFastDev)' == 'False' ">True</EmbedAssembliesIntoApk>
163163
<EmbedAssembliesIntoApk Condition=" '$(EmbedAssembliesIntoApk)' == '' ">True</EmbedAssembliesIntoApk>
164+
<_XAFastDevEnabled Condition=" '$(_XASupportsFastDev)' == 'True' And '$(EmbedAssembliesIntoApk)' != 'True' ">True</_XAFastDevEnabled>
165+
<_XAFastDevEnabled Condition=" '$(_XAFastDevEnabled)' == '' ">False</_XAFastDevEnabled>
164166
<AndroidPreferNativeLibrariesWithDebugSymbols Condition=" '$(AndroidPreferNativeLibrariesWithDebugSymbols)' == '' ">False</AndroidPreferNativeLibrariesWithDebugSymbols>
165167
<AndroidSkipJavacVersionCheck Condition="'$(AndroidSkipJavacVersionCheck)' == ''">False</AndroidSkipJavacVersionCheck>
166168
<AndroidBuildApplicationPackage Condition=" '$(AndroidBuildApplicationPackage)' == ''">False</AndroidBuildApplicationPackage>
@@ -1742,6 +1744,7 @@ because xbuild doesn't support framework reference assemblies.
17421744
RuntimeConfigBinFilePath="$(_BinaryRuntimeConfigPath)"
17431745
EnableMarshalMethods="$(_AndroidUseMarshalMethods)"
17441746
CustomBundleConfigFile="$(AndroidBundleConfigurationFile)"
1747+
FastDevEnabled="$(_XAFastDevEnabled)"
17451748
>
17461749
</GeneratePackageManagerJava>
17471750
<Touch Files="$(_AndroidStampDirectory)_GeneratePackageManagerJava.stamp" AlwaysCreate="True" />

‎src/native/monodroid/embedded-assemblies.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ template<LoaderData TLoaderData>
197197
force_inline MonoAssembly*
198198
EmbeddedAssemblies::open_from_bundles (MonoAssemblyName* aname, TLoaderData loader_data, [[maybe_unused]] MonoError *error, bool ref_only) noexcept
199199
{
200-
#if defined (DEBUG)
201-
if (assembly_store_hashes == nullptr) {
202-
// With FastDev we might not have any assembly stores present
203-
return nullptr;
200+
if constexpr (SharedConstants::debug_build) {
201+
if (application_config.fastdev_enabled && assembly_store_hashes == nullptr) {
202+
// With FastDev we might not have any assembly stores present
203+
return nullptr;
204+
}
204205
}
205-
#endif
206206

207207
const char *culture = mono_assembly_name_get_culture (aname);
208208
const char *asmname = mono_assembly_name_get_name (aname);

‎src/native/monodroid/embedded-assemblies.hh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ namespace xamarin::android::internal {
183183

184184
void ensure_valid_assembly_stores () const noexcept
185185
{
186+
if constexpr (SharedConstants::debug_build) {
187+
if (application_config.fastdev_enabled) {
188+
return;
189+
}
190+
}
191+
186192
abort_unless (assembly_store_hashes != nullptr, "Invalid or incomplete assembly store data");
187193
}
188194

‎src/native/xamarin-app-stub/application_dso_stub.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const ApplicationConfig application_config = {
4949
.broken_exception_transitions = false,
5050
.jni_add_native_method_registration_attribute_present = false,
5151
.have_runtime_config_blob = false,
52+
.fastdev_enabled = false,
5253
.marshal_methods_enabled = false,
5354
.ignore_split_configs = false,
5455
.bound_exception_type = 0, // System

‎src/native/xamarin-app-stub/xamarin-app.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ struct ApplicationConfig
228228
bool broken_exception_transitions;
229229
bool jni_add_native_method_registration_attribute_present;
230230
bool have_runtime_config_blob;
231+
bool fastdev_enabled;
231232
bool marshal_methods_enabled;
232233
bool ignore_split_configs;
233234
uint8_t bound_exception_type;

0 commit comments

Comments
 (0)
Please sign in to comment.