Browse Source

[cli] Improve error messages.

pull/914/head
Joao Matos 8 years ago
parent
commit
544cd68725
  1. 10
      src/CLI/CLI.cs
  2. 21
      src/CLI/Generator.cs

10
src/CLI/CLI.cs

@ -94,7 +94,7 @@ namespace CppSharp @@ -94,7 +94,7 @@ namespace CppSharp
if (Directory.Exists(dir))
options.IncludeDirs.Add(dir);
else
messages.Add(string.Format("Directory {0} doesn't exist. Not adding as include directory.", dir));
messages.Add(string.Format("Directory '{0}' doesn't exist. Ignoring as include directory.", dir));
}
static void HandleOutputArg(string arg, List<string> messages)
@ -138,12 +138,12 @@ namespace CppSharp @@ -138,12 +138,12 @@ namespace CppSharp
options.HeaderFiles.Add(args);
else
{
messages.Add(string.Format("File {0} doesn't exist. Not adding to the list of files to generate bindings from.", args));
messages.Add(string.Format("File '{0}' could not be found.", args));
}
}
catch(Exception)
catch(Exception ex)
{
messages.Add(string.Format("Error while looking for files inside path {0}. Ignoring.", args));
messages.Add(string.Format("Error while looking for files inside path '{0}'. Ignoring.", args));
}
}
@ -182,7 +182,7 @@ namespace CppSharp @@ -182,7 +182,7 @@ namespace CppSharp
}
catch (Exception)
{
messages.Add(string.Format("Error while looking for files inside path {0}. Ignoring.", path));
messages.Add(string.Format("Error while looking for files inside path '{0}'. Ignoring.", path));
}
}

21
src/CLI/Generator.cs

@ -43,61 +43,62 @@ namespace CppSharp @@ -43,61 +43,62 @@ namespace CppSharp
{
if (!options.Platform.HasValue)
options.Platform = GetCurrentPlatform();
if (Platform.IsWindows && options.Platform != TargetPlatform.Windows)
{
messages.Add("Cannot create bindings for a platform other that Windows from a Windows running machine");
messages.Add("Cannot create bindings for a platform other that Windows from a Windows host.");
return false;
}
else if (Platform.IsMacOS && options.Platform != TargetPlatform.MacOS)
{
messages.Add("Cannot create bindings for a platform other that MacOS from a MacOS running machine");
messages.Add("Cannot create bindings for a platform other that macOS from a macOS host.");
return false;
}
else if (Platform.IsLinux && options.Platform != TargetPlatform.Linux)
{
messages.Add("Cannot create bindings for a platform other that Linux from a Linux running machine");
messages.Add("Cannot create bindings for a platform other that Linux from a Linux host.");
return false;
}
if (options.Platform != TargetPlatform.Windows && options.Kind != GeneratorKind.CSharp)
{
messages.Add("Cannot create bindings for languages other than C# from a non Windows machine");
messages.Add("Cannot create bindings for languages other than C# from a non-Windows host.");
return false;
}
if (options.Platform == TargetPlatform.Linux && options.Architecture != TargetArchitecture.x64)
{
messages.Add("Cannot create bindings for architectures other than x64 for Linux machines");
messages.Add("Cannot create bindings for architectures other than x64 for Linux targets.");
return false;
}
if (options.HeaderFiles.Count == 0)
{
messages.Add("No source header file has been given to generate bindings from");
messages.Add("No source header file has been given to generate bindings from.");
return false;
}
if (string.IsNullOrEmpty(options.OutputNamespace))
{
messages.Add("Output namespace is empty");
messages.Add("Output namespace not specified (see --output-namespace option).");
return false;
}
if (string.IsNullOrEmpty(options.OutputFileName))
{
messages.Add("Output not specified");
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 not enabled. Either set the input library name or the check symbols flag");
messages.Add("Input library name not specified and check symbols option not enabled.\nEither set the input library name (see 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. Either set the input library name or add at least one library");
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;
}

Loading…
Cancel
Save