Skip to content

Commit

Permalink
Merge branch 'merge-clr' into 'dev'
Browse files Browse the repository at this point in the history
Add support for mixed/partial .Net C++ projects

See merge request Sharpmake/sharpmake!273
  • Loading branch information
belkiss committed Mar 18, 2022
2 parents 6a9de91 + 73ede62 commit 2218350
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions Sharpmake.Generators/FastBuild/Bff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ List<string> skipFiles
string projectPath = new FileInfo(projectFile).Directory.FullName;
var context = new BffGenerationContext(builder, project, projectPath, configurations);
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;
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"))
Expand Down Expand Up @@ -272,6 +271,7 @@ List<string> skipFiles
var platformBff = PlatformRegistry.Get<IPlatformBff>(conf.Platform);
var clangPlatformBff = PlatformRegistry.Query<IClangPlatformBff>(conf.Platform);
var microsoftPlatformBff = PlatformRegistry.Query<IMicrosoftPlatformBff>(conf.Platform);
var dotNetConf = Util.IsDotNet(conf);

// TODO: really not ideal, refactor and move the properties we need from it someplace else
var vcxprojPlatform = PlatformRegistry.Query<IPlatformVcxproj>(conf.Platform);
Expand Down Expand Up @@ -348,9 +348,11 @@ List<string> skipFiles
isUnity = false;
}

var useClr = dotNetConf && !isCompileAsNonCLRFile || isCompileAsCLRFile;
var fastBuildSubConfigClrSupport = useClr ? "/clr" : FileGeneratorUtilities.RemoveLineTag;

Trace.Assert(!isCompileAsCPPFile, "Sharpmake-FastBuild : CompiledAsCPP isn't yet supported.");
Trace.Assert(!isCompileAsCLRFile, "Sharpmake-FastBuild : CompiledAsCLR isn't yet supported.");
Trace.Assert(!isCompileAsNonCLRFile, "Sharpmake-FastBuild : !CompiledAsCLR isn't yet supported.");
Trace.Assert(!isCompileAsCLRFile || !isCompileAsNonCLRFile, "Sharpmake-FastBuild : a file cannot be simultaneously compiled with and without the CLR");

Strings fastBuildCompilerInputPatternList = isCompileAsCFile ? new Strings { ".c" } : project.SourceFilesCPPExtensions;
Strings fastBuildCompilerInputPatternTransformedList = new Strings(fastBuildCompilerInputPatternList.Select((s) => { return "*" + s; }));
Expand Down Expand Up @@ -1034,7 +1036,7 @@ List<string> skipFiles
using (bffGenerator.Declare("cmdLineOptions", confCmdLineOptions))
using (bffGenerator.Declare("fastBuildUsingPlatformConfig", "Using( " + fastBuildUsingPlatformConfig + " )"))
using (bffGenerator.Declare("fastBuildProjectName", projectName))
using (bffGenerator.Declare("fastBuildClrSupport", fastBuildClrSupport))
using (bffGenerator.Declare("fastBuildClrSupport", fastBuildSubConfigClrSupport))
using (bffGenerator.Declare("fastBuildOutputFileShortName", fastBuildOutputFileShortName))
using (bffGenerator.Declare("fastBuildOutputFile", fastBuildOutputFile))
using (bffGenerator.Declare("fastBuildLinkerOutputFile", fastBuildLinkerOutputFile))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public string GetOutputFileNamePrefix(Project.Configuration.OutputType outputTyp
public virtual IEnumerable<string> GetPlatformLibraryPaths(Project.Configuration configuration)
{
var dirs = new List<string>();
var dotnet = Util.IsDotNet(configuration) ? configuration.Target.GetFragment<DotNetFramework>() : default(DotNetFramework?);
var hasDotNetDependency = Util.IsDotNet(configuration) || configuration.ResolvedSourceFilesWithCompileAsCLROption.Count > 0;
var dotnet = hasDotNetDependency ? configuration.Target.GetFragment<DotNetFramework>() : default(DotNetFramework?);

var platformToolset = Options.GetObject<Options.Vc.General.PlatformToolset>(configuration);
if (platformToolset.IsLLVMToolchain())
Expand Down

0 comments on commit 2218350

Please sign in to comment.