コード例 #1
0
		private void PopulateTargets(List<string> GamePaths, List<XcodeProjectTarget> ProjectTargets, List<XcodeContainerItemProxy> ContainerItemProxies, List<XcodeTargetDependency> TargetDependencies, XcodeProjectTarget ProjectTarget, List<XcodeFramework> Frameworks)
		{
			foreach (string TargetPath in GamePaths)
			{
				string TargetName = Utils.GetFilenameWithoutAnyExtensions(Path.GetFileName(TargetPath));
				bool WantProjectFileForTarget = true;
				bool IsEngineTarget = false;
				if (bGeneratingGameProjectFiles || bGeneratingRocketProjectFiles)
				{
					// Check to see if this is an Engine target.  That is, the target is located under the "Engine" folder
					string TargetFileRelativeToEngineDirectory = Utils.MakePathRelativeTo(TargetPath, Path.Combine(EngineRelativePath), AlwaysTreatSourceAsDirectory: false);
					if (!TargetFileRelativeToEngineDirectory.StartsWith("..") && !Path.IsPathRooted(TargetFileRelativeToEngineDirectory))
					{
						// This is an engine target
						IsEngineTarget = true;
					}

					if (IsEngineTarget)
					{
						if (!IncludeEngineSource)
						{
							// We were asked to exclude engine modules from the generated projects
							WantProjectFileForTarget = false;
						}
						if (bGeneratingGameProjectFiles && this.GameProjectName == TargetName)
						{
							WantProjectFileForTarget = true;
						}
					}

					if (bGeneratingRocketProjectFiles && TargetName.EndsWith("Server"))
					{
						WantProjectFileForTarget = false;
					}
				}

				if (WantProjectFileForTarget)
				{
					string TargetFilePath;
					var Target = new TargetInfo(UnrealTargetPlatform.Mac, UnrealTargetConfiguration.Development);
					var TargetRulesObject = RulesCompiler.CreateTargetRules(TargetName, Target, false, out TargetFilePath);
					List<UnrealTargetPlatform> SupportedPlatforms = new List<UnrealTargetPlatform>();
					TargetRulesObject.GetSupportedPlatforms(ref SupportedPlatforms);
					LinkEnvironmentConfiguration LinkConfiguration = new LinkEnvironmentConfiguration();
					CPPEnvironmentConfiguration CPPConfiguration = new CPPEnvironmentConfiguration();
					TargetRulesObject.SetupGlobalEnvironment(Target, ref LinkConfiguration, ref CPPConfiguration);

					if (!LinkConfiguration.bIsBuildingConsoleApplication)
					{
						TargetsThatNeedApp.Add(TargetName);
					}

					// if the project is not an engine project check to make sure we have the correct name
					string DisplayName = TargetName;
					if (!IsEngineTarget && TargetRulesObject.Type != TargetRules.TargetType.Program && TargetRulesObject.Type != TargetRules.TargetType.Client)
					{
						List<UProjectInfo> AllGames = UProjectInfo.FilterGameProjects(true, bGeneratingGameProjectFiles ? GameProjectName : null);
						UProjectInfo ProjectInfo = FindGameContainingFile (AllGames, TargetFilePath);
						if (ProjectInfo != null)
						{
							DisplayName = ProjectInfo.GameName;
							if (TargetName.Contains("Editor"))
							{
								DisplayName += "Editor";
							}
							else if (TargetName.Contains("Server"))
							{
								DisplayName += "Server";
							}
						}
					}

					// @todo: Remove target platform param and merge Mac and iOS targets. For now BuildTarget knows how to build iOS, but cannot run iOS apps, so we need separate DeployTarget.
					bool bIsMacOnly = !SupportedPlatforms.Contains(UnrealTargetPlatform.IOS);

					XcodeProjectTarget BuildTarget = new XcodeProjectTarget(DisplayName + " - Mac", TargetName, XcodeTargetType.Legacy, TargetFilePath, "", UnrealTargetPlatform.Mac, bIsMacOnly);
					if (!bGeneratingRunIOSProject)
					{
						ProjectTargets.Add(BuildTarget);
					}

					if (ProjectFilePlatform.HasFlag(XcodeProjectFilePlatform.iOS) && SupportedPlatforms.Contains(UnrealTargetPlatform.IOS))
					{
						if ((bGeneratingRocketProjectFiles && TargetName == "UE4Game") || bGeneratingRunIOSProject)
						{
							// Generate Framework references.
							List<XcodeFrameworkRef> FrameworkRefs = new List<XcodeFrameworkRef>();
							foreach (XcodeFramework Framework in Frameworks)
							{
								FrameworkRefs.Add(new XcodeFrameworkRef(Framework));
							}

							XcodeProjectTarget IOSDeployTarget = new XcodeProjectTarget(DisplayName + " - iOS", TargetName, XcodeTargetType.Native, TargetFilePath, TargetName + ".app", UnrealTargetPlatform.IOS, false, null, true, FrameworkRefs);
							ProjectTargets.Add(IOSDeployTarget);
						}
						else
						{
							XcodeContainerItemProxy ContainerProxy = new XcodeContainerItemProxy(ProjectTarget.Guid, BuildTarget.Guid, BuildTarget.DisplayName);
							XcodeTargetDependency TargetDependency = new XcodeTargetDependency(BuildTarget.DisplayName, BuildTarget.Guid, ContainerProxy.Guid);
							XcodeProjectTarget IOSDeployTarget = new XcodeProjectTarget(DisplayName + " - iOS", TargetName, XcodeTargetType.Native, TargetFilePath, TargetName + ".app", UnrealTargetPlatform.IOS, false, new List<XcodeTargetDependency>() { TargetDependency }, true);
							ProjectTargets.Add(IOSDeployTarget);
							ContainerItemProxies.Add(ContainerProxy);
							TargetDependencies.Add(TargetDependency);
						}
					}
				}
			}
		}
コード例 #2
0
        private void PopulateTargets(List<string> GamePaths, List<XcodeProjectTarget> ProjectTargets, List<XcodeContainerItemProxy> ContainerItemProxies, List<XcodeTargetDependency> TargetDependencies, XcodeProjectTarget ProjectTarget, List<XcodeFramework> Frameworks)
        {
            foreach (string TargetPath in GamePaths)
            {
                string TargetName = Path.GetFileName(TargetPath);
                TargetName = TrimTargetCs(TargetName);
                if (ExternalExecution.GetRuntimePlatform() == UnrealTargetPlatform.Mac)
                {
                    bool WantProjectFileForTarget = true;
                    if( bGeneratingGameProjectFiles || bGeneratingRocketProjectFiles )
                    {
                        bool IsEngineTarget = false;

                        // Check to see if this is an Engine target.  That is, the target is located under the "Engine" folder
                        string TargetFileRelativeToEngineDirectory = Utils.MakePathRelativeTo( TargetPath, Path.Combine( EngineRelativePath ), AlwaysTreatSourceAsDirectory: false );
                        if( !TargetFileRelativeToEngineDirectory.StartsWith( ".." ) && !Path.IsPathRooted( TargetFileRelativeToEngineDirectory ) )
                        {
                            // This is an engine target
                            IsEngineTarget = true;
                        }

                        if( IsEngineTarget )
                        {
                            if (!bAlwaysIncludeEngineModules)
                            {
                                // We were asked to exclude engine modules from the generated projects
                                WantProjectFileForTarget = false;
                            }
                            if (bGeneratingGameProjectFiles && this.GameProjectName == TargetName)
                            {
                                WantProjectFileForTarget = true;
                            }
                        }
                    }

                    if( WantProjectFileForTarget )
                    {
                        string MacTargetRun = "";
                        string IOSTargetRun = " (Run)";
                        string IOSTargetBuild = " (Build)";
                        if (ProjectFilePlatform.HasFlag(XcodeProjectFilePlatform.All))
                        {
                            MacTargetRun = " - Mac";
                            IOSTargetRun = " - iOS (Run)";
                            IOSTargetBuild = " - iOS (Build)";
                        }

                        string TargetFilePath;
                        var Target = new TargetInfo(UnrealTargetPlatform.Mac, UnrealTargetConfiguration.Development);
                        var TargetRulesObject = RulesCompiler.CreateTargetRules( TargetName, Target, false, out TargetFilePath );
                        List<UnrealTargetPlatform> SupportedPlatforms = new List<UnrealTargetPlatform>();
                        TargetRulesObject.GetSupportedPlatforms(ref SupportedPlatforms);
                        LinkEnvironmentConfiguration LinkConfiguration = new LinkEnvironmentConfiguration();
                        CPPEnvironmentConfiguration CPPConfiguration = new CPPEnvironmentConfiguration();
                        TargetRulesObject.SetupGlobalEnvironment(Target, ref LinkConfiguration, ref CPPConfiguration);

                        if (!LinkConfiguration.bIsBuildingConsoleApplication)
                        {
                            TargetsThatNeedApp.Add(TargetName);
                        }

                        if (ProjectFilePlatform.HasFlag(XcodeProjectFilePlatform.Mac) && SupportedPlatforms.Contains(UnrealTargetPlatform.Mac))
                        {
                            XcodeProjectTarget MacBuildTarget = new XcodeProjectTarget(TargetName + MacTargetRun, TargetName, "Legacy");
                            ProjectTargets.Add(MacBuildTarget);
                        }

                        if (ProjectFilePlatform.HasFlag(XcodeProjectFilePlatform.iOS) && SupportedPlatforms.Contains(UnrealTargetPlatform.IOS))
                        {
                            if (bGeneratingRocketProjectFiles && TargetName == "UE4Game")
                            {
                                // Generate Framework references.
                                List<XcodeFrameworkRef> FrameworkRefs = new List<XcodeFrameworkRef>();
                                foreach (XcodeFramework Framework in Frameworks)
                                {
                                    FrameworkRefs.Add(new XcodeFrameworkRef(Framework));
                                }

                                XcodeProjectTarget IOSDeployTarget = new XcodeProjectTarget(TargetName + IOSTargetRun, TargetName, "Native", TargetName + ".app", UnrealTargetPlatform.IOS, null, true, FrameworkRefs);
                                ProjectTargets.Add(IOSDeployTarget);
                            }
                            else
                            {
                                XcodeProjectTarget IOSBuildTarget = new XcodeProjectTarget(TargetName + IOSTargetBuild, TargetName, "Legacy", "", UnrealTargetPlatform.IOS);
                                XcodeContainerItemProxy ContainerProxy = new XcodeContainerItemProxy(ProjectTarget.Guid, IOSBuildTarget.Guid, IOSBuildTarget.DisplayName);
                                XcodeTargetDependency TargetDependency = new XcodeTargetDependency(IOSBuildTarget.DisplayName, IOSBuildTarget.Guid, ContainerProxy.Guid);
                                XcodeProjectTarget IOSDeployTarget = new XcodeProjectTarget(TargetName + IOSTargetRun, TargetName, "Native", TargetName + ".app", UnrealTargetPlatform.IOS, new List<XcodeTargetDependency>() { TargetDependency }, true);
                                ProjectTargets.Add(IOSBuildTarget);
                                ProjectTargets.Add(IOSDeployTarget);
                                ContainerItemProxies.Add(ContainerProxy);
                                TargetDependencies.Add(TargetDependency);
                            }
                        }
                    }
                }
                else // when building on PC, only the code signing targets are needed
                {
                    string TargetFilePath;
                    TargetRules TargetRulesObject = RulesCompiler.CreateTargetRules(TargetName, new TargetInfo(UnrealTargetPlatform.IOS, UnrealTargetConfiguration.Development), false, out TargetFilePath);

                    if (TargetRulesObject.SupportsPlatform(UnrealTargetPlatform.IOS))
                    {
                        // Generate Framework references.
                        List<XcodeFrameworkRef> FrameworkRefs = new List<XcodeFrameworkRef>();
                        foreach (XcodeFramework Framework in Frameworks)
                        {
                            FrameworkRefs.Add(new XcodeFrameworkRef(Framework));
                        }

                        XcodeProjectTarget IOSDeployTarget = new XcodeProjectTarget(TargetName + "_RunIOS", TargetName, "Native", TargetName + ".app", UnrealTargetPlatform.IOS, null, true, FrameworkRefs);
                        ProjectTargets.Add(IOSDeployTarget);
                    }
                }
            }
        }