Skip to content

Commit

Permalink
Merge branch 'adding-always-deploy-flag' into 'main'
Browse files Browse the repository at this point in the history
Replacing DeployProject property with DeployProjectType to have finer control over project deployment

See merge request Sharpmake/sharpmake!584
  • Loading branch information
jspelletier committed Nov 29, 2024
2 parents 081f451 + 62566d1 commit 4bee97e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
11 changes: 8 additions & 3 deletions Sharpmake.Generators/VisualStudio/Sln.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,13 +585,15 @@ out bool updated
using (fileGenerator.Declare("configurationName", configurationName))
{
bool build = false;
bool forceDeploy = false;
if (solution is PythonSolution)
{
// nothing is built in python solutions
}
else if (perfectMatch)
{
build = includedProject.ToBuild == Solution.Configuration.IncludedProjectInfo.Build.Yes;
forceDeploy = includedProject.Project.DeployProjectType == Project.DeployType.AlwaysDeploy || includedProject.Configuration.DeployProjectType == Project.DeployType.AlwaysDeploy;

// for fastbuild, only build the projects that cannot be built through dependency chain
if (!projectConf.IsFastBuild)
Expand All @@ -604,13 +606,16 @@ out bool updated
}

fileGenerator.Write(Template.Solution.GlobalSectionProjectConfigurationActive);
bool buildDeploy = false;
if (build)
{
buildDeploy = includedProject.Project.DeployProjectType == Project.DeployType.OnlyIfBuild || includedProject.Configuration.DeployProjectType == Project.DeployType.OnlyIfBuild;
fileGenerator.Write(Template.Solution.GlobalSectionProjectConfigurationBuild);
}

bool deployProject = includedProject.Project.DeployProject || includedProject.Configuration.DeployProject;
if (deployProject)
fileGenerator.Write(Template.Solution.GlobalSectionProjectConfigurationDeploy);
if (forceDeploy || buildDeploy)
{
fileGenerator.Write(Template.Solution.GlobalSectionProjectConfigurationDeploy);
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion Sharpmake/Project.Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2395,7 +2395,20 @@ public virtual CustomFileBuildStepData MakePathRelative(Resolver resolver, Func<
/// <remarks>
/// This property only applies to Visual Studio projects.
/// </remarks>
public bool DeployProject = false;
[Obsolete("DeployProject is obsolete, use DeployProjectType instead (DeployType.OnlyIfBuild for the case where DeployProject == true)", false)]
public bool DeployProject
{
get => DeployProjectType != DeployType.NoDeploy;
set => DeployProjectType = value ? DeployType.OnlyIfBuild : DeployType.NoDeploy;
}

/// <summary>
/// Gets or sets whether this project is deployed and in which cases.
/// </summary>
/// <remarks>
/// This property only applies to Visual Studio projects.
/// </remarks>
public DeployType DeployProjectType {get; set; } = DeployType.NoDeploy;

/// <summary>
/// Gets or sets whether blobbing is enabled for this configuration.
Expand Down
24 changes: 21 additions & 3 deletions Sharpmake/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,29 @@ public static void AddFastbuildMasterGeneratedFile(string file)
}
}

private bool _deployProject = false;
[Obsolete("DeployProject is obsolete, use DeployProjectType instead (DeployType.OnlyIfBuild for the case where DeployProject == true)", false)]
public bool DeployProject
{
get { return _deployProject; }
set { SetProperty(ref _deployProject, value); }
get { return DeployProjectType != DeployType.NoDeploy; }
set { SetProperty(ref _deployProjectType, value ? DeployType.OnlyIfBuild : DeployType.NoDeploy); }
}

public enum DeployType
{
// The project would not be deployed.
NoDeploy,
// The project will be deployed only if it explicitly marked for build in visual studio
// (which is true for exe, but could be turned off automatically if FastBuildAll project is generated).
OnlyIfBuild,
// The project will be always deployed.
AlwaysDeploy
}

private DeployType _deployProjectType = DeployType.NoDeploy;
public DeployType DeployProjectType
{
get { return _deployProjectType; }
set { SetProperty(ref _deployProjectType, value); }
}

public static int BlobCleaned { get; private set; }
Expand Down
2 changes: 1 addition & 1 deletion samples/HelloAndroid/codebase/exe/exe.sharpmake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class ExePackaging : AndroidPackageProject

public ExePackaging() : base(typeof(CommonTarget))
{
DeployProject = true;
DeployProjectType = DeployType.OnlyIfBuild;

Name = "exepackaging";

Expand Down

0 comments on commit 4bee97e

Please sign in to comment.