diff --git a/Source/Tools/Flax.Build/Build/Builder.Projects.cs b/Source/Tools/Flax.Build/Build/Builder.Projects.cs index 21aa25788..42bda3ea5 100644 --- a/Source/Tools/Flax.Build/Build/Builder.Projects.cs +++ b/Source/Tools/Flax.Build/Build/Builder.Projects.cs @@ -433,7 +433,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, Platform.GetEditorBinaryDirectory(), "Development/FlaxEngine.CSharp.dll")); } } } diff --git a/Source/Tools/Flax.Build/Build/Platform.cs b/Source/Tools/Flax.Build/Build/Platform.cs index 72e6454a4..99edc7889 100644 --- a/Source/Tools/Flax.Build/Build/Platform.cs +++ b/Source/Tools/Flax.Build/Build/Platform.cs @@ -245,6 +245,24 @@ namespace Flax.Build return toolchain; } + /// + /// Gets path to the current platform binary directory + /// + public static string GetEditorBinaryDirectory() + { + var subdir = "Binaries/Editor/"; + switch (Platform.BuildTargetPlatform) + { + case TargetPlatform.Windows: + return subdir + "Win64"; + case TargetPlatform.Linux: + return subdir + "Linux"; + case TargetPlatform.Mac: + return subdir + "Mac"; + } + throw new NotImplementedException(); + } + /// /// Creates the project files generator for the specified project format. /// diff --git a/Source/Tools/Flax.Build/Configuration.cs b/Source/Tools/Flax.Build/Configuration.cs index 55f3d138d..4c3f63b0c 100644 --- a/Source/Tools/Flax.Build/Configuration.cs +++ b/Source/Tools/Flax.Build/Configuration.cs @@ -39,6 +39,12 @@ namespace Flax.Build [CommandLine("deploy", "Runs the deploy tool.")] public static bool Deploy = false; + /// + /// Compresses deployed files. + /// + [CommandLine("deployDontCompress", "Skips compressing deployed files, and keeps files.")] + public static bool DontCompress = false; + /// /// Builds the targets. Builds all the targets, use to select a custom set of targets for the build. /// diff --git a/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs b/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs index ad94da918..c4ca880f7 100644 --- a/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs +++ b/Source/Tools/Flax.Build/Deploy/Deployment.Editor.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using Flax.Build; +using Flax.Build.Platforms; namespace Flax.Deploy { @@ -126,21 +127,24 @@ namespace Flax.Deploy DeployFile(RootPath, OutputPath, "Flax.flaxproj"); // Compress + if (Configuration.DontCompress) + return; + Log.Info(string.Empty); Log.Info("Compressing editor files..."); string editorPackageZipPath; - if (Platform.BuildTargetPlatform == TargetPlatform.Linux) + var unix = Platform.BuildTargetPlatform == TargetPlatform.Linux || Platform.BuildTargetPlatform == TargetPlatform.Mac; + if (unix) { - // Use system tool (preserves executable file attributes and link files) - editorPackageZipPath = Path.Combine(Deployer.PackageOutputPath, "FlaxEditorLinux.zip"); - Utilities.FileDelete(editorPackageZipPath); - Utilities.Run("zip", "Editor.zip -r .", null, OutputPath, Utilities.RunOptions.ThrowExceptionOnError); - File.Move(Path.Combine(OutputPath, "Editor.zip"), editorPackageZipPath); + var zipEofPath = UnixPlatform.Which("zip"); + unix = File.Exists(zipEofPath); + if (!unix) + Log.Verbose("Using .NET compressing"); } - else if (Platform.BuildTargetPlatform == TargetPlatform.Mac) + if (unix) { // Use system tool (preserves executable file attributes and link files) - editorPackageZipPath = Path.Combine(Deployer.PackageOutputPath, "FlaxEditorMac.zip"); + editorPackageZipPath = Path.Combine(Deployer.PackageOutputPath, $"FlaxEditor{Enum.GetName(typeof(TargetPlatform), Platform.BuildTargetPlatform)}.zip"); Utilities.FileDelete(editorPackageZipPath); Utilities.Run("zip", "Editor.zip -r .", null, OutputPath, Utilities.RunOptions.ThrowExceptionOnError); File.Move(Path.Combine(OutputPath, "Editor.zip"), editorPackageZipPath); @@ -189,13 +193,14 @@ namespace Flax.Deploy private static void DeployEditorBinaries(TargetConfiguration configuration) { + var binariesSubDir = Path.Combine(Platform.GetEditorBinaryDirectory(), configuration.ToString()); + var src = Path.Combine(RootPath, binariesSubDir); + var dst = Path.Combine(OutputPath, binariesSubDir); + Directory.CreateDirectory(dst); + if (Platform.BuildTargetPlatform == TargetPlatform.Windows) { - var binariesSubDir = "Binaries/Editor/Win64/" + configuration; - var src = Path.Combine(RootPath, binariesSubDir); - var dst = Path.Combine(OutputPath, binariesSubDir); var dstDebug = Path.Combine(Deployer.PackageOutputPath, "EditorDebugSymbols/Win64/" + configuration); - Directory.CreateDirectory(dst); Directory.CreateDirectory(dstDebug); // Validate that build editor app has a valid version number @@ -229,11 +234,6 @@ namespace Flax.Deploy } else if (Platform.BuildTargetPlatform == TargetPlatform.Linux) { - var binariesSubDir = "Binaries/Editor/Linux/" + configuration; - var src = Path.Combine(RootPath, binariesSubDir); - var dst = Path.Combine(OutputPath, binariesSubDir); - Directory.CreateDirectory(dst); - // Deploy binaries DeployFile(src, dst, "FlaxEditor"); DeployFile(src, dst, "FlaxEditor.Build.json"); @@ -253,11 +253,6 @@ namespace Flax.Deploy } else if (Platform.BuildTargetPlatform == TargetPlatform.Mac) { - var binariesSubDir = "Binaries/Editor/Mac/" + configuration; - var src = Path.Combine(RootPath, binariesSubDir); - var dst = Path.Combine(OutputPath, binariesSubDir); - Directory.CreateDirectory(dst); - // Deploy binaries DeployFile(src, dst, "FlaxEditor"); DeployFile(src, dst, "FlaxEditor.Build.json"); @@ -274,10 +269,6 @@ namespace Flax.Deploy Utilities.Run("strip", "libmonosgen-2.0.1.dylib", null, dst, Utilities.RunOptions.None); Utilities.Run("strip", "libMoltenVK.dylib", null, dst, Utilities.RunOptions.None); } - else - { - throw new NotImplementedException(); - } } } } diff --git a/Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs b/Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs index 78e6183bb..9a6d372d2 100644 --- a/Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs +++ b/Source/Tools/Flax.Build/Deploy/Deployment.Platforms.cs @@ -63,6 +63,7 @@ namespace Flax.Deploy } // Compress + if (!Configuration.DontCompress) { Log.Info("Compressing platform files..."); @@ -84,10 +85,10 @@ namespace Flax.Deploy #endif Log.Info(string.Format("Compressed {0} package size: {1}", platformName, Utilities.GetFileSize(packageZipPath))); - } - // Remove files (only zip package is used) - Utilities.DirectoryDelete(dst); + // Remove files (only zip package is used) + Utilities.DirectoryDelete(dst); + } Log.Info(string.Empty); } diff --git a/Source/Tools/Flax.Build/Platforms/Linux/LinuxPlatform.cs b/Source/Tools/Flax.Build/Platforms/Linux/LinuxPlatform.cs index 1d0433f50..ced516a54 100644 --- a/Source/Tools/Flax.Build/Platforms/Linux/LinuxPlatform.cs +++ b/Source/Tools/Flax.Build/Platforms/Linux/LinuxPlatform.cs @@ -58,7 +58,7 @@ namespace Flax.Build.Platforms if (Compiler != null) { // System compiler - ToolchainRoot = string.Empty; + ToolchainRoot = "/"; Log.Verbose($"Using native Linux toolchain (compiler {Compiler})"); HasRequiredSDKsInstalled = true; } diff --git a/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs b/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs index ede17b639..2904b89a7 100644 --- a/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs @@ -23,9 +23,16 @@ namespace Flax.Build.Platforms : base(platform, architecture, platform.ToolchainRoot, platform.Compiler) { // Setup system paths - SystemIncludePaths.Add(Path.Combine(ToolsetRoot, "usr", "include")); - SystemIncludePaths.Add(Path.Combine(ToolsetRoot, "include", "c++", "5.2.0")); - SystemIncludePaths.Add(Path.Combine(ToolsetRoot, "lib", "clang", ClangVersion.Major.ToString(), "include")); + var includePath = Path.Combine(ToolsetRoot, "usr", "include"); + SystemIncludePaths.Add(includePath); + var cppIncludePath = Path.Combine(includePath, "c++", ClangVersion.ToString()); + if (Directory.Exists(cppIncludePath)) + SystemIncludePaths.Add(cppIncludePath); + var clangLibPath = Path.Combine(ToolsetRoot, "usr", "lib", "clang"); + var clangIncludePath = Path.Combine(clangLibPath, ClangVersion.Major.ToString(), "include"); + if (!Directory.Exists(clangIncludePath)) + clangIncludePath = Path.Combine(clangLibPath, ClangVersion.ToString(), "include"); + SystemIncludePaths.Add(clangIncludePath); } /// diff --git a/Source/Tools/Flax.Build/Projects/ProjectGenerator.cs b/Source/Tools/Flax.Build/Projects/ProjectGenerator.cs index f218a9a4f..cb0e5311e 100644 --- a/Source/Tools/Flax.Build/Projects/ProjectGenerator.cs +++ b/Source/Tools/Flax.Build/Projects/ProjectGenerator.cs @@ -138,7 +138,9 @@ namespace Flax.Build.Projects default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } } - case ProjectFormat.VisualStudioCode: return new VisualStudioCodeProjectGenerator(); + case ProjectFormat.VisualStudioCode: return type == TargetType.DotNet + ? (ProjectGenerator)new CSProjectGenerator(VisualStudioVersion.VisualStudio2015) + : (ProjectGenerator)new VisualStudioCodeProjectGenerator(); case ProjectFormat.XCode: return new XCodeProjectGenerator(); case ProjectFormat.Custom: if (CustomProjectTypes.TryGetValue(Configuration.ProjectFormatCustom, out var factory)) diff --git a/Source/Tools/Flax.Build/Projects/VisualStudioCode/VisualStudioCodeProjectGenerator.cs b/Source/Tools/Flax.Build/Projects/VisualStudioCode/VisualStudioCodeProjectGenerator.cs index f726ea0c4..f3a4a0e8e 100644 --- a/Source/Tools/Flax.Build/Projects/VisualStudioCode/VisualStudioCodeProjectGenerator.cs +++ b/Source/Tools/Flax.Build/Projects/VisualStudioCode/VisualStudioCodeProjectGenerator.cs @@ -547,6 +547,10 @@ namespace Flax.Build.Projects.VisualStudioCode json.AddField("**/Output", true); json.AddField("**/*.flax", true); json.EndObject(); + + // Extension settings + json.AddField("omnisharp.useModernNet", false); + json.EndRootObject(); json.Save(Path.Combine(vsCodeFolder, "settings.json"));