813 lines
34 KiB
C#
813 lines
34 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Sharpmake;
|
|
|
|
namespace JustDance.Engine
|
|
{
|
|
[Generate]
|
|
public class BaseCppProject : BaseCppProjectGeneric<BaseCppTarget>
|
|
{
|
|
public BaseCppProject()
|
|
{
|
|
AddTargets(GetDefaultTargets());
|
|
}
|
|
}
|
|
|
|
|
|
public class BaseCppProjectGeneric<T> : Project where T : BaseCppTarget
|
|
{
|
|
public static readonly string BranchRoot = Globals.BranchRoot;
|
|
|
|
public static readonly string SourcePath = BranchRoot + @"src\";
|
|
|
|
public static readonly string ToolsPath = BranchRoot + @"tools\";
|
|
|
|
public static readonly string ExternPath = BranchRoot + @"extern\";
|
|
|
|
public static readonly string DeploymentFilesPath = BranchRoot + @"gameroot\";
|
|
|
|
public static readonly string BuildPath = BranchRoot + @"build\";
|
|
|
|
public static readonly string OutputPath = BranchRoot + @"output\";
|
|
|
|
public static readonly string UnitTestsPath = BranchRoot + @"unittests\";
|
|
|
|
protected BaseCppProjectGeneric()
|
|
: base(typeof(T))
|
|
{
|
|
SourceRootPath = @"[project.RootPath]";
|
|
OutputType = Configuration.OutputType.Lib;
|
|
// PerforceRootPath = null;
|
|
IsFileNameToLower = false;
|
|
|
|
ResourceFilesExtensions.Add(".ico");
|
|
ResourceFilesExtensions.Add(".cfg");
|
|
ResourceFilesExtensions.Add(".def");
|
|
|
|
ExtensionBuildTools.Add(".ico", "None");
|
|
ExtensionBuildTools.Add(".def", "None");
|
|
ExtensionBuildTools.Add(".cfg", "None");
|
|
ExtensionBuildTools.Add(".png", "Image");
|
|
ExtensionBuildTools.Add(".txt", "Text");
|
|
|
|
BlobPath = BuildPath + @"blobs\[project.Name]";
|
|
BlobSize = 64*1024;
|
|
BlobSizeOverflow = 4 * 1024;
|
|
BlobPragmaMessageEnabled = false;
|
|
}
|
|
|
|
public string PrecompileHeader { get; set; }
|
|
|
|
public Configuration.OutputType OutputType { get; set; }
|
|
|
|
public bool ObjsInSubdirectories { get; set; }
|
|
|
|
[Configure]
|
|
public virtual void ConfigureAll(Configuration conf, T target)
|
|
{
|
|
conf.Output = OutputType;
|
|
Clean(conf, target);
|
|
ConfigurePathsAndNames(conf, target);
|
|
ConfigureIncludes(conf, target);
|
|
ConfigureDefines(conf, target);
|
|
ConfigureCompilerOptions(conf, target);
|
|
ConfigureLinkerOptions(conf, target);
|
|
ConfigurePlatformFilters(conf, target);
|
|
ConfigureDeployment(conf, target);
|
|
|
|
if (!string.IsNullOrEmpty(PrecompileHeader))
|
|
{
|
|
conf.PrecompSource = PrecompileHeader.Replace(".cpp", "").Replace(".h", "") + ".cpp";
|
|
conf.PrecompHeader = PrecompileHeader.Replace(".cpp", "").Replace(".h", "") + ".h";
|
|
}
|
|
conf.SourceFilesBuildExcludeRegex.Add("blob_");
|
|
|
|
if (target.Optimization == Optimization.Debug)
|
|
{
|
|
conf.DefaultOption = Options.DefaultTarget.Debug;
|
|
}
|
|
else
|
|
{
|
|
conf.DefaultOption = Options.DefaultTarget.Release;
|
|
}
|
|
|
|
}
|
|
|
|
protected virtual void ConfigurePathsAndNames(Configuration conf, T target)
|
|
{
|
|
conf.ProjectFileName = "[project.Name]";
|
|
conf.IntermediatePath = OutputPath + @"tmp\[project.Name]\[target.Platform]_[target.DevEnv]_[conf.Name]";
|
|
conf.ProjectPath = BuildPath + @"projects\[target.DevEnv]";
|
|
if (OutputType == Configuration.OutputType.Exe)
|
|
{
|
|
if (target.Platform.IsWindows())
|
|
{
|
|
conf.TargetPath = OutputPath + @"\bin\" + target.NameWithoutApplicationType();
|
|
}
|
|
else
|
|
{
|
|
conf.TargetPath = OutputPath + @"\bin\[conf.Name]\Platforms\" + GetTargetPlatformName(conf, target);
|
|
}
|
|
}
|
|
else if ( OutputType == Configuration.OutputType.Lib ||
|
|
OutputType == Configuration.OutputType.Dll ||
|
|
OutputType == Configuration.OutputType.DotNetClassLibrary)
|
|
{
|
|
conf.TargetPath = OutputPath + @"\lib\";
|
|
}
|
|
conf.TargetFileName = string.Format("{0}_{1}_{2}", GetTargetPlatformName(conf, target), ResolveString(Name).Replace(".", "_"), target.Optimization.GetLibrarySuffix());
|
|
conf.TargetFilePrefix = "";
|
|
|
|
if (ObjsInSubdirectories)
|
|
{
|
|
conf.ObjectFileName = filenameRelative => "$(IntDir)/" + Path.GetDirectoryName(filenameRelative) + "/";
|
|
}
|
|
}
|
|
|
|
protected virtual void ConfigureIncludes(Configuration conf, T target)
|
|
{
|
|
conf.IncludePaths.Add(SourceRootPath);
|
|
|
|
if (conf.Platform.IsWindows())
|
|
{
|
|
conf.IncludePaths.Add(@"$(DXSDK_DIR)\Include", @"$(DXSDK_DIR)\Extras\DirectShow\Include", ExternPath + @"Camcam/LIBS/DX9_Aug_2007/Include", @"$(WindowsSdkDir)\common\include", ExternPath + "UplaySDK/include", ExternPath + @"KinectPC_Sdk\v1.8\inc");
|
|
}
|
|
else if (conf.Platform == Platform.orbis)
|
|
{
|
|
conf.IncludePaths.Add(ExternPath + "PS4_SDK_Patches/include");
|
|
}
|
|
// else if (conf.Platform == Platform.durango)
|
|
// {
|
|
// conf.Options.Add(new Durango.Options.SDKReferences("Xbox Services API, Version=8.0"));
|
|
// }
|
|
|
|
if (target.IsPcStandalone())
|
|
{
|
|
//To support directx 11 we need to take latest headers. WindowsSDK_IncludePath needs to be before including dx sdk paths. Thus pushing it to the top.
|
|
conf.IncludePaths.Add(@"$(WindowsSDK_IncludePath)", -1);
|
|
}
|
|
}
|
|
|
|
protected virtual void ConfigureDefines(Configuration conf, T target)
|
|
{
|
|
if (target.Optimization == Optimization.Debug)
|
|
{
|
|
conf.Defines.Add("ITF_DEBUG");
|
|
}
|
|
else if (target.Optimization == Optimization.Release)
|
|
{
|
|
conf.Defines.Add("ITF_RELEASE");
|
|
}
|
|
else if (target.Optimization == Optimization.Retail)
|
|
{
|
|
conf.Defines.Add("ITF_RETAIL", "ITF_FINAL");
|
|
}
|
|
|
|
conf.Defines.Add(string.Format("ITF_PROJECT_{0}", Globals.CurrentProjectName.ToUpper()));
|
|
conf.Defines.Add(string.Format("ITF_PROJECT={0}", Globals.CurrentProjectName.ToUpper()));
|
|
conf.Defines.Add(string.Format("ITF_PROJECTID={0}", Globals.CurrentProjectId.ToUpper()));
|
|
|
|
if (target.Platform == Platform.win32)
|
|
{
|
|
conf.Defines.Add("ITF_WINDOWS", "WIN32", "ITF_WIN32", "ITF_MICROSOFT", "_CRT_SECURE_NO_WARNINGS");
|
|
if (target.DevEnv == DevEnv.vs2012 || target.DevEnv == DevEnv.vs2015 || target.DevEnv == DevEnv.vs2017)
|
|
{
|
|
conf.Defines.Add("_VARIADIC_MAX=10"); // Needed for compiling unit tests
|
|
}
|
|
}
|
|
else if (target.Platform == Platform.win64)
|
|
{
|
|
conf.Defines.Add("ITF_WINDOWS", "WIN64", "ITF_WIN64", "ITF_MICROSOFT", "_CRT_SECURE_NO_WARNINGS");
|
|
}
|
|
/*
|
|
else if (target.Platform == Platform.durango)
|
|
{
|
|
conf.Defines.Add("ITF_DURANGO", "WINAPI_FAMILY=WINAPI_FAMILY_TV_TITLE", "__WRL_NO_DEFAULT_LIB__", "UNICODE", "_UNICODE", "ITF_MICROSOFT");
|
|
}
|
|
else if (target.Platform == Platform.orbis)
|
|
{
|
|
conf.Defines.Add("ITF_ORBIS", "SN_TARGET_ORBIS", "__clang__");
|
|
}
|
|
else if (target.Platform == Platform.nx)
|
|
{
|
|
conf.Defines.Add("ITF_NX", "NX", "_NX");
|
|
//conf.Defines.Add("ITF_EMU_NX");
|
|
}
|
|
else if (target.Platform == Ggp.SharpmakePlatform) {
|
|
conf.Defines.Add("ITF_GGP");
|
|
}
|
|
else if(target.Platform == Scarlett.SharpmakePlatform)
|
|
{
|
|
conf.Defines.Add("ITF_SCARLETT");
|
|
}
|
|
else if(target.Platform == Prospero.SharpmakePlatform)
|
|
{
|
|
conf.Defines.Add("ITF_PROSPERO");
|
|
}
|
|
*/
|
|
|
|
if (target.IsPcStandalone())
|
|
{
|
|
conf.Defines.Add("ITF_PC");
|
|
}
|
|
}
|
|
|
|
protected virtual void ConfigureCompilerOptions(Configuration conf, T target)
|
|
{
|
|
if (target.Platform.IsWindows())
|
|
{
|
|
if (target.DevEnv == DevEnv.vs2015)
|
|
conf.Options.Add(Options.Vc.General.PlatformToolset.v140);
|
|
else if (target.DevEnv == DevEnv.vs2017)
|
|
conf.Options.Add(Options.Vc.General.PlatformToolset.v141);
|
|
|
|
conf.Options.Add(Options.Vc.General.CharacterSet.Unicode);
|
|
conf.Options.Add(Options.Vc.Compiler.RTTI.Disable);
|
|
conf.Options.Add(Options.Vc.Compiler.Exceptions.Enable);
|
|
conf.Options.Add(Options.Vc.Compiler.FloatingPointModel.Precise);
|
|
conf.Options.Add(Options.Vc.Compiler.FloatingPointExceptions.Enable);
|
|
conf.Options.Add(Options.Vc.Compiler.BufferSecurityCheck.Enable);
|
|
conf.Options.Add(Options.Vc.Compiler.MinimalRebuild.Disable);
|
|
conf.Options.Add(Options.Vc.General.WarningLevel.Level3);
|
|
conf.Options.Add(Options.Vc.General.TreatWarningsAsErrors.Disable);
|
|
conf.Options.Add(new Options.Vc.Compiler.DisableSpecificWarnings(new[] { "4100", "4201" }));
|
|
conf.Options.Add(Options.Vc.General.WholeProgramOptimization.Disable);
|
|
if (target.Optimization == Optimization.Debug)
|
|
{
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeLibrary.MultiThreadedDebugDLL);
|
|
conf.Options.Add(Options.Vc.Compiler.Optimization.Disable);
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeChecks.Both);
|
|
if(target.Platform != Platform.win64)
|
|
{
|
|
conf.Options.Add(Options.Vc.Compiler.CreateHotPatchableCode.Enable); // Recommended compiler option for Recode builds
|
|
}
|
|
}
|
|
else if (target.Optimization == Optimization.Release)
|
|
{
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeLibrary.MultiThreadedDLL);
|
|
conf.Options.Add(Options.Vc.Compiler.Optimization.FullOptimization);
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeChecks.Default);
|
|
if (target.Platform != Platform.win64)
|
|
{
|
|
conf.Options.Add(Options.Vc.Compiler.CreateHotPatchableCode.Enable); // Recommended compiler option for Recode builds
|
|
}
|
|
if (target.DevEnv == DevEnv.vs2012)
|
|
{
|
|
conf.AdditionalCompilerOptions.Add("/d2Zi+"); // See http://randomascii.wordpress.com/2013/09/11/debugging-optimized-codenew-in-visual-studio-2012/ <http://randomascii.wordpress.com/2013/09/11/debugging-optimized-codenew-in-visual-studio-2012/>
|
|
}
|
|
else if(target.DevEnv == DevEnv.vs2015 || target.DevEnv == DevEnv.vs2017)
|
|
{
|
|
conf.AdditionalCompilerOptions.Add("/Zo");
|
|
}
|
|
}
|
|
else if (target.Optimization == Optimization.Retail)
|
|
{
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeLibrary.MultiThreadedDLL);
|
|
conf.Options.Add(Options.Vc.Compiler.Optimization.FullOptimization);
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeChecks.Default);
|
|
if (target.DevEnv == DevEnv.vs2012)
|
|
{
|
|
conf.AdditionalCompilerOptions.Add("/d2Zi+"); // See http://randomascii.wordpress.com/2013/09/11/debugging-optimized-codenew-in-visual-studio-2012/ <http://randomascii.wordpress.com/2013/09/11/debugging-optimized-codenew-in-visual-studio-2012/>
|
|
}
|
|
else if (target.DevEnv == DevEnv.vs2015 || target.DevEnv == DevEnv.vs2017)
|
|
{
|
|
conf.AdditionalCompilerOptions.Add("/Zo");
|
|
}
|
|
}
|
|
|
|
conf.Options.Add(Options.Vc.Compiler.Inline.Default);
|
|
conf.Options.Add(Options.Vc.Compiler.Intrinsic.Disable);
|
|
conf.Options.Add(Options.Vc.Compiler.FavorSizeOrSpeed.Neither);
|
|
conf.Options.Add(Options.Vc.Compiler.OmitFramePointers.Disable);
|
|
conf.Options.Add(Options.Vc.Compiler.FiberSafe.Disable);
|
|
conf.Options.Add(Options.Vc.Compiler.StringPooling.Disable);
|
|
conf.Options.Add(Options.Vc.Compiler.TypeChecks.Disable);
|
|
|
|
if (target.DevEnv == DevEnv.vs2012 || target.DevEnv == DevEnv.vs2015 || target.DevEnv == DevEnv.vs2017)
|
|
{
|
|
if(target.Platform != Platform.win64)
|
|
{
|
|
// Hack disable SSE style optimization due to buggy aligned float based structs/classes
|
|
conf.Options.Add(Options.Vc.Compiler.EnhancedInstructionSet.NoEnhancedInstructions);
|
|
}
|
|
|
|
// Increased heap limit is needed to get the gtests templates to compile, in relation with the definition of _VARIADIC_MAX=10
|
|
conf.AdditionalCompilerOptions.Add("/Zm150");
|
|
}
|
|
}
|
|
/*
|
|
else if (target.Platform == Platform.orbis)
|
|
{
|
|
conf.Options.Add(Options.Vc.General.TreatWarningsAsErrors.Enable);
|
|
conf.Options.Add(Orbis.Options.Compiler.ExtraWarnings.Enable);
|
|
|
|
conf.AdditionalCompilerOptions.Add(
|
|
// Extra warnings
|
|
"-Wcast-qual",
|
|
"-Wdeprecated-writable-strings",
|
|
"-Wnon-literal-null-conversion",
|
|
"-Wnon-virtual-dtor",
|
|
"-Wnull-conversion",
|
|
"-Wpointer-arith",
|
|
"-Wreorder",
|
|
"-Wreturn-stack-address",
|
|
"-Wshadow",
|
|
"-Wstring-compare",
|
|
"-Wunreachable-code",
|
|
|
|
// Ignored warnings
|
|
"-Wno-inconsistent-missing-override",
|
|
"-Wno-missing-field-initializers",
|
|
"-Wno-switch",
|
|
"-Wno-unused-local-typedef",
|
|
"-Wno-deprecated-register",
|
|
|
|
// https://mdc-web-tomcat17.ubisoft.org/confluence/display/bloomdoc/Prepare+your+code+for+Bloomberg+integration
|
|
"-fno-omit-frame-pointer",
|
|
"-mno-omit-leaf-frame-pointer"
|
|
);
|
|
|
|
if (target.Optimization == Optimization.Debug)
|
|
{
|
|
conf.Options.Add(Orbis.Options.Compiler.UnrollLoops.Disable);
|
|
conf.Options.Add(Orbis.Options.Compiler.NoStrictAliasing.Disable);
|
|
conf.Options.Add(Orbis.Options.Compiler.FastMath.Disable);
|
|
}
|
|
else if (target.Optimization == Optimization.Release || target.Optimization == Optimization.Retail)
|
|
{
|
|
conf.Options.Add(Orbis.Options.Compiler.UnrollLoops.Enable);
|
|
conf.Options.Add(Orbis.Options.Compiler.NoStrictAliasing.Enable);
|
|
conf.Options.Add(Orbis.Options.Compiler.FastMath.Enable);
|
|
}
|
|
}
|
|
else if (target.Platform == Platform.durango)
|
|
{
|
|
conf.Options.Add(Options.Vc.General.CharacterSet.Unicode);
|
|
conf.Options.Add(Options.Vc.General.UseDebugLibraries.Disabled);
|
|
|
|
if (target.DevEnv == DevEnv.vs2010)
|
|
conf.Options.Add(Options.Vc.General.PlatformToolset.v100);
|
|
else if (target.DevEnv == DevEnv.vs2012)
|
|
conf.Options.Add(Options.Vc.General.PlatformToolset.v110);
|
|
else if (target.DevEnv == DevEnv.vs2015)
|
|
conf.Options.Add(Options.Vc.General.PlatformToolset.v140);
|
|
else if (target.DevEnv == DevEnv.vs2017)
|
|
conf.Options.Add(Options.Vc.General.PlatformToolset.v141);
|
|
|
|
// optimization
|
|
conf.Options.Add(Options.Vc.Compiler.Inline.Default);
|
|
conf.Options.Add(Options.Vc.Compiler.FavorSizeOrSpeed.Neither);
|
|
|
|
// code generation
|
|
conf.Options.Add(Options.Vc.Compiler.Exceptions.Enable);
|
|
conf.Options.Add(Options.Vc.Compiler.EnhancedInstructionSet.AdvancedVectorExtensions);
|
|
conf.Options.Add(Options.Vc.Compiler.FloatingPointExceptions.Disable);
|
|
|
|
conf.Options.Add(Options.Vc.General.TreatWarningsAsErrors.Enable);
|
|
conf.Options.Add(new Options.Vc.Compiler.DisableSpecificWarnings(new[] { "4100", "4201" }));
|
|
conf.Options.Add(Options.Vc.General.WarningLevel.Level3);
|
|
|
|
if (target.Optimization == Optimization.Debug)
|
|
{
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeLibrary.MultiThreadedDebugDLL);
|
|
conf.Options.Add(Options.Vc.Compiler.Optimization.Disable);
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeChecks.Both);
|
|
}
|
|
else if (target.Optimization == Optimization.Release || target.Optimization == Optimization.Retail)
|
|
{
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeLibrary.MultiThreadedDLL);
|
|
conf.Options.Add(Options.Vc.Compiler.Optimization.FullOptimization);
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeChecks.Default);
|
|
|
|
if (target.DevEnv == DevEnv.vs2012)
|
|
{
|
|
conf.AdditionalCompilerOptions.Add("/d2Zi+"); // See http://randomascii.wordpress.com/2013/09/11/debugging-optimized-codenew-in-visual-studio-2012/ <http://randomascii.wordpress.com/2013/09/11/debugging-optimized-codenew-in-visual-studio-2012/>
|
|
}
|
|
else if (target.DevEnv == DevEnv.vs2015 || target.DevEnv == DevEnv.vs2017)
|
|
{
|
|
conf.AdditionalCompilerOptions.Add("/Zo");
|
|
}
|
|
}
|
|
}
|
|
else if (target.Platform == Platform.nx)
|
|
{
|
|
conf.Options.Add(Options.Vc.General.TreatWarningsAsErrors.Enable);
|
|
|
|
conf.AdditionalCompilerOptions.Add(
|
|
// Extra warnings
|
|
"-Wcast-qual",
|
|
"-Wdeprecated-writable-strings",
|
|
"-Wnon-literal-null-conversion",
|
|
"-Wnon-virtual-dtor",
|
|
"-Wnull-conversion",
|
|
"-Wpointer-arith",
|
|
"-Wreorder",
|
|
"-Wreturn-stack-address",
|
|
"-Wshadow",
|
|
"-Wstring-compare",
|
|
"-Wunreachable-code",
|
|
|
|
// Ignored warnings
|
|
"-Wno-missing-field-initializers",
|
|
"-Wno-switch",
|
|
"-Wno-inconsistent-missing-override",
|
|
"-Wno-deprecated-register",
|
|
|
|
// https://mdc-web-tomcat17.ubisoft.org/confluence/display/bloomdoc/Prepare+your+code+for+Bloomberg+integration
|
|
"-fno-omit-frame-pointer",
|
|
"-mno-omit-leaf-frame-pointer",
|
|
|
|
// precompiled header timestamps are missing on the remote agents (this gets fixed with a new version of SNDBS v2.5.6.60)
|
|
"-Xclang -fno-pch-timestamp"
|
|
);
|
|
}
|
|
else if (target.Platform == Ggp.SharpmakePlatform)
|
|
{
|
|
conf.Options.Add(Options.Vc.General.TreatWarningsAsErrors.Enable);
|
|
|
|
conf.AdditionalCompilerOptions.Add(
|
|
"-Wnull-conversion",
|
|
"-fno-exceptions",
|
|
"-Wno-switch",
|
|
"-Wno-inconsistent-missing-override",
|
|
"-Wno-deprecated-register",
|
|
|
|
//SNDBS has 2 problems which we need to address using compilation flags:
|
|
// 1: precompiled header timestamps are missing on the remote agents (this gets fixed with a new version of SNDBS v2.5.6.60)
|
|
"-Xclang -fno-pch-timestamp",
|
|
// 2: SNDBS changes the names/paths of files to lower case for easy handling. Clang complains about it so we fix it by ignoring the warning.
|
|
"-Wno-nonportable-include-path"
|
|
);
|
|
}
|
|
else if(target.Platform == Prospero.SharpmakePlatform)
|
|
{
|
|
conf.Options.Add(Options.Vc.General.TreatWarningsAsErrors.Enable);
|
|
|
|
conf.AdditionalCompilerOptions.Add(
|
|
"-Wno-switch",
|
|
"-Wno-inconsistent-missing-override",
|
|
"-Wno-deprecated-register"
|
|
);
|
|
}
|
|
else if (target.Platform == Scarlett.SharpmakePlatform)
|
|
{
|
|
KitsRootPaths.SetUseKitsRootForDevEnv(DevEnv.vs2017, KitsRootEnum.KitsRoot10, Options.Vc.General.WindowsTargetPlatformVersion.Latest);
|
|
|
|
conf.Options.Add(Options.Vc.General.CharacterSet.Unicode);
|
|
|
|
if (target.DevEnv == DevEnv.vs2017)
|
|
conf.Options.Add(Options.Vc.General.PlatformToolset.v141);
|
|
if (target.DevEnv == DevEnv.vs2019)
|
|
conf.Options.Add(Options.Vc.General.PlatformToolset.v142);
|
|
|
|
// optimization
|
|
conf.Options.Add(Options.Vc.Compiler.Inline.Default);
|
|
conf.Options.Add(Options.Vc.Compiler.Intrinsic.Disable);
|
|
|
|
// code generation
|
|
conf.Options.Add(Options.Vc.Compiler.Exceptions.Enable);
|
|
conf.Options.Add(Options.Vc.Compiler.EnhancedInstructionSet.AdvancedVectorExtensions);
|
|
|
|
conf.Options.Add(Options.Vc.General.TreatWarningsAsErrors.Enable);
|
|
conf.Options.Add(new Options.Vc.Compiler.DisableSpecificWarnings(new[] { "4100", "4201" }));
|
|
conf.Options.Add(Options.Vc.General.WarningLevel.Level3);
|
|
|
|
if (target.Optimization == Optimization.Debug)
|
|
{
|
|
conf.Options.Add(Options.Vc.General.UseDebugLibraries.Enabled);
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeLibrary.MultiThreadedDebugDLL);
|
|
conf.Options.Add(Options.Vc.Compiler.Optimization.Disable);
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeChecks.Both);
|
|
}
|
|
else if (target.Optimization == Optimization.Release || target.Optimization == Optimization.Retail)
|
|
{
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeLibrary.MultiThreadedDLL);
|
|
conf.Options.Add(Options.Vc.Compiler.Optimization.FullOptimization);
|
|
conf.Options.Add(Options.Vc.Compiler.RuntimeChecks.Default);
|
|
}
|
|
}
|
|
*/
|
|
|
|
conf.DefaultOption = target.Optimization == Optimization.Debug ? Options.DefaultTarget.Debug : Options.DefaultTarget.Release;
|
|
}
|
|
|
|
protected virtual void ConfigureLinkerOptions(Configuration conf, T target)
|
|
{
|
|
if (conf.Platform.IsWindows())
|
|
{
|
|
string procArch = conf.Platform == Platform.win64 ? "x64" : "x86";
|
|
conf.AdditionalLinkerOptions.Add("/ignore:4221");
|
|
conf.AdditionalLibrarianOptions.Add("/ignore:4221");
|
|
conf.LibraryPaths.Add( @"$(WindowsSdkDir)\common\lib", @"$(DXSDK_DIR)\Lib\" + procArch, @"$(DXSDK_DIR)\Extras\DirectShow\Lib\" + procArch);
|
|
if (conf.Platform == Platform.win32)
|
|
{
|
|
conf.LibraryPaths.Add(ExternPath + @"Camcam/LIBS/DX9_Aug_2007/Lib");
|
|
}
|
|
conf.LibraryPaths.Add(@"$(WindowsSdkDir)lib", @"$(FrameworkSDKDir)\lib", @"$(XEDK)\lib\win32\vs2008");
|
|
}
|
|
/*
|
|
if (conf.Platform == Platform.durango)
|
|
{
|
|
conf.AdditionalLinkerOptions.Add("/ignore:4264,4099,4006,4221");
|
|
conf.AdditionalLibrarianOptions.Add("/ignore:4264,4099,4006,4221");
|
|
}
|
|
else if (conf.Platform == Platform.orbis)
|
|
{
|
|
conf.LibraryPaths.Add(ExternPath + "PS4_SDK_Patches/lib");
|
|
}
|
|
else if (conf.Platform == Platform.nx)
|
|
{
|
|
conf.Options.Add(Nx.Options.General.ApplicationProgramFormat.Raw);
|
|
if (target.Optimization == Optimization.Retail)
|
|
{
|
|
conf.Options.Add(Nx.Options.General.SdkBuildType.Release);
|
|
}
|
|
conf.Options.Add(Options.Vc.Linker.GenerateMapFile.Disable);
|
|
}
|
|
else if (conf.Platform == Scarlett.SharpmakePlatform)
|
|
{
|
|
conf.AdditionalLinkerOptions.Add("/ignore:4264,4099,4006,4221");
|
|
conf.AdditionalLibrarianOptions.Add("/ignore:4264,4099,4006,4221");
|
|
}
|
|
*/
|
|
}
|
|
|
|
protected virtual void ConfigurePlatformFilters(Configuration conf, T target)
|
|
{
|
|
foreach (var platform in Enum.GetValues(typeof(Platform)).Cast<Platform>().Where(x => x != conf.Platform))
|
|
{
|
|
foreach (var engineSuffix in platform.PathSuffixes(target))
|
|
{
|
|
if (!conf.Platform.PathSuffixes(target).Contains(engineSuffix))
|
|
{
|
|
conf.SourceFilesBuildExcludeRegex.Add(string.Format(@"\\{0}\\", engineSuffix), string.Format(@"_{0}", engineSuffix));
|
|
}
|
|
}
|
|
}
|
|
conf.SourceFilesBuildExcludeRegex.Add(@"\\3DS\\", "_3DS");
|
|
conf.SourceFilesBuildExcludeRegex.Add(@"\\VITA\\", "_VITA");
|
|
|
|
if (conf.Platform == Platform.win32 || conf.Platform == Platform.win64)
|
|
{
|
|
var consoleKeywords = new[] {
|
|
"Durango", "durango",
|
|
"Orbis", "orbis",
|
|
"NX", "Nx", "nx",
|
|
"GGP", "ggp",
|
|
"Prospero", "prospero",
|
|
"Scarlett", "scarlett",
|
|
"3DS", "3ds",
|
|
"VITA", "vita",
|
|
"Wii", "wii",
|
|
"X360", "x360",
|
|
"PS3", "ps3"
|
|
};
|
|
|
|
foreach (var kw in consoleKeywords)
|
|
{
|
|
conf.SourceFilesBuildExcludeRegex.Add(string.Format(@"\\{0}\\", kw), string.Format(@"_{0}", kw));
|
|
}
|
|
}
|
|
|
|
if (!target.IsPcStandalone())
|
|
{
|
|
conf.SourceFilesBuildExcludeRegex.Add(@"\\PC\\", "_PC");
|
|
}
|
|
}
|
|
|
|
protected virtual void Clean(Configuration conf, T target)
|
|
{
|
|
//TODO: TEMPORARY CODE, REMOVE ME IN A FEW DAYS AFTER 23/09/2014.
|
|
//This code is to remove blobs previously generated in wrong directories
|
|
var blobsDir = ResolveString(SourceRootPath + "/blobs/");
|
|
if (Directory.Exists(blobsDir) && !blobsDir.Contains("bloomberg"))
|
|
Directory.Delete(blobsDir, true);
|
|
var blobsDir2 = ResolveString(SourceRootPath + "/blob/");
|
|
if (Directory.Exists(blobsDir2) && !blobsDir2.Contains("bloomberg"))
|
|
Directory.Delete(blobsDir2, true);
|
|
}
|
|
|
|
protected virtual void ConfigureDeployment(Configuration conf, T target)
|
|
{
|
|
/*
|
|
if (target.Platform == Platform.durango)
|
|
{
|
|
conf.Options.Add(Durango.Options.General.DeployMode.Pull);
|
|
conf.PullMappingFile = "$(OutDir)mapping.xml";
|
|
}
|
|
*/
|
|
}
|
|
|
|
public static ITarget[] GetDefaultTargets()
|
|
{
|
|
return new ITarget[] {
|
|
new BaseCppTarget(Platform.win64,
|
|
DevEnv.vs2017,
|
|
Optimization.Debug | Optimization.Release | Optimization.Retail,
|
|
Sharpmake.OutputType.Lib,
|
|
ApplicationType.Editor),
|
|
|
|
new BaseCppTarget(Platform.win64,
|
|
DevEnv.vs2017,
|
|
Optimization.Debug | Optimization.Release | Optimization.Retail,
|
|
Sharpmake.OutputType.Lib,
|
|
ApplicationType.Standalone)
|
|
};
|
|
}
|
|
|
|
public static string GetTargetPlatformName(Configuration conf, T target)
|
|
{
|
|
switch (conf.Platform)
|
|
{
|
|
case Platform._reserved7:
|
|
return "scarlett";
|
|
case Platform._reserved8:
|
|
return "prospero";
|
|
}
|
|
|
|
return target.Platform.ToString().ToLower();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// represent the last character that needs to be appended in the name of the output binaries.
|
|
/// </summary>
|
|
[Fragment, Flags]
|
|
public enum LibrarySuffix
|
|
{
|
|
d, // debug
|
|
r, // release
|
|
f, // final
|
|
}
|
|
|
|
[Fragment, Flags]
|
|
public enum Optimization
|
|
{
|
|
Debug = 0x01,
|
|
Release = 0x02,
|
|
Retail = 0x04
|
|
}
|
|
|
|
|
|
[Fragment, Flags]
|
|
public enum ApplicationType
|
|
{
|
|
Standalone = 0x01,
|
|
Editor = 0x02,
|
|
}
|
|
|
|
public class BaseCppTarget : Sharpmake.ITarget
|
|
{
|
|
public Optimization Optimization;
|
|
public Platform Platform;
|
|
public BuildSystem BuildSystem;
|
|
public DevEnv DevEnv;
|
|
public OutputType OutputType;
|
|
public DotNetFramework Framework = DotNetFramework.v4_7;
|
|
public Blob Blob;
|
|
public ApplicationType ApplicationType = ApplicationType.Standalone;
|
|
// public Nx.NXBuildTargets NXBuildTargets = Nx.NXBuildTargets.NX_NXFP2_a64;
|
|
|
|
public BaseCppTarget() { }
|
|
|
|
public BaseCppTarget(Platform platform, DevEnv devEnv, Optimization optimization, OutputType outputType, ApplicationType applicationType = ApplicationType.Standalone)
|
|
{
|
|
Platform = platform;
|
|
DevEnv = devEnv;
|
|
Optimization = optimization;
|
|
OutputType = outputType;
|
|
ApplicationType = applicationType;
|
|
BuildSystem = BuildSystem.MSBuild;
|
|
Blob = Blob.NoBlob;
|
|
}
|
|
|
|
|
|
|
|
public override string Name
|
|
{
|
|
get
|
|
{
|
|
var optimization = Optimization.ToString().Replace("Retail", "Final");
|
|
switch (ApplicationType)
|
|
{
|
|
case ApplicationType.Standalone:
|
|
return optimization;
|
|
default:
|
|
return optimization + "_" + ApplicationType;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public abstract class BaseCppSolution : BaseCppSolutionGeneric<BaseCppTarget>
|
|
{
|
|
public BaseCppSolution()
|
|
{
|
|
AddTargets(BaseCppProject.GetDefaultTargets());
|
|
}
|
|
}
|
|
|
|
public abstract class BaseCppSolutionGeneric<T> : Solution where T : BaseCppTarget
|
|
{
|
|
public static readonly string BuildPath = Globals.BranchRoot + @"build\";
|
|
|
|
public static readonly string RootPath = Globals.BranchRoot;
|
|
|
|
protected BaseCppSolutionGeneric()
|
|
: base(typeof(T))
|
|
{
|
|
IsFileNameToLower = false;
|
|
}
|
|
|
|
[Configure]
|
|
public virtual void ConfigureAll(Configuration conf, T target)
|
|
{
|
|
conf.SolutionFileName = string.Format("{0}.{1}.{2}", Name, Globals.CurrentBranchName.ToLower(), target.DevEnv.GetDevEnvString());
|
|
conf.SolutionPath = BuildPath + @"projects\[target.DevEnv]";
|
|
|
|
//We create a virtual "pc" platform which is the combination of Windows and Standalone
|
|
if (target.IsPcStandalone())
|
|
{
|
|
if (conf.Platform == Platform.win32)
|
|
{
|
|
conf.PlatformName = "pc";
|
|
}
|
|
else if (conf.Platform == Platform.win64)
|
|
{
|
|
conf.PlatformName = "pc64";
|
|
}
|
|
}
|
|
else if (conf.Platform == Platform._reserved7)
|
|
{
|
|
conf.PlatformName = "scarlett";
|
|
}
|
|
else if (conf.Platform == Platform._reserved8)
|
|
{
|
|
conf.PlatformName = "prospero";
|
|
}
|
|
else
|
|
{
|
|
conf.PlatformName = target.Platform.ToString().ToLower();
|
|
}
|
|
|
|
//We remove the ApplicationType from the configuration name
|
|
conf.Name = target.NameWithoutApplicationType();
|
|
}
|
|
}
|
|
|
|
public static class CppExtensions
|
|
{
|
|
public static string[] PathSuffixes(this Platform platform, BaseCppTarget target)
|
|
{
|
|
if (target.IsPcStandalone())
|
|
{
|
|
if (platform == Platform.win32)
|
|
{
|
|
return new[] { "PC", "WIN32", "x32", "x86" };
|
|
}
|
|
if (platform == Platform.win64)
|
|
{
|
|
return new[] { "PC", "WIN64", "x64", "WIN32", "x32", "x86" };
|
|
}
|
|
}
|
|
|
|
switch (platform)
|
|
{
|
|
case Platform.win32: return new []{"WIN32", "x32", "x86"};
|
|
case Platform.win64: return new []{ "WIN64", "x64", "WIN32", "x32", "x86"};
|
|
case Platform.durango: return new []{"DURANGO"};
|
|
case Platform.orbis: return new []{"ORBIS"};
|
|
case Platform.nx: return new[] { "NX" };
|
|
case Platform.anycpu: return new []{"ANYCPU"};
|
|
}
|
|
return new string[]{};
|
|
}
|
|
|
|
public static LibrarySuffix GetLibrarySuffix(this Optimization optimization)
|
|
{
|
|
switch (optimization)
|
|
{
|
|
case Optimization.Debug: return LibrarySuffix.d;
|
|
case Optimization.Release: return LibrarySuffix.r;
|
|
case Optimization.Retail: return LibrarySuffix.f;
|
|
}
|
|
return LibrarySuffix.r;
|
|
}
|
|
|
|
public static bool IsPcStandalone(this BaseCppTarget target)
|
|
{
|
|
return target.Platform.IsWindows() && target.ApplicationType == ApplicationType.Standalone;
|
|
}
|
|
|
|
public static string NameWithoutApplicationType(this BaseCppTarget target)
|
|
{
|
|
var targetElementList = target.Name.Split('_').ToList();
|
|
foreach (var value in Enum.GetValues(typeof(ApplicationType)))
|
|
{
|
|
targetElementList.RemoveAll(x => x == value.ToString());
|
|
}
|
|
return string.Join("_", targetElementList);
|
|
}
|
|
}
|
|
}
|