Skip to content

Commit

Permalink
Add support for passing in compiler defines.
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Apr 23, 2019
1 parent 977973b commit caa7d01
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ClangSharpPInvokeGenerator/Program.cs
Expand Up @@ -18,6 +18,7 @@ public static void Main(string[] args)

var files = new List<string>();
var includeDirs = new List<string>();
var defines = new List<string>();
string outputFile = string.Empty;
string @namespace = string.Empty;
string libraryPath = string.Empty;
Expand All @@ -43,6 +44,11 @@ public static void Main(string[] args)
includeDirs.Add(match.Value);
}

if (string.Equals(match.Key, "--d") || string.Equals(match.Key, "--define"))
{
defines.Add(match.Value);
}

if (string.Equals(match.Key, "--o") || string.Equals(match.Key, "--output"))
{
outputFile = match.Value;
Expand Down Expand Up @@ -92,7 +98,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] --excludeFunctions [func1,func2]");
Console.WriteLine("Usage: ClangPInvokeGenerator --file [fileLocation] --libraryPath [library.dll] --output [output.cs] --namespace [Namespace] --include [headerFileIncludeDirs] --define [compilerDefine] --excludeFunctions [func1,func2]");
foreach (var error in errorList)
{
Console.WriteLine(error);
Expand All @@ -108,6 +114,7 @@ public static void Main(string[] args)
string[] arr = { "-x", "c++" };

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

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

Expand Down

0 comments on commit caa7d01

Please sign in to comment.