Fix using preprocessor define values in Flax.Build bindings parsing

This commit is contained in:
Wojtek Figat
2022-05-23 17:45:18 +02:00
parent 2eb51f9a83
commit c0412cc4f4

View File

@@ -378,7 +378,7 @@ namespace Flax.Build.Bindings
var negate = tokenValue[0] == '!';
if (negate)
tokenValue = tokenValue.Substring(1);
tokenValue = ReplacePreProcessorDefines(tokenValue, context.PreprocessorDefines.Keys);
tokenValue = ReplacePreProcessorDefines(tokenValue, context.PreprocessorDefines);
tokenValue = ReplacePreProcessorDefines(tokenValue, moduleOptions.PublicDefinitions);
tokenValue = ReplacePreProcessorDefines(tokenValue, moduleOptions.PrivateDefinitions);
tokenValue = ReplacePreProcessorDefines(tokenValue, moduleOptions.CompileEnv.PreprocessorDefinitions);
@@ -485,6 +485,16 @@ namespace Flax.Build.Bindings
return text;
}
private static string ReplacePreProcessorDefines(string text, IDictionary<string, string> defines)
{
foreach (var e in defines)
{
if (string.Equals(text, e.Key, StringComparison.Ordinal))
text = text.Replace(e.Key, string.IsNullOrEmpty(e.Value) ? "1" : e.Value);
}
return text;
}
private static void ParsePreprocessorIf(FileInfo fileInfo, Tokenizer tokenizer, ref Token token)
{
int ifsCount = 1;