Skip to content

Commit 69a8829

Browse files
committed
Remove a lot of code to handle packaging of individual assemblies
1 parent 9bb00af commit 69a8829

11 files changed

+23
-588
lines changed

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

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ public class GeneratePackageManagerJava : AndroidTask
3535

3636
public ITaskItem[] SatelliteAssemblies { get; set; }
3737

38-
public bool UseAssemblyStore { get; set; }
39-
4038
[Required]
4139
public string OutputDirectory { get; set; }
4240

@@ -204,21 +202,7 @@ void AddEnvironment ()
204202
throw new InvalidOperationException ($"Unsupported BoundExceptionType value '{BoundExceptionType}'");
205203
}
206204

207-
int assemblyNameWidth = 0;
208205
Encoding assemblyNameEncoding = Encoding.UTF8;
209-
210-
Action<ITaskItem> updateNameWidth = (ITaskItem assembly) => {
211-
if (UseAssemblyStore) {
212-
return;
213-
}
214-
215-
string assemblyName = Path.GetFileName (assembly.ItemSpec);
216-
int nameBytes = assemblyNameEncoding.GetBytes (assemblyName).Length;
217-
if (nameBytes > assemblyNameWidth) {
218-
assemblyNameWidth = nameBytes;
219-
}
220-
};
221-
222206
int assemblyCount = 0;
223207
bool enableMarshalMethods = EnableMarshalMethods;
224208
HashSet<string> archAssemblyNames = null;
@@ -249,7 +233,6 @@ void AddEnvironment ()
249233

250234
if (SatelliteAssemblies != null) {
251235
foreach (ITaskItem assembly in SatelliteAssemblies) {
252-
updateNameWidth (assembly);
253236
updateAssemblyCount (assembly);
254237
}
255238
}
@@ -258,7 +241,6 @@ void AddEnvironment ()
258241
int jnienv_initialize_method_token = -1;
259242
int jnienv_registerjninatives_method_token = -1;
260243
foreach (var assembly in ResolvedAssemblies) {
261-
updateNameWidth (assembly);
262244
updateAssemblyCount (assembly);
263245

264246
if (android_runtime_jnienv_class_token != -1) {
@@ -272,17 +254,6 @@ void AddEnvironment ()
272254
GetRequiredTokens (assembly.ItemSpec, out android_runtime_jnienv_class_token, out jnienv_initialize_method_token, out jnienv_registerjninatives_method_token);
273255
}
274256

275-
if (!UseAssemblyStore) {
276-
int abiNameLength = 0;
277-
foreach (string abi in SupportedAbis) {
278-
if (abi.Length <= abiNameLength) {
279-
continue;
280-
}
281-
abiNameLength = abi.Length;
282-
}
283-
assemblyNameWidth += abiNameLength + 2; // room for '/' and the terminating NUL
284-
}
285-
286257
MonoComponent monoComponents = MonoComponent.None;
287258
if (MonoComponents != null && MonoComponents.Length > 0) {
288259
foreach (ITaskItem item in MonoComponents) {
@@ -334,10 +305,8 @@ void AddEnvironment ()
334305
JniAddNativeMethodRegistrationAttributePresent = NativeCodeGenState.Template != null ? NativeCodeGenState.Template.JniAddNativeMethodRegistrationAttributePresent : false,
335306
HaveRuntimeConfigBlob = haveRuntimeConfigBlob,
336307
NumberOfAssembliesInApk = assemblyCount,
337-
BundledAssemblyNameWidth = assemblyNameWidth,
338308
MonoComponents = (MonoComponent)monoComponents,
339309
NativeLibraries = uniqueNativeLibraries,
340-
HaveAssemblyStore = UseAssemblyStore,
341310
AndroidRuntimeJNIEnvToken = android_runtime_jnienv_class_token,
342311
JNIEnvInitializeToken = jnienv_initialize_method_token,
343312
JNIEnvRegisterJniNativesToken = jnienv_registerjninatives_method_token,

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

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@ 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 have_assemblies_blob;
5049
public bool marshal_methods_enabled;
5150
public bool ignore_split_configs;
5251
public byte bound_stream_io_exception_type;
5352
public uint package_naming_policy;
5453
public uint environment_variable_count;
5554
public uint system_property_count;
5655
public uint number_of_assemblies_in_apk;
57-
public uint bundled_assembly_name_width;
5856
public uint number_of_assembly_store_files;
5957
public uint number_of_dso_cache_entries;
6058
public uint number_of_aot_cache_entries;
@@ -67,7 +65,7 @@ public sealed class ApplicationConfig
6765
public string android_package_name = String.Empty;
6866
}
6967

70-
const uint ApplicationConfigFieldCount = 26;
68+
const uint ApplicationConfigFieldCount = 24;
7169

7270
const string ApplicationConfigSymbolName = "application_config";
7371
const string AppEnvironmentVariablesSymbolName = "app_environment_variables";
@@ -241,97 +239,87 @@ static ApplicationConfig ReadApplicationConfig (EnvironmentFile envFile)
241239
ret.have_runtime_config_blob = ConvertFieldToBool ("have_runtime_config_blob", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
242240
break;
243241

244-
case 7: // have_assemblies_blob: bool / .byte
245-
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
246-
ret.have_assemblies_blob = ConvertFieldToBool ("have_assemblies_blob", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
247-
break;
248-
249-
case 8: // marshal_methods_enabled: bool / .byte
242+
case 7: // marshal_methods_enabled: bool / .byte
250243
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
251244
ret.marshal_methods_enabled = ConvertFieldToBool ("marshal_methods_enabled", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
252245
break;
253246

254-
case 9: // ignore_split_configs: bool / .byte
247+
case 8: // ignore_split_configs: bool / .byte
255248
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
256249
ret.ignore_split_configs = ConvertFieldToBool ("ignore_split_configs", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
257250
break;
258251

259-
case 10: // bound_stream_io_exception_type: byte / .byte
252+
case 9: // bound_stream_io_exception_type: byte / .byte
260253
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
261254
ret.bound_stream_io_exception_type = ConvertFieldToByte ("bound_stream_io_exception_type", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
262255
break;
263256

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

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

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

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

284-
case 15: // bundled_assembly_name_width: uint32_t / .word | .long
285-
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
286-
ret.bundled_assembly_name_width = ConvertFieldToUInt32 ("bundled_assembly_name_width", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
287-
break;
288-
289-
case 16: // number_of_assembly_store_files: uint32_t / .word | .long
277+
case 14: // number_of_assembly_store_files: uint32_t / .word | .long
290278
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
291279
ret.number_of_assembly_store_files = ConvertFieldToUInt32 ("number_of_assembly_store_files", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
292280
break;
293281

294-
case 17: // number_of_dso_cache_entries: uint32_t / .word | .long
282+
case 15: // number_of_dso_cache_entries: uint32_t / .word | .long
295283
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
296284
ret.number_of_dso_cache_entries = ConvertFieldToUInt32 ("number_of_dso_cache_entries", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
297285
break;
298286

299-
case 18: // number_of_aot_cache_entries: uint32_t / .word | .long
287+
case 16: // number_of_aot_cache_entries: uint32_t / .word | .long
300288
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
301289
ret.number_of_aot_cache_entries = ConvertFieldToUInt32 ("number_of_aot_cache_entries", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
302290
break;
303291

304-
case 19: // android_runtime_jnienv_class_token: uint32_t / .word | .long
292+
case 17: // android_runtime_jnienv_class_token: uint32_t / .word | .long
305293
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
306294
ret.android_runtime_jnienv_class_token = ConvertFieldToUInt32 ("android_runtime_jnienv_class_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
307295
break;
308296

309-
case 20: // jnienv_initialize_method_token: uint32_t / .word | .long
297+
case 18: // jnienv_initialize_method_token: uint32_t / .word | .long
310298
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
311299
ret.jnienv_initialize_method_token = ConvertFieldToUInt32 ("jnienv_initialize_method_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
312300
break;
313301

314-
case 21: // jnienv_registerjninatives_method_token: uint32_t / .word | .long
302+
case 19: // jnienv_registerjninatives_method_token: uint32_t / .word | .long
315303
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
316304
ret.jnienv_registerjninatives_method_token = ConvertFieldToUInt32 ("jnienv_registerjninatives_method_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
317305
break;
318306

319-
case 22: // jni_remapping_replacement_type_count: uint32_t / .word | .long
307+
case 20: // jni_remapping_replacement_type_count: uint32_t / .word | .long
320308
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
321309
ret.jni_remapping_replacement_type_count = ConvertFieldToUInt32 ("jni_remapping_replacement_type_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
322310
break;
323311

324-
case 23: // jni_remapping_replacement_method_index_entry_count: uint32_t / .word | .long
312+
case 21: // jni_remapping_replacement_method_index_entry_count: uint32_t / .word | .long
325313
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
326314
ret.jni_remapping_replacement_method_index_entry_count = ConvertFieldToUInt32 ("jni_remapping_replacement_method_index_entry_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
327315
break;
328316

329-
case 24: // mono_components_mask: uint32_t / .word | .long
317+
case 22: // mono_components_mask: uint32_t / .word | .long
330318
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
331319
ret.mono_components_mask = ConvertFieldToUInt32 ("mono_components_mask", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
332320
break;
333321

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

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ 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 have_assemblies_blob;
3534
public bool marshal_methods_enabled;
3635
public bool ignore_split_configs;
3736
public byte bound_stream_io_exception_type;
3837
public uint package_naming_policy;
3938
public uint environment_variable_count;
4039
public uint system_property_count;
4140
public uint number_of_assemblies_in_apk;
42-
public uint bundled_assembly_name_width;
4341
public uint number_of_dso_cache_entries;
4442
public uint number_of_aot_cache_entries;
4543
public uint number_of_shared_libraries;

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

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ sealed class XamarinAndroidBundledAssembly
175175
public global::Android.Runtime.BoundExceptionType BoundExceptionType { get; set; }
176176
public bool JniAddNativeMethodRegistrationAttributePresent { get; set; }
177177
public bool HaveRuntimeConfigBlob { get; set; }
178-
public bool HaveAssemblyStore { get; set; }
179178
public int NumberOfAssembliesInApk { get; set; }
180-
public int BundledAssemblyNameWidth { get; set; } // including the trailing NUL
181179
public int AndroidRuntimeJNIEnvToken { get; set; }
182180
public int JNIEnvInitializeToken { get; set; }
183181
public int JNIEnvRegisterJniNativesToken { get; set; }
@@ -227,7 +225,6 @@ protected override void Construct (LlvmIrModule module)
227225
broken_exception_transitions = BrokenExceptionTransitions,
228226
jni_add_native_method_registration_attribute_present = JniAddNativeMethodRegistrationAttributePresent,
229227
have_runtime_config_blob = HaveRuntimeConfigBlob,
230-
have_assemblies_blob = HaveAssemblyStore,
231228
marshal_methods_enabled = MarshalMethodsEnabled,
232229
ignore_split_configs = IgnoreSplitConfigs,
233230
bound_stream_io_exception_type = (byte)BoundExceptionType,
@@ -236,7 +233,6 @@ protected override void Construct (LlvmIrModule module)
236233
system_property_count = (uint)(systemProperties == null ? 0 : systemProperties.Count * 2),
237234
number_of_assemblies_in_apk = (uint)NumberOfAssembliesInApk,
238235
number_of_shared_libraries = (uint)NativeLibraries.Count,
239-
bundled_assembly_name_width = (uint)BundledAssemblyNameWidth,
240236
number_of_dso_cache_entries = (uint)dsoCache.Count,
241237
number_of_aot_cache_entries = (uint)aotDsoCache.Count,
242238
android_runtime_jnienv_class_token = (uint)AndroidRuntimeJNIEnvToken,
@@ -269,36 +265,12 @@ protected override void Construct (LlvmIrModule module)
269265
};
270266
module.Add (dso_apk_entries);
271267

272-
if (!HaveAssemblyStore) {
273-
xamarinAndroidBundledAssemblies = new List<StructureInstance<XamarinAndroidBundledAssembly>> (NumberOfAssembliesInApk);
274-
275-
var emptyBundledAssemblyData = new XamarinAndroidBundledAssembly {
276-
file_fd = -1,
277-
data_offset = 0,
278-
data_size = 0,
279-
data = 0,
280-
name_length = (uint)BundledAssemblyNameWidth,
281-
name = null,
282-
};
283-
284-
for (int i = 0; i < NumberOfAssembliesInApk; i++) {
285-
xamarinAndroidBundledAssemblies.Add (new StructureInstance<XamarinAndroidBundledAssembly> (xamarinAndroidBundledAssemblyStructureInfo, emptyBundledAssemblyData));
286-
}
287-
}
288-
289-
string bundledBuffersSize = xamarinAndroidBundledAssemblies == null ? "empty (unused when assembly stores are enabled)" : $"{BundledAssemblyNameWidth} bytes long";
290-
var bundled_assemblies = new LlvmIrGlobalVariable (typeof(List<StructureInstance<XamarinAndroidBundledAssembly>>), "bundled_assemblies", LlvmIrVariableOptions.GlobalWritable) {
291-
Value = xamarinAndroidBundledAssemblies,
292-
Comment = $" Bundled assembly name buffers, all {bundledBuffersSize}",
293-
};
294-
module.Add (bundled_assemblies);
295-
296268
AddAssemblyStores (module);
297269
}
298270

299271
void AddAssemblyStores (LlvmIrModule module)
300272
{
301-
ulong itemCount = (ulong)(HaveAssemblyStore ? NumberOfAssembliesInApk : 0);
273+
ulong itemCount = (ulong)NumberOfAssembliesInApk;
302274
var assembly_store_bundled_assemblies = new LlvmIrGlobalVariable (typeof(List<StructureInstance<AssemblyStoreSingleAssemblyRuntimeData>>), "assembly_store_bundled_assemblies", LlvmIrVariableOptions.GlobalWritable) {
303275
ZeroInitializeArray = true,
304276
ArrayItemCount = itemCount,

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,6 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
320320

321321
<PropertyGroup>
322322
<_AndroidAotStripLibraries Condition=" '$(_AndroidAotStripLibraries)' == '' And '$(AndroidIncludeDebugSymbols)' != 'true' ">True</_AndroidAotStripLibraries>
323-
<AndroidUseAssemblyStore Condition=" '$(EmbedAssembliesIntoApk)' != 'true' ">false</AndroidUseAssemblyStore>
324-
<AndroidUseAssemblyStore Condition=" '$(EmbedAssembliesIntoApk)' != 'true' ">true</AndroidUseAssemblyStore>
325323
<AndroidAotEnableLazyLoad Condition=" '$(AndroidAotEnableLazyLoad)' == '' And '$(AotAssemblies)' == 'true' And '$(AndroidIncludeDebugSymbols)' != 'true' ">True</AndroidAotEnableLazyLoad>
326324
<AndroidEnableMarshalMethods Condition=" '$(AndroidEnableMarshalMethods)' == '' and ('$(UsingMicrosoftNETSdkRazor)' == 'true') ">False</AndroidEnableMarshalMethods>
327325
<AndroidEnableMarshalMethods Condition=" '$(AndroidEnableMarshalMethods)' == '' ">False</AndroidEnableMarshalMethods>
@@ -1742,7 +1740,6 @@ because xbuild doesn't support framework reference assemblies.
17421740
PackageNamingPolicy="$(AndroidPackageNamingPolicy)"
17431741
BoundExceptionType="$(AndroidBoundExceptionType)"
17441742
RuntimeConfigBinFilePath="$(_BinaryRuntimeConfigPath)"
1745-
UseAssemblyStore="$(AndroidUseAssemblyStore)"
17461743
EnableMarshalMethods="$(_AndroidUseMarshalMethods)"
17471744
CustomBundleConfigFile="$(AndroidBundleConfigurationFile)"
17481745
>

0 commit comments

Comments
 (0)