Skip to content

Commit a00c2d5

Browse files
committed
More updates
1 parent 5aecb6d commit a00c2d5

File tree

7 files changed

+53
-32
lines changed

7 files changed

+53
-32
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ sealed class XamarinAndroidBundledAssembly
8888
public IntPtr data;
8989
public uint name_length;
9090

91-
[NativeAssemblerString (PointerToSymbol = true)]
91+
[NativeAssemblerString (AssemblerStringFormat.PointerToSymbol)]
9292
public string name;
9393
};
9494

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ sealed class CompressedAssemblyDescriptor
1616
public uint uncompressed_file_size;
1717
public bool loaded;
1818

19-
[NativeAssemblerString (PointerToSymbol = true)]
19+
[NativeAssemblerString (AssemblerStringFormat.PointerToSymbol)]
2020
public string data = String.Empty;
2121
};
2222

@@ -26,7 +26,7 @@ sealed class CompressedAssemblies
2626
{
2727
public uint count;
2828

29-
[NativeAssemblerString (PointerToSymbol = true)]
29+
[NativeAssemblerString (AssemblerStringFormat.PointerToSymbol)]
3030
public string descriptors;
3131
};
3232

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,14 @@ namespace Xamarin.Android.Tasks
1515
{
1616
static class ELFHelper
1717
{
18-
static ConcurrentDictionary<string, bool> checkedDSOs = new ConcurrentDictionary<string, bool> (StringComparer.OrdinalIgnoreCase);
19-
2018
public static bool IsEmptyAOTLibrary (TaskLoggingHelper log, string path)
2119
{
2220
if (String.IsNullOrEmpty (path) || !File.Exists (path)) {
2321
return false;
2422
}
2523

26-
if (checkedDSOs.TryGetValue (path, out bool isEmpty)) {
27-
return isEmpty;
28-
}
29-
3024
try {
31-
isEmpty = IsEmptyAOTLibrary (log, path, ELFReader.Load (path));
32-
checkedDSOs.TryAdd (path, isEmpty); // it's possible some other thread already added it, thus we don't care about the return value
33-
return isEmpty;
25+
return IsEmptyAOTLibrary (log, path, ELFReader.Load (path));
3426
} catch (Exception ex) {
3527
log.LogWarning ($"Attempt to check whether '{path}' is a valid ELF file failed with exception, ignoring AOT check for the file.");
3628
log.LogWarningFromException (ex, showStackTrace: true);

src/Xamarin.Android.Build.Tasks/Utilities/NativeAssemblyGenerator/Arm32NativeAssemblyGenerator.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ protected override void ConfigureTypeMappings (Dictionary<Type, NativeType?> map
5353

5454
// Alignments and sizes as per https://github.com/ARM-software/abi-aa/blob/320a56971fdcba282b7001cf4b84abb4fd993131/aapcs32/aapcs32.rst#fundamental-data-types
5555
// Assembler type directives are described in https://sourceware.org/binutils/docs-2.37/as/index.html
56-
ConfigureTypeMapping<short> (".short", size: 2, alignment: 2);
56+
ConfigureTypeMapping<short> (".short", size: 2, alignment: 2);
5757
ConfigureTypeMapping<ushort> (".short", size: 2, alignment: 2);
58-
ConfigureTypeMapping<int> (".long", size: 4, alignment: 4);
59-
ConfigureTypeMapping<uint> (".long", size: 4, alignment: 4);
60-
ConfigureTypeMapping<long> (".long", size: 8, alignment: 8);
61-
ConfigureTypeMapping<ulong> (".long", size: 8, alignment: 8);
62-
ConfigureTypeMapping<float> (".long", size: 4, alignment: 4);
63-
ConfigureTypeMapping<double> (".long", size: 8, alignment: 8);
64-
ConfigureTypeMapping<nint> (".long", size: 4, alignment: 4);
65-
ConfigureTypeMapping<nuint> (".long", size: 4, alignment: 4);
66-
ConfigureTypeMapping<IntPtr> (".long", size: 4, alignment: 4);
58+
ConfigureTypeMapping<int> (".long", size: 4, alignment: 4);
59+
ConfigureTypeMapping<uint> (".long", size: 4, alignment: 4);
60+
ConfigureTypeMapping<long> (".long", size: 8, alignment: 8);
61+
ConfigureTypeMapping<ulong> (".long", size: 8, alignment: 8);
62+
ConfigureTypeMapping<float> (".long", size: 4, alignment: 4);
63+
ConfigureTypeMapping<double> (".long", size: 8, alignment: 8);
64+
ConfigureTypeMapping<nint> (".long", size: 4, alignment: 4);
65+
ConfigureTypeMapping<nuint> (".long", size: 4, alignment: 4);
66+
ConfigureTypeMapping<IntPtr> (".long", size: 4, alignment: 4);
6767
}
6868

6969
public override void WriteFileTop ()

src/Xamarin.Android.Build.Tasks/Utilities/NativeAssemblyGenerator/NativeAssemblerAttribute.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,41 @@ class NativeAssemblerAttribute : Attribute
1111
public string? Name { get; set; }
1212
}
1313

14+
enum AssemblerStringFormat
15+
{
16+
/// <summary>
17+
/// Local string label is automatically generated for the string, this is the default behavior
18+
/// </summary>
19+
Automatic,
20+
21+
/// <summary>
22+
/// String is output as an inline (no pointer) array/buffer filled directly with string data
23+
/// </summary>
24+
InlineArray,
25+
26+
/// <summary>
27+
/// String is output as a pointer to symbol whose name is contents of the string being processed
28+
PointerToSymbol,
29+
}
30+
1431
[AttributeUsage (AttributeTargets.Field | AttributeTargets.Property, Inherited = true)]
1532
class NativeAssemblerStringAttribute : NativeAssemblerAttribute
1633
{
17-
public bool Inline { get; set; }
34+
AssemblerStringFormat format;
35+
36+
public bool Inline => format == AssemblerStringFormat.InlineArray;
1837
public bool PadToMaxLength { get; set; }
19-
public bool PointerToSymbol { get; set; }
38+
public bool PointerToSymbol => format == AssemblerStringFormat.PointerToSymbol;
39+
40+
public NativeAssemblerStringAttribute ()
41+
{
42+
format = AssemblerStringFormat.Automatic;
43+
}
44+
45+
public NativeAssemblerStringAttribute (AssemblerStringFormat format)
46+
{
47+
this.format = format;
48+
}
2049
}
2150

2251
[AttributeUsage (AttributeTargets.Class, Inherited = true)]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public override string GetComment (object data, string fieldName)
3535
// src/monodroid/jni/xamarin-app.hh TypeMapEntry structure
3636
sealed class TypeMapEntry
3737
{
38-
[NativeAssemblerString (PointerToSymbol = true)]
38+
[NativeAssemblerString (AssemblerStringFormat.PointerToSymbol)]
3939
public string from;
4040

41-
[NativeAssemblerString (PointerToSymbol = true)]
41+
[NativeAssemblerString (AssemblerStringFormat.PointerToSymbol)]
4242
public string to;
4343
};
4444

@@ -55,10 +55,10 @@ sealed class TypeMap
5555
[NativeAssembler (UsesDataProvider = true)]
5656
public IntPtr data = IntPtr.Zero; // unused in Debug mode
5757

58-
[NativeAssemblerString (PointerToSymbol = true)]
58+
[NativeAssemblerString (AssemblerStringFormat.PointerToSymbol)]
5959
public string java_to_managed;
6060

61-
[NativeAssemblerString (PointerToSymbol = true)]
61+
[NativeAssemblerString (AssemblerStringFormat.PointerToSymbol)]
6262
public string managed_to_java;
6363
};
6464

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ sealed class TypeMapModule
7171
public uint entry_count;
7272
public uint duplicate_count;
7373

74-
[NativeAssemblerString (PointerToSymbol = true)]
74+
[NativeAssemblerString (AssemblerStringFormat.PointerToSymbol)]
7575
public string map;
7676

77-
[NativeAssemblerString (PointerToSymbol = true)]
77+
[NativeAssemblerString (AssemblerStringFormat.PointerToSymbol)]
7878
public string duplicate_map;
7979

80-
[NativeAssemblerString (PointerToSymbol = true, UsesDataProvider = true)]
80+
[NativeAssemblerString (AssemblerStringFormat.PointerToSymbol, UsesDataProvider = true)]
8181
public string assembly_name;
8282
public IntPtr image;
8383
public uint java_name_width;
@@ -95,7 +95,7 @@ sealed class TypeMapJava
9595
public uint module_index;
9696
public uint type_token_id;
9797

98-
[NativeAssemblerString (Inline = true, PadToMaxLength = true)]
98+
[NativeAssemblerString (AssemblerStringFormat.InlineArray, PadToMaxLength = true)]
9999
public string java_name;
100100
}
101101

0 commit comments

Comments
 (0)