Exemplo n.º 1
0
    IEnumerable <string> EnumerateBuildFolders(string Target, string Configuration, string Platform, bool DebugRun)
    {
        FileReference OutputFile = FileReference.Combine(CommandUtils.EngineDirectory, "Intermediate", "Build", "ThirdParty.json");

        IProcessResult Result = Run(UE4Build.GetUBTExecutable(), String.Format("{0} {1} {2} -jsonexport=\"{3}\" -skipbuild", Target, Configuration, Platform, OutputFile.FullName), Options: DebugRun ? ERunOptions.Default : ERunOptions.NoLoggingOfRunCommand);

        if (Result.ExitCode != 0)
        {
            throw new AutomationException("Failed to run UBT");
        }

        JsonObject Object = JsonObject.Read(OutputFile);

        // local function that takes a RuntimeDependency path and resolves it (replacing Env vars that we support)
        Func <string, DirectoryReference> ResolveRuntimeDependencyFolder = (string DependencyPath) =>
        {
            return(new DirectoryReference(Path.GetDirectoryName(
                                              // Regex to replace the env vars we support $(EngineDir|ProjectDir), ignoring case
                                              Regex.Replace(DependencyPath, @"\$\((?<Type>Engine|Project)Dir\)", M =>
                                                            M.Groups["Type"].Value.Equals("Engine", StringComparison.InvariantCultureIgnoreCase)
                                                ? CommandUtils.EngineDirectory.FullName
                                                : new FileReference(Object.GetStringField("ProjectFile")).Directory.FullName,
                                                            RegexOptions.IgnoreCase))));
        };

        JsonObject Modules = Object.GetObjectField("Modules");

        // Create a set of directories used for each binary
        List <DirectoryReference> DirectoriesToScan = Modules
                                                      // get all directories that the module uses (source folder and any runtime dependencies)
                                                      .KeyNames.Select(KeyName => Modules.GetObjectField(KeyName))
                                                      .SelectMany(Module => Module
                                                                  // resolve any runtime dependency folders and add them.
                                                                  .GetObjectArrayField("RuntimeDependencies").Select(Dependency => ResolveRuntimeDependencyFolder(Dependency.GetStringField("Path")))
                                                      // Add on the module source directory
                                                                  .Concat(new[] { new DirectoryReference(Module.GetStringField("Directory")) }))
                                                      // remove any duplicate folders since some modules may be from the same plugin
                                                      .Distinct()
                                                      // Project to a list as we need to do an O(n^2) operation below.
                                                      .ToList();

        List <string> FinalDirs = DirectoriesToScan.Where(RemovalCandidate =>
                                                          // O(n^2) search to remove subfolders of any we are already searching.
                                                          // look for directories that aren't subdirectories of any other directory in the list.
                                                          !DirectoriesToScan.Any(DirectoryToScan =>
                                                          // != check because this inner loop will eventually check against itself
                                                                                 RemovalCandidate != DirectoryToScan &&
                                                                                 RemovalCandidate.IsUnderDirectory(DirectoryToScan)))
                                  // grab the full name
                                  .Select(Dir => Dir.FullName)
                                  // sort the final output
                                  .OrderBy(Dir => Dir)
                                  // log the folders
                                  .ToList();

        return(FinalDirs);
    }
 public override void PreBuildAgenda(UE4Build Build, UE4Build.BuildAgenda Agenda)
 {
     if (UnrealBuildTool.BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
     {
         Agenda.DotNetProjects.Add(@"Engine\Source\Programs\IOS\MobileDeviceInterface\MobileDeviceInterface.csproj");
         Agenda.DotNetProjects.Add(@"Engine\Source\Programs\IOS\iPhonePackager\iPhonePackager.csproj");
         Agenda.DotNetProjects.Add(@"Engine\Source\Programs\IOS\DeploymentServer\DeploymentServer.csproj");
     }
 }
    public override void ExecuteBuild()
    {
        UE4Build UE4Build                     = new UE4Build(this);
        int?     ChangelistOverride           = ParseParamNullableInt("cl");
        int?     CompatibleChangelistOverride = ParseParamNullableInt("compatiblecl");
        string   Build = ParseParamValue("Build", null);

        UE4Build.UpdateVersionFiles(ChangelistNumberOverride: ChangelistOverride, CompatibleChangelistNumberOverride: CompatibleChangelistOverride, Build: Build);
    }
Exemplo n.º 4
0
    public override void ExecuteBuild()
    {
        // Get the output directory
        string TargetDirParam = ParseParamValue("TargetDir");

        if (TargetDirParam == null)
        {
            throw new AutomationException("Missing -TargetDir=... argument to CopyUAT");
        }

        // Construct a dummy UE4Build object to get a list of the UAT and UBT build products
        UE4Build Build = new UE4Build(this);

        Build.AddUATFilesToBuildProducts();
        if (ParseParam("WithLauncher"))
        {
            Build.AddUATLauncherFilesToBuildProducts();
        }
        Build.AddUBTFilesToBuildProducts();

        // Get a list of all the input files
        List <FileReference> SourceFiles = new List <FileReference>();

        foreach (string BuildProductFile in Build.BuildProductFiles)
        {
            FileReference SourceFile = new FileReference(BuildProductFile);
            SourceFiles.Add(SourceFile);

            FileReference SourceSymbolFile = SourceFile.ChangeExtension(".pdb");
            if (FileReference.Exists(SourceSymbolFile))
            {
                SourceFiles.Add(SourceSymbolFile);
            }

            FileReference DocumentationFile = SourceFile.ChangeExtension(".xml");
            if (FileReference.Exists(DocumentationFile))
            {
                SourceFiles.Add(DocumentationFile);
            }
        }

        // Copy all the files over
        DirectoryReference TargetDir = new DirectoryReference(TargetDirParam);

        foreach (FileReference SourceFile in SourceFiles)
        {
            FileReference TargetFile = FileReference.Combine(TargetDir, SourceFile.MakeRelativeTo(CommandUtils.RootDirectory));
            DirectoryReference.CreateDirectory(TargetFile.Directory);
            CommandUtils.CopyFile(SourceFile.FullName, TargetFile.FullName);
        }

        Log("Copied {0} files to {1}", SourceFiles.Count, TargetDir);
    }
    public override void ExecuteBuild()
    {
        UE4Build Build = new UE4Build(this);

        Build.AddUATFilesToBuildProducts();

        LogInformation("Build products:");
        foreach (var Product in Build.BuildProductFiles)
        {
            LogInformation("  " + Product);
        }
    }
        /// <summary>
        /// Execute the task and compile these targets.
        /// </summary>
        /// <param name="BuildProducts">Current list of build products for this node</param>
        /// <returns>True if the task succeeded</returns>
        public override bool Execute(List <string> BuildProducts)
        {
            UE4Build Builder = new UE4Build(null);

            UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda();
            Agenda.Targets.AddRange(Targets);

            Builder.Build(Agenda, InDeleteBuildProducts: false, InUpdateVersionFiles: false, InForceNoXGE: true, InForceUnity: true, InUseParallelExecutor: false);
            UE4Build.CheckBuildProducts(Builder.BuildProductFiles);

            BuildProducts.AddRange(Builder.BuildProductFiles);
            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        public override void Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Update the version files
            List <FileReference> VersionFiles = UE4Build.StaticUpdateVersionFiles(Parameters.Change, Parameters.CompatibleChange, Parameters.Branch, Parameters.Build, Parameters.Licensee, Parameters.Promoted, !Parameters.SkipWrite);

            // Apply the optional tag to them
            foreach (string TagName in FindTagNamesFromList(Parameters.Tag))
            {
                FindOrAddTagSet(TagNameToFileSet, TagName).UnionWith(VersionFiles);
            }

            // Add them to the list of build products
            BuildProducts.UnionWith(VersionFiles);
        }
Exemplo n.º 8
0
    public override void ExecuteBuild()
    {
        Log("************************* BuildCommonTools");

        // Get the list of platform names
        string[] PlatformNames = ParseParamValue("platforms", BuildHostPlatform.Current.Platform.ToString()).Split('+');

        // Parse the platforms
        List <UnrealBuildTool.UnrealTargetPlatform> Platforms = new List <UnrealTargetPlatform>();

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

        // Get the agenda
        UE4Build.BuildAgenda Agenda = MakeAgenda(Platforms.ToArray());

        // 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, InDeleteBuildProducts: true, InUpdateVersionFiles: false);

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

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

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

        if (ManifestPath != null)
        {
            UnrealBuildTool.FileManifest Manifest = new UnrealBuildTool.FileManifest();
            foreach (string BuildProductFile in Builder.BuildProductFiles)
            {
                Manifest.AddFileName(BuildProductFile);
            }
            UnrealBuildTool.Utils.WriteClass(Manifest, ManifestPath, "");
        }
    }
 public override void PostBuildTarget(UE4Build Build, string ProjectName, string UProjectPath, string Config)
 {
     // Run UBT w/ the prep for deployment only option
     // This is required as UBT will 'fake' success when building via UAT and run
     // the deployment prep step before all the required parts are present.
     if (ProjectName.Length > 0)
     {
         string ProjectToBuild = ProjectName;
         if (ProjectToBuild != "UE4Game" && !string.IsNullOrEmpty(UProjectPath))
         {
             ProjectToBuild = UProjectPath;
         }
         string UBTCommand = string.Format("\"{0}\" Android {1} -prepfordeploy", ProjectToBuild, Config);
         CommandUtils.RunUBT(UE4Build.CmdEnv, Build.UBTExecutable, UBTCommand);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        /// <returns>True if the task succeeded</returns>
        public override bool Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Update the version files
            List <string>        FileNames    = UE4Build.StaticUpdateVersionFiles(Parameters.Change, Parameters.Branch, Parameters.Licensee, !Parameters.SkipWrite);
            List <FileReference> VersionFiles = FileNames.Select(x => new FileReference(x)).ToList();

            // Apply the optional tag to them
            if (!String.IsNullOrEmpty(Parameters.Tag))
            {
                FindOrAddTagSet(TagNameToFileSet, Parameters.Tag).UnionWith(VersionFiles);
            }

            // Add them to the list of build products
            BuildProducts.UnionWith(VersionFiles);
            return(true);
        }
Exemplo n.º 11
0
    private void ExportFileToDirectory(UploadedFile file, DirectoryInfo destination, IEnumerable <string> cultures)
    {
        foreach (var culture in cultures)
        {
            var cultureDirectory = new DirectoryInfo(Path.Combine(destination.FullName, culture));
            if (!cultureDirectory.Exists)
            {
                cultureDirectory.Create();
            }

            using (var memoryStream = new MemoryStream())
            {
                var exportFile = new FileInfo(Path.Combine(cultureDirectory.FullName, file.Filename));

                var exportTranslationState = file.ExportTranslation(culture, memoryStream).Result;
                if (exportTranslationState == UploadedFile.ExportTranslationState.Success)
                {
                    memoryStream.Position = 0;
                    using (Stream fileStream = File.OpenWrite(exportFile.FullName))
                    {
                        memoryStream.CopyTo(fileStream);
                        Console.WriteLine("[SUCCESS] Exporting: " + exportFile.FullName + " Locale: " + culture);
                    }
                    FileInfo exportFileCopy = new FileInfo(Path.Combine(exportFile.DirectoryName, Path.GetFileNameWithoutExtension(exportFile.Name) + "_FromOneSky" + exportFile.Extension));
                    // Add/check out backed up POs from OneSky.
                    if (P4Enabled)
                    {
                        UE4Build.AddBuildProductsToChangelist(OneSkyDownloadedPOChangeList, new List <string>()
                        {
                            exportFileCopy.FullName
                        });
                    }
                    File.Copy(exportFile.FullName, exportFileCopy.FullName, true);
                }
                else if (exportTranslationState == UploadedFile.ExportTranslationState.NoContent)
                {
                    Console.WriteLine("[WARNING] Exporting: " + exportFile.FullName + " Locale: " + culture + " has no translations!");
                }
                else
                {
                    Console.WriteLine("[FAILED] Exporting: " + exportFile.FullName + " Locale: " + culture);
                }
            }
        }
    }
Exemplo n.º 12
0
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        /// <returns>True if the task succeeded</returns>
        public override bool Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Create the agenda
            UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda();
            Agenda.Targets.AddRange(Targets);

            // Build everything
            Dictionary <UE4Build.BuildTarget, BuildManifest> TargetToManifest = new Dictionary <UE4Build.BuildTarget, BuildManifest>();
            UE4Build Builder = new UE4Build(Job.OwnerCommand);

            try
            {
                bool bCanUseParallelExecutor = (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win64);                      // parallel executor is only available on Windows as of 2016-09-22
                Builder.Build(Agenda, InDeleteBuildProducts: null, InUpdateVersionFiles: false, InForceNoXGE: false, InUseParallelExecutor: bCanUseParallelExecutor, InTargetToManifest: TargetToManifest);
            }
            catch (CommandUtils.CommandFailedException)
            {
                return(false);
            }
            UE4Build.CheckBuildProducts(Builder.BuildProductFiles);

            // Tag all the outputs
            foreach (KeyValuePair <UE4Build.BuildTarget, string> TargetTagName in TargetToTagName)
            {
                BuildManifest Manifest;
                if (!TargetToManifest.TryGetValue(TargetTagName.Key, out Manifest))
                {
                    throw new AutomationException("Missing manifest for target {0} {1} {2}", TargetTagName.Key.TargetName, TargetTagName.Key.Platform, TargetTagName.Key.Config);
                }

                foreach (string TagName in SplitDelimitedList(TargetTagName.Value))
                {
                    HashSet <FileReference> FileSet = FindOrAddTagSet(TagNameToFileSet, TagName);
                    FileSet.UnionWith(Manifest.BuildProducts.Select(x => new FileReference(x)));
                    FileSet.UnionWith(Manifest.LibraryBuildProducts.Select(x => new FileReference(x)));
                }
            }

            // Add everything to the list of build products
            BuildProducts.UnionWith(Builder.BuildProductFiles.Select(x => new FileReference(x)));
            BuildProducts.UnionWith(Builder.LibraryBuildProductFiles.Select(x => new FileReference(x)));
            return(true);
        }
Exemplo n.º 13
0
    void CompilePluginWithUBT(FileReference HostProjectFile, FileReference HostProjectPluginFile, PluginDescriptor Plugin, string TargetName, TargetType TargetType, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, List <FileReference> ManifestFileNames, string InAdditionalArgs)
    {
        // Find a list of modules that need to be built for this plugin
        bool bCompilePlatform = false;

        if (Plugin.Modules != null)
        {
            foreach (ModuleDescriptor Module in Plugin.Modules)
            {
                bool bBuildDeveloperTools     = (TargetType == TargetType.Editor || TargetType == TargetType.Program);
                bool bBuildRequiresCookedData = (TargetType != TargetType.Editor && TargetType != TargetType.Program);
                if (Module.IsCompiledInConfiguration(Platform, Configuration, TargetName, TargetType, bBuildDeveloperTools, bBuildRequiresCookedData))
                {
                    bCompilePlatform = true;
                }
            }
        }

        // Add these modules to the build agenda
        if (bCompilePlatform)
        {
            FileReference ManifestFileName = FileReference.Combine(HostProjectFile.Directory, "Saved", String.Format("Manifest-{0}-{1}-{2}.xml", TargetName, Platform, Configuration));
            ManifestFileNames.Add(ManifestFileName);

            string Arguments = String.Format("-plugin={0} -iwyu -noubtmakefiles -manifest={1} -nohotreload", CommandUtils.MakePathSafeToUseWithCommandLine(HostProjectPluginFile.FullName), CommandUtils.MakePathSafeToUseWithCommandLine(ManifestFileName.FullName));
            if (Platform == UnrealTargetPlatform.Android)
            {
                Arguments += String.Format(" -architectures={0}", AndroidArchitectures);
            }
            else if (Platform == UnrealTargetPlatform.HoloLens)
            {
                Arguments += String.Format(" -Architecture={0}", HoloLensArchitecture);
            }

            if (!String.IsNullOrEmpty(InAdditionalArgs))
            {
                Arguments += InAdditionalArgs;
            }

            CommandUtils.RunUBT(CmdEnv, UE4Build.GetUBTExecutable(), HostProjectFile, TargetName, Platform, Configuration, Arguments);
        }
    }
Exemplo n.º 14
0
    void CompilePluginWithUBT(FileReference HostProjectFile, FileReference HostProjectPluginFile, PluginDescriptor Plugin, string TargetName, TargetType TargetType, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, List <FileReference> ReceiptFileNames, string InAdditionalArgs)
    {
        // Find a list of modules that need to be built for this plugin
        List <string> ModuleNames = new List <string>();

        if (Plugin.Modules != null)
        {
            foreach (ModuleDescriptor Module in Plugin.Modules)
            {
                bool bBuildDeveloperTools     = (TargetType == TargetType.Editor || TargetType == TargetType.Program);
                bool bBuildEditor             = (TargetType == TargetType.Editor);
                bool bBuildRequiresCookedData = (TargetType != TargetType.Editor && TargetType != TargetType.Program);
                if (Module.IsCompiledInConfiguration(Platform, TargetType, bBuildDeveloperTools, bBuildEditor, bBuildRequiresCookedData))
                {
                    ModuleNames.Add(Module.Name);
                }
            }
        }

        // Add these modules to the build agenda
        if (ModuleNames.Count > 0)
        {
            string Arguments = "-iwyu";            // String.Format("-plugin={0}", CommandUtils.MakePathSafeToUseWithCommandLine(PluginFile.FullName));
            foreach (string ModuleName in ModuleNames)
            {
                Arguments += String.Format(" -module={0}", ModuleName);
            }

            string Architecture = PlatformExports.GetDefaultArchitecture(Platform, HostProjectFile);

            FileReference ReceiptFileName = TargetReceipt.GetDefaultPath(HostProjectPluginFile.Directory, TargetName, Platform, Configuration, Architecture);
            Arguments += String.Format(" -receipt={0}", CommandUtils.MakePathSafeToUseWithCommandLine(ReceiptFileName.FullName));
            ReceiptFileNames.Add(ReceiptFileName);

            if (!String.IsNullOrEmpty(InAdditionalArgs))
            {
                Arguments += InAdditionalArgs;
            }

            CommandUtils.RunUBT(CmdEnv, UE4Build.GetUBTExecutable(), String.Format("{0} {1} {2}{3} {4}", TargetName, Platform, Configuration, (HostProjectFile == null)? "" : String.Format(" -project=\"{0}\"", HostProjectFile.FullName), Arguments));
        }
    }
Exemplo n.º 15
0
    public override void ExecuteBuild()
    {
        // Get the output directory
        string TargetDir = ParseParamValue("TargetDir");

        if (TargetDir == null)
        {
            throw new AutomationException("Missing -Target argument to CopyUAT");
        }

        // Construct a dummy UE4Build object to get a list of the UAT and UBT build products
        UE4Build Build = new UE4Build(this);

        Build.AddUATFilesToBuildProducts();
        if (ParseParam("WithLauncher"))
        {
            Build.AddUATLauncherFilesToBuildProducts();
        }
        Build.AddUBTFilesToBuildProducts();

        // Get a list of all the input files
        List <string> FileNames = new List <string>(Build.BuildProductFiles);

        foreach (string FileName in Build.BuildProductFiles)
        {
            string SymbolFileName = Path.ChangeExtension(FileName, ".pdb");
            if (File.Exists(SymbolFileName))
            {
                FileNames.Add(SymbolFileName);
            }
        }

        // Copy all the files over
        foreach (string FileName in FileNames)
        {
            string TargetFileName = Utils.MakeRerootedFilePath(FileName, CommandUtils.CmdEnv.LocalRoot, TargetDir);
            Directory.CreateDirectory(Path.GetDirectoryName(TargetFileName));
            File.Copy(FileName, TargetFileName);
        }

        Log("Copied {0} files to {1}", FileNames.Count, TargetDir);
    }
        // Broken down steps used to run the process.
        #region RebuildLightMaps Process Steps

        private void BuildNecessaryTargets()
        {
            Log("Running Step:- RebuildLightMaps::BuildNecessaryTargets");
            UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda();
            Agenda.AddTarget("ShaderCompileWorker", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealLightmass", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget(CommandletTargetName, UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);

            try
            {
                UE4Build Builder = new UE4Build(this);
                Builder.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: true, InForceNoXGE: false);
                UE4Build.CheckBuildProducts(Builder.BuildProductFiles);
            }
            catch (AutomationException Ex)
            {
                LogError("Rebuild Light Maps has failed.");
                throw Ex;
            }
        }
        // Broken down steps used to run the process.
        #region RebuildHLOD Process Steps

        private void BuildNecessaryTargets()
        {
            LogInformation("Running Step:- RebuildHLOD::BuildNecessaryTargets");
            UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda();
            Agenda.AddTarget("UnrealHeaderTool", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("ShaderCompileWorker", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget(CommandletTargetName, UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);

            try
            {
                UE4Build Builder = new UE4Build(this);
                Builder.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: true, InForceNoXGE: false, InChangelistNumberOverride: GetLatestCodeChange());
                UE4Build.CheckBuildProducts(Builder.BuildProductFiles);
            }
            catch (AutomationException)
            {
                LogError("Rebuild HLOD for Maps has failed.");
                throw;
            }
        }
Exemplo n.º 18
0
    public override void ExecuteBuild()
    {
        var Build         = new UE4Build(this);
        var Agenda        = new UE4Build.BuildAgenda();
        var Platform      = UnrealBuildTool.UnrealTargetPlatform.Win64;
        var Configuration = UnrealBuildTool.UnrealTargetConfiguration.Development;
        var Targets       = new List <string>();

        foreach (var ObjParam in Params)
        {
            var Param = (string)ObjParam;
            if (!UnrealTargetPlatform.TryParse(Param, out Platform))
            {
                continue;
            }
            UnrealBuildTool.UnrealTargetConfiguration ParseConfiguration;
            if (Enum.TryParse <UnrealBuildTool.UnrealTargetConfiguration>(Param, true, out ParseConfiguration))
            {
                Configuration = ParseConfiguration;
                continue;
            }
            if (String.Compare("NoXGE", Param, true) != 0 && String.Compare("Clean", Param, true) != 0)
            {
                Targets.Add(Param);
            }
        }

        var Clean = ParseParam("Clean");

        Agenda.AddTargets(Targets.ToArray(), Platform, Configuration);

        LogInformation("UBT Buid");
        LogInformation("Targets={0}", String.Join(",", Targets));
        LogInformation("Platform={0}", Platform);
        LogInformation("Configuration={0}", Configuration);
        LogInformation("Clean={0}", Clean);

        Build.Build(Agenda, InUpdateVersionFiles: false);

        LogInformation("UBT Completed");
    }
Exemplo n.º 19
0
    private static void BuildProduct(BuildCommand Command, UE4Build.BuildTarget Target)
    {
        if (Target == null)
        {
            throw new AutomationException("Target is required when calling UE4BuildUtils.BuildProduct");
        }

        Log("Building {0}", Target.TargetName);

        if (Command == null)
        {
            Command = new UE4BuildUtilDummyBuildCommand();
        }

        var UE4Build = new UE4Build(Command);

        var Agenda = new UE4Build.BuildAgenda();

        Agenda.Targets.Add(Target);

        UE4Build.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: true);
        UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles);
    }
    void CompilePluginWithUBT(FileReference HostProjectFile, FileReference HostProjectPluginFile, PluginDescriptor Plugin, string TargetName, TargetType TargetType, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, List <FileReference> ReceiptFileNames, string InAdditionalArgs)
    {
        // Find a list of modules that need to be built for this plugin
        bool bCompilePlatform = false;

        if (Plugin.Modules != null)
        {
            foreach (ModuleDescriptor Module in Plugin.Modules)
            {
                bool bBuildDeveloperTools     = (TargetType == TargetType.Editor || TargetType == TargetType.Program);
                bool bBuildEditor             = (TargetType == TargetType.Editor);
                bool bBuildRequiresCookedData = (TargetType != TargetType.Editor && TargetType != TargetType.Program);
                if (Module.IsCompiledInConfiguration(Platform, TargetType, bBuildDeveloperTools, bBuildEditor, bBuildRequiresCookedData))
                {
                    bCompilePlatform = true;
                }
            }
        }

        // Add these modules to the build agenda
        if (bCompilePlatform)
        {
            string Architecture = PlatformExports.GetDefaultArchitecture(Platform, HostProjectFile);

            FileReference ReceiptFileName = TargetReceipt.GetDefaultPath(HostProjectPluginFile.Directory, TargetName, Platform, Configuration, Architecture);
            ReceiptFileNames.Add(ReceiptFileName);

            string Arguments = String.Format("-plugin {0} -iwyu -precompile -nosharedpch -noubtmakefiles -receipt {1}", CommandUtils.MakePathSafeToUseWithCommandLine(HostProjectPluginFile.FullName), CommandUtils.MakePathSafeToUseWithCommandLine(ReceiptFileName.FullName));
            if (!String.IsNullOrEmpty(InAdditionalArgs))
            {
                Arguments += InAdditionalArgs;
            }

            CommandUtils.RunUBT(CmdEnv, UE4Build.GetUBTExecutable(), String.Format("{0} {1} {2} {3}", TargetName, Platform, Configuration, Arguments));
        }
    }
Exemplo n.º 21
0
    /// <summary>
    /// Builds BuildPatchTool for the specified platform.
    /// </summary>
    /// <param name="Command"></param>
    /// <param name="InPlatform"></param>
    public static void BuildBuildPatchTool(BuildCommand Command, UnrealBuildTool.UnrealTargetPlatform InPlatform)
    {
        Log("Building BuildPatchTool");

        if (Command == null)
        {
            Command = new UE4BuildUtilDummyBuildCommand();
        }

        var UE4Build = new UE4Build(Command);

        var Agenda = new UE4Build.BuildAgenda();

        Agenda.Targets.Add(new UE4Build.BuildTarget()
        {
            ProjectName = "",
            TargetName  = "BuildPatchTool",
            Platform    = InPlatform,
            Config      = UnrealBuildTool.UnrealTargetConfiguration.Development,
        });

        UE4Build.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: true);
        UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles);
    }
Exemplo n.º 22
0
 public override void PreBuildAgenda(UE4Build Build, UE4Build.BuildAgenda Agenda)
 {
 }
Exemplo n.º 23
0
 public virtual void PostBuildTarget(UE4Build Build, FileReference UProjectPath, string TargetName, string Config)
 {
 }
Exemplo n.º 24
0
 public virtual void PreBuildAgenda(UE4Build Build, UE4Build.BuildAgenda Agenda)
 {
 }
    public static void Build(BuildCommand Command, ProjectParams Params, int WorkingCL = -1, ProjectBuildTargets TargetMask = ProjectBuildTargets.All)
    {
        Params.ValidateAndLog();

        if (!Params.Build)
        {
            return;
        }

        Log("********** BUILD COMMAND STARTED **********");

        var UE4Build             = new UE4Build(Command);
        var Agenda               = new UE4Build.BuildAgenda();
        var CrashReportPlatforms = new HashSet <UnrealTargetPlatform>();

        // Setup editor targets
        if (Params.HasEditorTargets && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.Editor) == ProjectBuildTargets.Editor)
        {
            // @todo Mac: proper platform detection
            UnrealTargetPlatform            EditorPlatform      = HostPlatform.Current.HostEditorPlatform;
            const UnrealTargetConfiguration EditorConfiguration = UnrealTargetConfiguration.Development;

            CrashReportPlatforms.Add(EditorPlatform);
            Agenda.AddTargets(Params.EditorTargets.ToArray(), EditorPlatform, EditorConfiguration, Params.CodeBasedUprojectPath);
            if (Params.EditorTargets.Contains("UnrealHeaderTool") == false)
            {
                Agenda.AddTargets(new string[] { "UnrealHeaderTool" }, EditorPlatform, EditorConfiguration);
            }
            if (Params.EditorTargets.Contains("ShaderCompileWorker") == false)
            {
                Agenda.AddTargets(new string[] { "ShaderCompileWorker" }, EditorPlatform, EditorConfiguration);
            }
            if (Params.Pak && Params.EditorTargets.Contains("UnrealPak") == false)
            {
                Agenda.AddTargets(new string[] { "UnrealPak" }, EditorPlatform, EditorConfiguration);
            }
            if (Params.FileServer && Params.EditorTargets.Contains("UnrealFileServer") == false)
            {
                Agenda.AddTargets(new string[] { "UnrealFileServer" }, EditorPlatform, EditorConfiguration);
            }
        }

        // Setup cooked targets
        if (Params.HasClientCookedTargets && (TargetMask & ProjectBuildTargets.ClientCooked) == ProjectBuildTargets.ClientCooked)
        {
            List <UnrealTargetPlatform> UniquePlatformTypes = Params.ClientTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList();

            foreach (var BuildConfig in Params.ClientConfigsToBuild)
            {
                foreach (var ClientPlatformType in UniquePlatformTypes)
                {
                    string AdditionalArgs = GetBlueprintPluginPathArgument(Params, true, ClientPlatformType);
                    AdditionalArgs += " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\"";
                    if (Params.IsCodeBasedProject == false)
                    {
                        AdditionalArgs += " -project=\"" + Path.GetFullPath(Params.RawProjectPath.FullName) + "\"";
                    }
                    CrashReportPlatforms.Add(ClientPlatformType);
                    Agenda.AddTargets(Params.ClientCookedTargets.ToArray(), ClientPlatformType, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: AdditionalArgs);
                }
            }
        }
        if (Params.HasServerCookedTargets && (TargetMask & ProjectBuildTargets.ServerCooked) == ProjectBuildTargets.ServerCooked)
        {
            List <UnrealTargetPlatform> UniquePlatformTypes = Params.ServerTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList();

            foreach (var BuildConfig in Params.ServerConfigsToBuild)
            {
                foreach (var ServerPlatformType in UniquePlatformTypes)
                {
                    string AdditionalArgs = GetBlueprintPluginPathArgument(Params, false, ServerPlatformType);
                    AdditionalArgs += " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\"";
                    if (Params.IsCodeBasedProject == false)
                    {
                        AdditionalArgs += " -project=\"" + Path.GetFullPath(Params.RawProjectPath.FullName) + "\"";
                    }

                    CrashReportPlatforms.Add(ServerPlatformType);
                    Agenda.AddTargets(Params.ServerCookedTargets.ToArray(), ServerPlatformType, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: AdditionalArgs);
                }
            }
        }
        if (!Params.NoBootstrapExe && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.Bootstrap) == ProjectBuildTargets.Bootstrap)
        {
            UnrealBuildTool.UnrealTargetPlatform[] BootstrapPackagedGamePlatforms = { UnrealBuildTool.UnrealTargetPlatform.Win32, UnrealBuildTool.UnrealTargetPlatform.Win64 };
            foreach (UnrealBuildTool.UnrealTargetPlatform BootstrapPackagedGamePlatformType in BootstrapPackagedGamePlatforms)
            {
                if (Params.ClientTargetPlatforms.Contains(new TargetPlatformDescriptor(BootstrapPackagedGamePlatformType)))
                {
                    Agenda.AddTarget("BootstrapPackagedGame", BootstrapPackagedGamePlatformType, UnrealBuildTool.UnrealTargetConfiguration.Shipping);
                }
            }
        }
        if (Params.CrashReporter && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.CrashReporter) == ProjectBuildTargets.CrashReporter)
        {
            foreach (var CrashReportPlatform in CrashReportPlatforms)
            {
                if (UnrealBuildTool.UnrealBuildTool.PlatformSupportsCrashReporter(CrashReportPlatform))
                {
                    Agenda.AddTarget("CrashReportClient", CrashReportPlatform, UnrealTargetConfiguration.Shipping);
                }
            }
        }
        if (Params.HasProgramTargets && (TargetMask & ProjectBuildTargets.Programs) == ProjectBuildTargets.Programs)
        {
            List <UnrealTargetPlatform> UniquePlatformTypes = Params.ClientTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList();

            foreach (var BuildConfig in Params.ClientConfigsToBuild)
            {
                foreach (var ClientPlatformType in UniquePlatformTypes)
                {
                    Agenda.AddTargets(Params.ProgramTargets.ToArray(), ClientPlatformType, BuildConfig, Params.CodeBasedUprojectPath);
                }
            }
        }
        UE4Build.Build(Agenda, InDeleteBuildProducts: Params.Clean, InUpdateVersionFiles: WorkingCL > 0);

        if (WorkingCL > 0)         // only move UAT files if we intend to check in some build products
        {
            UE4Build.AddUATFilesToBuildProducts();
        }
        UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles);

        if (WorkingCL > 0)
        {
            // Sign everything we built
            CodeSign.SignMultipleIfEXEOrDLL(Command, UE4Build.BuildProductFiles);

            // Open files for add or edit
            UE4Build.AddBuildProductsToChangelist(WorkingCL, UE4Build.BuildProductFiles);
        }

        Log("********** BUILD COMMAND COMPLETED **********");
    }
Exemplo n.º 26
0
    public override void ExecuteBuild()
    {
        int WorkingCL = -1;

        if (P4Enabled && AllowSubmit)
        {
            string CmdLine = "";
            foreach (var Arg in Params)
            {
                CmdLine += Arg.ToString() + " ";
            }
            WorkingCL = P4.CreateChange(P4Env.Client, String.Format("MegaXGE build from changelist {0} - Params: {1}", P4Env.Changelist, CmdLine));
        }

        LogInformation("************************* MegaXGE");

        bool   Clean             = ParseParam("Clean");
        string CleanToolLocation = CombinePaths(CmdEnv.LocalRoot, "Engine", "Build", "Batchfiles", "Clean.bat");

        bool ShowProgress = ParseParam("Progress");

        var UE4Build = new UE4Build(this);

        var Agenda = new UE4Build.BuildAgenda();

        // we need to always build UHT when we use mega XGE
        var ProgramTargets = new string[]
        {
            "UnrealHeaderTool",
        };

        Agenda.AddTargets(ProgramTargets, UnrealTargetPlatform.Win64, UnrealTargetConfiguration.Development);
        if (Clean)
        {
            LogSetProgress(ShowProgress, "Cleaning previous builds...");
            foreach (var CurTarget in ProgramTargets)
            {
                string Args = String.Format("{0} {1} {2}", CurTarget, UnrealTargetPlatform.Win64.ToString(), UnrealTargetConfiguration.Development.ToString());
                RunAndLog(CmdEnv, CleanToolLocation, Args);
            }
        }

        LogInformation("*************************");
        for (int Arg = 1; Arg < 100; Arg++)
        {
            string Parm   = String.Format("Target{0}", Arg);
            string Target = ParseParamValue(Parm, "");
            if (String.IsNullOrEmpty(Target))
            {
                break;
            }

            FileReference ProjectFile = null;

            string ProjectFileParam = ParseParamValue(String.Format("Project{0}", Arg), null);
            if (ProjectFileParam != null)
            {
                ProjectFile = new FileReference(ProjectFileParam);
                if (!FileReference.Exists(ProjectFile))
                {
                    throw new AutomationException("Project file '{0}' could not be found");
                }
            }

            var Parts = Target.Split(' ');

            string JustTarget = Parts[0];
            if (String.IsNullOrEmpty(JustTarget))
            {
                throw new AutomationException("BUILD FAILED target option '{0}' not parsed.", Target);
            }
            var Targets = JustTarget.Split('|');
            if (Targets.Length < 1)
            {
                throw new AutomationException("BUILD FAILED target option '{0}' not parsed.", Target);
            }

            var Platforms      = new List <UnrealTargetPlatform>();
            var Configurations = new List <UnrealTargetConfiguration>();

            for (int Part = 1; Part < Parts.Length; Part++)
            {
                if (!String.IsNullOrEmpty(Parts[Part]))
                {
                    var SubParts = Parts[Part].Split('|');

                    foreach (var SubPart in SubParts)
                    {
                        UnrealTargetPlatform Platform;
                        if (UnrealTargetPlatform.TryParse(SubPart, out Platform))
                        {
                            Platforms.Add(Platform);
                        }
                        else
                        {
                            switch (SubPart.ToUpperInvariant())
                            {
                            case "DEBUG":
                                Configurations.Add(UnrealTargetConfiguration.Debug);
                                break;

                            case "DEBUGGAME":
                                Configurations.Add(UnrealTargetConfiguration.DebugGame);
                                break;

                            case "DEVELOPMENT":
                                Configurations.Add(UnrealTargetConfiguration.Development);
                                break;

                            case "SHIPPING":
                                Configurations.Add(UnrealTargetConfiguration.Shipping);
                                break;

                            case "TEST":
                                Configurations.Add(UnrealTargetConfiguration.Test);
                                break;

                            default:
                                throw new AutomationException("BUILD FAILED target option {0} not recognized.", SubPart);
                            }
                        }
                    }
                }
            }
            if (Platforms.Count < 1)
            {
                Platforms.Add(UnrealTargetPlatform.Win64);
            }
            if (Configurations.Count < 1)
            {
                Configurations.Add(UnrealTargetConfiguration.Development);
            }
            foreach (var Platform in Platforms)
            {
                foreach (var CurTarget in Targets)
                {
                    foreach (var Configuration in Configurations)
                    {
                        Agenda.AddTargets(new string[] { CurTarget }, Platform, Configuration, ProjectFile);
                        LogInformation("Target {0} {1} {2}", CurTarget, Platform.ToString(), Configuration.ToString());
                        if (Clean)
                        {
                            string Args = String.Format("{0} {1} {2}", CurTarget, Platform.ToString(), Configuration.ToString());
                            RunAndLog(CmdEnv, CleanToolLocation, Args);
                        }
                    }
                }
            }
        }
        LogInformation("*************************");

        UE4Build.Build(Agenda, InUpdateVersionFiles: IsBuildMachine, InUseParallelExecutor: ParseParam("useparallelexecutor"), InShowProgress: ShowProgress);

        //      if (WorkingCL > 0) // only move UAT files if we intend to check in some build products
        //      {
        //          UE4Build.CopyUATFilesAndAddToBuildProducts();
        //      }

        UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles);

        if (WorkingCL > 0)
        {
            // Sign everything we built
            CodeSign.SignMultipleIfEXEOrDLL(this, UE4Build.BuildProductFiles);

            // Open files for add or edit
            UE4Build.AddBuildProductsToChangelist(WorkingCL, UE4Build.BuildProductFiles);

            int SubmittedCL;
            P4.Submit(WorkingCL, out SubmittedCL, true, true);
        }

        PrintRunTime();
    }
    public override void ExecuteBuild()
    {
        if (ParseParam("BuildEditor"))
        {
            UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda();
            Agenda.AddTarget("UE4Editor", HostPlatform.Current.HostEditorPlatform, UnrealTargetConfiguration.Development);
            Agenda.AddTarget("ShaderCompileWorker", HostPlatform.Current.HostEditorPlatform, UnrealTargetConfiguration.Development);

            UE4Build Builder = new UE4Build(this);
            Builder.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: true, InForceNoXGE: true);
        }

        var EditorExe = CombinePaths(CmdEnv.LocalRoot, @"Engine/Binaries/Win64/UE4Editor-Cmd.exe");

        if (P4Enabled)
        {
            Log("Sync necessary content to head revision");
            P4.Sync(P4Env.Branch + "/Engine/Config/...");
            P4.Sync(P4Env.Branch + "/Engine/Content/...");
            P4.Sync(P4Env.Branch + "/Engine/Source/...");

            P4.Sync(P4Env.Branch + "/Portal/Config/...");
            P4.Sync(P4Env.Branch + "/Portal/Content/...");
            P4.Sync(P4Env.Branch + "/Portal/Source/...");
        }

        OneSkyConfigData OneSkyConfig = OneSkyConfigHelper.Find("OneSkyConfig_EpicGames");
        var oneSkyService             = new OneSkyService(OneSkyConfig.ApiKey, OneSkyConfig.ApiSecret);

        // Export Launcher text from OneSky
        {
            var launcherGroup = GetLauncherGroup(oneSkyService);
            var appProject    = GetAppProject(oneSkyService);
            var appFile       = appProject.UploadedFiles.FirstOrDefault(f => f.Filename == "App.po");

            //Export
            if (appFile != null)
            {
                ExportFileToDirectory(appFile, new DirectoryInfo(CmdEnv.LocalRoot + "/Portal/Content/Localization/App"), launcherGroup.EnabledCultures);
            }
        }

        // Setup editor arguments for SCC.
        string EditorArguments = String.Empty;

        if (P4Enabled)
        {
            EditorArguments = String.Format("-SCCProvider={0} -P4Port={1} -P4User={2} -P4Client={3} -P4Passwd={4}", "Perforce", P4Env.ServerAndPort, P4Env.User, P4Env.Client, P4.GetAuthenticationToken());
        }
        else
        {
            EditorArguments = String.Format("-SCCProvider={0}", "None");
        }

        // Setup commandlet arguments for SCC.
        string CommandletSCCArguments = String.Empty;

        if (P4Enabled)
        {
            CommandletSCCArguments += "-EnableSCC";
        }
        if (!AllowSubmit)
        {
            CommandletSCCArguments += (string.IsNullOrEmpty(CommandletSCCArguments) ? "" : " ") + "-DisableSCCSubmit";
        }

        // Setup commandlet arguments with configurations.
        var CommandletArgumentSets = new string[]
        {
            String.Format("-config={0}", @"../Portal/Config/Localization/App.ini") + (string.IsNullOrEmpty(CommandletSCCArguments) ? "" : " " + CommandletSCCArguments)
        };

        // Execute commandlet for each set of arguments.
        foreach (var CommandletArguments in CommandletArgumentSets)
        {
            Log("Localization for {0} {1}", EditorArguments, CommandletArguments);

            Log("Running UE4Editor to generate Localization data");

            string Arguments = String.Format("-run=GatherText {0} {1}", EditorArguments, CommandletArguments);
            var    RunResult = Run(EditorExe, Arguments);

            if (RunResult.ExitCode != 0)
            {
                throw new AutomationException("Error while executing localization commandlet '{0}'", Arguments);
            }
        }

        // Upload Launcher text to OneSky
        UploadDirectoryToProject(GetAppProject(oneSkyService), new DirectoryInfo(CmdEnv.LocalRoot + "/Portal/Content/Localization/App"), "*.po");
    }
Exemplo n.º 28
0
    public override void ExecuteBuild()
    {
        Log("************************* BuildCommonTools");

        // Get the list of platform names
        string[] PlatformNames = ParseParamValue("platforms", BuildHostPlatform.Current.Platform.ToString()).Split('+');

        // Parse the platforms
        List <UnrealBuildTool.UnrealTargetPlatform> Platforms = new List <UnrealTargetPlatform>();

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

        // Add all the platforms if specified
        if (ParseParam("allplatforms"))
        {
            foreach (UnrealTargetPlatform Platform in Enum.GetValues(typeof(UnrealTargetPlatform)))
            {
                if (!Platforms.Contains(Platform))
                {
                    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());
        }
    }
Exemplo n.º 29
0
    public override void ExecuteBuild()
    {
        CommandUtils.Log("************************* List Third Party Software");

        string ProjectPath = ParseParamValue("Project", String.Empty);

        //Add quotes to avoid issues with spaces in project path
        if (ProjectPath != String.Empty)
        {
            ProjectPath = "\"" + ProjectPath + "\"";
        }

        // Parse the list of targets to list TPS for. Each target is specified by -Target="Name|Configuration|Platform" on the command line.
        HashSet <FileReference> TpsFiles = new HashSet <FileReference>();

        foreach (string Target in ParseParamValues(Params, "Target"))
        {
            // Get the path to store the exported JSON target data
            FileReference OutputFile = FileReference.Combine(CommandUtils.EngineDirectory, "Intermediate", "Build", "ThirdParty.json");

            IProcessResult Result;

            Result = Run(UE4Build.GetUBTExecutable(), String.Format("{0} {1} -jsonexport=\"{2}\" -skipbuild", Target.Replace('|', ' '), ProjectPath, OutputFile.FullName), Options: ERunOptions.Default);

            if (Result.ExitCode != 0)
            {
                throw new AutomationException("Failed to run UBT");
            }

            // Read the exported target info back in
            JsonObject Object = JsonObject.Read(OutputFile);

            // Get the project file if there is one
            FileReference ProjectFile = null;
            string        ProjectFileName;
            if (Object.TryGetStringField("ProjectFile", out ProjectFileName))
            {
                ProjectFile = new FileReference(ProjectFileName);
            }

            // Get the default paths to search
            HashSet <DirectoryReference> DirectoriesToScan = new HashSet <DirectoryReference>();
            DirectoriesToScan.Add(DirectoryReference.Combine(CommandUtils.EngineDirectory, "Shaders"));
            DirectoriesToScan.Add(DirectoryReference.Combine(CommandUtils.EngineDirectory, "Content"));
            if (ProjectFile != null)
            {
                DirectoriesToScan.Add(DirectoryReference.Combine(ProjectFile.Directory, "Content"));
            }

            // Get the variables to be expanded in any runtime dependencies variables
            Dictionary <string, string> Variables = new Dictionary <string, string>();
            Variables.Add("EngineDir", CommandUtils.EngineDirectory.FullName);
            if (ProjectFile != null)
            {
                Variables.Add("ProjectDir", ProjectFile.Directory.FullName);
            }

            // Add all the paths for each module, and its runtime dependencies
            JsonObject Modules = Object.GetObjectField("Modules");
            foreach (string ModuleName in Modules.KeyNames)
            {
                JsonObject Module = Modules.GetObjectField(ModuleName);
                DirectoriesToScan.Add(new DirectoryReference(Module.GetStringField("Directory")));

                foreach (JsonObject RuntimeDependency in Module.GetObjectArrayField("RuntimeDependencies"))
                {
                    string RuntimeDependencyPath = RuntimeDependency.GetStringField("Path");
                    RuntimeDependencyPath = Utils.ExpandVariables(RuntimeDependencyPath, Variables);
                    DirectoriesToScan.Add(new FileReference(RuntimeDependencyPath).Directory);
                }
            }

            // Remove any directories that are under other directories, and sort the output list
            List <DirectoryReference> SortedDirectoriesToScan = new List <DirectoryReference>();
            foreach (DirectoryReference DirectoryToScan in DirectoriesToScan.OrderBy(x => x.FullName))
            {
                if (SortedDirectoriesToScan.Count == 0 || !DirectoryToScan.IsUnderDirectory(SortedDirectoriesToScan[SortedDirectoriesToScan.Count - 1]))
                {
                    SortedDirectoriesToScan.Add(DirectoryToScan);
                }
            }

            // Get the platforms to exclude
            List <UnrealTargetPlatform> SupportedPlatforms = new List <UnrealTargetPlatform> {
                (UnrealTargetPlatform)Enum.Parse(typeof(UnrealTargetPlatform), Object.GetStringField("Platform"))
            };
            FileSystemName[] ExcludePlatformNames = Utils.MakeListOfUnsupportedPlatforms(SupportedPlatforms).Select(x => new FileSystemName(x)).ToArray();

            // Find all the TPS files under the engine directory which match
            foreach (DirectoryReference DirectoryToScan in SortedDirectoriesToScan)
            {
                foreach (FileReference TpsFile in DirectoryReference.EnumerateFiles(DirectoryToScan, "*.tps", SearchOption.AllDirectories))
                {
                    if (!TpsFile.ContainsAnyNames(ExcludePlatformNames, DirectoryToScan))
                    {
                        TpsFiles.Add(TpsFile);
                    }
                }
            }
        }

        // Also add any redirects
        List <string> OutputMessages = new List <string>();

        foreach (FileReference TpsFile in TpsFiles)
        {
            string Message = TpsFile.FullName;

            string[] Lines = FileReference.ReadAllLines(TpsFile);
            foreach (string Line in Lines)
            {
                const string RedirectPrefix = "Redirect:";

                int Idx = Line.IndexOf(RedirectPrefix, StringComparison.InvariantCultureIgnoreCase);
                if (Idx >= 0)
                {
                    FileReference RedirectTpsFile = FileReference.Combine(TpsFile.Directory, Line.Substring(Idx + RedirectPrefix.Length).Trim());
                    Message = String.Format("{0} (redirect from {1})", RedirectTpsFile.FullName, TpsFile.FullName);
                    break;
                }
            }

            OutputMessages.Add(Message);
        }
        OutputMessages.Sort();

        // Print them all out
        foreach (string OutputMessage in OutputMessages)
        {
            CommandUtils.Log(OutputMessage);
        }
    }
Exemplo n.º 30
0
    public static void Build(BuildCommand Command, ProjectParams Params, int WorkingCL = -1)
    {
        Params.ValidateAndLog();

        if (!Params.Build)
        {
            return;
        }

        Log("********** BUILD COMMAND STARTED **********");

        var UE4Build             = new UE4Build(Command);
        var Agenda               = new UE4Build.BuildAgenda();
        var CrashReportPlatforms = new HashSet <UnrealTargetPlatform>();

        // Setup editor targets
        if (Params.HasEditorTargets && !Params.Rocket)
        {
            // @todo Mac: proper platform detection
            UnrealTargetPlatform            EditorPlatform      = HostPlatform.Current.HostEditorPlatform;
            const UnrealTargetConfiguration EditorConfiguration = UnrealTargetConfiguration.Development;

            CrashReportPlatforms.Add(EditorPlatform);
            Agenda.AddTargets(Params.EditorTargets.ToArray(), EditorPlatform, EditorConfiguration, Params.CodeBasedUprojectPath);
            if (Params.EditorTargets.Contains("UnrealHeaderTool") == false)
            {
                Agenda.AddTargets(new string[] { "UnrealHeaderTool" }, EditorPlatform, EditorConfiguration);
            }
            if (Params.EditorTargets.Contains("ShaderCompileWorker") == false)
            {
                Agenda.AddTargets(new string[] { "ShaderCompileWorker" }, EditorPlatform, EditorConfiguration);
            }
            if (Params.Pak && Params.EditorTargets.Contains("UnrealPak") == false)
            {
                Agenda.AddTargets(new string[] { "UnrealPak" }, EditorPlatform, EditorConfiguration);
            }
            if (Params.FileServer && Params.EditorTargets.Contains("UnrealFileServer") == false)
            {
                Agenda.AddTargets(new string[] { "UnrealFileServer" }, EditorPlatform, EditorConfiguration);
            }
        }

        // Setup cooked targets
        if (Params.HasClientCookedTargets)
        {
            foreach (var BuildConfig in Params.ClientConfigsToBuild)
            {
                foreach (var ClientPlatform in Params.ClientTargetPlatforms)
                {
                    CrashReportPlatforms.Add(ClientPlatform);
                    Agenda.AddTargets(Params.ClientCookedTargets.ToArray(), ClientPlatform, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: " -remoteini=\"" + Path.GetDirectoryName(Params.RawProjectPath) + "\"");
                }
            }
        }
        if (Params.HasServerCookedTargets)
        {
            foreach (var BuildConfig in Params.ServerConfigsToBuild)
            {
                foreach (var ServerPlatform in Params.ServerTargetPlatforms)
                {
                    CrashReportPlatforms.Add(ServerPlatform);
                    Agenda.AddTargets(Params.ServerCookedTargets.ToArray(), ServerPlatform, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: " -remoteini=\"" + Path.GetDirectoryName(Params.RawProjectPath) + "\"");
                }
            }
        }
        if (Params.CrashReporter && !Params.Rocket)
        {
            var CrashReportClientTarget = new[] { "CrashReportClient" };
            foreach (var CrashReportPlatform in CrashReportPlatforms)
            {
                if (UnrealBuildTool.UnrealBuildTool.PlatformSupportsCrashReporter(CrashReportPlatform))
                {
                    Agenda.AddTargets(CrashReportClientTarget, CrashReportPlatform, UnrealTargetConfiguration.Development);
                }
            }
        }
        if (Params.HasProgramTargets && !Params.Rocket)
        {
            foreach (var BuildConfig in Params.ClientConfigsToBuild)
            {
                foreach (var ClientPlatform in Params.ClientTargetPlatforms)
                {
                    Agenda.AddTargets(Params.ProgramTargets.ToArray(), ClientPlatform, BuildConfig, Params.CodeBasedUprojectPath);
                }
            }
        }
        UE4Build.Build(Agenda, InDeleteBuildProducts: Params.Clean, InUpdateVersionFiles: WorkingCL > 0);

        if (WorkingCL > 0)         // only move UAT files if we intend to check in some build products
        {
            UE4Build.AddUATFilesToBuildProducts();
        }
        UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles);

        if (WorkingCL > 0)
        {
            // Sign everything we built
            CodeSign.SignMultipleIfEXEOrDLL(Command, UE4Build.BuildProductFiles);

            // Open files for add or edit
            UE4Build.AddBuildProductsToChangelist(WorkingCL, UE4Build.BuildProductFiles);
        }

        Log("********** BUILD COMMAND COMPLETED **********");
    }