示例#1
0
        /// <summary>
        /// Updates the public key file (decryption)
        /// </summary>
        public void UpdatePublicKey(string KeyFilename)
        {
            var Lines = ReadEncryptionKeys(KeyFilename);
            if (Lines != null && Lines.Length >= 3)
            {
                // Line0: Private key exponent, Line1: Modulus, Line2: Public key exponent.
                string Modulus = String.Format("\"{0}\"", Lines[1]);
                string PublicKeyExponent = String.Format("\"{0}\"", Lines[2]);
                string VerFile = CmdEnv.LocalRoot + @"/Engine/Source/Runtime/PakFile/Private/PublicKey.inl";

                Log("Updating {0} with:", VerFile);
                Log(" #define DECRYPTION_KEY_EXPONENT {0}", PublicKeyExponent);
                Log(" #define DECYRPTION_KEY_MODULUS {0}", Modulus);

                VersionFileUpdater PublicKeyInl = new VersionFileUpdater(VerFile);
                PublicKeyInl.ReplaceLine("#define DECRYPTION_KEY_EXPONENT ", PublicKeyExponent);
                PublicKeyInl.ReplaceLine("#define DECYRPTION_KEY_MODULUS ", Modulus);
                PublicKeyInl.Commit();
            }
            else
            {
                LogError("{0} doesn't look like a valid encryption key file or value.");
            }
        }
示例#2
0
        /// <summary>
        /// Updates the engine version files
        /// </summary>
        public List<string> UpdateVersionFiles(bool ActuallyUpdateVersionFiles = true, int? ChangelistNumberOverride = null)
        {
            bool bIsLicenseeVersion = OwnerCommand.ParseParam("Licensee");
            bool bDoUpdateVersionFiles = CommandUtils.P4Enabled && ActuallyUpdateVersionFiles;
            int ChangelistNumber = 0;
            string ChangelistString = String.Empty;
            if (bDoUpdateVersionFiles)
            {
                ChangelistNumber = ChangelistNumberOverride.GetValueOrDefault(P4Env.Changelist);
                ChangelistString = ChangelistNumber.ToString();
            }

            var Result = new List<String>();
            string Branch = P4Enabled ? P4Env.BuildRootEscaped : "";
            {
                string VerFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Build", "build.properties");
                if (bDoUpdateVersionFiles)
                {
                    Log("Updating {0} with:", VerFile);
                    Log("  TimestampForBVT={0}", CmdEnv.TimestampAsString);
                    Log("  EngineVersion={0}", ChangelistNumber.ToString());
                    Log("  BranchName={0}", Branch);

                    PrepareBuildProduct(VerFile, false);
                    VersionFileUpdater BuildProperties = new VersionFileUpdater(VerFile);
                    BuildProperties.ReplaceLine("TimestampForBVT=", CmdEnv.TimestampAsString);
                    BuildProperties.ReplaceLine("EngineVersion=", ChangelistNumber.ToString());
                    BuildProperties.ReplaceLine("BranchName=", Branch);
                    BuildProperties.Commit();
                }
                else
                {
                    Log("{0} will not be updated because P4 is not enabled.", VerFile);
                }
                if (IsBuildMachine)
                {
                    // Only BuildMachines can check this file in
                    AddBuildProduct(VerFile);
                }
                Result.Add(VerFile);
            }

            {
                string VerFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Source", "Runtime", "Core", "Private", "UObject", "ObjectVersion.cpp");
                if (bDoUpdateVersionFiles)
                {
                    Log("Updating {0} with:", VerFile);
                    Log(" #define	ENGINE_VERSION  {0}", ChangelistNumber.ToString());

                    VersionFileUpdater ObjectVersionCpp = new VersionFileUpdater(VerFile);
                    ObjectVersionCpp.ReplaceLine("#define	ENGINE_VERSION	", ChangelistNumber.ToString());
                    ObjectVersionCpp.Commit();
                }
                else
                {
                    Log("{0} will not be updated because P4 is not enabled.", VerFile);
                }
                Result.Add(VerFile);
            }

            string EngineVersionFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Source", "Runtime", "Launch", "Resources", "Version.h");
            {
                string VerFile = EngineVersionFile;
                if (bDoUpdateVersionFiles)
                {
                    Log("Updating {0} with:", VerFile);
                    Log(" #define	ENGINE_VERSION  {0}", ChangelistNumber.ToString());
                    Log(" #define	BRANCH_NAME  {0}", Branch);
                    Log(" #define	BUILT_FROM_CHANGELIST  {0}", ChangelistString);
                    Log(" #define   ENGINE_IS_LICENSEE_VERSION  {0}", bIsLicenseeVersion ? "1" : "0");

                    VersionFileUpdater VersionH = new VersionFileUpdater(VerFile);
                    VersionH.ReplaceLine("#define ENGINE_VERSION ", ChangelistNumber.ToString());
                    VersionH.ReplaceLine("#define BRANCH_NAME ", "\"" + Branch + "\"");
                    VersionH.ReplaceLine("#define BUILT_FROM_CHANGELIST ", ChangelistString);
                    VersionH.ReplaceOrAddLine("#define ENGINE_IS_LICENSEE_VERSION ", bIsLicenseeVersion ? "1" : "0");

                    VersionH.Commit();
                }
                else
                {
                    Log("{0} will not be updated because P4 is not enabled.", VerFile);
                }
                Result.Add(VerFile);
            }

            {
                // Use Version.h data to update MetaData.cs so the assemblies match the engine version.
                string VerFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Source", "Programs", "DotNETCommon", "MetaData.cs");

                if (bDoUpdateVersionFiles)
                {
                    // Get the MAJOR/MINOR/PATCH from the Engine Version file, as it is authoritative. The rest we get from the P4Env.
                    string NewInformationalVersion = FEngineVersionSupport.FromVersionFile(EngineVersionFile, ChangelistNumber).ToString();

                    Log("Updating {0} with AssemblyInformationalVersion: {1}", VerFile, NewInformationalVersion);

                    VersionFileUpdater VersionH = new VersionFileUpdater(VerFile);
                    VersionH.SetAssemblyInformationalVersion(NewInformationalVersion);
                    VersionH.Commit();
                }
                else
                {
                    Log("{0} will not be updated because P4 is not enabled.", VerFile);
                }
                Result.Add(VerFile);
            }

            return Result;
        }
    public override void ExecuteBuild()
    {
        string ObjectVersionFilename = CmdEnv.LocalRoot + @"/Engine/Source/Runtime/Core/Private/UObject/ObjectVersion.cpp";
        string VersionFilename = CmdEnv.LocalRoot + @"/Engine/Source/Runtime/Launch/Resources/Version.h";
        if (P4Env.Changelist > 0)
        {
            var Stat = P4.FStat(ObjectVersionFilename);
            if (Stat.IsValid && Stat.Action != P4Action.None)
            {
                Log("Reverting {0}", ObjectVersionFilename);
                P4.Revert(ObjectVersionFilename);
            }
            Stat = P4.FStat(VersionFilename);
            if (Stat.IsValid && Stat.Action != P4Action.None)
            {
                Log("Reverting {0}", VersionFilename);
                P4.Revert(VersionFilename);
            }

            Log("Gettting engine version files @{0}", P4Env.Changelist);
            P4.Sync(String.Format("-f {0}@{1}", ObjectVersionFilename, P4Env.Changelist));
            P4.Sync(String.Format("-f {0}@{1}", VersionFilename, P4Env.Changelist));
        }

        Log("Checking if engine version files need to be reset...");
        List<string> FilesToSubmit = new List<string>();
        {
            VersionFileUpdater ObjectVersionCpp = new VersionFileUpdater(ObjectVersionFilename);
            if (ObjectVersionCpp.Contains("#define	ENGINE_VERSION	0") == false)
            {
                Log("Zeroing out engine versions in {0}", ObjectVersionFilename);
                ObjectVersionCpp.ReplaceLine("#define	ENGINE_VERSION	", "0");
                ObjectVersionCpp.Commit();
                FilesToSubmit.Add(ObjectVersionFilename);
            }
        }
        {
            VersionFileUpdater VersionH = new VersionFileUpdater(VersionFilename);
            if (VersionH.Contains("#define ENGINE_VERSION 0") == false)
            {
                Log("Zeroing out engine versions in {0}", VersionFilename);
                VersionH.ReplaceLine("#define ENGINE_VERSION ", "0");
                VersionH.ReplaceLine("#define BRANCH_NAME ", "\"" + P4Env.BranchName + "\"");
                VersionH.ReplaceLine("#define BUILT_FROM_CHANGELIST ", "0");

                VersionH.Commit();
                FilesToSubmit.Add(VersionFilename);
            }
        }

        if (FilesToSubmit.Count > 0)
        {
            int CL = P4.CreateChange(null, "Zero engine versions");
            foreach (var Filename in FilesToSubmit)
            {
                P4.Edit(CL, Filename);
            }
            Log("Submitting CL #{0}...", CL);
            int SubmittedCL;
            P4.Submit(CL, out SubmittedCL, false, true);
            Log("CL #{0} submitted as {1}", CL, SubmittedCL);
        }
        else
        {
            Log("Engine version files are set to 0.");
        }
    }
示例#4
0
		public static List<string> StaticUpdateVersionFiles(int ChangelistNumber, int CompatibleChangelistNumber, string Branch, string Build, bool bIsLicenseeVersion, bool bDoUpdateVersionFiles)
		{
			string ChangelistString = (ChangelistNumber != 0 && bDoUpdateVersionFiles)? ChangelistNumber.ToString() : String.Empty;

			var Result = new List<String>();
			{
				string VerFile = BuildVersion.GetDefaultFileName();
				if (bDoUpdateVersionFiles)
				{
					LogLog("Updating {0} with:", VerFile);
					LogLog("  Changelist={0}", ChangelistNumber);
					LogLog("  CompatibleChangelist={0}", CompatibleChangelistNumber);
					LogLog("  IsLicenseeVersion={0}", bIsLicenseeVersion? 1 : 0);
					LogLog("  BranchName={0}", Branch);

					BuildVersion Version;
					if(!BuildVersion.TryRead(VerFile, out Version))
					{
						Version = new BuildVersion();
					}

					Version.Changelist = ChangelistNumber;
					Version.CompatibleChangelist = CompatibleChangelistNumber;
					Version.IsLicenseeVersion = bIsLicenseeVersion? 1 : 0;
					Version.BranchName = Branch;

					VersionFileUpdater.MakeFileWriteable(VerFile);

					Version.Write(VerFile);
				}
				else
				{
					LogVerbose("{0} will not be updated because P4 is not enabled.", VerFile);
				}
				Result.Add(VerFile);
			}

            string EngineVersionFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Source", "Runtime", "Launch", "Resources", "Version.h");
            {
                string VerFile = EngineVersionFile;
				if (bDoUpdateVersionFiles)
				{
					LogLog("Updating {0} with:", VerFile);
					LogLog(" #define	BRANCH_NAME  {0}", Branch);
					LogLog(" #define	BUILT_FROM_CHANGELIST  {0}", ChangelistString);
					if(CompatibleChangelistNumber > 0)
					{
						LogLog(" #define	ENGINE_COMPATIBLE_CL_VERSION  {0}", CompatibleChangelistNumber);
					}
					if (Build != null)
					{
						LogLog(" #define	BUILD_VERSION  {0}", Build);
					}
					LogLog(" #define   ENGINE_IS_LICENSEE_VERSION  {0}", bIsLicenseeVersion ? "1" : "0");

					VersionFileUpdater VersionH = new VersionFileUpdater(VerFile);
					VersionH.ReplaceLine("#define BRANCH_NAME ", "\"" + Branch + "\"");
					VersionH.ReplaceLine("#define BUILT_FROM_CHANGELIST ", ChangelistString);
					if (Build != null)
					{
						VersionH.ReplaceLine("#define BUILD_VERSION ", "L\"" + Build + "\"");
					}
					if(CompatibleChangelistNumber > 0)
					{
						VersionH.ReplaceLine("#define ENGINE_COMPATIBLE_CL_VERSION", CompatibleChangelistNumber.ToString(), bIsLicenseeVersion? 0 : 1);
					}
					VersionH.ReplaceLine("#define ENGINE_IS_LICENSEE_VERSION ", bIsLicenseeVersion ? "1" : "0");

                    VersionH.Commit();
                }
				else
				{
					LogVerbose("{0} will not be updated because P4 is not enabled.", VerFile);
				}
                Result.Add(VerFile);
            }

            {
                // Use Version.h data to update MetaData.cs so the assemblies match the engine version.
                string VerFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Source", "Programs", "DotNETCommon", "MetaData.cs");

				if (bDoUpdateVersionFiles)
                {
                    // Get the MAJOR/MINOR/PATCH from the Engine Version file, as it is authoritative. The rest we get from the P4Env.
                    string NewInformationalVersion = FEngineVersionSupport.FromVersionFile(EngineVersionFile, ChangelistNumber).ToString();

                    LogLog("Updating {0} with AssemblyInformationalVersion: {1}", VerFile, NewInformationalVersion);

                    VersionFileUpdater VersionH = new VersionFileUpdater(VerFile);
                    VersionH.SetAssemblyInformationalVersion(NewInformationalVersion);
                    VersionH.Commit();
                }
                else
                {
                    LogVerbose("{0} will not be updated because P4 is not enabled.", VerFile);
                }
                Result.Add(VerFile);
            }

			return Result;
		}
    private void MakeForeignSample()
    {
        string Sample = "BlankProject";
        var DestSample = ParseParamValue("DestSample", "CopiedBlankProject");
        var Src = CombinePaths(CmdEnv.LocalRoot, "Samples", "SampleGames", Sample);
        if (!DirectoryExists(Src))
        {
            throw new AutomationException("Can't find source directory to make foreign sample {0}.", Src);
        }

        var Dest = ParseParamValue("ForeignDest", CombinePaths(@"C:\testue4\foreign\", DestSample + "_ _Dir"));
        Log("Make a foreign sample {0} -> {1}", Src, Dest);

        CloneDirectory(Src, Dest);

        DeleteDirectory_NoExceptions(CombinePaths(Dest, "Intermediate"));
        DeleteDirectory_NoExceptions(CombinePaths(Dest, "Saved"));

        RenameFile(CombinePaths(Dest, Sample + ".uproject"), CombinePaths(Dest, DestSample + ".uproject"));

        var IniFile = CombinePaths(Dest, "Config", "DefaultEngine.ini");
        var Ini = new VersionFileUpdater(IniFile);
        Ini.ReplaceLine("GameName=", DestSample);
        Ini.Commit();
    }
示例#6
0
        /// <summary>
        /// Updates the engine version files
        /// </summary>
        public List<string> UpdateVersionFiles()
        {
            var Result = new List<String>();
            string Branch = P4Enabled ? P4Env.BuildRootEscaped : "";
            {
                string VerFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Build", "build.properties");
                if (CommandUtils.P4Enabled)
                {
                    Log("Updating {0} with:", VerFile);
                    Log("  TimestampForBVT={0}", CmdEnv.TimestampAsString);
                    Log("  EngineVersion={0}", P4Env.ChangelistString);
                    Log("  BranchName={0}", Branch);

                    PrepareBuildProduct(VerFile, false);
                    VersionFileUpdater BuildProperties = new VersionFileUpdater(VerFile);
                    BuildProperties.ReplaceLine("TimestampForBVT=", CmdEnv.TimestampAsString);
                    BuildProperties.ReplaceLine("EngineVersion=", P4Env.ChangelistString);
                    BuildProperties.ReplaceLine("BranchName=", Branch);
                    BuildProperties.Commit();
                }
                else
                {
                    Log("{0} will not be updated because P4 is not enabled.", VerFile);
                }
                if (IsBuildMachine)
                {
                    // Only BuildMachines can check this file in
                    AddBuildProduct(VerFile);
                }
                Result.Add(VerFile);
            }

            {
                string VerFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Source", "Runtime", "Core", "Private", "UObject", "ObjectVersion.cpp");
                if (CommandUtils.P4Enabled)
                {
                    Log("Updating {0} with:", VerFile);
                    Log(" #define	ENGINE_VERSION  {0}", P4Env.ChangelistString);

                    VersionFileUpdater ObjectVersionCpp = new VersionFileUpdater(VerFile);
                    ObjectVersionCpp.ReplaceLine("#define	ENGINE_VERSION	", P4Env.ChangelistString);
                    ObjectVersionCpp.Commit();
                }
                else
                {
                    Log("{0} will not be updated because P4 is not enabled.", VerFile);
                }
                Result.Add(VerFile);
            }

            string EngineVersionFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Source", "Runtime", "Launch", "Resources", "Version.h");
            {
                string VerFile = EngineVersionFile;
                if (CommandUtils.P4Enabled)
                {
                    Log("Updating {0} with:", VerFile);
                    Log(" #define	ENGINE_VERSION  {0}", P4Env.ChangelistString);
                    Log(" #define	ENGINE_VERSION_HIWORD  {0}", (P4Env.Changelist >> 16).ToString());
                    Log(" #define	ENGINE_VERSION_LOWORD  {0}", (P4Env.Changelist & 0xFFFF).ToString());
                    Log(" #define	BRANCH_NAME  {0}", Branch);
                    Log(" #define	BUILT_FROM_CHANGELIST  {0}", P4Env.ChangelistString);

                    VersionFileUpdater VersionH = new VersionFileUpdater(VerFile);
                    VersionH.ReplaceLine("#define ENGINE_VERSION ", P4Env.ChangelistString);
                    VersionH.ReplaceLine("#define ENGINE_VERSION_HIWORD ", (P4Env.Changelist >> 16).ToString());
                    VersionH.ReplaceLine("#define ENGINE_VERSION_LOWORD ", (P4Env.Changelist & 0xFFFF).ToString());
                    VersionH.ReplaceLine("#define BRANCH_NAME ", "\"" + Branch + "\"");
                    VersionH.ReplaceLine("#define BUILT_FROM_CHANGELIST ", P4Env.ChangelistString);

                    VersionH.Commit();
                }
                else
                {
                    Log("{0} will not be updated because P4 is not enabled.", VerFile);
                }
                Result.Add(VerFile);
            }

            {
                // Use Version.h data to update MetaData.cs so the assemblies match the engine version.
                string VerFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Source", "Programs", "DotNETCommon", "MetaData.cs");

                if (CommandUtils.P4Enabled)
                {
                    // Get the MAJOR/MINOR/PATCH from the Engine Version file, as it is authoritative. The rest we get from the P4Env.
                    string NewInformationalVersion = FEngineVersionSupport.FromVersionFile(EngineVersionFile).ToString();

                    Log("Updating {0} with AssemblyInformationalVersion: {1}", VerFile, NewInformationalVersion);

                    VersionFileUpdater VersionH = new VersionFileUpdater(VerFile);
                    VersionH.SetAssemblyInformationalVersion(NewInformationalVersion);
                    VersionH.Commit();
                }
                else
                {
                    Log("{0} will not be updated because P4 is not enabled.", VerFile);
                }
                Result.Add(VerFile);
            }

            return Result;
        }
示例#7
0
		/// <summary>
		/// Updates the engine version files
		/// </summary>
		public List<string> UpdateVersionFiles(bool ActuallyUpdateVersionFiles = true, int? ChangelistNumberOverride = null)
		{
			bool bIsLicenseeVersion = OwnerCommand.ParseParam("Licensee");
			bool bDoUpdateVersionFiles = CommandUtils.P4Enabled && ActuallyUpdateVersionFiles;		
			int ChangelistNumber = 0;
			string ChangelistString = String.Empty;
			if (bDoUpdateVersionFiles)
			{
				ChangelistNumber = ChangelistNumberOverride.GetValueOrDefault(P4Env.Changelist);
				ChangelistString = ChangelistNumber.ToString();
			}

			var Result = new List<String>();
			string Branch = P4Enabled ? P4Env.BuildRootEscaped : "";
			{
				string VerFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Build", "Build.version");
				if (bDoUpdateVersionFiles)
				{
					Log("Updating {0} with:", VerFile);
					Log("  Changelist={0}", ChangelistNumber);
					Log("  IsLicenseeVersion={0}", bIsLicenseeVersion? 1 : 0);
					Log("  BranchName={0}", Branch);

					string VerText = CommandUtils.ReadAllText(VerFile);

					JavaScriptSerializer Serializer = new JavaScriptSerializer();
					Dictionary<string, object> Pairs = Serializer.Deserialize<Dictionary<string, object>>(VerText);
					Pairs["Changelist"] = ChangelistNumber;
					Pairs["IsLicenseeVersion"] = bIsLicenseeVersion? 1 : 0;
					Pairs["BranchName"] = Branch;
					VerText = Serializer.Serialize(Pairs).Replace("{\"", "{\n\t\"").Replace(",\"", ",\n\t\"").Replace("\":", "\": ").Replace("\"}", "\"\n}");

					CommandUtils.SetFileAttributes(VerFile, ReadOnly: false);
					CommandUtils.WriteAllText(VerFile, VerText);
				}
				else
				{
					Log("{0} will not be updated because P4 is not enabled.", VerFile);
				}
				if (IsBuildMachine)
				{
					// Only BuildMachines can check this file in
					AddBuildProduct(VerFile);
				}
				Result.Add(VerFile);
			}

            string EngineVersionFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Source", "Runtime", "Launch", "Resources", "Version.h");
            {
                string VerFile = EngineVersionFile;
				if (bDoUpdateVersionFiles)
				{
					Log("Updating {0} with:", VerFile);
					Log(" #define	BRANCH_NAME  {0}", Branch);
					Log(" #define	BUILT_FROM_CHANGELIST  {0}", ChangelistString);
					Log(" #define   ENGINE_IS_LICENSEE_VERSION  {0}", bIsLicenseeVersion ? "1" : "0");

					VersionFileUpdater VersionH = new VersionFileUpdater(VerFile);
					VersionH.ReplaceLine("#define BRANCH_NAME ", "\"" + Branch + "\"");
					VersionH.ReplaceLine("#define BUILT_FROM_CHANGELIST ", ChangelistString);
					VersionH.ReplaceOrAddLine("#define ENGINE_IS_LICENSEE_VERSION ", bIsLicenseeVersion ? "1" : "0");

                    VersionH.Commit();
                }
				else
				{
					Log("{0} will not be updated because P4 is not enabled.", VerFile);
				}
                Result.Add(VerFile);
            }

            {
                // Use Version.h data to update MetaData.cs so the assemblies match the engine version.
                string VerFile = CombinePaths(CmdEnv.LocalRoot, "Engine", "Source", "Programs", "DotNETCommon", "MetaData.cs");

				if (bDoUpdateVersionFiles)
                {
                    // Get the MAJOR/MINOR/PATCH from the Engine Version file, as it is authoritative. The rest we get from the P4Env.
                    string NewInformationalVersion = FEngineVersionSupport.FromVersionFile(EngineVersionFile, ChangelistNumber).ToString();

                    Log("Updating {0} with AssemblyInformationalVersion: {1}", VerFile, NewInformationalVersion);

                    VersionFileUpdater VersionH = new VersionFileUpdater(VerFile);
                    VersionH.SetAssemblyInformationalVersion(NewInformationalVersion);
                    VersionH.Commit();
                }
                else
                {
                    Log("{0} will not be updated because P4 is not enabled.", VerFile);
                }
                Result.Add(VerFile);
            }

			return Result;
		}