From 017967d5f83914c61dc08c30af3c2e8343816aa7 Mon Sep 17 00:00:00 2001 From: Andrew Spiering Date: Fri, 22 Sep 2023 02:13:49 -0700 Subject: [PATCH 1/3] Fixing non-windows platforms csproj files * Seems there was a hardcoded path ? for the prebuilt binaries for the FlaxEngine dll --- Source/Tools/Flax.Build/Build/Builder.Projects.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Tools/Flax.Build/Build/Builder.Projects.cs b/Source/Tools/Flax.Build/Build/Builder.Projects.cs index 4b606a36d..52c6d4ac9 100644 --- a/Source/Tools/Flax.Build/Build/Builder.Projects.cs +++ b/Source/Tools/Flax.Build/Build/Builder.Projects.cs @@ -497,7 +497,7 @@ namespace Flax.Build else if (dependencyModule.BinaryModuleName == "FlaxEngine") { // TODO: instead of this hack find a way to reference the prebuilt target bindings binary (example: game C# project references FlaxEngine C# prebuilt dll) - project.CSharp.FileReferences.Add(Path.Combine(Globals.EngineRoot, "Binaries/Editor/Win64/Development/FlaxEngine.CSharp.dll")); + project.CSharp.FileReferences.Add(Path.Combine(Globals.EngineRoot, $"Binaries/Editor/{project.Configurations[0].PlatformName}/Development/FlaxEngine.CSharp.dll")); } } } @@ -519,7 +519,7 @@ namespace Flax.Build project.Dependencies.Remove(flaxDependency); // TODO: instead of this hack find a way to reference the prebuilt target bindings binary (example: game C# project references FlaxEngine C# prebuilt dll) - project.CSharp.FileReferences.Add(Path.Combine(Globals.EngineRoot, "Binaries/Editor/Win64/Development/FlaxEngine.CSharp.dll")); + project.CSharp.FileReferences.Add(Path.Combine(Globals.EngineRoot, $"Binaries/Editor/{project.Configurations[0].PlatformName}/Development/FlaxEngine.CSharp.dll")); // Remove FlaxEngine from projects to prevent duplicated types errors in Intellisense (eg. Actor type defined in both FlaxEngine.CSharp.dll and FlaxEngine.csproj) flaxDependencyToRemove = flaxDependency; From 1537f49e736750898e0e4b1d3a92aaaa65c5d9b7 Mon Sep 17 00:00:00 2001 From: Andrew Spiering Date: Fri, 22 Sep 2023 02:41:09 -0700 Subject: [PATCH 2/3] Fixing Editor Path * Again the path was hardcoded to win64 --- .../VisualStudio/VisualStudioProjectGenerator.cs | 10 ++++++++-- Source/Tools/Flax.Build/Utilities/Utilities.cs | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Source/Tools/Flax.Build/Projects/VisualStudio/VisualStudioProjectGenerator.cs b/Source/Tools/Flax.Build/Projects/VisualStudio/VisualStudioProjectGenerator.cs index 6653a8dac..16ab543ad 100644 --- a/Source/Tools/Flax.Build/Projects/VisualStudio/VisualStudioProjectGenerator.cs +++ b/Source/Tools/Flax.Build/Projects/VisualStudio/VisualStudioProjectGenerator.cs @@ -405,6 +405,8 @@ namespace Flax.Build.Projects.VisualStudio vcSolutionFileContent.AppendLine("EndProject"); } + var globalPlatformName = ""; + // Global configuration { vcSolutionFileContent.AppendLine("Global"); @@ -422,6 +424,10 @@ namespace Flax.Build.Projects.VisualStudio foreach (var configuration in project.Configurations) { + // We just grab the platform name from the first config + if (string.IsNullOrEmpty(globalPlatformName)) + globalPlatformName = configuration.PlatformName; + configurations.Add(new SolutionConfiguration(configuration)); } } @@ -558,8 +564,8 @@ namespace Flax.Build.Projects.VisualStudio { var profiles = new Dictionary(); var profile = new StringBuilder(); - var editorPath = Path.Combine(Globals.EngineRoot, "Binaries/Editor/Win64/Development/FlaxEditor.exe").Replace('/', '\\').Replace("\\", "\\\\"); - var workspacePath = solutionDirectory.Replace('/', '\\').Replace("\\", "\\\\"); + var editorPath = Utilities.NormalizePath(Path.Combine(Globals.EngineRoot, $"Binaries/Editor/{globalPlatformName}/Development/FlaxEditor{Utilities.GetPlatformExecutableExt()}")); + var workspacePath = Utilities.NormalizePath(solutionDirectory); foreach (var project in projects) { if (project.Type == TargetType.DotNetCore) diff --git a/Source/Tools/Flax.Build/Utilities/Utilities.cs b/Source/Tools/Flax.Build/Utilities/Utilities.cs index af6777199..994e11c8e 100644 --- a/Source/Tools/Flax.Build/Utilities/Utilities.cs +++ b/Source/Tools/Flax.Build/Utilities/Utilities.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; +using System.Runtime.InteropServices; using System.Text; namespace Flax.Build @@ -746,5 +747,19 @@ namespace Flax.Build text = text.Replace(findWhat, replaceWith); File.WriteAllText(file, text); } + + /// + /// Returns back the exe ext for the current platform + /// + public static string GetPlatformExecutableExt() + { + var extEnding = ".exe"; + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + extEnding = ""; + } + + return extEnding; + } } } From ab7ca683bb684745c2ee0751e5d178a490000289 Mon Sep 17 00:00:00 2001 From: Andrew Spiering Date: Fri, 22 Sep 2023 02:59:38 -0700 Subject: [PATCH 3/3] Addressing Feedback * use a better method of getting Editor binary folder --- Source/Tools/Flax.Build/Build/Builder.Projects.cs | 4 ++-- .../VisualStudio/VisualStudioProjectGenerator.cs | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Source/Tools/Flax.Build/Build/Builder.Projects.cs b/Source/Tools/Flax.Build/Build/Builder.Projects.cs index 52c6d4ac9..166e78036 100644 --- a/Source/Tools/Flax.Build/Build/Builder.Projects.cs +++ b/Source/Tools/Flax.Build/Build/Builder.Projects.cs @@ -497,7 +497,7 @@ namespace Flax.Build else if (dependencyModule.BinaryModuleName == "FlaxEngine") { // TODO: instead of this hack find a way to reference the prebuilt target bindings binary (example: game C# project references FlaxEngine C# prebuilt dll) - project.CSharp.FileReferences.Add(Path.Combine(Globals.EngineRoot, $"Binaries/Editor/{project.Configurations[0].PlatformName}/Development/FlaxEngine.CSharp.dll")); + project.CSharp.FileReferences.Add(Path.Combine(Globals.EngineRoot, Platform.GetEditorBinaryDirectory(), "Development/FlaxEngine.CSharp.dll")); } } } @@ -519,7 +519,7 @@ namespace Flax.Build project.Dependencies.Remove(flaxDependency); // TODO: instead of this hack find a way to reference the prebuilt target bindings binary (example: game C# project references FlaxEngine C# prebuilt dll) - project.CSharp.FileReferences.Add(Path.Combine(Globals.EngineRoot, $"Binaries/Editor/{project.Configurations[0].PlatformName}/Development/FlaxEngine.CSharp.dll")); + project.CSharp.FileReferences.Add(Path.Combine(Globals.EngineRoot, Platform.GetEditorBinaryDirectory(), "Development/FlaxEngine.CSharp.dll")); // Remove FlaxEngine from projects to prevent duplicated types errors in Intellisense (eg. Actor type defined in both FlaxEngine.CSharp.dll and FlaxEngine.csproj) flaxDependencyToRemove = flaxDependency; diff --git a/Source/Tools/Flax.Build/Projects/VisualStudio/VisualStudioProjectGenerator.cs b/Source/Tools/Flax.Build/Projects/VisualStudio/VisualStudioProjectGenerator.cs index 16ab543ad..8cbd6b01a 100644 --- a/Source/Tools/Flax.Build/Projects/VisualStudio/VisualStudioProjectGenerator.cs +++ b/Source/Tools/Flax.Build/Projects/VisualStudio/VisualStudioProjectGenerator.cs @@ -405,8 +405,6 @@ namespace Flax.Build.Projects.VisualStudio vcSolutionFileContent.AppendLine("EndProject"); } - var globalPlatformName = ""; - // Global configuration { vcSolutionFileContent.AppendLine("Global"); @@ -423,11 +421,7 @@ namespace Flax.Build.Projects.VisualStudio continue; foreach (var configuration in project.Configurations) - { - // We just grab the platform name from the first config - if (string.IsNullOrEmpty(globalPlatformName)) - globalPlatformName = configuration.PlatformName; - + { configurations.Add(new SolutionConfiguration(configuration)); } } @@ -564,7 +558,7 @@ namespace Flax.Build.Projects.VisualStudio { var profiles = new Dictionary(); var profile = new StringBuilder(); - var editorPath = Utilities.NormalizePath(Path.Combine(Globals.EngineRoot, $"Binaries/Editor/{globalPlatformName}/Development/FlaxEditor{Utilities.GetPlatformExecutableExt()}")); + var editorPath = Utilities.NormalizePath(Path.Combine(Globals.EngineRoot, Platform.GetEditorBinaryDirectory(), $"Development/FlaxEditor{Utilities.GetPlatformExecutableExt()}")); var workspacePath = Utilities.NormalizePath(solutionDirectory); foreach (var project in projects) {