Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions SamplesDef.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,20 @@
"&'./{testFolder}/projects/output/win64/{configuration}/helloWorld.exe'"
]
},
{
"Name": "JumboBuild",
"CIs": [ "github", "gitlab" ],
"OSs": [ "windows-2019", "windows-2022" ],
"Frameworks": [ "net6.0" ],
"Configurations": [ "debug", "release" ],
"TestFolder": "samples/JumboBuild",
"Commands":
[
"./RunSharpmake.ps1 -workingDirectory {testFolder} -sharpmakeFile \"JumboBuild.sharpmake.cs\" -framework {framework}",
"./Compile.ps1 -slnOrPrjFile \"jumbobuild_vs2019_win64.sln\" -configuration {configuration} -platform \"x64\" -WorkingDirectory \"{testFolder}/projects\" -VsVersion {os} -compiler MsBuild",
"&'./{testFolder}/projects/output/win64/{configuration}/jumboBuild.exe'"
]
},
{
"Name": "NetCore-DotNetCoreFrameworkHelloWorld",
"CIs": [ "gitlab" ],
Expand Down
18 changes: 18 additions & 0 deletions Sharpmake.Generators/VisualStudio/ProjectOptionsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,24 @@ private void GenerateCompilerOptions(IGenerationContext context, ProjectOptionsG
Options.Option(Options.Vc.Compiler.EnableAsan.Enable, () => { context.Options["EnableASAN"] = "true"; context.CommandLineOptions["EnableASAN"] = "/fsanitize=address"; })
);

context.SelectOption
(
Options.Option(Options.Vc.Compiler.JumboBuild.Disable, () =>
{
context.Options["JumboBuild"] = FileGeneratorUtilities.RemoveLineTag;
context.Options["MaxFilesPerJumboFile"] = FileGeneratorUtilities.RemoveLineTag;
context.Options["MinFilesPerJumboFile"] = FileGeneratorUtilities.RemoveLineTag;
context.Options["MinJumboFiles"] = FileGeneratorUtilities.RemoveLineTag;
}),
Options.Option(Options.Vc.Compiler.JumboBuild.Enable, () =>
{
context.Options["JumboBuild"] = "true";
context.Options["MaxFilesPerJumboFile"] = context.Configuration.MaxFilesPerJumboFile.ToString();
context.Options["MinFilesPerJumboFile"] = context.Configuration.MinFilesPerJumboFile.ToString();
context.Options["MinJumboFiles"] = context.Configuration.MinJumboFiles.ToString();
})
);

if (context.DevelopmentEnvironment.IsVisualStudio() && context.DevelopmentEnvironment >= DevEnv.vs2017)
{
//Options.Vc.Compiler.DefineCPlusPlus. See: https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ public abstract partial class BasePlatform
<WindowsTargetPlatformVersion>[options.WindowsTargetPlatformVersion]</WindowsTargetPlatformVersion>
<SpectreMitigation>[options.SpectreMitigation]</SpectreMitigation>
<EnableASAN>[options.EnableASAN]</EnableASAN>
<EnableUnitySupport>[options.JumboBuild]</EnableUnitySupport>
<MaxFilesInUnityFile>[options.MaxFilesPerJumboFile]</MaxFilesInUnityFile>
<MinFilesInUnityFile>[options.MinFilesPerJumboFile]</MinFilesInUnityFile>
<MinUnityFiles>[options.MinJumboFiles]</MinUnityFiles>
</PropertyGroup>
";

Expand Down
14 changes: 14 additions & 0 deletions Sharpmake/Options.Vc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,20 @@ public enum EnableAsan
[DevEnvVersion(minimum = DevEnv.vs2019)]
Enable
}

/// <summary>
/// Enable Jumbo/Unity builds for msbuild. Only usable with msbuild.
/// </summary>
/// <remarks>
/// Merges multiple translation units together
/// </remarks>
public enum JumboBuild
{
[Default]
Disable,
[DevEnvVersion(minimum = DevEnv.vs2019)]
Enable
}
}

public static class CodeAnalysis
Expand Down
5 changes: 5 additions & 0 deletions Sharpmake/Project.Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,11 @@ public string FastBuildUnityPath
/// </remarks>
public bool DoNotGenerateFastBuild = false;

// Jumbo builds support for msbuild
public int MaxFilesPerJumboFile = 0;
public int MinFilesPerJumboFile = 2;
public int MinJumboFiles = 1;

// container for executable
/// <summary>
/// Represents a build step that invokes an executable on the file system.
Expand Down
2 changes: 2 additions & 0 deletions UpdateSamplesOutput.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ call :UpdateRef samples CPPCLI CLRTest.sharpmake.cs
if not "%ERRORLEVEL_BACKUP%" == "0" goto error
call :UpdateRef samples CSharpHelloWorld HelloWorld.sharpmake.cs reference CSharpHelloWorld
if not "%ERRORLEVEL_BACKUP%" == "0" goto error
call :UpdateRef samples JumboBuild JumboBuild.sharpmake.cs reference JumboBuild
if not "%ERRORLEVEL_BACKUP%" == "0" goto error
call :UpdateRef samples HelloWorld HelloWorld.sharpmake.cs reference HelloWorld
if not "%ERRORLEVEL_BACKUP%" == "0" goto error
call :UpdateRef samples HelloLinux HelloLinux.Main.sharpmake.cs reference HelloLinux
Expand Down
1 change: 1 addition & 0 deletions regression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def launch_tests():
Test("CPPCLI", "CLRTest.sharpmake.cs"),
Test("CSharpHelloWorld", "HelloWorld.sharpmake.cs"),
Test("HelloWorld", "HelloWorld.sharpmake.cs"),
Test("JumboBuild", "JumboBuild.sharpmake.cs"),
Test("HelloLinux", "HelloLinux.Main.sharpmake.cs"),
Comment thread
Say-Y marked this conversation as resolved.
Test("HelloAssembly", "HelloAssembly.sharpmake.cs"),
Test("CSharpVsix", "CSharpVsix.sharpmake.cs"),
Expand Down
73 changes: 73 additions & 0 deletions samples/JumboBuild/JumboBuild.sharpmake.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) Ubisoft. All Rights Reserved.
// Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license information.

using Sharpmake;

namespace JumboBuild
{
[Sharpmake.Generate]
public class JumboBuildProject : Project
{
public JumboBuildProject()
{
Name = "JumboBuild";

AddTargets(new Target(
Platform.win32 | Platform.win64,
Comment thread
Say-Y marked this conversation as resolved.
DevEnv.vs2019,
Optimization.Debug | Optimization.Release
));

SourceRootPath = @"[project.SharpmakeCsPath]\codebase";
}

[Configure]
public void ConfigureAll(Configuration conf, Target target)
{
conf.ProjectFileName = "[project.Name]_[target.DevEnv]_[target.Platform]";
conf.ProjectPath = @"[project.SharpmakeCsPath]\projects";

conf.Defines.Add("_HAS_EXCEPTIONS=0");

conf.CustomProperties.Add("CustomOptimizationProperty", $"Custom-{target.Optimization}");

conf.Options.Add(Options.Vc.Compiler.JumboBuild.Enable);
conf.MaxFilesPerJumboFile = 0;
conf.MinFilesPerJumboFile = 2;
conf.MinJumboFiles = 1;
}
}

[Sharpmake.Generate]
public class JumboBuildSolution : Sharpmake.Solution
{
public JumboBuildSolution()
{
Name = "JumboBuild";

AddTargets(new Target(
Platform.win32 | Platform.win64,
DevEnv.vs2019,
Optimization.Debug | Optimization.Release
));
}

[Configure()]
public void ConfigureAll(Configuration conf, Target target)
{
conf.SolutionFileName = "[solution.Name]_[target.DevEnv]_[target.Platform]";
conf.SolutionPath = @"[solution.SharpmakeCsPath]\projects";
conf.AddProject<JumboBuildProject>(target);
}
}

public static class Main
{
[Sharpmake.Main]
public static void SharpmakeMain(Sharpmake.Arguments arguments)
{
KitsRootPaths.SetUseKitsRootForDevEnv(DevEnv.vs2019, KitsRootEnum.KitsRoot10, Options.Vc.General.WindowsTargetPlatformVersion.v10_0_19041_0);
arguments.Generate<JumboBuildSolution>();
}
}
}
29 changes: 29 additions & 0 deletions samples/JumboBuild/codebase/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
#include "test1.h"
#include "test2.h"

int main(int, char**)
{
std::cout << "I was built in "

#if _DEBUG
"Debug"
#endif

#if NDEBUG
"Release"
#endif

#if _WIN64
" x64"
#else
" x86"
#endif

<< std::endl;

std::cout << "test1: " << test1() << std::endl;
std::cout << "test2: " << test2() << std::endl;

return 0;
}
6 changes: 6 additions & 0 deletions samples/JumboBuild/codebase/test1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "test1.h"

int test1()
{
return 1;
}
3 changes: 3 additions & 0 deletions samples/JumboBuild/codebase/test1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

int test1();
6 changes: 6 additions & 0 deletions samples/JumboBuild/codebase/test2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "test2.h"

int test2()
{
return 2;
}
3 changes: 3 additions & 0 deletions samples/JumboBuild/codebase/test2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

int test2();
21 changes: 21 additions & 0 deletions samples/JumboBuild/reference/projects/jumbobuild_vs2019_win32.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29424.173
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JumboBuild", "jumbobuild_vs2019_win32.vcxproj", "{7E5D7FA3-1BD1-D52B-649E-C932F0163E62}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7E5D7FA3-1BD1-D52B-649E-C932F0163E62}.Debug|Win32.ActiveCfg = Debug|Win32
{7E5D7FA3-1BD1-D52B-649E-C932F0163E62}.Debug|Win32.Build.0 = Debug|Win32
{7E5D7FA3-1BD1-D52B-649E-C932F0163E62}.Release|Win32.ActiveCfg = Release|Win32
{7E5D7FA3-1BD1-D52B-649E-C932F0163E62}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading