Merge remote-tracking branch 'origin/master' into 1.10

# Conflicts:
#	Source/Engine/Graphics/Materials/MaterialShader.h
This commit is contained in:
Wojtek Figat
2025-02-18 09:19:59 +01:00
133 changed files with 2253 additions and 654 deletions

View File

@@ -1938,19 +1938,20 @@ namespace Flax.Build.Bindings
contents.Append('}').AppendLine();
}
private static string GenerateCppInterfaceInheritanceTable(BuildData buildData, StringBuilder contents, ModuleInfo moduleInfo, VirtualClassInfo typeInfo, string typeNameNative)
private static string GenerateCppInterfaceInheritanceTable(BuildData buildData, StringBuilder contents, ModuleInfo moduleInfo, ClassStructInfo typeInfo, string typeNameNative, string typeNameInternal)
{
var interfacesPtr = "nullptr";
var interfaces = typeInfo.Interfaces;
if (interfaces != null)
{
interfacesPtr = typeNameNative + "_Interfaces";
var virtualTypeInfo = typeInfo as VirtualClassInfo;
interfacesPtr = typeNameInternal + "_Interfaces";
contents.Append("static const ScriptingType::InterfaceImplementation ").Append(interfacesPtr).AppendLine("[] = {");
for (int i = 0; i < interfaces.Count; i++)
{
var interfaceInfo = interfaces[i];
var scriptVTableOffset = typeInfo.GetScriptVTableOffset(interfaceInfo);
contents.AppendLine($" {{ &{interfaceInfo.NativeName}::TypeInitializer, (int16)VTABLE_OFFSET({typeInfo.NativeName}, {interfaceInfo.NativeName}), {scriptVTableOffset}, true }},");
var scriptVTableOffset = virtualTypeInfo?.GetScriptVTableOffset(interfaceInfo) ?? 0;
contents.AppendLine($" {{ &{interfaceInfo.NativeName}::TypeInitializer, (int16)VTABLE_OFFSET({typeNameNative}, {interfaceInfo.NativeName}), {scriptVTableOffset}, true }},");
}
contents.AppendLine(" { nullptr, 0 },");
contents.AppendLine("};");
@@ -2254,7 +2255,7 @@ namespace Flax.Build.Bindings
contents.AppendLine();
// Interfaces
var interfacesTable = GenerateCppInterfaceInheritanceTable(buildData, contents, moduleInfo, classInfo, classTypeNameNative);
var interfacesTable = GenerateCppInterfaceInheritanceTable(buildData, contents, moduleInfo, classInfo, classTypeNameNative, classTypeNameInternal);
// Type initializer
if (GenerateCppIsTemplateInstantiationType(classInfo))
@@ -2269,7 +2270,7 @@ namespace Flax.Build.Bindings
contents.Append("&ScriptingType::DefaultSpawn, ");
else
contents.Append($"(ScriptingType::SpawnHandler)&{classTypeNameNative}::Spawn, ");
if (classInfo.BaseType != null && useScripting)
if (classInfo.BaseType != null)
contents.Append($"&{classInfo.BaseType.FullNameNative}::TypeInitializer, ");
else
contents.Append("nullptr, ");
@@ -2286,9 +2287,7 @@ namespace Flax.Build.Bindings
else
contents.Append("nullptr");
}
contents.Append(", ").Append(interfacesTable);
contents.Append(");");
contents.AppendLine();
contents.Append(", ").Append(interfacesTable).Append(");").AppendLine();
// Nested types
foreach (var apiTypeInfo in classInfo.Children)
@@ -2495,13 +2494,22 @@ namespace Flax.Build.Bindings
contents.Append('}').Append(';').AppendLine();
contents.AppendLine();
// Interfaces
var interfacesTable = GenerateCppInterfaceInheritanceTable(buildData, contents, moduleInfo, structureInfo, structureTypeNameNative, structureTypeNameInternal);
// Type initializer
if (GenerateCppIsTemplateInstantiationType(structureInfo))
contents.Append("template<> ");
contents.Append($"ScriptingTypeInitializer {structureTypeNameNative}::TypeInitializer((BinaryModule*)GetBinaryModule{moduleInfo.Name}(), ");
contents.Append($"StringAnsiView(\"{structureTypeNameManaged}\", {structureTypeNameManaged.Length}), ");
contents.Append($"sizeof({structureTypeNameNative}), ");
contents.Append($"&{structureTypeNameInternal}Internal::InitRuntime, ");
contents.Append($"&{structureTypeNameInternal}Internal::Ctor, &{structureTypeNameInternal}Internal::Dtor, &{structureTypeNameInternal}Internal::Copy, &{structureTypeNameInternal}Internal::Box, &{structureTypeNameInternal}Internal::Unbox, &{structureTypeNameInternal}Internal::GetField, &{structureTypeNameInternal}Internal::SetField);").AppendLine();
contents.Append($"&{structureTypeNameInternal}Internal::Ctor, &{structureTypeNameInternal}Internal::Dtor, &{structureTypeNameInternal}Internal::Copy, &{structureTypeNameInternal}Internal::Box, &{structureTypeNameInternal}Internal::Unbox, &{structureTypeNameInternal}Internal::GetField, &{structureTypeNameInternal}Internal::SetField, ");
if (structureInfo.BaseType != null)
contents.Append($"&{structureInfo.BaseType.FullNameNative}::TypeInitializer");
else
contents.Append("nullptr");
contents.Append(", ").Append(interfacesTable).Append(");").AppendLine();
// Nested types
foreach (var apiTypeInfo in structureInfo.Children)

View File

@@ -301,7 +301,7 @@ namespace Flax.Build
else
project.Path = targets[0].CustomExternalProjectFilePath;
if (project.WorkspaceRootPath.StartsWith(rootProject.ProjectFolderPath))
project.GroupName = Utilities.MakePathRelativeTo(project.WorkspaceRootPath, rootProject.ProjectFolderPath);
project.GroupName = Utilities.NormalizePath(Utilities.MakePathRelativeTo(project.WorkspaceRootPath, rootProject.ProjectFolderPath));
else if (projectInfo != Globals.Project)
project.GroupName = projectInfo.Name;
project.SourceDirectories = new List<string>
@@ -349,7 +349,10 @@ namespace Flax.Build
var referenceBinaryModules = referenceModules.Keys.GroupBy(x => x.BinaryModuleName).ToArray();
foreach (var binaryModule in referenceBinaryModules)
{
project.Defines.Add(binaryModule.Key.ToUpperInvariant() + "_API=");
var binaryModuleName = binaryModule.Key;
if (string.IsNullOrEmpty(binaryModuleName))
continue;
project.Defines.Add(binaryModuleName.ToUpperInvariant() + "_API=");
}
}
catch

View File

@@ -409,7 +409,7 @@ namespace Flax.Build
var referencedBuild = buildData.FinReferenceBuildModule(dependencyModule.BinaryModuleName);
if (referencedBuild != null && !string.IsNullOrEmpty(referencedBuild.ManagedPath))
{
// Reference binary module build build for referenced target
// Reference binary module build for referenced target
fileReferences.Add(referencedBuild.ManagedPath);
}
}

View File

@@ -282,6 +282,17 @@ namespace Flax.Build
var dotnetSdkVersion = GetVersion(dotnetSdkVersions);
var dotnetRuntimeVersion = GetVersion(dotnetRuntimeVersions);
if (!string.IsNullOrEmpty(dotnetRuntimeVersion) && ParseVersion(dotnetRuntimeVersion).Major > ParseVersion(dotnetSdkVersion).Major)
{
// Make sure the reference assemblies are not newer than the SDK itself
var dotnetRuntimeVersionsRemaining = dotnetRuntimeVersions;
do
{
dotnetRuntimeVersionsRemaining = dotnetRuntimeVersionsRemaining.Skip(1);
dotnetRuntimeVersion = GetVersion(dotnetRuntimeVersionsRemaining);
} while (!string.IsNullOrEmpty(dotnetRuntimeVersion) && ParseVersion(dotnetRuntimeVersion).Major > ParseVersion(dotnetSdkVersion).Major);
}
var minVer = string.IsNullOrEmpty(Configuration.Dotnet) ? MinimumVersion.ToString() : Configuration.Dotnet;
if (string.IsNullOrEmpty(dotnetSdkVersion))
{

View File

@@ -57,22 +57,11 @@ namespace Flax.Deps.Dependencies
// Default build
GitCheckout(root, "flax-net80");
Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, buildPlatform);
foreach (var platform in options.Platforms)
{
BuildStarted(platform);
switch (platform)
{
case TargetPlatform.Windows:
case TargetPlatform.Linux:
case TargetPlatform.Mac:
{
foreach (var file in outputFileNames)
{
Utilities.FileCopy(Path.Combine(binFolder, file), Path.Combine(options.PlatformsFolder, "DotNet", file));
}
break;
}
}
var platform = "JIT";
Log.Info($"Building {GetType().Name} for {platform}");
foreach (var file in outputFileNames)
Utilities.FileCopy(Path.Combine(binFolder, file), Path.Combine(options.PlatformsFolder, "DotNet", file));
}
// AOT build (disabled codegen)
@@ -82,24 +71,11 @@ namespace Flax.Deps.Dependencies
Utilities.ReplaceInFile(Path.Combine(root, "Src", "Newtonsoft.Json", "Newtonsoft.Json.csproj"), "HAVE_REGEX;", ";");
Utilities.ReplaceInFile(Path.Combine(root, "Src", "Newtonsoft.Json", "Newtonsoft.Json.csproj"), "HAVE_TYPE_DESCRIPTOR;", ";");
Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, buildPlatform);
foreach (var platform in options.Platforms)
{
BuildStarted(platform);
switch (platform)
{
case TargetPlatform.UWP:
case TargetPlatform.XboxOne:
case TargetPlatform.XboxScarlett:
case TargetPlatform.PS4:
case TargetPlatform.PS5:
case TargetPlatform.Switch:
case TargetPlatform.iOS:
{
var file = "Newtonsoft.Json.dll";
Utilities.FileCopy(Path.Combine(binFolder, file), Path.Combine(options.PlatformsFolder, "DotNet/AOT", file));
break;
}
}
var platform = "AOT";
Log.Info($"Building {GetType().Name} for {platform}");
var file = "Newtonsoft.Json.dll";
Utilities.FileCopy(Path.Combine(binFolder, file), Path.Combine(options.PlatformsFolder, "DotNet/AOT", file));
}
}
}

View File

@@ -356,13 +356,13 @@ namespace Flax.Build.Projects.VisualStudio
if (project.SourceDirectories != null && project.SourceDirectories.Count == 1)
{
var subFolder = Utilities.MakePathRelativeTo(Path.GetDirectoryName(project.SourceDirectories[0]), project.WorkspaceRootPath);
if (subFolder.StartsWith("Source\\"))
subFolder = subFolder.Substring(7);
var subFolder = Utilities.NormalizePath(Utilities.MakePathRelativeTo(Path.GetDirectoryName(project.SourceDirectories[0]), project.WorkspaceRootPath));
if (subFolder.StartsWith("Source/"))
subFolder = subFolder.Substring("Source/".Length);
if (subFolder.Length != 0)
{
if (folder.Length != 0)
folder += '\\';
folder += '/';
folder += subFolder;
}
}
@@ -370,12 +370,12 @@ namespace Flax.Build.Projects.VisualStudio
if (string.IsNullOrEmpty(folder))
continue;
var folderParents = folder.Split('\\');
var folderParents = folder.Split('/');
for (int i = 0; i < folderParents.Length; i++)
{
var folderPath = folderParents[0];
for (int j = 1; j <= i; j++)
folderPath += '\\' + folderParents[j];
folderPath += '/' + folderParents[j];
if (folderNames.Contains(folderPath))
{
@@ -397,7 +397,7 @@ namespace Flax.Build.Projects.VisualStudio
{
var folderGuid = folderIds[folder].ToString("B").ToUpperInvariant();
var typeGuid = ProjectTypeGuids.ToOption(ProjectTypeGuids.SolutionFolder);
var lastSplit = folder.LastIndexOf('\\');
var lastSplit = folder.LastIndexOf('/');
var name = lastSplit != -1 ? folder.Substring(lastSplit + 1) : folder;
vcSolutionFileContent.AppendLine(string.Format("Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\"", typeGuid, name, folder, folderGuid));
@@ -573,7 +573,7 @@ namespace Flax.Build.Projects.VisualStudio
// Write nested folders hierarchy
foreach (var folder in folderNames)
{
var lastSplit = folder.LastIndexOf('\\');
var lastSplit = folder.LastIndexOf('/');
if (lastSplit != -1)
{
var folderGuid = folderIds[folder].ToString("B").ToUpperInvariant();
@@ -615,8 +615,9 @@ namespace Flax.Build.Projects.VisualStudio
{
var profiles = new Dictionary<string, string>();
var profile = new StringBuilder();
var editorPath = Utilities.NormalizePath(Path.Combine(Globals.EngineRoot, Platform.GetEditorBinaryDirectory(), $"Development/FlaxEditor{Utilities.GetPlatformExecutableExt()}")).Replace('\\', '/');
var workspacePath = Utilities.NormalizePath(solutionDirectory).Replace('\\', '/');
var configuration = "Development";
var editorPath = Utilities.NormalizePath(Path.Combine(Globals.EngineRoot, Platform.GetEditorBinaryDirectory(), configuration, $"FlaxEditor{Utilities.GetPlatformExecutableExt()}"));
var workspacePath = Utilities.NormalizePath(solutionDirectory);
foreach (var project in projects)
{
if (project.Type == TargetType.DotNetCore)