Skip to content

Commit

Permalink
Adding the ability to pass arbitrary additional args to clang.
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Apr 23, 2019
1 parent caa7d01 commit 83aef60
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ClangSharpPInvokeGenerator/Program.cs
Expand Up @@ -19,12 +19,13 @@ public static void Main(string[] args)
var files = new List<string>();
var includeDirs = new List<string>();
var defines = new List<string>();
var additionalArgs = new List<string>();
string outputFile = string.Empty;
string @namespace = string.Empty;
string libraryPath = string.Empty;
string prefixStrip = string.Empty;
string methodClassName = "Methods";
string excludeFunctions = "";
string excludeFunctions = string.Empty;
string[] excludeFunctionsArray = null;

foreach (KeyValuePair<string, string> match in matches)
Expand All @@ -49,6 +50,11 @@ public static void Main(string[] args)
defines.Add(match.Value);
}

if (string.Equals(match.Key, "--a") || string.Equals(match.Key, "--additional"))
{
additionalArgs.Add(match.Value);
}

if (string.Equals(match.Key, "--o") || string.Equals(match.Key, "--output"))
{
outputFile = match.Value;
Expand Down Expand Up @@ -98,7 +104,7 @@ public static void Main(string[] args)

if (errorList.Any())
{
Console.WriteLine("Usage: ClangPInvokeGenerator --file [fileLocation] --libraryPath [library.dll] --output [output.cs] --namespace [Namespace] --include [headerFileIncludeDirs] --define [compilerDefine] --excludeFunctions [func1,func2]");
Console.WriteLine("Usage: ClangPInvokeGenerator --file [fileLocation] --libraryPath [library.dll] --output [output.cs] --namespace [Namespace] --include [headerFileIncludeDirs] --define [compilerDefine] --additional [compilerArg] --excludeFunctions [func1,func2]");
foreach (var error in errorList)
{
Console.WriteLine(error);
Expand All @@ -115,6 +121,7 @@ public static void Main(string[] args)

arr = arr.Concat(includeDirs.Select(x => "-I" + x)).ToArray();
arr = arr.Concat(defines.Select(x => "-D" + x)).ToArray();
arr = arr.Concat(additionalArgs).ToArray();

List<CXTranslationUnit> translationUnits = new List<CXTranslationUnit>();

Expand Down

0 comments on commit 83aef60

Please sign in to comment.