You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- PR #861 contributed by salamanderrake. https://github.com/EpicGames/UnrealEngine/pull/861 [CL 2473402 by Dmitry Rekman in Main branch]
191 lines
7.5 KiB
C#
191 lines
7.5 KiB
C#
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.IO;
|
|
|
|
namespace UnrealBuildTool
|
|
{
|
|
/// <summary>
|
|
/// Represents a folder within the master project (e.g. Visual Studio solution)
|
|
/// </summary>
|
|
public class MakefileFolder : MasterProjectFolder
|
|
{
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
public MakefileFolder( ProjectFileGenerator InitOwnerProjectFileGenerator, string InitFolderName )
|
|
: base(InitOwnerProjectFileGenerator, InitFolderName)
|
|
{
|
|
}
|
|
}
|
|
|
|
public class MakefileProjectFile : ProjectFile
|
|
{
|
|
public MakefileProjectFile( string InitFilePath )
|
|
: base(InitFilePath)
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Makefile project file generator implementation
|
|
/// </summary>
|
|
public class MakefileGenerator : ProjectFileGenerator
|
|
{
|
|
/// True if intellisense data should be generated (takes a while longer)
|
|
bool bGenerateIntelliSenseData = false;
|
|
|
|
/// True if we should include IntelliSense data in the generated project files when possible
|
|
override public bool ShouldGenerateIntelliSenseData()
|
|
{
|
|
return bGenerateIntelliSenseData;
|
|
}
|
|
|
|
/// File extension for project files we'll be generating (e.g. ".vcxproj")
|
|
override public string ProjectFileExtension
|
|
{
|
|
get
|
|
{
|
|
return ".mk";
|
|
}
|
|
}
|
|
|
|
protected override bool WriteMasterProjectFile( ProjectFile UBTProject )
|
|
{
|
|
bool bSuccess = true;
|
|
return bSuccess;
|
|
}
|
|
|
|
private bool WriteMakefile()
|
|
{
|
|
string GameProjectFile = "";
|
|
string BuildCommand = "";
|
|
string ProjectBuildCommand = "";
|
|
|
|
string MakeGameProjectFile = "";
|
|
|
|
var UnrealRootPath = Path.GetFullPath(ProjectFileGenerator.RootRelativePath);
|
|
|
|
if (!String.IsNullOrEmpty(GameProjectName))
|
|
{
|
|
GameProjectFile = UnrealBuildTool.GetUProjectFile();
|
|
MakeGameProjectFile = "GAMEPROJECTFILE =" + GameProjectFile + "\n";
|
|
ProjectBuildCommand = "PROJECTBUILD = mono $(UNREALROOTPATH)/Engine/Binaries/DotNET/UnrealBuildTool.exe\n";
|
|
}
|
|
|
|
BuildCommand = "BUILD = bash $(UNREALROOTPATH)/Engine/Build/BatchFiles/Linux/Build.sh\n";
|
|
|
|
var FileName = "Makefile"; // MasterProjectName + ".mk";
|
|
var MakefileContent = new StringBuilder();
|
|
MakefileContent.Append(
|
|
"# Makefile generated by MakefileGenerator.cs\n" +
|
|
"# *DO NOT EDIT*\n\n" +
|
|
"UNREALROOTPATH = \"" + UnrealRootPath + "\"\n" +
|
|
MakeGameProjectFile + "\n" +
|
|
"TARGETS ="
|
|
);
|
|
String MakeProjectCmdArg = "";
|
|
String MakeBuildCommand = "";
|
|
foreach (string Target in DiscoverTargets())
|
|
{
|
|
var Basename = Path.GetFileNameWithoutExtension(Target);
|
|
Basename = Path.GetFileNameWithoutExtension(Basename);
|
|
foreach (UnrealTargetConfiguration CurConfiguration in Enum.GetValues(typeof(UnrealTargetConfiguration)))
|
|
{
|
|
if (CurConfiguration != UnrealTargetConfiguration.Unknown && CurConfiguration != UnrealTargetConfiguration.Development)
|
|
{
|
|
if (UnrealBuildTool.IsValidConfiguration(CurConfiguration))
|
|
{
|
|
var Confname = Enum.GetName(typeof(UnrealTargetConfiguration), CurConfiguration);
|
|
MakefileContent.Append(String.Format(" \\\n\t{0}-Linux-{1} ", Basename, Confname));
|
|
}
|
|
}
|
|
}
|
|
MakefileContent.Append(" \\\n\t" + Basename);
|
|
}
|
|
MakefileContent.Append("\\\n\tconfigure");
|
|
|
|
MakefileContent.Append("\n\n" + BuildCommand + ProjectBuildCommand + "\n" +
|
|
"all: $(TARGETS)\n"
|
|
);
|
|
|
|
foreach (string Target in DiscoverTargets())
|
|
{
|
|
var Basename = Path.GetFileNameWithoutExtension(Target);
|
|
Basename = Path.GetFileNameWithoutExtension(Basename);
|
|
foreach (UnrealTargetConfiguration CurConfiguration in Enum.GetValues(typeof(UnrealTargetConfiguration)))
|
|
{
|
|
if (Basename == GameProjectName || Basename == (GameProjectName + "Editor"))
|
|
{
|
|
MakeProjectCmdArg = " -project=\"\\\"$(GAMEPROJECTFILE)\\\"\"";
|
|
MakeBuildCommand = "$(PROJECTBUILD)";
|
|
}
|
|
else
|
|
{
|
|
MakeBuildCommand = "$(BUILD)";
|
|
}
|
|
|
|
if (CurConfiguration != UnrealTargetConfiguration.Unknown && CurConfiguration != UnrealTargetConfiguration.Development)
|
|
{
|
|
if (UnrealBuildTool.IsValidConfiguration(CurConfiguration))
|
|
{
|
|
var Confname = Enum.GetName(typeof(UnrealTargetConfiguration), CurConfiguration);
|
|
MakefileContent.Append(String.Format("\n{1}-Linux-{2}:\n\t {0} {1} Linux {2} {3} $(ARGS)\n", MakeBuildCommand, Basename, Confname, MakeProjectCmdArg));
|
|
}
|
|
}
|
|
}
|
|
|
|
MakefileContent.Append(String.Format("\n{1}:\n\t {0} {1} Linux Development {2} $(ARGS)\n", MakeBuildCommand, Basename, MakeProjectCmdArg));
|
|
}
|
|
|
|
MakefileContent.Append("\nconfigure:\n");
|
|
if (!String.IsNullOrEmpty (GameProjectName))
|
|
{
|
|
// Make sure UBT is updated.
|
|
MakefileContent.Append("\txbuild /property:Configuration=Development /property:TargetFrameworkVersion=v4.0 /verbosity:quiet /nologo ");
|
|
MakefileContent.Append("$(UNREALROOTPATH)/Engine/Source/Programs/UnrealBuildTool/UnrealBuildTool_Mono.csproj\n");
|
|
MakefileContent.Append("\t$(PROJECTBUILD) -makefile -qmakefile -cmakefile -project=\"\\\"$(GAMEPROJECTFILE)\\\"\" -game -engine \n");
|
|
}
|
|
else
|
|
{
|
|
MakefileContent.Append("\tbash $(UNREALROOTPATH)/GenerateProjectFiles.sh \n");
|
|
}
|
|
|
|
MakefileContent.Append("\n.PHONY: $(TARGETS)\n");
|
|
var FullFileName = Path.Combine(MasterProjectRelativePath, FileName);
|
|
return WriteFileIfChanged(FullFileName, MakefileContent.ToString());
|
|
}
|
|
|
|
/// ProjectFileGenerator interface
|
|
//protected override bool WriteMasterProjectFile( ProjectFile UBTProject )
|
|
protected override bool WriteProjectFiles()
|
|
{
|
|
return WriteMakefile();
|
|
}
|
|
|
|
/// ProjectFileGenerator interface
|
|
public override MasterProjectFolder AllocateMasterProjectFolder( ProjectFileGenerator InitOwnerProjectFileGenerator, string InitFolderName )
|
|
{
|
|
return new MakefileFolder( InitOwnerProjectFileGenerator, InitFolderName );
|
|
}
|
|
|
|
/// ProjectFileGenerator interface
|
|
/// <summary>
|
|
/// Allocates a generator-specific project file object
|
|
/// </summary>
|
|
/// <param name="InitFilePath">Path to the project file</param>
|
|
/// <returns>The newly allocated project file object</returns>
|
|
protected override ProjectFile AllocateProjectFile( string InitFilePath )
|
|
{
|
|
return new MakefileProjectFile( InitFilePath );
|
|
}
|
|
|
|
/// ProjectFileGenerator interface
|
|
public override void CleanProjectFiles(string InMasterProjectRelativePath, string InMasterProjectName, string InIntermediateProjectFilesPath)
|
|
{
|
|
}
|
|
}
|
|
}
|