예제 #1
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;
        }
예제 #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.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;
		}