Add improved dll import/export attributes injection when building binary modules
This commit is contained in:
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Engine/Core/Compiler.h"
|
|
||||||
|
|
||||||
struct Vector2;
|
struct Vector2;
|
||||||
struct Vector3;
|
struct Vector3;
|
||||||
struct Vector4;
|
struct Vector4;
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
#if COMPILE_WITH_NAV_MESH_BUILDER
|
#if COMPILE_WITH_NAV_MESH_BUILDER
|
||||||
|
|
||||||
#include "Engine/Core/Compiler.h"
|
|
||||||
|
|
||||||
class Scene;
|
class Scene;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Engine/Core/Compiler.h"
|
|
||||||
|
|
||||||
struct RenderContext;
|
struct RenderContext;
|
||||||
struct RenderView;
|
struct RenderView;
|
||||||
class ParticleEmitter;
|
class ParticleEmitter;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Engine/Core/Singleton.h"
|
#include "Engine/Core/Singleton.h"
|
||||||
#include "Engine/Core/Compiler.h"
|
|
||||||
|
|
||||||
class MClass;
|
class MClass;
|
||||||
class MMethod;
|
class MMethod;
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Engine/Core/Compiler.h"
|
|
||||||
|
|
||||||
#define FLAXENGINE_NAME "FlaxEngine"
|
#define FLAXENGINE_NAME "FlaxEngine"
|
||||||
#define FLAXENGINE_VERSION Version(1, 0, 6216)
|
#define FLAXENGINE_VERSION Version(1, 0, 6216)
|
||||||
#define FLAXENGINE_VERSION_TEXT "1.0.6216"
|
#define FLAXENGINE_VERSION_TEXT "1.0.6216"
|
||||||
|
|||||||
@@ -2005,8 +2005,6 @@ namespace Flax.Build.Bindings
|
|||||||
contents.AppendLine();
|
contents.AppendLine();
|
||||||
contents.AppendLine("#pragma once");
|
contents.AppendLine("#pragma once");
|
||||||
contents.AppendLine();
|
contents.AppendLine();
|
||||||
contents.AppendLine("#include \"Engine/Core/Compiler.h\"");
|
|
||||||
contents.AppendLine();
|
|
||||||
contents.AppendLine($"#define {binaryModuleNameUpper}_NAME \"{binaryModuleName}\"");
|
contents.AppendLine($"#define {binaryModuleNameUpper}_NAME \"{binaryModuleName}\"");
|
||||||
if (version.Build == -1)
|
if (version.Build == -1)
|
||||||
contents.AppendLine($"#define {binaryModuleNameUpper}_VERSION Version({version.Major}, {version.Minor})");
|
contents.AppendLine($"#define {binaryModuleNameUpper}_VERSION Version({version.Major}, {version.Minor})");
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ namespace Flax.Build
|
|||||||
mainModuleOptions.SourcePaths.Add(mainModule.FolderPath);
|
mainModuleOptions.SourcePaths.Add(mainModule.FolderPath);
|
||||||
mainModule.Setup(mainModuleOptions);
|
mainModule.Setup(mainModuleOptions);
|
||||||
mainModuleOptions.MergeSourcePathsIntoSourceFiles();
|
mainModuleOptions.MergeSourcePathsIntoSourceFiles();
|
||||||
mainModuleOptions.CompileEnv.PreprocessorDefinitions.Add("FLAXENGINE_API=DLLIMPORT");
|
mainModuleOptions.CompileEnv.PreprocessorDefinitions.Add("FLAXENGINE_API=" + buildOptions.Toolchain.DllImport);
|
||||||
Builder.BuildModuleInner(buildData, mainModule, mainModuleOptions, false);
|
Builder.BuildModuleInner(buildData, mainModule, mainModuleOptions, false);
|
||||||
|
|
||||||
// Link executable
|
// Link executable
|
||||||
|
|||||||
@@ -695,14 +695,14 @@ namespace Flax.Build
|
|||||||
if (buildData.Target.LinkType == TargetLinkType.Modular)
|
if (buildData.Target.LinkType == TargetLinkType.Modular)
|
||||||
{
|
{
|
||||||
// Export symbols from binary module
|
// 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
|
else
|
||||||
{
|
{
|
||||||
// Export symbols from all binary modules in the build
|
// Export symbols from all binary modules in the build
|
||||||
foreach (var q in buildData.BinaryModules)
|
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)
|
if (buildData.Target.LinkType == TargetLinkType.Modular)
|
||||||
{
|
{
|
||||||
// Import symbols from referenced binary module
|
// 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
|
// Link against the referenced binary module
|
||||||
if (toolchain.UseImportLibraryWhenLinking)
|
if (toolchain.UseImportLibraryWhenLinking)
|
||||||
@@ -726,7 +726,7 @@ namespace Flax.Build
|
|||||||
else if (target.UseSymbolsExports)
|
else if (target.UseSymbolsExports)
|
||||||
{
|
{
|
||||||
// Export symbols from referenced binary module to be visible further
|
// 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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,16 @@ namespace Flax.Build
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool GeneratesImportLibraryWhenLinking => false;
|
public virtual bool GeneratesImportLibraryWhenLinking => false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the compiler attribute for symbols exported to shared library (dll file).
|
||||||
|
/// </summary>
|
||||||
|
public abstract string DllExport { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the compiler attribute for symbols imported from shared library (dll file).
|
||||||
|
/// </summary>
|
||||||
|
public abstract string DllImport { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Toolchain"/> class.
|
/// Initializes a new instance of the <see cref="Toolchain"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -195,6 +195,12 @@ namespace Flax.Build.Platforms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string DllExport => "__attribute__ ((__visibility__ (\"default\")))";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string DllImport => "";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void LogInfo()
|
public override void LogInfo()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -330,6 +330,12 @@ namespace Flax.Build.Platforms
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool GeneratesImportLibraryWhenLinking => true;
|
public override bool GeneratesImportLibraryWhenLinking => true;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string DllExport => "__declspec(dllexport)";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string DllImport => "__declspec(dllimport)";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void LogInfo()
|
public override void LogInfo()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user