diff --git a/Sharpmake.Application/CommandLineArguments.cs b/Sharpmake.Application/CommandLineArguments.cs
index 7d29d42d6..40b019f42 100644
--- a/Sharpmake.Application/CommandLineArguments.cs
+++ b/Sharpmake.Application/CommandLineArguments.cs
@@ -63,7 +63,6 @@ public enum InputType
public string DebugSolutionStartArguments = string.Empty;
public string DebugSolutionPath = string.Empty;
public DevEnv DebugSolutionDevEnv = DebugProjectGenerator.DefaultDevEnv;
- public bool GenerateRdJson = false;
[CommandLine.Option("sources", @"sharpmake sources files: ex: /sources( ""project1.sharpmake"", ""..\..\project2.sharpmake"" )")]
public void SetSources(params string[] files)
@@ -363,14 +362,6 @@ public void CommandLineForceCleanup(string autocleanupDb)
Exit = true;
}
- [CommandLine.Option("rdjson", @"Generate Rider project files")]
- public void CommandLineGenerateRdJson(bool minimize = false, bool ignoreDefaults = false)
- {
- GenerateRdJson = true;
- RiderJson.Minimize = minimize;
- RiderJson.IgnoreDefaults = ignoreDefaults;
- }
-
public void Validate()
{
if (Assemblies.Length == 0 && Sources.Length == 0)
diff --git a/Sharpmake.Application/Program.cs b/Sharpmake.Application/Program.cs
index 6f2ac81c1..61b73c9c9 100644
--- a/Sharpmake.Application/Program.cs
+++ b/Sharpmake.Application/Program.cs
@@ -658,11 +658,6 @@ public static Builder CreateBuilder(BuildContext.BaseBuildContext context, Argum
+ $" Make sure to have a static entry point method flagged with [{typeof(Main).FullName}] attribute, and add 'arguments.Generate<[your_class]>();' in it.");
builder.Context.ConfigureOrder = builder.Arguments.ConfigureOrder;
- if (parameters.GenerateRdJson)
- {
- builder.EventPostGenerationReport += RiderJson.PostGenerationCallback;
- }
-
// Call all configuration's methods and resolve project/solution member's values
using (Builder.Instance.CreateProfilingScope("Build"))
builder.BuildProjectAndSolution();
diff --git a/Sharpmake.Application/Properties/launchSettings.json b/Sharpmake.Application/Properties/launchSettings.json
index 463c0e209..06f06b2b9 100644
--- a/Sharpmake.Application/Properties/launchSettings.json
+++ b/Sharpmake.Application/Properties/launchSettings.json
@@ -116,6 +116,11 @@
"commandLineArgs": "/sources(@\u0027QTFileCustomBuild.sharpmake.cs\u0027)",
"workingDirectory": "$(ProjectDir)\\..\\samples\\QTFileCustomBuild"
},
+ "Sample (RiderJson)": {
+ "commandName": "Project",
+ "commandLineArgs": "/sources(@\u0027RiderJson.sharpmake.cs\u0027)",
+ "workingDirectory": "$(ProjectDir)\\..\\samples\\RiderJson"
+ },
"Sample (SimpleExeLibDependency)": {
"commandName": "Project",
"commandLineArgs": "/sources(@\u0027SimpleExeLibDependency.sharpmake.cs\u0027)",
diff --git a/Sharpmake.Generators/GeneratorManager.cs b/Sharpmake.Generators/GeneratorManager.cs
index 9055263af..e68fde9b4 100644
--- a/Sharpmake.Generators/GeneratorManager.cs
+++ b/Sharpmake.Generators/GeneratorManager.cs
@@ -5,6 +5,7 @@
using Sharpmake.Generators.Apple;
using Sharpmake.Generators.FastBuild;
using Sharpmake.Generators.Generic;
+using Sharpmake.Generators.Rider;
using Sharpmake.Generators.VisualStudio;
namespace Sharpmake.Generators
@@ -25,6 +26,9 @@ public class GeneratorManager : IGeneratorManager
private MakeApplication _makeApplicationGenerator = null;
public MakeApplication MakeApplicationGenerator => _makeApplicationGenerator ?? (_makeApplicationGenerator = new MakeApplication());
+ public RiderJson _riderJsonGenerator = null;
+ public RiderJson RiderJsonGenerator => _riderJsonGenerator ?? (_riderJsonGenerator = new RiderJson());
+
// Project generators
private CSproj _csprojGenerator = null;
public CSproj CsprojGenerator => _csprojGenerator ?? (_csprojGenerator = new CSproj());
@@ -104,6 +108,11 @@ public void Generate(Builder builder,
BffGenerator.Generate(builder, project, configurations, projectFile, generatedFiles, skipFiles);
break;
}
+ case DevEnv.rider:
+ {
+ BffGenerator.Generate(builder, project, configurations, projectFile, generatedFiles, skipFiles);
+ break;
+ }
default:
{
throw new Error("Generate called with unknown DevEnv: " + devEnv);
@@ -158,6 +167,17 @@ public void Generate(Builder builder,
SlnGenerator.Generate(builder, solution, configurations, solutionFile, generatedFiles, skipFiles);
break;
}
+ case DevEnv.rider:
+ {
+ if (UtilityMethods.HasFastBuildConfig(configurations))
+ {
+ var masterBff = new MasterBff();
+ masterBff.Generate(builder, solution, configurations, solutionFile, generatedFiles, skipFiles);
+ }
+
+ RiderJsonGenerator.Generate(builder, solution, configurations, solutionFile, generatedFiles, skipFiles);
+ break;
+ }
default:
{
throw new Error("Generate called with unknown DevEnv: " + devEnv);
diff --git a/Sharpmake.Generators/Rider/RiderJson.Template.cs b/Sharpmake.Generators/Rider/RiderJson.Template.cs
index 1a6839883..e07dc8d1e 100644
--- a/Sharpmake.Generators/Rider/RiderJson.Template.cs
+++ b/Sharpmake.Generators/Rider/RiderJson.Template.cs
@@ -1,4 +1,7 @@
-namespace Sharpmake.Generators.Rider
+// Copyright (c) Ubisoft. All Rights Reserved.
+// Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license information.
+
+namespace Sharpmake.Generators.Rider
{
public partial class RiderJson
{
diff --git a/Sharpmake.Generators/Rider/RiderJson.Util.cs b/Sharpmake.Generators/Rider/RiderJson.Util.cs
index 553a63aa8..1987487e5 100644
--- a/Sharpmake.Generators/Rider/RiderJson.Util.cs
+++ b/Sharpmake.Generators/Rider/RiderJson.Util.cs
@@ -1,4 +1,7 @@
-using System;
+// Copyright (c) Ubisoft. All Rights Reserved.
+// Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license information.
+
+using System;
using System.Collections;
using System.Linq;
using Sharpmake.Generators.VisualStudio;
@@ -81,7 +84,7 @@ public static string GetCompiler(this IGenerationContext context)
return Compiler.Clang;
}
- switch (context.Configuration.Compiler)
+ switch (toolset.GetDefaultDevEnvForToolset())
{
case DevEnv.vs2015:
return Compiler.Vs15;
diff --git a/Sharpmake.Generators/Rider/RiderJson.cs b/Sharpmake.Generators/Rider/RiderJson.cs
index 63e68efc1..7024f9582 100644
--- a/Sharpmake.Generators/Rider/RiderJson.cs
+++ b/Sharpmake.Generators/Rider/RiderJson.cs
@@ -1,5 +1,7 @@
-using System;
-using System.Collections.Concurrent;
+// Copyright (c) Ubisoft. All Rights Reserved.
+// Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license information.
+
+using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
@@ -13,74 +15,12 @@ namespace Sharpmake.Generators.Rider
///
/// Generator for Rider project model json files.
///
- public partial class RiderJson : IProjectGenerator, ISolutionGenerator
+ public partial class RiderJson : ISolutionGenerator
{
public static bool Minimize = false;
public static bool IgnoreDefaults = false;
- ///
- /// Callback which should be added to in order to generate Rider project model.
- ///
- public static void PostGenerationCallback(List projects, List solutions, ConcurrentDictionary generationReport)
- {
- var builder = Builder.Instance;
- var generator = new RiderJson();
-
- builder.LogWriteLine(" RdJson files generated:");
-
- foreach (var project in projects)
- {
- foreach (var config in project.Configurations)
- {
- if (!generator._projectsInfo.ContainsKey(config.Target))
- {
- generator._projectsInfo.Add(config.Target, new Dictionary());
- }
-
- if (!generator._projectsInfo[config.Target].ContainsKey(project.Name))
- {
- generator._projectsInfo[config.Target].Add(project.Name, new RiderProjectInfo(project));
- }
-
- var riderProjInfo = generator._projectsInfo[config.Target][project.Name];
- riderProjInfo.ReadConfiguration(config);
- }
- }
-
- foreach (var solution in solutions)
- {
- foreach (var solutionFileEntry in solution.SolutionFilesMapping)
- {
- var solutionFolder = Path.GetDirectoryName(solutionFileEntry.Key);
-
- var generationOutput = generationReport[solution.GetType()];
- var fileWithExtension = Path.Combine(solutionFileEntry.Key + ".rdjson");
-
- var configurations = solutionFileEntry.Value
- .Where(it => PlatformRegistry.Has(it.Platform)).ToList();
-
- generator.Generate(builder, solution, configurations, fileWithExtension, generationOutput.Generated,
- generationOutput.Skipped);
-
- builder.LogWriteLine(" {0,5}", fileWithExtension);
-
- var solutionFileName = Path.GetFileName(solutionFileEntry.Key);
-
- foreach (var projectInfo in configurations.SelectMany(solutionConfig => solutionConfig.IncludedProjectInfos))
- {
- if (projectInfo.Project.SharpmakeProjectType != Project.ProjectTypeAttribute.Generate)
- {
- continue;
- }
-
- var projectOutput = generationReport[projectInfo.Project.GetType()];
- generator.Generate(builder, projectInfo.Project,
- new List {projectInfo.Configuration},
- Path.Combine(solutionFolder, $".{solutionFileName}"), projectOutput.Generated, projectOutput.Skipped);
- }
- }
- }
- }
+ private const string RiderJsonFileExtension = ".rdjson";
///
/// Helper class to keep all the project information for "Modules" section of json file.
@@ -140,12 +80,6 @@ public OrderedDictionary ToDictionary()
}
}
- ///
- /// Maps projects information for later usage in "Modules" section.
- ///
- private readonly Dictionary> _projectsInfo
- = new Dictionary>();
-
///
/// Helper class for storing all the project-related information.
///
@@ -171,7 +105,7 @@ private class RiderGenerationContext : IGenerationContext
public FastBuildMakeCommandGenerator FastBuildMakeCommandGenerator { get; }
public string FastBuildArguments { get; }
-
+
public RiderGenerationContext(Builder builder, Project project, Project.Configuration configuration,
string projectPath, string solutionName)
{
@@ -223,12 +157,25 @@ public void SelectOptionWithFallback(Action fallbackAction, params Options.Optio
public void Generate(Builder builder, Solution solution, List configurations, string solutionFile,
List generatedFiles, List skipFiles)
{
- var projects = new OrderedDictionary();
+ var configurationMapping = new Dictionary>();
+ var fileInfo = new FileInfo(solutionFile);
+ var solutionPath = fileInfo.Directory.FullName;
+
+ var solutionFileName = fileInfo.Name;
+ var file = new FileInfo(
+ Util.GetCapitalizedPath(solutionPath + Path.DirectorySeparatorChar + solutionFileName + RiderJsonFileExtension));
+ var projects = new OrderedDictionary();
+
foreach (var solutionConfig in configurations)
{
foreach (var proj in solutionConfig.IncludedProjectInfos)
{
+ if (proj.Project.SharpmakeProjectType != Project.ProjectTypeAttribute.Generate)
+ {
+ continue;
+ }
+
var solutionFolder = string.IsNullOrEmpty(proj.SolutionFolder)
? proj.Configuration.GetSolutionFolder(solution.Name)
: proj.SolutionFolder;
@@ -237,28 +184,25 @@ public void Generate(Builder builder, Solution solution, List>());
}
-
+
var projObject = projects[projectEntry] as Dictionary>;
var projConfig = new Dictionary();
+ var projectConfigurations = configurationMapping.GetValueOrAdd(proj.Project, new List());
+ projectConfigurations.Add(proj.Configuration);
+
projConfig.Add("ProjectConfig", proj.Configuration.Name);
projConfig.Add("SolutionConfig", solutionConfig.Name);
projConfig.Add("DoBuild", (proj.ToBuild != Solution.Configuration.IncludedProjectInfo.Build.No).ToString());
- if (!projObject.ContainsKey(proj.Configuration.Platform.ToString()))
- {
- projObject.Add(proj.Configuration.Platform.ToString(), new List
make = 1 << 9,
+
+ ///
+ /// Rider project files
+ ///
+ rider = 1 << 10,
///
/// All supported Visual Studio versions.
diff --git a/Sharpmake/Util.cs b/Sharpmake/Util.cs
index 302cb27e9..88e05ad12 100644
--- a/Sharpmake/Util.cs
+++ b/Sharpmake/Util.cs
@@ -1437,7 +1437,9 @@ public static bool IsDotNet(Project.Configuration conf)
public static bool IsCpp(Project.Configuration conf)
{
string extension = Path.GetExtension(conf.ProjectFullFileNameWithExtension);
- return (string.Compare(extension, ".vcxproj", StringComparison.OrdinalIgnoreCase) == 0);
+ return (string.Compare(extension, ".vcxproj", StringComparison.OrdinalIgnoreCase) == 0) ||
+ // RiderJson project files
+ (string.Compare(extension, ".json", StringComparison.OrdinalIgnoreCase) == 0);
}
public static string GetProjectFileExtension(Project.Configuration conf)
@@ -1472,6 +1474,9 @@ public static string GetProjectFileExtension(Project.Configuration conf)
case DevEnv.make:
return ".make";
+ case DevEnv.rider:
+ return ".json";
+
default:
throw new NotImplementedException("GetProjectFileExtension called with unknown DevEnv: " + devEnv);
}
diff --git a/samples/RiderJson/RiderJson.sharpmake.cs b/samples/RiderJson/RiderJson.sharpmake.cs
index d24dafc25..9a51b5825 100644
--- a/samples/RiderJson/RiderJson.sharpmake.cs
+++ b/samples/RiderJson/RiderJson.sharpmake.cs
@@ -9,7 +9,7 @@ public BaseProject()
{
AddTargets(new Target(
Platform.win64,
- DevEnv.vs2017 | DevEnv.vs2019,
+ DevEnv.rider | DevEnv.vs2022,
Optimization.Debug | Optimization.Release,
OutputType.Lib,
Blob.FastBuildUnitys,
@@ -27,6 +27,17 @@ public virtual void ConfigureAll(Configuration conf, Target target)
conf.FastBuildBlobbed = target.Blob == Blob.FastBuildUnitys;
conf.AdditionalCompilerOptions.Add("/FS");
conf.Options.Add(Options.Vc.Compiler.CppLanguageStandard.CPP17);
+
+ if (conf.Compiler == DevEnv.rider)
+ {
+ if (target.BuildSystem == BuildSystem.MSBuild)
+ {
+ conf.TargetPath = @"[conf.ProjectPath]\..\vs2022\output\[target.Platform]\[conf.Name]";
+ conf.Options.Add(new Options.Rider.MsBuildOverrideProjectFile(@"[conf.ProjectPath]\..\vs2022\[project.Name].vcxproj"));
+ }
+
+ conf.Options.Add(Options.Vc.General.PlatformToolset.v143);
+ }
}
}
@@ -111,7 +122,7 @@ public BaseSolution()
{
AddTargets(new Target(
Platform.win64,
- DevEnv.vs2019 | DevEnv.vs2017,
+ DevEnv.rider | DevEnv.vs2022,
Optimization.Debug | Optimization.Release,
OutputType.Lib,
Blob.FastBuildUnitys,