Fix using cross-module references inside C++ game project
This commit is contained in:
@@ -82,6 +82,17 @@ namespace Flax.Build
|
||||
return GetModuleProject(module, buildData.Project);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the project that contains a given module (checks for modules located in the given project Source folder).
|
||||
/// </summary>
|
||||
/// <param name="module">The module.</param>
|
||||
/// <param name="project">The project to check.</param>
|
||||
/// <returns>True if project contains that module inside, otherwise it's external or referenced.</returns>
|
||||
public static bool IsModuleFromProject(Module module, ProjectInfo project)
|
||||
{
|
||||
return GetModuleProject(module, project) == project;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the targets.
|
||||
/// </summary>
|
||||
|
||||
@@ -696,6 +696,26 @@ namespace Flax.Build
|
||||
{
|
||||
// Export symbols from binary module
|
||||
moduleOptions.CompileEnv.PreprocessorDefinitions.Add(binaryModuleNameUpper + (target.UseSymbolsExports ? "_API=" + toolchain.DllExport : "_API="));
|
||||
|
||||
// Import symbols from binary modules containing the referenced modules (from this project only, external ones are handled via ReferenceBuilds below)
|
||||
foreach (var moduleName in moduleOptions.PrivateDependencies)
|
||||
{
|
||||
var dependencyModule = buildData.Rules.GetModule(moduleName);
|
||||
if (dependencyModule != null && !string.IsNullOrEmpty(dependencyModule.BinaryModuleName) && dependencyModule.BinaryModuleName != binaryModule.Key && IsModuleFromProject(dependencyModule, project) && buildData.Modules.TryGetValue(dependencyModule, out var dependencyOptions))
|
||||
{
|
||||
// Import symbols from referenced binary module
|
||||
moduleOptions.CompileEnv.PreprocessorDefinitions.Add(dependencyModule.BinaryModuleName.ToUpperInvariant() + "_API=" + toolchain.DllImport);
|
||||
}
|
||||
}
|
||||
foreach (var moduleName in moduleOptions.PublicDependencies)
|
||||
{
|
||||
var dependencyModule = buildData.Rules.GetModule(moduleName);
|
||||
if (dependencyModule != null && !string.IsNullOrEmpty(dependencyModule.BinaryModuleName) && dependencyModule.BinaryModuleName != binaryModule.Key && IsModuleFromProject(dependencyModule, project) && buildData.Modules.TryGetValue(dependencyModule, out var dependencyOptions))
|
||||
{
|
||||
// Import symbols from referenced binary module
|
||||
moduleOptions.CompileEnv.PreprocessorDefinitions.Add(dependencyModule.BinaryModuleName.ToUpperInvariant() + "_API=" + toolchain.DllImport);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user