Browse Source

[cli] Added a new -A option to pass compiler arguments to Clang parser.

pull/914/head
Joao Matos 8 years ago
parent
commit
a302beccdc
  1. 9
      src/CLI/CLI.cs
  2. 5
      src/CLI/Generator.cs
  3. 2
      src/CLI/Options.cs

9
src/CLI/CLI.cs

@ -18,6 +18,7 @@ namespace CppSharp @@ -18,6 +18,7 @@ namespace CppSharp
optionSet.Add("l=", "{LIBRARY} that that contains the symbols of the generated code", l => options.Libraries.Add(l) );
optionSet.Add("L=", "the {PATH} of a folder to search for additional libraries", l => options.LibraryDirs.Add(l) );
optionSet.Add("D:", "additional define with (optional) value to add to be used while parsing the given header files", (n, v) => AddDefine(n, v, messages) );
optionSet.Add("A=", "additional Clang arguments to pass to the compiler while parsing the given header files", (v) => AddArgument(v, messages) );
optionSet.Add("o=|output=", "the {PATH} for the generated bindings file (doesn't need the extension since it will depend on the generator)", v => HandleOutputArg(v, messages) );
optionSet.Add("on=|outputnamespace=", "the {NAMESPACE} that will be used for the generated code", on => options.OutputNamespace = on );
@ -116,6 +117,14 @@ namespace CppSharp @@ -116,6 +117,14 @@ namespace CppSharp
}
}
static void AddArgument(string value, List<string> messages)
{
if (value == null)
messages.Add("Invalid compiler argument name for option -A.");
else
options.Arguments.Add(value);
}
static void AddDefine(string name, string value, List<string> messages)
{
if (name == null)

5
src/CLI/Generator.cs

@ -157,7 +157,10 @@ namespace CppSharp @@ -157,7 +157,10 @@ namespace CppSharp
if (triple.Contains("linux"))
SetupLinuxOptions(parserOptions);
foreach (string s in options.Arguments)
parserOptions.AddArguments(s);
foreach (string s in options.IncludeDirs)
parserOptions.AddIncludeDirs(s);

2
src/CLI/Options.cs

@ -19,6 +19,8 @@ namespace CppSharp @@ -19,6 +19,8 @@ namespace CppSharp
public List<string> Libraries { get; } = new List<string>();
public List<string> Arguments { get; } = new List<string>();
public Dictionary<string, string> Defines { get; } = new Dictionary<string, string>();
public string OutputDir { get; set; }

Loading…
Cancel
Save