Browse Source

Improve the defaults of necessary generation options to improve accessibility.

pull/1139/head
Joao Matos 8 years ago
parent
commit
d5e6e11046
  1. 50
      src/CLI/Generator.cs

50
src/CLI/Generator.cs

@ -74,9 +74,29 @@ namespace CppSharp @@ -74,9 +74,29 @@ namespace CppSharp
public bool ValidateOptions(List<string> messages)
{
if (options.HeaderFiles.Count == 0)
{
messages.Add("No source header file has been given to generate bindings from.");
return false;
}
if (!options.Platform.HasValue)
options.Platform = GetCurrentPlatform();
if (string.IsNullOrEmpty(options.OutputDir))
{
options.OutputDir = Path.Combine(Directory.GetCurrentDirectory(), "gen");
}
var dir = Path.GetDirectoryName(options.HeaderFiles.First());
var moduleName = new DirectoryInfo(dir).Name;
if (string.IsNullOrEmpty(options.OutputFileName))
options.OutputFileName = moduleName;
if (string.IsNullOrEmpty(options.OutputNamespace))
options.OutputNamespace = moduleName;
if (Platform.IsWindows && options.Platform != TargetPlatform.Windows)
{
messages.Add("Cannot create bindings for a platform other that Windows from a Windows host.");
@ -105,36 +125,6 @@ namespace CppSharp @@ -105,36 +125,6 @@ namespace CppSharp
return false;
}
if (options.HeaderFiles.Count == 0)
{
messages.Add("No source header file has been given to generate bindings from.");
return false;
}
if (string.IsNullOrEmpty(options.OutputNamespace))
{
messages.Add("Output namespace not specified (see --outputnamespace option).");
return false;
}
if (string.IsNullOrEmpty(options.OutputFileName))
{
messages.Add("Output directory not specified (see --output option).");
return false;
}
if (string.IsNullOrEmpty(options.InputLibraryName) && !options.CheckSymbols)
{
messages.Add("Input library name not specified and check symbols option not enabled.\nEither set the input library name or the check symbols flag.");
return false;
}
if (string.IsNullOrEmpty(options.InputLibraryName) && options.CheckSymbols && options.Libraries.Count == 0)
{
messages.Add("Input library name not specified and check symbols is enabled but no libraries were given.\nEither set the input library name or add at least one library.");
return false;
}
SetupTargetTriple();

Loading…
Cancel
Save