Implement Wayland protocols module and file generation
This commit is contained in:
63
Source/Tools/Flax.Build/Deps/Dependencies/Wayland.cs
Normal file
63
Source/Tools/Flax.Build/Deps/Dependencies/Wayland.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Wayland protocols.
|
||||
/// </summary>
|
||||
/// <seealso cref="Flax.Deps.Dependency" />
|
||||
class Wayland : Dependency
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override TargetPlatform[] Platforms
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (BuildPlatform)
|
||||
{
|
||||
case TargetPlatform.Linux:
|
||||
return new[]
|
||||
{
|
||||
TargetPlatform.Linux,
|
||||
};
|
||||
default: return new TargetPlatform[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user