Skip to content

Commit 8df92d0

Browse files
committed
Hopefully fix some tests and builds
1 parent ea6efd6 commit 8df92d0

File tree

4 files changed

+53
-24
lines changed

4 files changed

+53
-24
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public class GeneratePackageManagerJava : AndroidTask
2828
[Required]
2929
public ITaskItem[] ResolvedUserAssemblies { get; set; }
3030

31-
[Required]
3231
public ITaskItem[] NativeLibraries { get; set; }
3332

3433
public ITaskItem[] MonoComponents { get; set; }
@@ -355,16 +354,18 @@ void AddEnvironment ()
355354
}
356355

357356
var uniqueNativeLibraries = new List<ITaskItem> ();
358-
var seenNativeLibraryNames = new HashSet<string> (StringComparer.OrdinalIgnoreCase);
359-
foreach (ITaskItem item in NativeLibraries) {
360-
// We don't care about different ABIs here, just the file name
361-
string name = Path.GetFileName (item.ItemSpec);
362-
if (seenNativeLibraryNames.Contains (name)) {
363-
continue;
364-
}
357+
if (NativeLibraries != null) {
358+
var seenNativeLibraryNames = new HashSet<string> (StringComparer.OrdinalIgnoreCase);
359+
foreach (ITaskItem item in NativeLibraries) {
360+
// We don't care about different ABIs here, just the file name
361+
string name = Path.GetFileName (item.ItemSpec);
362+
if (seenNativeLibraryNames.Contains (name)) {
363+
continue;
364+
}
365365

366-
seenNativeLibraryNames.Add (name);
367-
uniqueNativeLibraries.Add (item);
366+
seenNativeLibraryNames.Add (name);
367+
uniqueNativeLibraries.Add (item);
368+
}
368369
}
369370

370371
bool haveRuntimeConfigBlob = !String.IsNullOrEmpty (RuntimeConfigBinFilePath) && File.Exists (RuntimeConfigBinFilePath);

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

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics;
4+
using System.Globalization;
45
using System.IO;
56
using System.Text;
67
using System.Text.RegularExpressions;
@@ -42,7 +43,7 @@ public sealed class ApplicationConfig
4243

4344
static readonly object ndkInitLock = new object ();
4445
static readonly char[] readElfFieldSeparator = new [] { ' ', '\t' };
45-
static readonly Regex stringLabelRegex = new Regex ("^\\.L\\.env\\.str\\.[0-9]+:", RegexOptions.Compiled);
46+
static readonly Regex stringLabelRegex = new Regex ("^\\.L\\.autostr\\.[0-9]+:", RegexOptions.Compiled);
4647

4748
static readonly HashSet <string> expectedPointerTypes = new HashSet <string> (StringComparer.Ordinal) {
4849
".long",
@@ -103,7 +104,6 @@ static ApplicationConfig ReadApplicationConfig (string envFile)
103104

104105
line = lines [++i];
105106
field = GetField (envFile, line, i);
106-
107107
AssertFieldType (envFile, ".asciz", field [0], i);
108108
strings [label] = AssertIsAssemblerString (envFile, field [1], i);
109109
continue;
@@ -222,7 +222,7 @@ static ApplicationConfig ReadApplicationConfig (string envFile)
222222
if (String.Compare (".size", field [0], StringComparison.Ordinal) == 0) {
223223
fieldCount--;
224224
Assert.IsTrue (field [1].StartsWith ("application_config", StringComparison.Ordinal), $"Mismatched .size directive in '{envFile}:{i}'");
225-
break; // We've reached the end of the application_config structure
225+
gatherFields = false; // We've reached the end of the application_config structure
226226
}
227227
}
228228
Assert.AreEqual (ApplicationConfigFieldCount, fieldCount, $"Invalid 'application_config' field count in environment file '{envFile}'");
@@ -317,13 +317,20 @@ static Dictionary<string, string> ReadEnvironmentVariables (string envFile)
317317
static bool IsCommentLine (string line)
318318
{
319319
string l = line?.Trim ();
320-
return !String.IsNullOrEmpty (l) && l.StartsWith ("/*", StringComparison.Ordinal);
320+
if (String.IsNullOrEmpty (l)) {
321+
return false;
322+
}
323+
324+
return l.StartsWith ("/*", StringComparison.Ordinal) ||
325+
l.StartsWith ("//", StringComparison.Ordinal) ||
326+
l.StartsWith ("#", StringComparison.Ordinal) ||
327+
l.StartsWith ("@", StringComparison.Ordinal);
321328
}
322329

323330
static string[] GetField (string file, string line, int lineNumber)
324331
{
325332
string[] ret = line?.Trim ()?.Split ('\t');
326-
Assert.AreEqual (2, ret.Length, $"Invalid assembler field format in file '{file}:{lineNumber}': '{line}'");
333+
Assert.IsTrue (ret.Length >= 2, $"Invalid assembler field format in file '{file}:{lineNumber}': '{line}'");
327334

328335
return ret;
329336
}
@@ -503,10 +510,11 @@ static void DumpLines (string streamName, List <string> lines)
503510

504511
static bool ConvertFieldToBool (string fieldName, string envFile, int fileLine, string value)
505512
{
506-
Assert.AreEqual (1, value.Length, $"Field '{fieldName}' in {envFile}:{fileLine} is not a valid boolean value (too long)");
513+
// Allow both decimal and hexadecimal values
514+
Assert.IsTrue (value.Length > 0 && value.Length <= 3, $"Field '{fieldName}' in {envFile}:{fileLine} is not a valid boolean value (length not between 1 and 3)");
507515

508516
uint fv;
509-
Assert.IsTrue (UInt32.TryParse (value, out fv), $"Field '{fieldName}' in {envFile}:{fileLine} is not a valid boolean value (not a valid integer)");
517+
Assert.IsTrue (TryParseInteger (value, out fv), $"Field '{fieldName}' in {envFile}:{fileLine} is not a valid boolean value (not a valid integer)");
510518
Assert.IsTrue (fv == 0 || fv == 1, $"Field '{fieldName}' in {envFile}:{fileLine} is not a valid boolean value (not a valid boolean value 0 or 1)");
511519

512520
return fv == 1;
@@ -517,7 +525,7 @@ static uint ConvertFieldToUInt32 (string fieldName, string envFile, int fileLine
517525
Assert.IsTrue (value.Length > 0, $"Field '{fieldName}' in {envFile}:{fileLine} is not a valid uint32_t value (not long enough)");
518526

519527
uint fv;
520-
Assert.IsTrue (UInt32.TryParse (value, out fv), $"Field '{fieldName}' in {envFile}:{fileLine} is not a valid uint32_t value (not a valid integer)");
528+
Assert.IsTrue (TryParseInteger (value, out fv), $"Field '{fieldName}' in {envFile}:{fileLine} is not a valid uint32_t value (not a valid integer)");
521529

522530
return fv;
523531
}
@@ -527,9 +535,27 @@ static byte ConvertFieldToByte (string fieldName, string envFile, int fileLine,
527535
Assert.IsTrue (value.Length > 0, $"Field '{fieldName}' in {envFile}:{fileLine} is not a valid uint8_t value (not long enough)");
528536

529537
byte fv;
530-
Assert.IsTrue (Byte.TryParse (value, out fv), $"Field '{fieldName}' in {envFile}:{fileLine} is not a valid uint8_t value (not a valid integer)");
538+
Assert.IsTrue (TryParseInteger (value, out fv), $"Field '{fieldName}' in {envFile}:{fileLine} is not a valid uint8_t value (not a valid integer)");
531539

532540
return fv;
533541
}
542+
543+
static bool TryParseInteger (string value, out uint fv)
544+
{
545+
if (value.StartsWith ("0x", StringComparison.Ordinal)) {
546+
return UInt32.TryParse (value.Substring (2), NumberStyles.AllowHexSpecifier, null, out fv);
547+
}
548+
549+
return UInt32.TryParse (value, out fv);
550+
}
551+
552+
static bool TryParseInteger (string value, out byte fv)
553+
{
554+
if (value.StartsWith ("0x", StringComparison.Ordinal)) {
555+
return Byte.TryParse (value.Substring (2), NumberStyles.AllowHexSpecifier, null, out fv);
556+
}
557+
558+
return Byte.TryParse (value, out fv);
559+
}
534560
}
535561
}

src/monodroid/jni/embedded-assemblies.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#if !defined (__MINGW32__) || (defined (__MINGW32__) && __GNUC__ >= 10)
44
#include <compare>
5-
#endif
5+
#endif // ndef MINGW32 || def MINGW32 && GNUC >= 10
66
#include <cstdio>
77
#include <cstdlib>
88
#include <cstring>
@@ -345,7 +345,7 @@ EmbeddedAssemblies::individual_assemblies_open_from_bundles (dynamic_local_strin
345345
}
346346

347347
force_inline const AssemblyStoreHashEntry*
348-
EmbeddedAssemblies::find_assembly_store_entry (hash_t hash, const AssemblyStoreHashEntry *entries, size_t entry_count) noexcept
348+
EmbeddedAssemblies::find_assembly_store_entry ([[maybe_unused]] hash_t hash, [[maybe_unused]] const AssemblyStoreHashEntry *entries, [[maybe_unused]] size_t entry_count) noexcept
349349
{
350350
#if !defined (__MINGW32__) || (defined (__MINGW32__) && __GNUC__ >= 10)
351351
hash_t entry_hash;

src/monodroid/jni/monodroid-glue.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
#include <strings.h>
1010
#include <cctype>
1111
#include <cerrno>
12+
#if !defined (__MINGW32__) || (defined (__MINGW32__) && __GNUC__ >= 10)
1213
#include <compare>
13-
14+
#endif // ndef MINGW32 || def MINGW32 && GNUC >= 10
1415
#if defined (APPLE_OS_X)
1516
#include <dlfcn.h>
1617
#endif // def APPLE_OX_X
@@ -1284,8 +1285,9 @@ MonodroidRuntime::init_internal_api_dso (void *handle)
12841285
#endif // ndef NET6
12851286

12861287
force_inline DSOCacheEntry*
1287-
MonodroidRuntime::find_dso_cache_entry (hash_t hash) noexcept
1288+
MonodroidRuntime::find_dso_cache_entry ([[maybe_unused]] hash_t hash) noexcept
12881289
{
1290+
#if !defined (__MINGW32__) || (defined (__MINGW32__) && __GNUC__ >= 10)
12891291
hash_t entry_hash;
12901292
DSOCacheEntry *ret = nullptr;
12911293
size_t entry_count = application_config.number_of_dso_cache_entries;
@@ -1307,7 +1309,7 @@ MonodroidRuntime::find_dso_cache_entry (hash_t hash) noexcept
13071309
return ret;
13081310
}
13091311
}
1310-
1312+
#endif // ndef MINGW32 || def MINGW32 && GNUC >= 10
13111313
return nullptr;
13121314
}
13131315

0 commit comments

Comments
 (0)