示例#1
0
    public override void ExecuteBuild()
    {
        LogInformation("************************* BuildCommonTools");

        List <UnrealTargetPlatform> Platforms = new List <UnrealTargetPlatform>();

        // Add all the platforms if specified
        if (ParseParam("allplatforms"))
        {
            Platforms = UnrealTargetPlatform.GetValidPlatforms().ToList();
        }
        else
        {
            // Get the list of platform names
            string[] PlatformNames = ParseParamValue("platforms", BuildHostPlatform.Current.Platform.ToString()).Split('+');

            // Parse the platforms
            foreach (string PlatformName in PlatformNames)
            {
                UnrealBuildTool.UnrealTargetPlatform Platform;
                if (!UnrealTargetPlatform.TryParse(PlatformName, out Platform))
                {
                    throw new AutomationException("Unknown platform specified on command line - '{0}' - valid platforms are {1}", PlatformName, String.Join("/", UnrealTargetPlatform.GetValidPlatformNames()));
                }
                Platforms.Add(Platform);
            }
        }

        // Get the agenda
        List <string> ExtraBuildProducts = new List <string>();

        UE4Build.BuildAgenda Agenda = MakeAgenda(Platforms.ToArray(), ExtraBuildProducts);

        // Build everything. We don't want to touch version files for GitHub builds -- these are "programmer builds" and won't have a canonical build version
        UE4Build Builder = new UE4Build(this);

        Builder.Build(Agenda, InUpdateVersionFiles: false);

        // Add UAT and UBT to the build products
        Builder.AddUATFilesToBuildProducts();
        Builder.AddUBTFilesToBuildProducts();

        // Add all the extra build products
        foreach (string ExtraBuildProduct in ExtraBuildProducts)
        {
            Builder.AddBuildProduct(ExtraBuildProduct);
        }

        // Make sure all the build products exist
        UE4Build.CheckBuildProducts(Builder.BuildProductFiles);

        // Write the manifest if needed
        string ManifestPath = ParseParamValue("manifest");

        if (ManifestPath != null)
        {
            SortedSet <string> Files = new SortedSet <string>();
            foreach (string BuildProductFile in Builder.BuildProductFiles)
            {
                Files.Add(BuildProductFile);
            }
            File.WriteAllLines(ManifestPath, Files.ToArray());
        }
    }
示例#2
0
        /// <summary>
        /// Reserve devices from service
        /// </summary>
        public bool ReserveDevicesFromService(string DeviceURL, Dictionary <UnrealTargetConstraint, int> DeviceTypes)
        {
            if (String.IsNullOrEmpty(DeviceURL))
            {
                return(false);
            }

            Dictionary <UnrealTargetPlatform, string> DeviceMap = new Dictionary <UnrealTargetPlatform, string>();

            foreach (string Platform in UnrealTargetPlatform.GetValidPlatformNames())
            {
                if (Platform == "PS4" || Platform == "XboxOne")
                {
                    DeviceMap.Add(UnrealTargetPlatform.Parse(Platform), string.Format("{0}-DevKit", Platform));
                }
                else
                {
                    DeviceMap.Add(UnrealTargetPlatform.Parse(Platform), Platform);
                }
            }

            List <string> Devices = new List <string>();

            // convert devices to request list
            foreach (KeyValuePair <UnrealTargetConstraint, int> Entry in DeviceTypes)
            {
                if (Entry.Key.Platform == null)
                {
                    continue;
                }

                if (!DeviceMap.ContainsKey(Entry.Key.Platform.Value))
                {
                    // if an unsupported device, we can't reserve it
                    Log.Info("Unable to reserve service device of type: {0}", Entry.Key);
                    return(false);
                }

                if (!string.IsNullOrEmpty(Entry.Key.Model))
                {
                    // if specific device model, we can't currently reserve it from (legacy) service
                    if (DeviceURL.ToLower().Contains("deviceservice.epicgames.net"))
                    {
                        Log.Info("Unable to reserve service device of model: {0} on legacy service", Entry.Key.Model);
                        return(false);
                    }
                }

                for (int i = 0; i < Entry.Value; i++)
                {
                    // @todo: if any additional reservation requirements, encode constraint into json
                    string Constraint = Entry.Key.PerfSpec.ToString();
                    if (!string.IsNullOrEmpty(Entry.Key.Model))
                    {
                        Constraint = Entry.Key.Model;
                    }
                    Devices.Add(DeviceMap[Entry.Key.Platform.Value] + ":" + Constraint);
                }
            }

            // reserve devices
            Uri ReservationServerUri;

            if (Uri.TryCreate(DeviceURL, UriKind.Absolute, out ReservationServerUri))
            {
                DeviceReservationAutoRenew DeviceReservation = null;

                string PoolID = Globals.WorkerPoolID != -1 ? Globals.WorkerPoolID.ToString() : "";

                try
                {
                    DeviceReservation = new DeviceReservationAutoRenew(DeviceURL, 0, PoolID, Devices.ToArray());
                }
                catch (Exception Ex)
                {
                    Log.Info("Unable to make device registration: {0}", Ex.Message);
                    return(false);
                }

                if (DeviceReservation == null || DeviceReservation.Devices.Count != Devices.Count())
                {
                    return(false);
                }

                // Add target devices from reservation
                List <ITargetDevice> ReservedDevices = new List <ITargetDevice>();
                foreach (var Device in DeviceReservation.Devices)
                {
                    DeviceDefinition Def = new DeviceDefinition();
                    Def.Address    = Device.IPOrHostName;
                    Def.Name       = Device.Name;
                    Def.Platform   = DeviceMap.FirstOrDefault(Entry => Entry.Value == Device.Type).Key;
                    Def.DeviceData = Device.DeviceData;
                    Def.Model      = string.Empty;

                    if (!String.IsNullOrEmpty(Device.PerfSpec) && !Enum.TryParse <EPerfSpec>(Device.PerfSpec, true, out Def.PerfSpec))
                    {
                        throw new AutomationException("Unable to convert perfspec '{0}' into an EPerfSpec", Device.PerfSpec);
                    }

                    ITargetDevice TargetDevice = CreateAndRegisterDeviceFromDefinition(Def);

                    // If a device from service can't be added, fail reservation and cleanup devices
                    // @todo: device problem reporting, requesting additional devices
                    if (TargetDevice == null)
                    {
                        ReportDeviceError(Device.Name, "CreateDeviceError");

                        // If some devices from reservation have been created, release them which will also dispose of reservation
                        if (ReservedDevices.Count > 0)
                        {
                            ReleaseDevices(ReservedDevices);
                        }
                        else
                        {
                            // otherwise, no devices have been creation so just cancel this reservation
                            DeviceReservation.Dispose();
                        }

                        Log.Info("Unable to make device registration: device registration failed for {0}:{1}", Def.Platform, Def.Name);
                        return(false);
                    }
                    else
                    {
                        ReservedDevices.Add(TargetDevice);
                    }

                    ServiceDeviceInfo[TargetDevice]   = Def;
                    ServiceReservations[TargetDevice] = DeviceReservation;
                }

                Log.Info("Successfully reserved service devices");
                Devices.ForEach(Device => Log.Verbose("    Device: {0}", Device));

                return(true);
            }

            Log.Info("Unable to reserve service devices:");
            Devices.ForEach(Device => Log.Info("    Device: {0}", Device));
            return(false);
        }