Add improved dll import/export attributes injection when building binary modules

This commit is contained in:
Wojtek Figat
2021-02-25 13:02:13 +01:00
parent b193a7abc4
commit 6f12dc8567
11 changed files with 27 additions and 16 deletions

View File

@@ -695,14 +695,14 @@ namespace Flax.Build
if (buildData.Target.LinkType == TargetLinkType.Modular)
{
// Export symbols from binary module
moduleOptions.CompileEnv.PreprocessorDefinitions.Add(binaryModuleNameUpper + (target.UseSymbolsExports ? "_API=DLLEXPORT" : "_API="));
moduleOptions.CompileEnv.PreprocessorDefinitions.Add(binaryModuleNameUpper + (target.UseSymbolsExports ? "_API=" + toolchain.DllExport : "_API="));
}
else
{
// Export symbols from all binary modules in the build
foreach (var q in buildData.BinaryModules)
{
moduleOptions.CompileEnv.PreprocessorDefinitions.Add(q.Key.ToUpperInvariant() + (target.UseSymbolsExports ? "_API=DLLEXPORT" : "_API="));
moduleOptions.CompileEnv.PreprocessorDefinitions.Add(q.Key.ToUpperInvariant() + (target.UseSymbolsExports ? "_API=" + toolchain.DllExport : "_API="));
}
}
@@ -715,7 +715,7 @@ namespace Flax.Build
if (buildData.Target.LinkType == TargetLinkType.Modular)
{
// Import symbols from referenced binary module
moduleOptions.CompileEnv.PreprocessorDefinitions.Add(q.Name.ToUpperInvariant() + "_API=DLLIMPORT");
moduleOptions.CompileEnv.PreprocessorDefinitions.Add(q.Name.ToUpperInvariant() + "_API=" + toolchain.DllImport);
// Link against the referenced binary module
if (toolchain.UseImportLibraryWhenLinking)
@@ -726,7 +726,7 @@ namespace Flax.Build
else if (target.UseSymbolsExports)
{
// Export symbols from referenced binary module to be visible further
moduleOptions.CompileEnv.PreprocessorDefinitions.Add(q.Name.ToUpperInvariant() + "_API=DLLEXPORT");
moduleOptions.CompileEnv.PreprocessorDefinitions.Add(q.Name.ToUpperInvariant() + "_API=" + toolchain.DllExport);
}
else
{