diff --git a/Source/Engine/Platform/Platform.Build.cs b/Source/Engine/Platform/Platform.Build.cs index 131bedffb..7272270c0 100644 --- a/Source/Engine/Platform/Platform.Build.cs +++ b/Source/Engine/Platform/Platform.Build.cs @@ -101,6 +101,8 @@ public class Platform : EngineModule options.SourcePaths.Add(Path.Combine(FolderPath, "SDL")); break; } + if (options.Platform.Target == TargetPlatform.Linux) + options.PublicDependencies.Add("Wayland"); } if (options.Target.IsEditor) { diff --git a/Source/ThirdParty/Wayland/LICENSE.txt b/Source/ThirdParty/Wayland/LICENSE.txt new file mode 100644 index 000000000..eb25a4e2b --- /dev/null +++ b/Source/ThirdParty/Wayland/LICENSE.txt @@ -0,0 +1,29 @@ +Copyright © 2008-2012 Kristian Høgsberg +Copyright © 2010-2012 Intel Corporation +Copyright © 2011 Benjamin Franzke +Copyright © 2012 Collabora, Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +--- + +The above is the version of the MIT "Expat" License used by X.org: + + http://cgit.freedesktop.org/xorg/xserver/tree/COPYING diff --git a/Source/ThirdParty/Wayland/Wayland.Build.cs b/Source/ThirdParty/Wayland/Wayland.Build.cs new file mode 100644 index 000000000..c2d924367 --- /dev/null +++ b/Source/ThirdParty/Wayland/Wayland.Build.cs @@ -0,0 +1,37 @@ +// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. + +using System.Collections.Generic; +using System.IO; +using Flax.Build; +using Flax.Build.NativeCpp; + +/// +/// https://gitlab.freedesktop.org/wayland/wayland-protocolsk +/// +public class Wayland : ThirdPartyModule +{ + /// + public override void Init() + { + base.Init(); + + LicenseType = LicenseTypes.MIT; + LicenseFilePath = "LICENSE.txt"; + + // Merge third-party modules into engine binary + BinaryModuleName = "FlaxEngine"; + } + + /// + public override void Setup(BuildOptions options) + { + base.Setup(options); + + if (options.Platform.Target != TargetPlatform.Linux) + throw new InvalidPlatformException(options.Platform.Target); + + // Include generated protocol files for dependency + options.PublicIncludePaths.Add(Path.Combine(FolderPath, "include")); + options.SourceFiles.AddRange(Directory.GetFiles(FolderPath, "*.cpp", SearchOption.TopDirectoryOnly)); + } +} diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/Wayland.cs b/Source/Tools/Flax.Build/Deps/Dependencies/Wayland.cs new file mode 100644 index 000000000..eeb6ebca8 --- /dev/null +++ b/Source/Tools/Flax.Build/Deps/Dependencies/Wayland.cs @@ -0,0 +1,63 @@ +// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. + +using System.Collections.Generic; +using System.IO; +using Flax.Build; + +namespace Flax.Deps.Dependencies +{ + /// + /// Wayland protocols. + /// + /// + class Wayland : Dependency + { + /// + public override TargetPlatform[] Platforms + { + get + { + switch (BuildPlatform) + { + case TargetPlatform.Linux: + return new[] + { + TargetPlatform.Linux, + }; + default: return new TargetPlatform[0]; + } + } + } + + /// + public override void Build(BuildOptions options) + { + var dstPath = Path.Combine(options.ThirdPartyFolder, "Wayland"); + var protocolsPath = Path.Combine(dstPath, "protocols"); + var includePath = Path.Combine(dstPath, "include"); + + foreach (var platform in options.Platforms) + { + BuildStarted(platform); + switch (platform) + { + case TargetPlatform.Linux: + if (!Directory.Exists(Path.Combine(includePath, "wayland"))) + Directory.CreateDirectory(Path.Combine(includePath, "wayland")); + + string[] protocolFiles = Directory.GetFiles(protocolsPath, "*.xml", SearchOption.TopDirectoryOnly); + foreach (var protocolPath in protocolFiles) + { + var headerFile = Path.ChangeExtension(Path.GetFileName(protocolPath), "h"); + var glueFile = Path.ChangeExtension(Path.GetFileName(protocolPath), "cpp"); + Utilities.Run("wayland-scanner", $"client-header {protocolPath} include/wayland/{headerFile}", null, dstPath, Utilities.RunOptions.DefaultTool); + Utilities.Run("wayland-scanner", $"private-code {protocolPath} {glueFile}", null, dstPath, Utilities.RunOptions.DefaultTool); + } + break; + } + } + + Utilities.FileCopy("/usr/share/licenses/wayland/COPYING", Path.Combine(dstPath, "LICENSE.txt")); + } + } +}