// Copyright (c) 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 TargetArchitecture[] Architectures { get { switch (BuildPlatform) { case TargetPlatform.Linux: return new[] { TargetArchitecture.x64, TargetArchitecture.ARM64, }; default: return new TargetArchitecture[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, TargetArchitecture.AnyCPU); 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), "c"); 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")); } } }