Skip to content

Commit 75e6902

Browse files
committed
Rebase on main and fix NRT errors
1 parent dbdd569 commit 75e6902

File tree

4 files changed

+41
-37
lines changed

4 files changed

+41
-37
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,33 @@ public class GetNativeRuntimeComponents : AndroidTask
1212
{
1313
public override string TaskPrefix => "GNRC";
1414

15-
public ITaskItem[] MonoComponents { get; set; }
15+
public ITaskItem[]? MonoComponents { get; set; }
1616

1717
[Required]
18-
public ITaskItem[] ResolvedNativeArchives { get; set; }
18+
public ITaskItem[] ResolvedNativeArchives { get; set; } = null!;
1919

2020
[Required]
21-
public ITaskItem[] ResolvedNativeObjectFiles { get; set; }
21+
public ITaskItem[] ResolvedNativeObjectFiles { get; set; } = null!;
2222

2323
[Required]
24-
public string HackLocalClrRepoPath { get; set; }
24+
public string HackLocalClrRepoPath { get; set; } = "";
2525

2626
[Output]
27-
public ITaskItem[] NativeArchives { get; set; }
27+
public ITaskItem[] NativeArchives { get; set; } = null!;
2828

2929
[Output]
30-
public ITaskItem[] RequiredLibraries { get; set; }
30+
public ITaskItem[] RequiredLibraries { get; set; } = null!;
3131

3232
[Output]
33-
public ITaskItem[] LinkStartFiles { get; set; }
33+
public ITaskItem[] LinkStartFiles { get; set; } = null!;
3434

3535
[Output]
36-
public ITaskItem[] LinkEndFiles { get; set; }
36+
public ITaskItem[] LinkEndFiles { get; set; } = null!;
3737

3838
// TODO: more research, for now it seems `--export-dynamic-symbol=name` options generated from
3939
// this array don't work as expected.
4040
[Output]
41-
public ITaskItem[] NativeSymbolsToExport { get; set; }
41+
public ITaskItem[] NativeSymbolsToExport { get; set; } = [];
4242

4343
public override bool RunTask ()
4444
{
@@ -151,7 +151,7 @@ void MakeArchiveItem (NativeRuntimeComponents.Archive archive, List<ITaskItem> a
151151
ITaskItem DoMakeItem (string msbuildItemName, ITaskItem sourceItem, HashSet<string> uniqueAbis)
152152
{
153153
var ret = new TaskItem (sourceItem.ItemSpec);
154-
string rid = sourceItem.GetRequiredMetadata (msbuildItemName, KnownMetadata.RuntimeIdentifier, Log);
154+
string rid = sourceItem.GetRequiredMetadata (msbuildItemName, KnownMetadata.RuntimeIdentifier, Log) ?? String.Empty;
155155
string abi = MonoAndroidHelper.RidToAbi (rid);
156156
uniqueAbis.Add (abi);
157157
ret.SetMetadata (KnownMetadata.Abi, abi);

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,43 @@ public class LinkNativeRuntime : AsyncTask
1313
{
1414
public override string TaskPrefix => "LNR";
1515

16-
public ITaskItem[] MonoComponents { get; set; }
16+
public ITaskItem[]? MonoComponents { get; set; }
1717

1818
[Required]
19-
public string AndroidBinUtilsDirectory { get; set; }
19+
public string AndroidBinUtilsDirectory { get; set; } = "";
2020

2121
public string? AndroidNdkDirectory { get; set; }
2222
public string? AndroidApiLevel { get; set; }
2323

2424
[Required]
25-
public string IntermediateOutputPath { get; set; }
25+
public string IntermediateOutputPath { get; set; } = "";
2626

2727
[Required]
28-
public ITaskItem[] LinkLibraries { get; set; }
28+
public ITaskItem[] LinkLibraries { get; set; } = null!;
2929

3030
[Required]
31-
public ITaskItem[] NativeArchives { get; set; }
31+
public ITaskItem[] NativeArchives { get; set; } = null!;
3232

3333
[Required]
34-
public ITaskItem[] NativeObjectFiles { get; set; }
34+
public ITaskItem[] NativeObjectFiles { get; set; } = null!;
3535

3636
[Required]
37-
public ITaskItem[] NativeLinkStartFiles { get; set; }
37+
public ITaskItem[] NativeLinkStartFiles { get; set; } = null!;
3838

3939
[Required]
40-
public ITaskItem[] NativeLinkEndFiles { get; set; }
40+
public ITaskItem[] NativeLinkEndFiles { get; set; } = null!;
4141

4242
[Required]
43-
public ITaskItem[] NativeSymbolsToExport { get; set; }
43+
public ITaskItem[] NativeSymbolsToExport { get; set; } = null!;
4444

4545
[Required]
46-
public ITaskItem[] OutputRuntimes { get; set; }
46+
public ITaskItem[] OutputRuntimes { get; set; } = null!;
4747

4848
[Required]
49-
public ITaskItem[] SupportedAbis { get; set; }
49+
public ITaskItem[] SupportedAbis { get; set; } = null!;
5050

5151
[Required]
52-
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = Array.Empty<ITaskItem> ();
52+
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = null!;
5353

5454
public bool SaveDebugSymbols { get; set; } = true;
5555
public bool StripDebugSymbols { get; set; } = true;
@@ -99,7 +99,7 @@ List<ITaskItem> OrganizeCommandLineItemsCLR (string abi)
9999
// let the exception be thrown should a required (and assumed to be present) set be missing.
100100
var sets = new Dictionary<string, List<ITaskItem>> (StringComparer.Ordinal);
101101
foreach (ITaskItem item in GetAbiItems (NativeArchives, "_SelectedNativeArchive", abi)) {
102-
string setName = item.GetRequiredMetadata ("_SelectedNativeArchive", KnownMetadata.NativeLinkItemSet, Log);
102+
string setName = item.GetRequiredMetadata ("_SelectedNativeArchive", KnownMetadata.NativeLinkItemSet, Log) ?? String.Empty;
103103
if (!sets.TryGetValue (setName, out List<ITaskItem>? items)) {
104104
items = new List<ITaskItem> ();
105105
sets.Add (setName, items);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public sealed class KnownSets
1818
internal class Archive
1919
{
2020
public readonly string Name;
21-
public readonly string JniOnLoadName;
21+
public readonly string? JniOnLoadName;
2222
public bool Include => shouldInclude (this);
2323
public readonly bool WholeArchive;
2424
public bool DontExportSymbols { get; set; }
@@ -81,14 +81,14 @@ public CplusPlusArchive (string name)
8181
}
8282
}
8383

84-
readonly ITaskItem[] monoComponents;
84+
readonly ITaskItem[]? monoComponents;
8585

8686
public readonly List<Archive> KnownArchives;
8787
public readonly List<string> NativeLibraries;
8888
public readonly List<string> LinkStartFiles;
8989
public readonly List<string> LinkEndFiles;
9090

91-
public NativeRuntimeComponents (ITaskItem[] monoComponents)
91+
public NativeRuntimeComponents (ITaskItem[]? monoComponents)
9292
{
9393
this.monoComponents = monoComponents;
9494
KnownArchives = new () {

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ public void Sort ()
6060

6161
sealed class ConstructionState
6262
{
63-
public LlvmIrFunction Func;
64-
public LlvmIrFunctionLabelItem ReturnLabel;
65-
public LlvmIrFunctionParameter EntryPointHashParam;
66-
public LlvmIrInstructions.Phi Phi;
63+
public LlvmIrFunction Func = null!;
64+
public LlvmIrFunctionLabelItem ReturnLabel = null!;
65+
public LlvmIrFunctionParameter EntryPointHashParam = null!;
66+
public LlvmIrInstructions.Phi Phi = null!;
6767
public bool Is64Bit;
6868
}
6969

@@ -111,8 +111,8 @@ protected override void Construct (LlvmIrModule module)
111111

112112
Log.LogDebugMessage ($" {archiveItem.Name}");
113113
componentNames.Add (archiveItem.Name);
114-
if (!String.IsNullOrEmpty (archiveItem.JniOnLoadName)) {
115-
componentLoadHandlers.Add (archiveItem.Name, archiveItem.JniOnLoadName);
114+
if (!archiveItem.JniOnLoadName.IsNullOrEmpty ()) {
115+
componentLoadHandlers.Add (archiveItem.Name, archiveItem.JniOnLoadName!);
116116
}
117117

118118
if (archiveItem.SymbolsToPreserve == null || archiveItem.SymbolsToPreserve.Count == 0) {
@@ -164,19 +164,19 @@ protected override void Construct (LlvmIrModule module)
164164
}
165165
Log.LogDebugMessage (" must be preserved");
166166

167-
if (!String.IsNullOrEmpty (componentName)) {
168-
if (haveLoadHandlers && componentLoadHandlers.TryGetValue (componentName, out string jniOnLoadName)) {
167+
if (!componentName.IsNullOrEmpty ()) {
168+
if (haveLoadHandlers && componentLoadHandlers.TryGetValue (componentName!, out string jniOnLoadName)) {
169169
if (jniOnLoadNames.Add (jniOnLoadName)) {
170170
Log.LogDebugMessage ($" component '{componentName}' registers a load handler '{jniOnLoadName}'");
171171
}
172172
}
173173

174-
if (havePreservedSymbols && componentPreservedSymbols.TryGetValue (componentName, out HashSet<LlvmIrGlobalVariableReference> preservedSymbols)) {
174+
if (havePreservedSymbols && componentPreservedSymbols.TryGetValue (componentName!, out HashSet<LlvmIrGlobalVariableReference> preservedSymbols)) {
175175
foreach (LlvmIrGlobalVariableReference vref in preservedSymbols) {
176176
DeclareDummyFunction (module, vref);
177177
symbolsToExplicitlyPreserve.Add (vref);
178178
}
179-
componentPreservedSymbols.Remove (componentName);
179+
componentPreservedSymbols.Remove (componentName!);
180180
}
181181
}
182182

@@ -395,8 +395,12 @@ bool Matches (string libraryName, string componentName)
395395

396396
static void DeclareDummyFunction (LlvmIrModule module, LlvmIrGlobalVariableReference symref)
397397
{
398+
if (symref.Name.IsNullOrEmpty ()) {
399+
throw new InvalidOperationException ("Internal error: variable reference must have a name");
400+
}
401+
398402
// Just a dummy declaration, we don't care about the arguments
399-
var funcSig = new LlvmIrFunctionSignature (symref.Name, returnType: typeof(void));
403+
var funcSig = new LlvmIrFunctionSignature (symref.Name!, returnType: typeof(void));
400404
var _ = module.DeclareExternalFunction (funcSig);
401405
}
402406
}

0 commit comments

Comments
 (0)