Skip to content

Commit

Permalink
Merge branch 'hotfix-0.14.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
belkiss committed Oct 22, 2020
2 parents de84348 + 0508243 commit 9cf3f65
Show file tree
Hide file tree
Showing 17 changed files with 818 additions and 559 deletions.
7 changes: 7 additions & 0 deletions Sharpmake.Application/CommandLineArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public enum InputType
public string[] Assemblies = new string[0];
public HashSet<string> Defines = new HashSet<string>();
public InputType Input = InputType.Undefined;
public string ProfileFile = null;
public bool Exit = false;
public bool BlobOnly = false;
public bool CleanBlobsOnly = false;
Expand Down Expand Up @@ -95,6 +96,12 @@ public void SetDefines(params string[] defines)
DebugWriteLine(" " + define);
}

[CommandLine.Option("profile", @"Profile file used to activate and output profiling: ex: /profile( @""D:\profile.json"" )")]
public void SetProfileFile(string profileFile)
{
ProfileFile = profileFile;
}

[CommandLine.Option("projectlogfiles", @"log files contained in a project for debug purpose: ex: /projectlogfiles( ""s:\p4\ac\dev\sharpmake\projects\win32\system\system.vcproj"" )")]
public void ProjectLogFiles(string projectFile)
{
Expand Down
50 changes: 32 additions & 18 deletions Sharpmake.Application/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,16 +444,19 @@ private static void CreateBuilderAndGenerate(BuildContext.BaseBuildContext build
}
else
{
if (parameters.GenerateDebugSolution)
LogWriteLine("Generate debug solution...");
IDictionary<Type, GenerationOutput> outputs;
using (Builder.Instance.CreateProfilingScope("Generate"))
outputs = builder.Generate();

var outputs = builder.Generate();
foreach (var output in outputs)
{
if (output.Value.Exception != null)
throw new Error(output.Value.Exception, "Error encountered while generating {0}", output.Key);
}

if (!string.IsNullOrEmpty(parameters.ProfileFile))
builder.DumpTraceFile(parameters.ProfileFile);

if (parameters.DumpDependency)
DependencyTracker.Instance.DumpGraphs(outputs);

Expand Down Expand Up @@ -598,28 +601,38 @@ public static Builder CreateBuilder(BuildContext.BaseBuildContext context, Argum
if (parameters.ProfileOutput)
builder.EventOutputProfile += LogWrite;

if (!string.IsNullOrEmpty(parameters.ProfileFile))
builder.EnableProfiling();

try
{
// Generate debug solution
if (generateDebugSolution)
using (Builder.Instance.CreateProfilingScope("Debug solution"))
{
DebugProjectGenerator.GenerateDebugSolution(parameters.Sources, builder.Arguments, parameters.DebugSolutionStartArguments, parameters.Defines.ToArray());
builder.BuildProjectAndSolution();
return builder;
if (generateDebugSolution)
{
LogWriteLine("Generate debug solution...");
DebugProjectGenerator.GenerateDebugSolution(parameters.Sources, builder.Arguments, parameters.DebugSolutionStartArguments, parameters.Defines.ToArray());
builder.BuildProjectAndSolution();
return builder;
}
}

// Load user input (either files or pre-built assemblies)
switch (parameters.Input)
using (Builder.Instance.CreateProfilingScope("EntryPoints"))
{
case Argument.InputType.File:
builder.ExecuteEntryPointInAssemblies<Main>(builder.LoadSharpmakeFiles(parameters.Sources));
break;
case Argument.InputType.Assembly:
builder.ExecuteEntryPointInAssemblies<Main>(builder.LoadAssemblies(parameters.Assemblies));
break;
case Argument.InputType.Undefined:
default:
throw new Error("Sharpmake input missing, use /sources() or /assemblies()");
switch (parameters.Input)
{
case Argument.InputType.File:
builder.ExecuteEntryPointInAssemblies<Main>(builder.LoadSharpmakeFiles(parameters.Sources));
break;
case Argument.InputType.Assembly:
builder.ExecuteEntryPointInAssemblies<Main>(builder.LoadAssemblies(parameters.Assemblies));
break;
case Argument.InputType.Undefined:
default:
throw new Error("Sharpmake input missing, use /sources() or /assemblies()");
}
}

if (builder.Arguments.TypesToGenerate.Count == 0)
Expand All @@ -628,7 +641,8 @@ public static Builder CreateBuilder(BuildContext.BaseBuildContext context, Argum
builder.Context.ConfigureOrder = builder.Arguments.ConfigureOrder;

// Call all configuration's methods and resolve project/solution member's values
builder.BuildProjectAndSolution();
using (Builder.Instance.CreateProfilingScope("Build"))
builder.BuildProjectAndSolution();

return builder;
}
Expand Down
2 changes: 1 addition & 1 deletion Sharpmake.Application/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.14.5.0")]
[assembly: AssemblyVersion("0.14.6.0")]
58 changes: 32 additions & 26 deletions Sharpmake.Generators/FastBuild/Bff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,36 +206,46 @@ List<string> skipFiles
string projectBffFile = Bff.GetBffFileName(projectPath, firstConf.BffFileName); // TODO: bff file name could be different per conf, hence we would generate more than one file
string fastBuildClrSupport = Util.IsDotNet(firstConf) ? "/clr" : FileGeneratorUtilities.RemoveLineTag;
List<Vcxproj.ProjectFile> filesInNonDefaultSection;
var confSourceFiles = GetGeneratedFiles(context, configurations, out filesInNonDefaultSection);
Dictionary<Project.Configuration, Dictionary<Tuple<bool, bool, bool, bool, bool, bool, Options.Vc.Compiler.Exceptions, Tuple<bool>>, List<Vcxproj.ProjectFile>>> confSourceFiles;
using (builder.CreateProfilingScope("BffGenerator.Generate:GetGeneratedFiles"))
{
confSourceFiles = GetGeneratedFiles(context, configurations, out filesInNonDefaultSection);
}

// Generate all configuration options onces...
var options = new Dictionary<Project.Configuration, Options.ExplicitOptions>();
var cmdLineOptions = new Dictionary<Project.Configuration, ProjectOptionsGenerator.VcxprojCmdLineOptions>();
var additionalDependenciesPerConf = new Dictionary<Project.Configuration, OrderableStrings>();
var projectOptionsGen = new ProjectOptionsGenerator();
foreach (Project.Configuration conf in configurations)
ProjectOptionsGenerator projectOptionsGen;
using (builder.CreateProfilingScope("BffGenerator.Generate:ProjectOptionsGenerator()"))
{
projectOptionsGen = new ProjectOptionsGenerator();
}
using (builder.CreateProfilingScope("BffGenerator.Generate:confs1"))
{
context.Options = new Options.ExplicitOptions();
context.CommandLineOptions = new ProjectOptionsGenerator.VcxprojCmdLineOptions();
context.Configuration = conf;
foreach (Project.Configuration conf in configurations)
{
context.Options = new Options.ExplicitOptions();
context.CommandLineOptions = new ProjectOptionsGenerator.VcxprojCmdLineOptions();
context.Configuration = conf;

GenerateBffOptions(projectOptionsGen, context, additionalDependenciesPerConf);
GenerateBffOptions(projectOptionsGen, context, additionalDependenciesPerConf);

options.Add(conf, context.Options);
cmdLineOptions.Add(conf, (ProjectOptionsGenerator.VcxprojCmdLineOptions)context.CommandLineOptions);
options.Add(conf, context.Options);
cmdLineOptions.Add(conf, (ProjectOptionsGenerator.VcxprojCmdLineOptions)context.CommandLineOptions);

// Validation of unsupported cases
if (conf.EventPreLink.Count > 0)
throw new Error("Sharpmake-FastBuild : Pre-Link Events not yet supported.");
if (context.Options["IgnoreImportLibrary"] == "true")
throw new Error("Sharpmake-FastBuild : IgnoreImportLibrary not yet supported.");
// Validation of unsupported cases
if (conf.EventPreLink.Count > 0)
throw new Error("Sharpmake-FastBuild : Pre-Link Events not yet supported.");
if (context.Options["IgnoreImportLibrary"] == "true")
throw new Error("Sharpmake-FastBuild : IgnoreImportLibrary not yet supported.");

if (conf.Output != Project.Configuration.OutputType.None && conf.FastBuildBlobbed)
{
ConfigureUnities(context, confSourceFiles);
if (conf.Output != Project.Configuration.OutputType.None && conf.FastBuildBlobbed)
{
ConfigureUnities(context, confSourceFiles);
}
}
}

ResolveUnities(project, projectPath);

// Start writing Bff
Expand Down Expand Up @@ -1453,10 +1463,11 @@ private static void FillLinkerOptions(BffGenerationContext context)
private static Strings CollectNatvisFiles(BffGenerationContext context)
{
Project.Configuration projectConfig = context.Configuration;

var natvisFiles = new Strings(projectConfig.Project.NatvisFiles);
if (projectConfig.Output == Project.Configuration.OutputType.Dll || projectConfig.Output == Project.Configuration.OutputType.Exe)
{
Strings natvisFiles = new Strings(projectConfig.Project.NatvisFiles);
HashSet<Project> visitedProjects = new HashSet<Project>();
var visitedProjects = new HashSet<Project>();
foreach (Project.Configuration resolvedDepConfig in projectConfig.ResolvedDependencies)
{
if (resolvedDepConfig.Output != Project.Configuration.OutputType.Dll && resolvedDepConfig.Output != Project.Configuration.OutputType.Exe)
Expand All @@ -1471,13 +1482,8 @@ private static Strings CollectNatvisFiles(BffGenerationContext context)
}
}
}

return natvisFiles;
}
else
{
return projectConfig.Project.NatvisFiles;
}
return natvisFiles;
}

private static void FillEmbeddedNatvisOptions(BffGenerationContext context)
Expand Down
2 changes: 1 addition & 1 deletion Sharpmake.Generators/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.14.5.0")]
[assembly: AssemblyVersion("0.14.6.0")]

[assembly: InternalsVisibleTo("Sharpmake")]
1 change: 1 addition & 0 deletions Sharpmake.Generators/VisualStudio/Csproj.Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public static class Project
<LangVersion>[options.LanguageVersion]</LangVersion>
<CopyVsixExtensionFiles>[options.CopyVsixExtensionFiles]</CopyVsixExtensionFiles>
<CopyVsixExtensionLocation>[options.CopyVsixExtensionLocation]</CopyVsixExtensionLocation>
<ProduceReferenceAssembly>[options.ProduceReferenceAssembly]</ProduceReferenceAssembly>
</PropertyGroup>
";

Expand Down
12 changes: 12 additions & 0 deletions Sharpmake.Generators/VisualStudio/Csproj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,12 @@ List<string> skipFiles

project.AddCSharpSpecificImportProjects(importProjects, devenv);

// Add custom .targets files as import projects.
foreach (string targetsFile in project.CustomTargetsFiles)
{
importProjects.AddRange(targetsFile.Select(f => new ImportProject() { Project = targetsFile }));
}

WriteImportProjects(importProjects.Distinct(EqualityComparer<ImportProject>.Default), project, configurations.First(), writer, resolver);

foreach (var element in project.UsingTasks)
Expand Down Expand Up @@ -3321,6 +3327,12 @@ private Options.ExplicitOptions GenerateOptions(CSharpProject project, Project.C
Options.Option(Options.CSharp.SonarQubeExclude.Enabled, () => { options["SonarQubeExclude"] = "True"; })
);

SelectOption
(
Options.Option(Options.CSharp.ProduceReferenceAssembly.Enabled, () => { options["ProduceReferenceAssembly"] = "True"; }),
Options.Option(Options.CSharp.ProduceReferenceAssembly.Disabled, () => { options["ProduceReferenceAssembly"] = RemoveLineTag; })
);

options["AssemblyOriginatorKeyFile"] = Options.PathOption.Get<Options.CSharp.AssemblyOriginatorKeyFile>(conf, RemoveLineTag, _projectPath);
options["MinimumVisualStudioVersion"] = Options.StringOption.Get<Options.CSharp.MinimumVisualStudioVersion>(conf);
options["OldToolsVersion"] = Options.StringOption.Get<Options.CSharp.OldToolsVersion>(conf);
Expand Down
Loading

0 comments on commit 9cf3f65

Please sign in to comment.