Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for ninja generator #229

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion Sharpmake.Application/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ private static int Main()
CommandLine.ExecuteOnObject(platformCmdLine);
platformCmdLine.Validate();
}

CompilerFlagLookupTable.Init();
LinkerFlagLookupTable.Init();

bool oneInstanceMutexCreated;
string mutexName = string.Format("SharpmakeSingleInstanceMutex{0}", parameters.MutexSuffix); // Allow custom mutex name suffix. Useful to debug concurrently multiple sharpmake running from different branches
Expand Down Expand Up @@ -393,7 +396,7 @@ private static int Main()
if (Debugger.IsAttached)
{
LogWriteLine("Please look at the errors.");
Debugger.Break();
Debugger.Break();
}
}

Expand Down
1 change: 1 addition & 0 deletions Sharpmake.Generators/Apple/XCodeProj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private class XCodeGenerationContext : IGenerationContext
public DevEnv DevelopmentEnvironment => Configuration.Compiler;
public Options.ExplicitOptions Options { get; set; } = new Options.ExplicitOptions();
public IDictionary<string, string> CommandLineOptions { get; set; } = new VisualStudio.ProjectOptionsGenerator.VcxprojCmdLineOptions();
public IDictionary<string, string> LinkerCommandLineOptions { get; set; } = new ProjectOptionsGenerator.VcxprojCmdLineOptions();

public string ProjectDirectoryCapitalized { get; }
public string ProjectSourceCapitalized { get; }
Expand Down
1 change: 1 addition & 0 deletions Sharpmake.Generators/FastBuild/Bff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private class BffGenerationContext : IBffGenerationContext
public Options.ExplicitOptions Options { get; set; } = new Options.ExplicitOptions();

public IDictionary<string, string> CommandLineOptions { get; set; } = new ProjectOptionsGenerator.VcxprojCmdLineOptions();
public IDictionary<string, string> LinkerCommandLineOptions { get; set; } = new ProjectOptionsGenerator.VcxprojCmdLineOptions();

public DevEnv DevelopmentEnvironment => Configuration.Compiler;

Expand Down
77 changes: 53 additions & 24 deletions Sharpmake.Generators/GeneratorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public class GeneratorManager : IGeneratorManager

private Makefile _makefileGenerator = null;
public Makefile MakefileGenerator => _makefileGenerator ?? (_makefileGenerator = new Makefile());

private NinjaProject _ninjaProjectGenerator = null;
public NinjaProject NinjaProjectGenerator => _ninjaProjectGenerator ?? (_ninjaProjectGenerator = new NinjaProject());
#endregion

// singleton
Expand Down Expand Up @@ -114,6 +117,11 @@ public void Generate(Builder builder,
BffGenerator.Generate(builder, project, configurations, projectFile, generatedFiles, skipFiles);
break;
}
case DevEnv.ninja:
{
NinjaProjectGenerator.Generate(builder, project, configurations, projectFile, generatedFiles, skipFiles);
break;
}
default:
{
throw new Error("Generate called with unknown DevEnv: " + devEnv);
Expand All @@ -139,34 +147,55 @@ public void Generate(Builder builder,
}
else
{
DevEnv devEnv = configurations[0].Target.GetFragment<DevEnv>();
switch (devEnv)
Dictionary<DevEnv, List<Solution.Configuration>> devEnvToConfigs = new Dictionary<DevEnv, List<Solution.Configuration>>();

foreach (var config in configurations)
{
case DevEnv.make:
{
if (configurations[0].Platform == Platform.android)
MakeApplicationGenerator.Generate(builder, solution, configurations, solutionFile, generatedFiles, skipFiles);
else
MakefileGenerator.Generate(builder, solution, configurations, solutionFile, generatedFiles, skipFiles);
break;
}
case DevEnv.vs2015:
case DevEnv.vs2017:
case DevEnv.vs2019:
case DevEnv.vs2022:
{
if (UtilityMethods.HasFastBuildConfig(configurations))
DevEnv devEnv = config.Target.GetFragment<DevEnv>();
if (!devEnvToConfigs.ContainsKey(devEnv))
{
devEnvToConfigs.Add(devEnv, new List<Solution.Configuration>());
}
devEnvToConfigs[devEnv].Add(config);
}

foreach (var devEnvAndConfigs in devEnvToConfigs)
{
DevEnv devEnv = devEnvAndConfigs.Key;
List<Solution.Configuration> devEnvConfigurations = devEnvAndConfigs.Value;
switch (devEnv)
{
case DevEnv.make:
{
MasterBffGenerator.Generate(builder, solution, configurations, solutionFile, generatedFiles, skipFiles);
if (devEnvConfigurations[0].Platform == Platform.android)
MakeApplicationGenerator.Generate(builder, solution, devEnvConfigurations, solutionFile, generatedFiles, skipFiles);
else
MakefileGenerator.Generate(builder, solution, devEnvConfigurations, solutionFile, generatedFiles, skipFiles);
break;
}
case DevEnv.vs2015:
case DevEnv.vs2017:
case DevEnv.vs2019:
case DevEnv.vs2022:
{
if (UtilityMethods.HasFastBuildConfig(devEnvConfigurations))
{
MasterBffGenerator.Generate(builder, solution, devEnvConfigurations, solutionFile, generatedFiles, skipFiles);
}

SlnGenerator.Generate(builder, solution, configurations, solutionFile, generatedFiles, skipFiles);
break;
}
default:
{
throw new Error("Generate called with unknown DevEnv: " + devEnv);
}
SlnGenerator.Generate(builder, solution, devEnvConfigurations, solutionFile, generatedFiles, skipFiles);
break;
}
case DevEnv.ninja:
{
NinjaProjectGenerator.Generate(builder, solution, devEnvConfigurations, solutionFile, generatedFiles, skipFiles);
break;
}
default:
{
throw new Error("Generate called with unknown DevEnv: " + devEnv);
}
}
}
}
}
Expand Down
Loading