JD2022-TU1/main/build/sharpmake/Tools/BaseSolution.cs

57 lines
1.9 KiB
C#

using Sharpmake;
namespace JustDance.Tools
{
[Generate]
public class BaseSolution : CSharpSolution
{
/// <summary>
/// Set to true to add the target project to the solution and project name.
/// <remarks>Mandatory if you try to generate the solutions for several projects. </remarks>
/// </summary>
public bool UseMultiProject = Globals.UseMultiProject;
public virtual string RootPath { get { return Globals.BranchRoot; } }
public virtual string BuildPath { get { return Globals.BranchRoot + @"build\"; } }
public virtual string ToolsPath { get { return Globals.BranchRoot + @"tools\"; } }
public BaseSolution()
{
AddTargets(Utilities.GetDefaultTargets());
IsFileNameToLower = false;
}
[Configure]
public virtual void ConfigureAll(Configuration conf, Target target)
{
conf.SolutionFileName = string.Format("{0}.{1}.{2}", Name, Globals.CurrentBranchName.ToLower(), target.DevEnv.GetDevEnvString());
if (UseMultiProject)
conf.SolutionFileName += "." + Globals.CurrentProjectName;
conf.SolutionPath = ToolsPath;
}
}
abstract class SingleProjectSolution : BaseSolution
{
}
/// <summary>
/// Inherit from this class to generate a solution for a single project.
/// </summary>
abstract class SingleProjectSolution<TProject> : SingleProjectSolution
where TProject : BaseProject, new()
{
protected SingleProjectSolution()
{
Name = new TProject().Name;
}
public override void ConfigureAll(Configuration conf, Target target)
{
base.ConfigureAll(conf, target);
conf.AddProject<TProject>(target);
conf.SolutionPath = string.Format(ToolsPath + @"{0}\[solution.Name]\", new TProject().ProjectType);
}
}
}