Exemplo n.º 1
0
		/// <summary>
		/// Gets the standard path for an manifest
		/// </summary>
		/// <param name="DirectoryName">The directory containing this manifest</param>
		/// <param name="AppName">The modular app name being built</param>
		/// <param name="Configuration">The target configuration</param>
		/// <param name="Platform">The target platform</param>
		/// <param name="BuildArchitecture">The architecture of the target platform</param>
		/// <returns>Filename for the app receipt</returns>
		public static string GetStandardFileName(string AppName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string BuildArchitecture, bool bIsGameDirectory)
		{
			string BaseName = AppName;
			if(Configuration != UnrealTargetConfiguration.Development && !(Configuration == UnrealTargetConfiguration.DebugGame && !bIsGameDirectory))
			{
				BaseName += String.Format("-{0}-{1}", Platform.ToString(), Configuration.ToString());
			}
			return String.Format("{0}{1}.modules", BaseName, BuildArchitecture);
		}
Exemplo n.º 2
0
        public FormalBuildTestNode(GUBP.GUBPBranchConfig InBranchConfig,
            BranchInfo.BranchUProject InGameProj,
            UnrealTargetPlatform InHostPlatform,
            UnrealTargetPlatform InClientTargetPlatform,
            UnrealTargetConfiguration InClientConfig
            )
            : base(InHostPlatform)
        {
			BranchConfig = InBranchConfig;
            GameProj = InGameProj;
            ClientTargetPlatform = InClientTargetPlatform;
            ClientConfig = InClientConfig;
            GameOrClient = TargetRules.TargetType.Game;

            // verify we actually built these
            var WorkingGameProject = InGameProj;
            if (!WorkingGameProject.Properties.Targets.ContainsKey(TargetRules.TargetType.Editor))
            {
                // this is a codeless project, use the base project
                WorkingGameProject = BranchConfig.Branch.BaseEngineProject;
            }
            if (!WorkingGameProject.Properties.Targets.ContainsKey(GameOrClient))
            {
                throw new AutomationException("Can't make a game build for {0} because it doesn't have a {1} target.", WorkingGameProject.GameName, GameOrClient.ToString());
            }

            if (!WorkingGameProject.Properties.Targets[GameOrClient].Rules.GUBP_GetPlatforms_MonolithicOnly(HostPlatform).Contains(ClientTargetPlatform))
            {
                throw new AutomationException("Can't make a game/client build for {0} because we didn't build platform {1}.", WorkingGameProject.GameName, ClientTargetPlatform.ToString());
            }
            if (!WorkingGameProject.Properties.Targets[GameOrClient].Rules.GUBP_GetConfigs_MonolithicOnly(HostPlatform, ClientTargetPlatform).Contains(ClientConfig))
            {
                throw new AutomationException("Can't make a game/client build for {0} because we didn't build platform {1} config {2}.", WorkingGameProject.GameName, ClientTargetPlatform.ToString(), ClientConfig.ToString());
            }
            AddDependency(FormalBuildNode.StaticGetFullName(GameProj, HostPlatform, new List<UnrealTargetPlatform>() { ClientTargetPlatform }, InClientConfigs: new List<UnrealTargetConfiguration>() { ClientConfig }, InClientNotGame: GameOrClient == TargetRules.TargetType.Client));
        }
		/// <summary>
		/// Composes a string to use for the Visual Studio solution configuration, given a build configuration and target rules configuration name
		/// </summary>
		/// <param name="Configuration">The build configuration</param>
		/// <param name="TargetConfigurationName">The target rules configuration name</param>
		/// <returns>The generated solution configuration name</returns>
		string MakeSolutionConfigurationName(UnrealTargetConfiguration Configuration, string TargetConfigurationName)
		{
			string SolutionConfigName = Configuration.ToString();

			// Don't bother postfixing "Game" or "Program" -- that will be the default when using "Debug", "Development", etc.
			// Also don't postfix "RocketGame" when we're building Rocket game projects.  That's the only type of game there is in that case!
			if (!TargetConfigurationName.Equals(TargetRules.TargetType.Game.ToString(), StringComparison.InvariantCultureIgnoreCase) &&
				!TargetConfigurationName.Equals(TargetRules.TargetType.Program.ToString(), StringComparison.InvariantCultureIgnoreCase))
			{
				SolutionConfigName += " " + TargetConfigurationName;
			}

			return SolutionConfigName;
		}
	protected string MakeIPAFileName( UnrealTargetConfiguration TargetConfiguration, ProjectParams Params )
	{
		string ProjectIPA = Path.Combine(Path.GetDirectoryName(Params.RawProjectPath), "Binaries", "IOS", (Params.Distribution ? "Distro_" : "") + Params.ShortProjectName);
		if (TargetConfiguration != UnrealTargetConfiguration.Development)
		{
			ProjectIPA += "-" + PlatformType.ToString() + "-" + TargetConfiguration.ToString();
		}
		ProjectIPA += ".ipa";
		return ProjectIPA;
	}
Exemplo n.º 5
0
        /// <summary>
        /// Returns the standard path to the build receipt for a given target
        /// </summary>
        /// <param name="BaseDir">Base directory for the target being built; either the project directory or engine directory.</param>
        /// <param name="TargetName">The target being built</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="Configuration">The target configuration</param>
        /// <param name="BuildArchitecture">The architecture being built</param>
        /// <returns>Path to the receipt for this target</returns>
        public static FileReference GetDefaultPath(DirectoryReference BaseDir, string TargetName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string BuildArchitecture)
        {
            // Get the architecture suffix. Platforms have the option of overriding whether to include this string in filenames.
            string ArchitectureSuffix = "";

            if (UEBuildPlatform.GetBuildPlatform(Platform).RequiresArchitectureSuffix())
            {
                ArchitectureSuffix = BuildArchitecture;
            }

            // Build the output filename
            if (String.IsNullOrEmpty(ArchitectureSuffix) && Configuration == UnrealTargetConfiguration.Development)
            {
                return(FileReference.Combine(BaseDir, "Binaries", Platform.ToString(), String.Format("{0}.target", TargetName)));
            }
            else
            {
                return(FileReference.Combine(BaseDir, "Binaries", Platform.ToString(), String.Format("{0}-{1}-{2}{3}.target", TargetName, Platform.ToString(), Configuration.ToString(), ArchitectureSuffix)));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Given a target platform and configuration, generates a platform and configuration name string to use in Visual Studio projects.
        /// Unlike with solution configurations, Visual Studio project configurations only support certain types of platforms, so we'll
        /// generate a configuration name that has the platform "built in", and use a default platform type
        /// </summary>
        /// <param name="Platform">Actual platform</param>
        /// <param name="Configuration">Actual configuration</param>
        /// <param name="TargetConfigurationName">The configuration name from the target rules, or null if we don't have one</param>
        /// <param name="ProjectPlatformName">Name of platform string to use for Visual Studio project</param>
        /// <param name="ProjectConfigurationName">Name of configuration string to use for Visual Studio project</param>
        public void MakeProjectPlatformAndConfigurationNames(UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string TargetConfigurationName, out string ProjectPlatformName, out string ProjectConfigurationName)
        {
            if (IsStubProject)
            {
                if (Platform != UnrealTargetPlatform.Unknown || Configuration != UnrealTargetConfiguration.Unknown)
                {
                    throw new BuildException("Stub project was expecting platform and configuration type to be set to Unknown");
                }
                ProjectPlatformName = StubProjectPlatformName;
                ProjectConfigurationName = StubProjectConfigurationName;
            }
            else
            {
                // If this is a C# project, then the project platform name must always be "Any CPU"
                if (this is VCSharpProjectFile)
                {
                    ProjectConfigurationName = Configuration.ToString();
                    ProjectPlatformName = VCProjectFileGenerator.DotNetPlatformName;
                }
                else
                {
                    var PlatformProjectGenerator = UEPlatformProjectGenerator.GetPlatformProjectGenerator(Platform, bInAllowFailure: true);

                    // Check to see if this platform is supported directly by Visual Studio projects.
                    bool HasActualVSPlatform = (PlatformProjectGenerator != null) ? PlatformProjectGenerator.HasVisualStudioSupport(Platform, Configuration) : false;

                    if (HasActualVSPlatform)
                    {
                        // Great!  Visual Studio supports this platform natively, so we don't need to make up
                        // a fake project configuration name.

                        // Allow the platform to specify the name used in VisualStudio.
                        // Note that the actual name of the platform on the Visual Studio side may be different than what
                        // UnrealBuildTool calls it (e.g. "Win64" -> "x64".) GetVisualStudioPlatformName() will figure this out.
                        ProjectConfigurationName = Configuration.ToString();
                        ProjectPlatformName = PlatformProjectGenerator.GetVisualStudioPlatformName(Platform, Configuration);
                    }
                    else
                    {
                        // Visual Studio doesn't natively support this platform, so we fake it by mapping it to
                        // a project configuration that has the platform name in that configuration as a suffix,
                        // and then using "Win32" as the actual VS platform name
                        ProjectConfigurationName = ProjectConfigurationNameOverride == "" ? Platform.ToString() + "_" + Configuration.ToString() : ProjectConfigurationNameOverride;
                        ProjectPlatformName = ProjectPlatformNameOverride == "" ? VCProjectFileGenerator.DefaultPlatformName : ProjectPlatformNameOverride;
                    }

                    if( !String.IsNullOrEmpty( TargetConfigurationName ) )
                    {
                        ProjectConfigurationName += "_" + TargetConfigurationName;
                    }
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Returns the standard path to the build receipt for a given target
 /// </summary>
 /// <param name="DirectoryName">Base directory for the target being built; either the project directory or engine directory.</param>
 /// <param name="TargetName">The target being built</param>
 /// <param name="Configuration">The target configuration</param>
 /// <param name="Platform">The target platform</param>
 /// <returns>Path to the receipt for this target</returns>
 public static string GetDefaultPath(string BaseDir, string TargetName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string BuildArchitecture)
 {
     return Path.Combine(BaseDir, "Build", "Receipts", String.Format("{0}-{1}-{2}{3}.target.xml", TargetName, Platform.ToString(), Configuration.ToString(), BuildArchitecture));
 }
	private void CodeSign(string BaseDirectory, string GameName, FileReference RawProjectPath, UnrealTargetConfiguration TargetConfig, string LocalRoot, string ProjectName, string ProjectDirectory, bool IsCode, bool Distribution = false, string Provision = null, string Certificate = null, string SchemeName = null, string SchemeConfiguration = null)
	{
		// check for the proper xcodeproject
		bool bWasGenerated = false;
		string XcodeProj = EnsureXcodeProjectExists (RawProjectPath, LocalRoot, ProjectName, ProjectDirectory, IsCode, out bWasGenerated);

		string Arguments = "UBT_NO_POST_DEPLOY=true";
		Arguments += " /usr/bin/xcrun xcodebuild build -workspace \"" + XcodeProj + "\"";
		Arguments += " -scheme '";
		Arguments += SchemeName != null ? SchemeName : GameName;
		Arguments += "'";
		Arguments += " -configuration \"" + (SchemeConfiguration != null ? SchemeConfiguration : TargetConfig.ToString()) + "\"";
		Arguments += " -destination generic/platform=" + (PlatformName == "TVOS" ? "tvOS" : "iOS");
		Arguments += " -sdk " + SDKName;
		if (!string.IsNullOrEmpty(Certificate))
		{
			Arguments += " CODE_SIGN_IDENTITY=\"" + Certificate + "\"";
		}
		else
		{
			Arguments += " CODE_SIGN_IDENTITY=" + (Distribution ? "\"iPhone Distribution\"" : "\"iPhone Developer\"");
		}
		if (!string.IsNullOrEmpty(Provision))
		{
			// read the provision to get the UUID
			if (File.Exists(Environment.GetEnvironmentVariable("HOME") + "/Library/MobileDevice/Provisioning Profiles/" + Provision))
			{
				string UUID = "";
				string AllText = File.ReadAllText(Environment.GetEnvironmentVariable("HOME") + "/Library/MobileDevice/Provisioning Profiles/" + Provision);
				int idx = AllText.IndexOf("<key>UUID</key>");
				if (idx > 0)
				{
					idx = AllText.IndexOf("<string>", idx);
					if (idx > 0)
					{
						idx += "<string>".Length;
						UUID = AllText.Substring(idx, AllText.IndexOf("</string>", idx) - idx);
                        Arguments += " PROVISIONING_PROFILE_SPECIFIER=" + UUID;
                    }
                }
			}
		}
		IProcessResult Result = Run ("/usr/bin/env", Arguments, null, ERunOptions.Default);
		if (bWasGenerated)
		{
			InternalUtils.SafeDeleteDirectory( XcodeProj, true);
		}
		if (Result.ExitCode != 0)
		{
			throw new AutomationException(ExitCode.Error_FailedToCodeSign, "CodeSign Failed");
		}
	}
Exemplo n.º 9
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="InDesc">Target descriptor</param>
        /// <param name="InRules">The target rules, as created by RulesCompiler.</param>
        /// <param name="InPossibleAppName">The AppName for shared binaries of this target type, if used (null if there is none).</param>
        /// <param name="InTargetCsFilename">The name of the target </param>
        public UEBuildTarget(TargetDescriptor InDesc, TargetRules InRules, string InPossibleAppName, string InTargetCsFilename)
        {
            AppName = InDesc.TargetName;
            TargetName = InDesc.TargetName;
            Platform = InDesc.Platform;
            Configuration = InDesc.Configuration;
            Rules = InRules;
            TargetType = Rules.Type;
            bEditorRecompile = InDesc.bIsEditorRecompile;
            bPrecompile = InDesc.bPrecompile;
            bUsePrecompiled = InDesc.bUsePrecompiled;
            ForeignPlugins = InDesc.ForeignPlugins;
            ForceReceiptFileName = InDesc.ForceReceiptFileName;

            Debug.Assert(InTargetCsFilename == null || InTargetCsFilename.EndsWith(".Target.cs", StringComparison.InvariantCultureIgnoreCase));
            TargetCsFilenameField = InTargetCsFilename;

            {
                bCompileMonolithic = Rules.ShouldCompileMonolithic(InDesc.Platform, InDesc.Configuration);

                // Platforms may *require* monolithic compilation...
                bCompileMonolithic |= UEBuildPlatform.PlatformRequiresMonolithicBuilds(InDesc.Platform, InDesc.Configuration);

                // Force monolithic or modular mode if we were asked to
                if( UnrealBuildTool.CommandLineContains("-Monolithic") ||
                    UnrealBuildTool.CommandLineContains("MONOLITHIC_BUILD=1") )
                {
                    bCompileMonolithic = true;
                }
                else if( UnrealBuildTool.CommandLineContains( "-Modular" ) )
                {
                    bCompileMonolithic = false;
                }
            }

            TargetInfo = new TargetInfo(Platform, Configuration, Rules.Type, bCompileMonolithic);

            if(InPossibleAppName != null && InRules.ShouldUseSharedBuildEnvironment(TargetInfo))
            {
                AppName = InPossibleAppName;
                bUseSharedBuildEnvironment = true;
            }

            // Figure out what the project directory is. If we have a uproject file, use that. Otherwise use the engine directory.
            if (UnrealBuildTool.HasUProjectFile())
            {
                ProjectDirectory = Path.GetFullPath(UnrealBuildTool.GetUProjectPath());
            }
            else
            {
                ProjectDirectory = Path.GetFullPath(BuildConfiguration.RelativeEnginePath);
            }

            // Build the project intermediate directory
            ProjectIntermediateDirectory = Path.GetFullPath(Path.Combine(ProjectDirectory, BuildConfiguration.PlatformIntermediateFolder, GetTargetName(), Configuration.ToString()));

            // Build the engine intermediate directory. If we're building agnostic engine binaries, we can use the engine intermediates folder. Otherwise we need to use the project intermediates directory.
            if (!bUseSharedBuildEnvironment)
            {
                EngineIntermediateDirectory = ProjectIntermediateDirectory;
            }
            else if(Configuration == UnrealTargetConfiguration.DebugGame)
            {
                EngineIntermediateDirectory = Path.GetFullPath(Path.Combine(BuildConfiguration.RelativeEnginePath, BuildConfiguration.PlatformIntermediateFolder, AppName, UnrealTargetConfiguration.Development.ToString()));
            }
            else
            {
                EngineIntermediateDirectory = Path.GetFullPath(Path.Combine(BuildConfiguration.RelativeEnginePath, BuildConfiguration.PlatformIntermediateFolder, AppName, Configuration.ToString()));
            }

            RemoteRoot = InDesc.RemoteRoot;

            OnlyModules = InDesc.OnlyModules;

            // Construct the output paths for this target's executable
            string OutputDirectory;
            if((bCompileMonolithic || TargetType == TargetRules.TargetType.Program) && !Rules.bOutputToEngineBinaries)
            {
                OutputDirectory = ProjectDirectory;
            }
            else
            {
                OutputDirectory = Path.GetFullPath(BuildConfiguration.RelativeEnginePath);
            }
            OutputPaths = MakeExecutablePaths(OutputDirectory, bCompileMonolithic? TargetName : AppName, Platform, Configuration, Rules.UndecoratedConfiguration, bCompileMonolithic && UnrealBuildTool.HasUProjectFile(), Rules.ExeBinariesSubFolder);

            // handle some special case defines (so build system can pass -DEFINE as normal instead of needing
            // to know about special parameters)
            foreach (string Define in InDesc.AdditionalDefinitions)
            {
                switch (Define)
                {
                    case "WITH_EDITOR=0":
                        UEBuildConfiguration.bBuildEditor = false;
                        break;

                    case "WITH_EDITORONLY_DATA=0":
                        UEBuildConfiguration.bBuildWithEditorOnlyData = false;
                        break;

                    // Memory profiler doesn't work if frame pointers are omitted
                    case "USE_MALLOC_PROFILER=1":
                        BuildConfiguration.bOmitFramePointers = false;
                        break;

                    case "WITH_LEAN_AND_MEAN_UE=1":
                        UEBuildConfiguration.bCompileLeanAndMeanUE = true;
                        break;
                }
            }

            // Add the definitions specified on the command-line.
            GlobalCompileEnvironment.Config.Definitions.AddRange(InDesc.AdditionalDefinitions);
        }
Exemplo n.º 10
0
        /**
         * @param InAppName - The name of the application being built, which is used to scope all intermediate and output file names.
         * @param InGameName - The name of the game being build - can be empty
         * @param InPlatform - The platform the target is being built for.
         * @param InConfiguration - The configuration the target is being built for.
         * @param InAdditionalDefinitions - Additional definitions provided on the UBT command-line for the target.
         * @param InRemoteRoot - The remote path that the build output is synced to.
         */
        public UEBuildTarget(
			string InAppName,
			string InGameName,
			UnrealTargetPlatform InPlatform,
			UnrealTargetConfiguration InConfiguration,
			TargetRules InRulesObject,
			List<string> InAdditionalDefinitions,
			string InRemoteRoot,
			List<OnlyModule> InOnlyModules,
			bool bInEditorRecompile)
        {
            AppName = InAppName;
            GameName = InGameName;
            Platform = InPlatform;
            Configuration = InConfiguration;
            Rules = InRulesObject;
            bEditorRecompile = bInEditorRecompile;

            {
                bCompileMonolithic = (Rules != null) ? Rules.ShouldCompileMonolithic(InPlatform, InConfiguration) : false;

                // Platforms may *require* monolithic compilation...
                bCompileMonolithic |= UEBuildPlatform.PlatformRequiresMonolithicBuilds(InPlatform, InConfiguration);

                // Force monolithic or modular mode if we were asked to
                if( UnrealBuildTool.CommandLineContains("-Monolithic") ||
                    UnrealBuildTool.CommandLineContains("MONOLITHIC_BUILD=1") )
                {
                    bCompileMonolithic = true;
                }
                else if( UnrealBuildTool.CommandLineContains( "-Modular" ) )
                {
                    bCompileMonolithic = false;
                }
            }

            // Figure out what the project directory is. If we have a uproject file, use that. Otherwise use the engine directory.
            if (UnrealBuildTool.HasUProjectFile())
            {
                ProjectDirectory = Path.GetFullPath(UnrealBuildTool.GetUProjectPath());
            }
            else
            {
                ProjectDirectory = Path.GetFullPath(BuildConfiguration.RelativeEnginePath);
            }

            // Build the project intermediate directory
            ProjectIntermediateDirectory = Path.GetFullPath(Path.Combine(ProjectDirectory, BuildConfiguration.PlatformIntermediateFolder, GetTargetName(), Configuration.ToString()));

            // Build the engine intermediate directory. If we're building agnostic engine binaries, we can use the engine intermediates folder. Otherwise we need to use the project intermediates directory.
            if (ShouldCompileMonolithic())
            {
                EngineIntermediateDirectory = ProjectIntermediateDirectory;
            }
            else if(Configuration == UnrealTargetConfiguration.DebugGame)
            {
                EngineIntermediateDirectory = Path.GetFullPath(Path.Combine(BuildConfiguration.RelativeEnginePath, BuildConfiguration.PlatformIntermediateFolder, AppName, UnrealTargetConfiguration.Development.ToString()));
            }
            else
            {
                EngineIntermediateDirectory = Path.GetFullPath(Path.Combine(BuildConfiguration.RelativeEnginePath, BuildConfiguration.PlatformIntermediateFolder, AppName, Configuration.ToString()));
            }

            RemoteRoot = InRemoteRoot;

            OnlyModules = InOnlyModules;

            TargetTypeOrNull = (Rules != null) ? Rules.Type : (TargetRules.TargetType?)null;

            // Construct the output path based on configuration, platform, game if not specified.
            OutputPaths = MakeBinaryPaths("", AppName, UEBuildBinaryType.Executable, TargetType, null, InAppName, Configuration == UnrealTargetConfiguration.Shipping ? Rules.ForceNameAsForDevelopment() : false, Rules.ExeBinariesSubFolder);
            for (int Index = 0; Index < OutputPaths.Length; Index++)
            {
                OutputPaths[Index] = Path.GetFullPath(OutputPaths[Index]);
            }

            if (bCompileMonolithic && TargetRules.IsGameType(InRulesObject.Type))
            {
                // For Rocket, UE4Game.exe and UE4Editor.exe still go into Engine/Binaries/<PLATFORM>
                if (!InRulesObject.bOutputToEngineBinaries)
                {
                    // We are compiling a monolithic game...
                    // We want the output to go into the <GAME>\Binaries folder
                    if (UnrealBuildTool.HasUProjectFile() == false)
                    {
                        for (int Index = 0; Index < OutputPaths.Length; Index++)
                        {
                            OutputPaths[Index] = OutputPaths[Index].Replace(Path.Combine("Engine", "Binaries"), Path.Combine(InGameName, "Binaries"));
                        }
                    }
                    else
                    {
                        string EnginePath = Path.GetFullPath(Path.Combine(ProjectFileGenerator.EngineRelativePath, "Binaries"));
                        string UProjectPath = UnrealBuildTool.GetUProjectPath();
                        if (Path.IsPathRooted(UProjectPath) == false)
                        {
                            string FilePath = UProjectInfo.GetProjectForTarget(InGameName);
                            string FullPath = Path.GetFullPath(FilePath);
                            UProjectPath = Path.GetDirectoryName(FullPath);
                        }
                        string ProjectPath = Path.GetFullPath(Path.Combine(UProjectPath, "Binaries"));
                        for (int Index = 0; Index < OutputPaths.Length; Index++)
                        {
                            OutputPaths[Index] = OutputPaths[Index].Replace(EnginePath, ProjectPath);
                        }
                    }
                }
            }

            // handle some special case defines (so build system can pass -DEFINE as normal instead of needing
            // to know about special parameters)
            foreach (string Define in InAdditionalDefinitions)
            {
                switch (Define)
                {
                    case "WITH_EDITOR=0":
                        UEBuildConfiguration.bBuildEditor = false;
                        break;

                    case "WITH_EDITORONLY_DATA=0":
                        UEBuildConfiguration.bBuildWithEditorOnlyData = false;
                        break;

                    // Memory profiler doesn't work if frame pointers are omitted
                    case "USE_MALLOC_PROFILER=1":
                        BuildConfiguration.bOmitFramePointers = false;
                        break;

                    case "WITH_LEAN_AND_MEAN_UE=1":
                        UEBuildConfiguration.bCompileLeanAndMeanUE = true;
                        break;
                }
            }

            // Add the definitions specified on the command-line.
            GlobalCompileEnvironment.Config.Definitions.AddRange(InAdditionalDefinitions);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Write the receipt to disk.
        /// </summary>
        /// <param name="FileName">Output filename</param>
        public void Write(string FileName)
        {
            using (JsonWriter Writer = new JsonWriter(FileName))
            {
                Writer.WriteObjectStart();
                Writer.WriteValue("TargetName", TargetName);
                Writer.WriteValue("Platform", Platform.ToString());
                Writer.WriteValue("Configuration", Configuration.ToString());
                Writer.WriteValue("BuildId", BuildId);

                Writer.WriteObjectStart("Version");
                Version.Write(Writer);
                Writer.WriteObjectEnd();

                Writer.WriteArrayStart("BuildProducts");
                foreach (BuildProduct BuildProduct in BuildProducts)
                {
                    Writer.WriteObjectStart();
                    Writer.WriteValue("Path", BuildProduct.Path);
                    Writer.WriteValue("Type", BuildProduct.Type.ToString());
                    if (BuildProduct.IsPrecompiled)
                    {
                        Writer.WriteValue("IsPrecompiled", BuildProduct.IsPrecompiled);
                    }
                    Writer.WriteObjectEnd();
                }
                Writer.WriteArrayEnd();

                Writer.WriteArrayStart("RuntimeDependencies");
                foreach (RuntimeDependency RuntimeDependency in RuntimeDependencies)
                {
                    Writer.WriteObjectStart();
                    Writer.WriteValue("Path", RuntimeDependency.Path);
                    if (RuntimeDependency.StagePath != null)
                    {
                        Writer.WriteValue("StagePath", RuntimeDependency.StagePath);
                    }
                    if (RuntimeDependency.bIgnoreIfMissing)
                    {
                        Writer.WriteValue("IgnoreIfMissing", RuntimeDependency.bIgnoreIfMissing);
                    }
                    Writer.WriteObjectEnd();
                }
                Writer.WriteArrayEnd();

                if (AdditionalProperties.Count > 0)
                {
                    Writer.WriteArrayStart("AdditionalProperties");
                    foreach (ReceiptProperty AdditionalProperty in AdditionalProperties)
                    {
                        Writer.WriteObjectStart();
                        Writer.WriteValue("Name", AdditionalProperty.Name);
                        Writer.WriteValue("Value", AdditionalProperty.Value);
                        Writer.WriteObjectEnd();
                    }
                    Writer.WriteArrayEnd();
                }

                Writer.WriteObjectEnd();
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Returns the standard path to the build receipt for a given target
 /// </summary>
 /// <param name="DirectoryName">Base directory for the target being built; either the project directory or engine directory.</param>
 /// <param name="TargetName">The target being built</param>
 /// <param name="Configuration">The target configuration</param>
 /// <param name="Platform">The target platform</param>
 /// <returns>Path to the receipt for this target</returns>
 public static string GetDefaultPath(string BaseDir, string TargetName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string BuildArchitecture)
 {
     if (String.IsNullOrEmpty(BuildArchitecture) && Configuration == UnrealTargetConfiguration.Development)
     {
         return(Path.Combine(BaseDir, "Binaries", Platform.ToString(), String.Format("{0}.target", TargetName)));
     }
     else
     {
         return(Path.Combine(BaseDir, "Binaries", Platform.ToString(), String.Format("{0}-{1}-{2}{3}.target", TargetName, Platform.ToString(), Configuration.ToString(), BuildArchitecture)));
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Given a platform, a build config, and true/false for client, returns the path to the binary for that config. E.g.
        /// Win64, Shipping, false = Binaries\Win64\FooServer-Win64-Shipping.exe
        /// </summary>
        /// <param name="TargetPlatform"></param>
        /// <param name="BuildConfig"></param>
        /// <param name="IsClient"></param>
        /// <returns></returns>
        virtual public string GetRelativeExecutablePath(UnrealTargetRole TargetType, UnrealTargetPlatform TargetPlatform, UnrealTargetConfiguration TargetConfiguration)
        {
            string ExePath;

            if (TargetType.UsesEditor())
            {
                ExePath = string.Format("Engine/Binaries/{0}/UE4Editor{1}", BuildHostPlatform.Current.Platform, Platform.GetExeExtension(TargetPlatform));
            }
            else
            {
                string BuildType = "";

                if (TargetType == UnrealTargetRole.Client)
                {
                    if (!UsesSharedBuildType)
                    {
                        BuildType = "Client";
                    }
                }
                else if (TargetType == UnrealTargetRole.Server)
                {
                    if (!UsesSharedBuildType)
                    {
                        BuildType = "Server";
                    }
                }

                bool IsRunningDev = Globals.Params.ParseParam("dev");

                // Turn FooGame into Foo
                string ExeBase = ProjectName.Replace("Game", "");

                if (TargetPlatform == UnrealTargetPlatform.Android)
                {
                    // use the archive results for android.
                    //var AndroidSource = new AndroidBuild(ProjectName, GetPlatformPath(TargetType, TargetPlatform), TargetConfiguration);

                    // We always (currently..) need to be able to replace the command line
                    BuildFlags Flags = BuildFlags.CanReplaceCommandLine;
                    if (IsRunningDev)
                    {
                        Flags |= BuildFlags.CanReplaceExecutable;
                    }
                    if (Globals.Params.ParseParam("bulk"))
                    {
                        Flags |= BuildFlags.Bulk;
                    }

                    var Build = GetMatchingBuilds(TargetType, TargetPlatform, TargetConfiguration, Flags).FirstOrDefault();

                    if (Build != null)
                    {
                        AndroidBuild AndroidBuild = Build as AndroidBuild;
                        ExePath = AndroidBuild.SourceApkPath;
                    }
                    else
                    {
                        throw new AutomationException("No suitable build for {0} found at {1}", TargetPlatform, BuildPath);
                    }

                    //ExePath = AndroidSource.SourceApkPath;
                }
                else
                {
                    string ExeFileName = string.Format("{0}{1}", ExeBase, BuildType);

                    if (TargetConfiguration != UnrealTargetConfiguration.Development)
                    {
                        ExeFileName += string.Format("-{0}-{1}", TargetPlatform.ToString(), TargetConfiguration.ToString());
                    }

                    ExeFileName += Platform.GetExeExtension(TargetPlatform);

                    string BasePath      = GetPlatformPath(TargetType, TargetPlatform);
                    string ProjectBinary = string.Format("{0}\\Binaries\\{1}\\{2}", ProjectName, TargetPlatform.ToString(), ExeFileName);
                    string StubBinary    = Path.Combine(BasePath, ExeFileName);
                    string DevBinary     = Path.Combine(Environment.CurrentDirectory, ProjectBinary);

                    string NonCodeProjectName   = "UE4Game" + Platform.GetExeExtension(TargetPlatform);
                    string NonCodeProjectBinary = Path.Combine(BasePath, "Engine", "Binaries", TargetPlatform.ToString());
                    NonCodeProjectBinary = Path.Combine(NonCodeProjectBinary, NonCodeProjectName);

                    // check the project binaries folder
                    if (File.Exists(Path.Combine(BasePath, ProjectBinary)))
                    {
                        ExePath = ProjectBinary;
                    }
                    else if (File.Exists(StubBinary))
                    {
                        ExePath = Path.Combine(BasePath, ExeFileName);
                    }
                    else if (IsRunningDev && File.Exists(DevBinary))
                    {
                        ExePath = DevBinary;
                    }
                    else if (File.Exists(NonCodeProjectBinary))
                    {
                        ExePath = NonCodeProjectBinary;
                    }
                    else
                    {
                        List <string> CheckedFiles = new List <String>()
                        {
                            Path.Combine(BasePath, ProjectBinary), StubBinary, NonCodeProjectBinary
                        };
                        if (IsRunningDev)
                        {
                            CheckedFiles.Add(DevBinary);
                        }

                        throw new AutomationException("Executable not found, upstream compile job may have failed.  Could not find executable {0} within {1}, binaries checked: {2}", ExeFileName, BasePath, String.Join(" - ", CheckedFiles));
                    }
                }
            }

            return(Utils.SystemHelpers.CorrectDirectorySeparators(ExePath));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Write the receipt to disk.
        /// </summary>
        /// <param name="Location">Output filename</param>
        /// <param name="EngineDir">Engine directory for expanded paths</param>
        /// <param name="ProjectDir">Project directory for expanded paths</param>
        public void Write(FileReference Location, DirectoryReference EngineDir, DirectoryReference ProjectDir)
        {
            using (JsonWriter Writer = new JsonWriter(Location.FullName))
            {
                Writer.WriteObjectStart();
                Writer.WriteValue("TargetName", TargetName);
                Writer.WriteValue("Platform", Platform.ToString());
                Writer.WriteValue("Configuration", Configuration.ToString());

                Writer.WriteObjectStart("Version");
                Version.WriteProperties(Writer);
                Writer.WriteObjectEnd();

                Writer.WriteArrayStart("BuildProducts");
                foreach (BuildProduct BuildProduct in BuildProducts)
                {
                    Writer.WriteObjectStart();
                    Writer.WriteValue("Path", InsertPathVariables(BuildProduct.Path, EngineDir, ProjectDir));
                    Writer.WriteValue("Type", BuildProduct.Type.ToString());
                    if (BuildProduct.IsPrecompiled)
                    {
                        Writer.WriteValue("IsPrecompiled", BuildProduct.IsPrecompiled);
                    }
                    Writer.WriteObjectEnd();
                }
                Writer.WriteArrayEnd();

                Writer.WriteArrayStart("RuntimeDependencies");
                foreach (RuntimeDependency RuntimeDependency in RuntimeDependencies)
                {
                    Writer.WriteObjectStart();
                    Writer.WriteValue("Path", InsertPathVariables(RuntimeDependency.Path, EngineDir, ProjectDir));
                    Writer.WriteValue("Type", RuntimeDependency.Type.ToString());
                    Writer.WriteObjectEnd();
                }
                Writer.WriteArrayEnd();

                if (AdditionalProperties.Count > 0)
                {
                    Writer.WriteArrayStart("AdditionalProperties");
                    foreach (ReceiptProperty AdditionalProperty in AdditionalProperties)
                    {
                        Writer.WriteObjectStart();
                        Writer.WriteValue("Name", AdditionalProperty.Name);
                        Writer.WriteValue("Value", AdditionalProperty.Value);
                        Writer.WriteObjectEnd();
                    }
                    Writer.WriteArrayEnd();
                }

                if (PrecompiledBuildDependencies.Count > 0)
                {
                    Writer.WriteArrayStart("PrecompiledBuildDependencies");
                    foreach (string PrecompiledBuildDependency in PrecompiledBuildDependencies.Select(x => InsertPathVariables(x, EngineDir, ProjectDir)).OrderBy(x => x))
                    {
                        Writer.WriteValue(PrecompiledBuildDependency);
                    }
                    Writer.WriteArrayEnd();
                }

                if (PrecompiledRuntimeDependencies.Count > 0)
                {
                    Writer.WriteArrayStart("PrecompiledRuntimeDependencies");
                    foreach (string PrecompiledRuntimeDependency in PrecompiledRuntimeDependencies.Select(x => InsertPathVariables(x, EngineDir, ProjectDir)).OrderBy(x => x))
                    {
                        Writer.WriteValue(PrecompiledRuntimeDependency);
                    }
                    Writer.WriteArrayEnd();
                }

                Writer.WriteObjectEnd();
            }
        }
Exemplo n.º 15
0
 public static string StaticGetFullName(BranchInfo.BranchUProject InGameProj, UnrealTargetPlatform InHostPlatform, UnrealTargetPlatform InClientTargetPlatform, UnrealTargetConfiguration InClientConfig)
 {
     string Infix = "_" + InClientTargetPlatform.ToString();
     Infix += "_" + InClientConfig.ToString();
     return InGameProj.GameName + Infix + "_TestBuild" + HostPlatformNode.StaticGetHostPlatformSuffix(InHostPlatform);
 }
	protected string MakeExeFileName( UnrealTargetConfiguration TargetConfiguration, ProjectParams Params )
	{
		string ProjectIPA = Path.Combine(Path.GetDirectoryName(Params.RawProjectPath.FullName), "Binaries", PlatformName, Params.ShortProjectName);
		if (TargetConfiguration != UnrealTargetConfiguration.Development)
		{
			ProjectIPA += "-" + PlatformType.ToString() + "-" + TargetConfiguration.ToString();
		}
		ProjectIPA += ".ipa";
		return ProjectIPA;
	}
Exemplo n.º 17
0
        /// <summary>
        /// Makes a filename (without path) for a compiled binary (e.g. "Core-Win64-Debug.lib") */
        /// </summary>
        /// <param name="BinaryName">The name of this binary</param>
        /// <param name="Platform">The platform being built for</param>
        /// <param name="Configuration">The configuration being built</param>
        /// <param name="UndecoratedConfiguration">The target configuration which doesn't require a platform and configuration suffix. Development by default.</param>
        /// <param name="BinaryType">Type of binary</param>
        /// <returns>Name of the binary</returns>
        public static string MakeBinaryFileName(string BinaryName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, UnrealTargetConfiguration UndecoratedConfiguration, UEBuildBinaryType BinaryType)
        {
            StringBuilder Result = new StringBuilder();

            if (Platform == UnrealTargetPlatform.Linux && (BinaryType == UEBuildBinaryType.DynamicLinkLibrary || BinaryType == UEBuildBinaryType.StaticLibrary))
            {
                Result.Append("lib");
            }

            Result.Append(BinaryName);

            if(Configuration != UndecoratedConfiguration)
            {
                Result.AppendFormat("-{0}-{1}", Platform.ToString(), Configuration.ToString());
            }

            IUEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(Platform);
            Result.Append(BuildPlatform.ApplyArchitectureName(""));

            if (BuildConfiguration.bRunUnrealCodeAnalyzer)
            {
                Result.AppendFormat("-{0}.analysis", BuildConfiguration.UCAModuleToAnalyze);
            }
            else
            {
                Result.Append(BuildPlatform.GetBinaryExtension(BinaryType));
            }

            return Result.ToString();
        }
	private void PackageIPA(string BaseDirectory, string GameName, string ProjectName, string ProjectDirectory, UnrealTargetConfiguration TargetConfig, bool Distribution = false)
	{
		// create the ipa
		string IPAName = CombinePaths(ProjectDirectory, "Binaries", PlatformName, (Distribution ? "Distro_" : "") + ProjectName + (TargetConfig != UnrealTargetConfiguration.Development ? ("-" + PlatformName + "-" + TargetConfig.ToString()) : "") + ".ipa");
		// delete the old one
		if (File.Exists(IPAName))
		{
			File.Delete(IPAName);
		}

		// make the subdirectory if needed
		string DestSubdir = Path.GetDirectoryName(IPAName);
		if (!Directory.Exists(DestSubdir))
		{
			Directory.CreateDirectory(DestSubdir);
		}

		// set up the directories
		string ZipWorkingDir = String.Format("Payload/{0}.app/", GameName);
		string ZipSourceDir = string.Format("{0}/Payload/{1}.app", BaseDirectory, GameName);

		// create the file
		using (ZipFile Zip = new ZipFile())
		{
            // Set encoding to support unicode filenames
            Zip.AlternateEncodingUsage = ZipOption.Always;
            Zip.AlternateEncoding = Encoding.UTF8;

			// set the compression level
			if (Distribution)
			{
				Zip.CompressionLevel = CompressionLevel.BestCompression;
			}

			// add the entire directory
			Zip.AddDirectory(ZipSourceDir, ZipWorkingDir);

			// Update permissions to be UNIX-style
			// Modify the file attributes of any added file to unix format
			foreach (ZipEntry E in Zip.Entries)
			{
				const byte FileAttributePlatform_NTFS = 0x0A;
				const byte FileAttributePlatform_UNIX = 0x03;
				const byte FileAttributePlatform_FAT = 0x00;

				const int UNIX_FILETYPE_NORMAL_FILE = 0x8000;
				//const int UNIX_FILETYPE_SOCKET = 0xC000;
				//const int UNIX_FILETYPE_SYMLINK = 0xA000;
				//const int UNIX_FILETYPE_BLOCKSPECIAL = 0x6000;
				const int UNIX_FILETYPE_DIRECTORY = 0x4000;
				//const int UNIX_FILETYPE_CHARSPECIAL = 0x2000;
				//const int UNIX_FILETYPE_FIFO = 0x1000;

				const int UNIX_EXEC = 1;
				const int UNIX_WRITE = 2;
				const int UNIX_READ = 4;


				int MyPermissions = UNIX_READ | UNIX_WRITE;
				int OtherPermissions = UNIX_READ;

				int PlatformEncodedBy = (E.VersionMadeBy >> 8) & 0xFF;
				int LowerBits = 0;

				// Try to preserve read-only if it was set
				bool bIsDirectory = E.IsDirectory;

				// Check to see if this 
				bool bIsExecutable = false;
				if (Path.GetFileNameWithoutExtension(E.FileName).Equals(GameName, StringComparison.InvariantCultureIgnoreCase))
				{
					bIsExecutable = true;
				}

				if (bIsExecutable)
				{
					// The executable will be encrypted in the final distribution IPA and will compress very poorly, so keeping it
					// uncompressed gives a better indicator of IPA size for our distro builds
					E.CompressionLevel = CompressionLevel.None;
				}

				if ((PlatformEncodedBy == FileAttributePlatform_NTFS) || (PlatformEncodedBy == FileAttributePlatform_FAT))
				{
					FileAttributes OldAttributes = E.Attributes;
					//LowerBits = ((int)E.Attributes) & 0xFFFF;

					if ((OldAttributes & FileAttributes.Directory) != 0)
					{
						bIsDirectory = true;
					}

					// Permissions
					if ((OldAttributes & FileAttributes.ReadOnly) != 0)
					{
						MyPermissions &= ~UNIX_WRITE;
						OtherPermissions &= ~UNIX_WRITE;
					}
				}

				if (bIsDirectory || bIsExecutable)
				{
					MyPermissions |= UNIX_EXEC;
					OtherPermissions |= UNIX_EXEC;
				}

				// Re-jigger the external file attributes to UNIX style if they're not already that way
				if (PlatformEncodedBy != FileAttributePlatform_UNIX)
				{
					int NewAttributes = bIsDirectory ? UNIX_FILETYPE_DIRECTORY : UNIX_FILETYPE_NORMAL_FILE;

					NewAttributes |= (MyPermissions << 6);
					NewAttributes |= (OtherPermissions << 3);
					NewAttributes |= (OtherPermissions << 0);

					// Now modify the properties
					E.AdjustExternalFileAttributes(FileAttributePlatform_UNIX, (NewAttributes << 16) | LowerBits);
				}
			}

			// Save it out
			Zip.Save(IPAName);
		}
	}
 protected string MakeIPAFileName( UnrealTargetConfiguration TargetConfiguration, string ProjectGameExeFilename )
 {
     var ProjectIPA = Path.ChangeExtension(ProjectGameExeFilename, null);
     if (TargetConfiguration != UnrealTargetConfiguration.Development)
     {
         ProjectIPA += "-" + PlatformType.ToString() + "-" + TargetConfiguration.ToString();
     }
     ProjectIPA += ".ipa";
     return ProjectIPA;
 }
 private void CodeSign(string BaseDirectory, string GameName, string RawProjectPath, UnrealTargetConfiguration TargetConfig, bool Distribution = false)
 {
     // check for the proper xcodeproject
     bool bWasGenerated = false;
     string XcodeProj = EnsureXcodeProjectExists (RawProjectPath, out bWasGenerated);
     string Arguments = "UBT_NO_POST_DEPLOY=true";
     Arguments += " /usr/bin/xcrun xcodebuild build -project \"" + XcodeProj + "\"";
     Arguments += " -scheme '";
     Arguments += GameName;
     Arguments += " - iOS (Run)'";
     Arguments += " -configuration " + TargetConfig.ToString();
     Arguments += " CODE_SIGN_IDENTITY=" + (Distribution ? "\"iPhone Distribution\"" : "\"iPhone Developer\"");
     Run ("/usr/bin/env", Arguments, null, ERunOptions.Default);
     if (bWasGenerated)
     {
         InternalUtils.SafeDeleteDirectory( XcodeProj, true);
     }
 }
Exemplo n.º 21
0
	private void CodeSign(string BaseDirectory, string GameName, string RawProjectPath, UnrealTargetConfiguration TargetConfig, string LocalRoot, string ProjectName, string ProjectDirectory, bool IsCode, bool Distribution = false)
	{
		// check for the proper xcodeproject
		bool bWasGenerated = false;
		string XcodeProj = EnsureXcodeProjectExists (RawProjectPath, LocalRoot, ProjectName, ProjectDirectory, IsCode, out bWasGenerated);

		string Arguments = "UBT_NO_POST_DEPLOY=true";
		Arguments += " /usr/bin/xcrun xcodebuild build -project \"" + XcodeProj + "\"";
		Arguments += " -scheme '";
		Arguments += GameName;
		Arguments += " - iOS'";
		Arguments += " -configuration " + TargetConfig.ToString();
		Arguments += " -sdk iphoneos";
		Arguments += " CODE_SIGN_IDENTITY=" + (Distribution ? "\"iPhone Distribution\"" : "\"iPhone Developer\"");
		ProcessResult Result = Run ("/usr/bin/env", Arguments, null, ERunOptions.Default);
		if (bWasGenerated)
		{
			InternalUtils.SafeDeleteDirectory( XcodeProj, true);
		}
		if (Result.ExitCode != 0)
		{
			throw new AutomationException(ErrorCodes.Error_FailedToCodeSign, "CodeSign Failed");
		}
	}
Exemplo n.º 22
0
        // Anonymous function that writes project configuration data
        private void WriteConfiguration(string ProjectName, UnrealTargetConfiguration Configuration, UnrealTargetPlatform Platform, string TargetFilePath, TargetRules TargetRulesObject, StringBuilder VCProjectFileContent, StringBuilder VCUserFileContent)
        {
            UEPlatformProjectGenerator ProjGenerator = UEPlatformProjectGenerator.GetPlatformProjectGenerator(Platform, true);
            if (((ProjGenerator == null) && (Platform != UnrealTargetPlatform.Unknown)))
            {
                return;
            }

            string UProjectPath = "";
            bool bIsProjectTarget = UnrealBuildTool.HasUProjectFile() && Utils.IsFileUnderDirectory(TargetFilePath, UnrealBuildTool.GetUProjectPath());

            // @todo Rocket: HACK: Only use long project names on the UBT command-line for out-of-root projects for now.  We need to revisit all uses of HasUProjectFile and short names in general to fix this.
            if (bIsProjectTarget && !UnrealBuildTool.RunningRocket() && Utils.IsFileUnderDirectory(UnrealBuildTool.GetUProjectFile(), ProjectFileGenerator.RootRelativePath))
            {
                bIsProjectTarget = false;
            }

            if (bIsProjectTarget)
            {
                UProjectPath = "\"$(SolutionDir)$(SolutionName).uproject\"";
            }

            string ProjectConfigName = StubProjectConfigurationName;
            string ProjectPlatformName = StubProjectPlatformName;
            MakeProjectPlatformAndConfigurationNames(Platform, Configuration, TargetRulesObject.ConfigurationName, out ProjectPlatformName, out ProjectConfigName);
            var ConfigAndPlatformName = ProjectConfigName + "|" + ProjectPlatformName;
            string ConditionString = "Condition=\"'$(Configuration)|$(Platform)'=='" + ConfigAndPlatformName + "'\"";

            {
                VCProjectFileContent.Append(
                    "	<ImportGroup " + ConditionString + " Label=\"PropertySheets\">" + ProjectFileGenerator.NewLine +
                    "		<Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />" + ProjectFileGenerator.NewLine +
                    "	</ImportGroup>" + ProjectFileGenerator.NewLine);

                VCProjectFileContent.Append(
                    "	<PropertyGroup " + ConditionString + ">" + ProjectFileGenerator.NewLine);

                if (IsStubProject)
                {
                    string ProjectRelativeUnusedDirectory = NormalizeProjectPath(Path.Combine(ProjectFileGenerator.EngineRelativePath, BuildConfiguration.BaseIntermediateFolder, "Unused"));

                    VCProjectFileContent.Append(
                        "		<OutDir></OutDir>" + ProjectFileGenerator.NewLine +
                        "		<IntDir>" + ProjectRelativeUnusedDirectory + Path.DirectorySeparatorChar + "</IntDir>" + ProjectFileGenerator.NewLine +
                        "		<NMakeBuildCommandLine/>" + ProjectFileGenerator.NewLine +
                        "		<NMakeReBuildCommandLine/>" + ProjectFileGenerator.NewLine +
                        "		<NMakeCleanCommandLine/>" + ProjectFileGenerator.NewLine +
                        "		<NMakeOutput/>" + ProjectFileGenerator.NewLine);
                }
                else
                {
                    string TargetName = Utils.GetFilenameWithoutAnyExtensions(TargetFilePath);
                    var UBTPlatformName = IsStubProject ? StubProjectPlatformName : Platform.ToString();
                    var UBTConfigurationName = IsStubProject ? StubProjectConfigurationName : Configuration.ToString();

                    // Setup output path
                    UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(Platform);

                    // Figure out if this is a monolithic build
                    bool bShouldCompileMonolithic = BuildPlatform.ShouldCompileMonolithicBinary(Platform);
                    bShouldCompileMonolithic |= TargetRulesObject.ShouldCompileMonolithic(Platform, Configuration);

                    // Get the output directory
                    string RootDirectory = Path.GetFullPath(ProjectFileGenerator.EngineRelativePath);
                    if ((TargetRules.IsAGame(TargetRulesObject.Type) || TargetRulesObject.Type == TargetRules.TargetType.Server) && bShouldCompileMonolithic && !TargetRulesObject.bOutputToEngineBinaries)
                    {
                        if (UnrealBuildTool.HasUProjectFile() && Utils.IsFileUnderDirectory(TargetFilePath, UnrealBuildTool.GetUProjectPath()))
                        {
                            RootDirectory = Path.GetFullPath(UnrealBuildTool.GetUProjectPath());
                        }
                        else
                        {
                            string UnrealProjectPath = UProjectInfo.GetProjectFilePath(ProjectName);
                            if (!String.IsNullOrEmpty(UnrealProjectPath))
                            {
                                RootDirectory = Path.GetDirectoryName(Path.GetFullPath(UnrealProjectPath));
                            }
                        }
                    }

                    // Get the output directory
                    string OutputDirectory = Path.Combine(RootDirectory, "Binaries", UBTPlatformName);

                    // Get the executable name (minus any platform or config suffixes)
                    string BaseExeName = TargetName;
                    if (!bShouldCompileMonolithic && TargetRulesObject.Type != TargetRules.TargetType.Program)
                    {
                        // Figure out what the compiled binary will be called so that we can point the IDE to the correct file
                        string TargetConfigurationName = TargetRulesObject.ConfigurationName;
                        if (TargetConfigurationName != TargetRules.TargetType.Game.ToString() && TargetConfigurationName != TargetRules.TargetType.RocketGame.ToString() && TargetConfigurationName != TargetRules.TargetType.Program.ToString())
                        {
                            BaseExeName = "UE4" + TargetConfigurationName;
                        }
                    }

                    // Make the output file path
                    string NMakePath = Path.Combine(OutputDirectory, BaseExeName);
                    if (Configuration != UnrealTargetConfiguration.Development && (Configuration != UnrealTargetConfiguration.DebugGame || bShouldCompileMonolithic))
                    {
                        NMakePath += "-" + UBTPlatformName + "-" + UBTConfigurationName;
                    }
                    NMakePath += BuildPlatform.GetActiveArchitecture();
                    NMakePath += BuildPlatform.GetBinaryExtension(UEBuildBinaryType.Executable);
                    NMakePath = BuildPlatform.ModifyNMakeOutput(NMakePath);

                    string PathStrings = (ProjGenerator != null) ? ProjGenerator.GetVisualStudioPathsEntries(Platform, Configuration, TargetRulesObject.Type, TargetFilePath, ProjectFilePath, NMakePath) : "";
                    if (string.IsNullOrEmpty(PathStrings) || (PathStrings.Contains("<IntDir>") == false))
                    {
                        string ProjectRelativeUnusedDirectory = "$(ProjectDir)..\\Build\\Unused";
                        VCProjectFileContent.Append(
                            PathStrings +
                            "		<OutDir>" + ProjectRelativeUnusedDirectory + Path.DirectorySeparatorChar + "</OutDir>" + ProjectFileGenerator.NewLine +
                            "		<IntDir>" + ProjectRelativeUnusedDirectory + Path.DirectorySeparatorChar + "</IntDir>" + ProjectFileGenerator.NewLine);
                    }
                    else
                    {
                        VCProjectFileContent.Append(PathStrings);
                    }

                    // Force specification of TargetName on XboxOne so that the manifest can identify the correct executable to the debugger.
                    if (Platform == UnrealTargetPlatform.XboxOne)
                    {
                        VCProjectFileContent.Append("		<TargetName>$(ProjectName)");
                        if (Configuration != UnrealTargetConfiguration.Development)
                        {
                            VCProjectFileContent.Append(UBTConfigurationName);
                        }
                        VCProjectFileContent.Append("</TargetName>" + ProjectFileGenerator.NewLine);
                    }

                    // This is the standard UE4 based project NMake build line:
                    //	..\..\Build\BatchFiles\Build.bat <TARGETNAME> <PLATFORM> <CONFIGURATION>
                    //	ie ..\..\Build\BatchFiles\Build.bat BlankProgram Win64 Debug

                    string ProjectPlatformConfiguration = " " + TargetName + " " + UBTPlatformName + " " + UBTConfigurationName;
                    string BatchFilesDirectoryName = Path.Combine(ProjectFileGenerator.EngineRelativePath, "Build", "BatchFiles");

                    // NMake Build command line
                    VCProjectFileContent.Append("		<NMakeBuildCommandLine>");
                    VCProjectFileContent.Append(EscapePath(NormalizeProjectPath(Path.Combine(BatchFilesDirectoryName, "Build.bat"))) + ProjectPlatformConfiguration.ToString());
                    if (bIsProjectTarget)
                    {
                        VCProjectFileContent.Append(" " + UProjectPath + (UnrealBuildTool.RunningRocket() ? " -rocket" : ""));
                    }
                    VCProjectFileContent.Append("</NMakeBuildCommandLine>" + ProjectFileGenerator.NewLine);

                    // NMake ReBuild command line
                    VCProjectFileContent.Append("		<NMakeReBuildCommandLine>");
                    VCProjectFileContent.Append(EscapePath(NormalizeProjectPath(Path.Combine(BatchFilesDirectoryName, "Rebuild.bat"))) + ProjectPlatformConfiguration.ToString());
                    if (bIsProjectTarget)
                    {
                        VCProjectFileContent.Append(" " + UProjectPath + (UnrealBuildTool.RunningRocket() ? " -rocket" : ""));
                    }
                    VCProjectFileContent.Append("</NMakeReBuildCommandLine>" + ProjectFileGenerator.NewLine);

                    // NMake Clean command line
                    VCProjectFileContent.Append("		<NMakeCleanCommandLine>");
                    VCProjectFileContent.Append(EscapePath(NormalizeProjectPath(Path.Combine(BatchFilesDirectoryName, "Clean.bat"))) + ProjectPlatformConfiguration.ToString());
                    if (bIsProjectTarget)
                    {
                        VCProjectFileContent.Append(" " + UProjectPath + (UnrealBuildTool.RunningRocket() ? " -rocket" : ""));
                    }
                    VCProjectFileContent.Append("</NMakeCleanCommandLine>" + ProjectFileGenerator.NewLine);
                    VCProjectFileContent.Append("		<NMakeOutput>");
                    VCProjectFileContent.Append(NormalizeProjectPath(NMakePath));
                    VCProjectFileContent.Append("</NMakeOutput>" + ProjectFileGenerator.NewLine);
                }
                VCProjectFileContent.Append("	</PropertyGroup>" + ProjectFileGenerator.NewLine);

                if (VCUserFileContent != null)
                {
                    if (UnrealBuildTool.HasUProjectFile())
                    {
                        if ((Platform == UnrealTargetPlatform.Win32) || (Platform == UnrealTargetPlatform.Win64))
                        {
                            VCUserFileContent.Append(
                                "	<PropertyGroup " + ConditionString + ">" + ProjectFileGenerator.NewLine);
                            if ((TargetRulesObject.Type != TargetRules.TargetType.RocketGame) && (TargetRulesObject.Type != TargetRules.TargetType.Game))
                            {
                                string DebugOptions = UProjectPath;

                                if(DebugOptions.Length == 0 && TargetRulesObject.Type == TargetRules.TargetType.Editor && ProjectName != "UE4")
                                {
                                    DebugOptions += ProjectName;
                                }

                                if (Configuration == UnrealTargetConfiguration.Debug || Configuration == UnrealTargetConfiguration.DebugGame)
                                {
                                    DebugOptions += " -debug";
                                }
                                else if (Configuration == UnrealTargetConfiguration.Shipping)
                                {
                                    DebugOptions += " -shipping";
                                }

                                VCUserFileContent.Append(
                                    "		<LocalDebuggerCommandArguments>" + DebugOptions + "</LocalDebuggerCommandArguments>" + ProjectFileGenerator.NewLine
                                    );
                            }
                            VCUserFileContent.Append(
                                "		<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>" + ProjectFileGenerator.NewLine
                                );
                            VCUserFileContent.Append(
                                "	</PropertyGroup>" + ProjectFileGenerator.NewLine
                                );
                        }
                    }

                    string PlatformUserFileStrings = (ProjGenerator != null) ? ProjGenerator.GetVisualStudioUserFileStrings(Platform, Configuration, ConditionString, TargetRulesObject, TargetFilePath, ProjectFilePath) : "";
                    VCUserFileContent.Append(PlatformUserFileStrings);
                }
            }

            string LayoutDirString = (ProjGenerator != null) ? ProjGenerator.GetVisualStudioLayoutDirSection(Platform, Configuration, ConditionString, TargetRulesObject.Type, TargetFilePath, ProjectFilePath) : "";
            VCProjectFileContent.Append(LayoutDirString);
        }
Exemplo n.º 23
0
        private FileReference GetExecutableFilename(ProjectFile Project, ProjectTarget Target, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration)
        {
            TargetRules   TargetRulesObject = Target.TargetRules;
            FileReference TargetFilePath    = Target.TargetFilePath;
            string        TargetName        = TargetFilePath == null?Project.ProjectFilePath.GetFileNameWithoutExtension() : TargetFilePath.GetFileNameWithoutAnyExtensions();

            string UBTPlatformName      = Platform.ToString();
            string UBTConfigurationName = Configuration.ToString();

            string ProjectName = Project.ProjectFilePath.GetFileNameWithoutExtension();

            // Setup output path
            UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(Platform);

            // Figure out if this is a monolithic build
            bool bShouldCompileMonolithic = BuildPlatform.ShouldCompileMonolithicBinary(Platform);

            if (TargetRulesObject != null)
            {
                bShouldCompileMonolithic |= (Target.CreateRulesDelegate(Platform, Configuration).GetLegacyLinkType(Platform, Configuration) == TargetLinkType.Monolithic);
            }

            TargetType TargetRulesType = Target.TargetRules == null ? TargetType.Program : Target.TargetRules.Type;

            // Get the output directory
            DirectoryReference RootDirectory = UnrealBuildTool.EngineDirectory;

            if (TargetRulesType != TargetType.Program && (bShouldCompileMonolithic || TargetRulesObject.BuildEnvironment == TargetBuildEnvironment.Unique) && !TargetRulesObject.bOutputToEngineBinaries)
            {
                if (OnlyGameProject != null && TargetFilePath.IsUnderDirectory(OnlyGameProject.Directory))
                {
                    RootDirectory = OnlyGameProject.Directory;
                }
                else
                {
                    FileReference ProjectFileName;
                    if (UProjectInfo.TryGetProjectFileName(ProjectName, out ProjectFileName))
                    {
                        RootDirectory = ProjectFileName.Directory;
                    }
                }
            }

            if (TargetRulesType == TargetType.Program && (TargetRulesObject == null || !TargetRulesObject.bOutputToEngineBinaries))
            {
                FileReference ProjectFileName;
                if (UProjectInfo.TryGetProjectForTarget(TargetName, out ProjectFileName))
                {
                    RootDirectory = ProjectFileName.Directory;
                }
            }

            // Get the output directory
            DirectoryReference OutputDirectory = DirectoryReference.Combine(RootDirectory, "Binaries", UBTPlatformName);

            // Get the executable name (minus any platform or config suffixes)
            string BaseExeName = TargetName;

            if (!bShouldCompileMonolithic && TargetRulesType != TargetType.Program)
            {
                // Figure out what the compiled binary will be called so that we can point the IDE to the correct file
                string TargetConfigurationName = TargetRulesType.ToString();
                if (TargetConfigurationName != TargetType.Game.ToString() && TargetConfigurationName != TargetType.Program.ToString())
                {
                    BaseExeName = "UE4" + TargetConfigurationName;
                }
            }

            // Make the output file path
            string ExecutableFilename = FileReference.Combine(OutputDirectory, BaseExeName).ToString();

            if ((Configuration != UnrealTargetConfiguration.DebugGame || bShouldCompileMonolithic))
            {
                ExecutableFilename += "-" + UBTPlatformName + "-" + UBTConfigurationName;
            }
            ExecutableFilename += TargetRulesObject.Architecture;
            ExecutableFilename += BuildPlatform.GetBinaryExtension(UEBuildBinaryType.Executable);

            return(FileReference.MakeFromNormalizedFullPath(ExecutableFilename));
        }