Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions msbuild/Xamarin.MacDev.Tasks/ErrorHelper.msbuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ namespace Xamarin.Bundler {
public static partial class ErrorHelper {
public static ApplePlatform Platform;

internal static string Prefix {
get {
return Xamarin.MacDev.Tasks.LoggingExtensions.ErrorPrefix;
}
internal static string GetPrefix (IToolLog? log)
{
return Xamarin.MacDev.Tasks.LoggingExtensions.ErrorPrefix;
}

public enum WarningLevel {
Expand All @@ -24,7 +23,7 @@ public enum WarningLevel {

static Dictionary<int, WarningLevel>? warning_levels;

public static WarningLevel GetWarningLevel (int code)
public static WarningLevel GetWarningLevel (IToolLog log, int code)
{
WarningLevel level;

Expand Down
1 change: 1 addition & 0 deletions src/bgen/BindingTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class BindingTouch : IDisposable, IToolLog {
public static ApplePlatform [] AllPlatforms = new ApplePlatform [] { ApplePlatform.iOS, ApplePlatform.MacOSX, ApplePlatform.TVOS, ApplePlatform.MacCatalyst };
public static PlatformName [] AllPlatformNames = new PlatformName [] { PlatformName.iOS, PlatformName.MacOSX, PlatformName.TvOS, PlatformName.MacCatalyst };
public PlatformName CurrentPlatform;
public ApplePlatform Platform { get => CurrentPlatform.AsApplePlatform (); }
public bool BindThirdPartyLibrary = true;
public string? outfile;

Expand Down
41 changes: 20 additions & 21 deletions tests/common/ErrorHelper.tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#nullable enable

using System.Linq;
using System.Runtime.CompilerServices;

using Mono.Cecil;
using Mono.Cecil.Cil;
Expand All @@ -13,10 +14,9 @@ namespace Xamarin.Bundler {
public static partial class ErrorHelper {
public static ApplePlatform Platform;

internal static string Prefix {
get {
return "TESTS";
}
internal static string GetPrefix (IToolLog? log)
{
return "TESTS";
}

public enum WarningLevel {
Expand All @@ -25,33 +25,32 @@ public enum WarningLevel {
Disable = 1,
}

static Dictionary<int, WarningLevel>? warning_levels;
static ConditionalWeakTable<IToolLog, Dictionary<int, WarningLevel>> warning_levels = new ();

public static WarningLevel GetWarningLevel (int code)
public static WarningLevel GetWarningLevel (IToolLog log, int code)
{
WarningLevel level;

if (warning_levels is null)
return WarningLevel.Warning;
if (warning_levels.TryGetValue (log, out var log_warning_levels)) {
// code -1: all codes
if (log_warning_levels.TryGetValue (-1, out var level))
return level;

// code -1: all codes
if (warning_levels.TryGetValue (-1, out level))
return level;

if (warning_levels.TryGetValue (code, out level))
return level;
if (log_warning_levels.TryGetValue (code, out level))
return level;
}

return WarningLevel.Warning;
}

public static void SetWarningLevel (WarningLevel level, int? code = null /* if null, apply to all warnings */)
public static void SetWarningLevel (IToolLog log, WarningLevel level, int? code = null /* if null, apply to all warnings */)
{
if (warning_levels is null)
warning_levels = new Dictionary<int, WarningLevel> ();
if (!warning_levels.TryGetValue (log, out var log_warning_levels)) {
log_warning_levels = new Dictionary<int, WarningLevel> ();
warning_levels.Add (log, log_warning_levels);
}
if (code.HasValue) {
warning_levels [code.Value] = level;
log_warning_levels [code.Value] = level;
} else {
warning_levels [-1] = level; // code -1: all codes.
log_warning_levels [-1] = level; // code -1: all codes.
}
}
}
Expand Down
61 changes: 49 additions & 12 deletions tools/common/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public partial class Application : IToolLog {
public HashSet<string> WeakFrameworks = new HashSet<string> ();

public bool IsExtension;
public ApplePlatform Platform { get { return Driver.TargetFramework.Platform; } }
public TargetFramework TargetFramework { get; set; }
public ApplePlatform Platform { get { return TargetFramework.Platform; } }

public List<string> MonoLibraries = new List<string> ();
public List<string> InterpretedAssemblies = new List<string> ();
Expand Down Expand Up @@ -266,7 +267,7 @@ public bool PackageManagedDebugSymbols {
public Version GetMacCatalystiOSVersion (Version macOSVersion)
{
#if LEGACY_TOOLS
if (macOSVersion.Major >= 26 && Driver.SdkRoot is null) {
if (macOSVersion.Major >= 26 && SdkRoot is null) {
// this shouldn't happen for normal builds, nor for customers, so just show an internal 99 warning.
ErrorHelper.Warning (this, 99, Errors.MX0099, $"No Xcode configured, assuming the macOS version {macOSVersion} is identical to the Mac Catalyst/iOS version.");
return macOSVersion;
Expand All @@ -287,6 +288,7 @@ public Application (LinkerConfiguration configuration)
#endif
this.StaticRegistrar = new StaticRegistrar (this);
this.Resolver = new PlatformResolver (this);
SetDefaultHiddenWarnings ();
}

#if !LEGACY_TOOLS
Expand Down Expand Up @@ -1032,7 +1034,7 @@ public void GetAotArguments (string filename, Abi abi, string outputDir, string
if (!string.IsNullOrEmpty (llvm_path)) {
aotArguments.Add ($"llvm-path={llvm_path}");
} else {
aotArguments.Add ($"llvm-path={Driver.GetFrameworkCurrentDirectory (app)}/LLVM/bin/");
aotArguments.Add ($"llvm-path={app.FrameworkCurrentDirectory}/LLVM/bin/");
}
}

Expand Down Expand Up @@ -1198,17 +1200,12 @@ public bool VerifyDynamicFramework (string framework_path)
}
#endif // !LEGACY_TOOLS

static Application ()
{
SetDefaultHiddenWarnings ();
}

public static void SetDefaultHiddenWarnings ()
public void SetDefaultHiddenWarnings ()
{
// People don't like these warnings (#20670), and they also complicate our tests, so ignore them.
ErrorHelper.ParseWarningLevel (ErrorHelper.WarningLevel.Disable, "4178"); // The class '{0}' will not be registered because the {1} framework has been removed from the {2} SDK.
ErrorHelper.ParseWarningLevel (ErrorHelper.WarningLevel.Disable, "4189"); // The class '{0}' will not be registered because it has been removed from the {1} SDK.
ErrorHelper.ParseWarningLevel (ErrorHelper.WarningLevel.Disable, "4190"); // The class '{0}' will not be registered because the {1} framework has been deprecated from the {2} SDK.
ErrorHelper.ParseWarningLevel (this, ErrorHelper.WarningLevel.Disable, "4178"); // The class '{0}' will not be registered because the {1} framework has been removed from the {2} SDK.
ErrorHelper.ParseWarningLevel (this, ErrorHelper.WarningLevel.Disable, "4189"); // The class '{0}' will not be registered because it has been removed from the {1} SDK.
ErrorHelper.ParseWarningLevel (this, ErrorHelper.WarningLevel.Disable, "4190"); // The class '{0}' will not be registered because the {1} framework has been deprecated from the {2} SDK.
}

public void Log (string message)
Expand Down Expand Up @@ -1236,5 +1233,45 @@ public int Verbosity {
get => verbosity;
set => verbosity = value;
}

public string? SdkRoot { get; set; }
public string? DeveloperDirectory { get; set; }

string? framework_dir;
public string FrameworkCurrentDirectory {
get {
if (framework_dir is null)
throw new InvalidOperationException ($"Teh current framework directory hasn't been set.");
return framework_dir;
}
set {
framework_dir = value;
}
}

/// <summary>
/// This returns the /Applications/Xcode*.app/Contents/Developer/Platforms directory
/// </summary>
public string PlatformsDirectory {
get {
if (DeveloperDirectory is null)
throw new InvalidOperationException ("DeveloperDirectory is not set");
return Path.Combine (DeveloperDirectory, "Platforms");
}
}

Version? xcode_version;
public Version XcodeVersion {
get {
if (xcode_version is null)
throw ErrorHelper.CreateError (99, Errors.MX0099, "The Xcode version has not been configured. Pass --xcode-version or configure an Xcode installation.");
return xcode_version;
}
set {
xcode_version = value;
}
}

public string? XcodeProductVersion { get; set; }
}
}
Loading