Esempio n. 1
0
        void LogErrorsFromOutput(string output)
        {
            try {
                if (string.IsNullOrEmpty(output))
                {
                    return;
                }

                var plist   = PObject.FromString(output) as PDictionary;
                var errors  = PObject.Create(PObjectType.Array) as PArray;
                var message = PObject.Create(PObjectType.String) as PString;

                if ((plist?.TryGetValue("product-errors", out errors) == true))
                {
                    foreach (var error in errors)
                    {
                        var dict = error as PDictionary;
                        if (dict?.TryGetValue("message", out message) == true)
                        {
                            Log.LogError(ToolName, null, null, null, 0, 0, 0, 0, "{0}", message.Value);
                        }
                    }
                }
            } catch (Exception ex) {
                Log.LogWarning($"Failed to parse altool output: {ex.Message}. \nOutput: {output}");
            }
        }
Esempio n. 2
0
        public override bool Execute()
        {
            TargetArchitecture architectures, deviceArchitectures, target = TargetArchitecture.Default;
            string             targetOperatingSystem;
            PDictionary        plist, device;
            PString            value, os;

            switch (PlatformFrameworkHelper.GetFramework(TargetFrameworkIdentifier))
            {
            case ApplePlatform.WatchOS:
                targetOperatingSystem = "watchOS";
                break;

            case ApplePlatform.TVOS:
                targetOperatingSystem = "tvOS";
                break;

            default:
                targetOperatingSystem = "iOS";
                break;
            }

            if (!Enum.TryParse(Architectures, out architectures))
            {
                Log.LogError("Invalid architectures: '{0}'.", Architectures);
                return(false);
            }

            if ((plist = PObject.FromString(TargetiOSDevice) as PDictionary) == null)
            {
                Log.LogError("Failed to parse the target device information.");
                return(false);
            }

            if (!plist.TryGetValue("device", out device))
            {
                Log.LogError("No target device found.");
                return(false);
            }

            if (!device.TryGetValue("architecture", out value))
            {
                Log.LogError("No device architecture information found.");
                return(false);
            }

            if (!Enum.TryParse(value.Value, out deviceArchitectures) || deviceArchitectures == TargetArchitecture.Default)
            {
                Log.LogError("Invalid target architecture: '{0}'", value.Value);
                return(false);
            }

            if (!device.TryGetValue("os", out os))
            {
                Log.LogError("No device operating system information found.");
                return(false);
            }

            if (os.Value != targetOperatingSystem || (architectures & deviceArchitectures) == 0)
            {
                // the TargetiOSDevice property conflicts with the build configuration (*.user file?), do not build this project for a specific device
                DeviceSpecificIntermediateOutputPath = IntermediateOutputPath;
                DeviceSpecificOutputPath             = OutputPath;
                TargetArchitectures   = Architectures;
                TargetDeviceOSVersion = string.Empty;
                TargetDeviceModel     = string.Empty;

                return(!Log.HasLoggedErrors);
            }

            for (int bit = 0; bit < 32; bit++)
            {
                var architecture = (TargetArchitecture)(1 << bit);

                if ((architectures & architecture) == 0)
                {
                    continue;
                }

                if ((deviceArchitectures & architecture) != 0)
                {
                    target = architecture;
                }
            }

            TargetArchitectures = target.ToString();

            if (!device.TryGetValue("model", out value))
            {
                Log.LogError("No device model information found.");
                return(false);
            }

            TargetDeviceModel = value.Value;

            if (!device.TryGetValue("os-version", out value))
            {
                Log.LogError("No iOS version information found.");
                return(false);
            }

            TargetDeviceOSVersion = value.Value;

            // Note: we replace ',' with '.' because the ',' breaks the Mono AOT compiler which tries to treat arguments with ','s in them as options.
            var dirName = TargetDeviceModel.ToLowerInvariant().Replace(",", ".") + "-" + TargetDeviceOSVersion;

            DeviceSpecificIntermediateOutputPath = Path.Combine(IntermediateOutputPath, "device-builds", dirName) + "/";
            DeviceSpecificOutputPath             = Path.Combine(OutputPath, "device-builds", dirName) + "/";

            return(!Log.HasLoggedErrors);
        }
        public override bool Execute()
        {
            TargetArchitecture architectures, deviceArchitectures, target = TargetArchitecture.Default;
            PDictionary        plist, device;
            PString            value;

            Log.LogTaskName("ParseDeviceSpecificBuildInformation");
            Log.LogTaskProperty("Architectures", Architectures);
            Log.LogTaskProperty("IntermediateOutputPath", IntermediateOutputPath);
            Log.LogTaskProperty("OutputPath", OutputPath);
            Log.LogTaskProperty("TargetiOSDevice", TargetiOSDevice);

            if (!Enum.TryParse(Architectures, out architectures))
            {
                Log.LogError("Invalid architectures: '{0}'.", Architectures);
                return(false);
            }

            if ((plist = PObject.FromString(TargetiOSDevice) as PDictionary) == null)
            {
                Log.LogError("Failed to parse the target iOS device information.");
                return(false);
            }

            if (!plist.TryGetValue("device", out device))
            {
                Log.LogError("No target device found.");
                return(false);
            }

            if (!device.TryGetValue("architecture", out value))
            {
                Log.LogError("No device architecture information found.");
                return(false);
            }

            if (!Enum.TryParse(value.Value, out deviceArchitectures) || deviceArchitectures == TargetArchitecture.Default)
            {
                Log.LogError("Invalid target architecture: '{0}'", value.Value);
                return(false);
            }

            if ((architectures & deviceArchitectures) == 0)
            {
                Log.LogError("The target iOS device architecture {0} is not supported by the build configuration: {1}", architectures, deviceArchitectures);
                return(false);
            }

            for (int bit = 0; bit < 32; bit++)
            {
                var architecture = (TargetArchitecture)(1 << bit);

                if ((architectures & architecture) == 0)
                {
                    continue;
                }

                if ((deviceArchitectures & architecture) != 0)
                {
                    target = architecture;
                }
            }

            TargetArchitectures = target.ToString();

            if (!device.TryGetValue("model", out value))
            {
                Log.LogError("No device model information found.");
                return(false);
            }

            TargetDeviceModel = value.Value;

            if (!device.TryGetValue("os-version", out value))
            {
                Log.LogError("No iOS version information found.");
                return(false);
            }

            TargetDeviceOSVersion = value.Value;

            // Note: we replace ',' with '.' because the ',' breaks the Mono AOT compiler which tries to treat arguments with ','s in them as options.
            var dirName = "build-" + TargetDeviceModel.ToLowerInvariant().Replace(",", ".") + "-" + TargetDeviceOSVersion;

            DeviceSpecificIntermediateOutputPath = Path.Combine(IntermediateOutputPath, dirName) + "/";
            DeviceSpecificOutputPath             = Path.Combine(OutputPath, dirName) + "/";

            return(!Log.HasLoggedErrors);
        }