crafter-build V2
This commit is contained in:
parent
8b12dc39b3
commit
8a2fd33efc
5 changed files with 138 additions and 216 deletions
109
project.cpp
Normal file
109
project.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
import std;
|
||||
import Crafter.Build;
|
||||
namespace fs = std::filesystem;
|
||||
using namespace Crafter;
|
||||
|
||||
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
||||
std::vector<std::string> depArgs(args.begin(), args.end());
|
||||
Configuration* event = GitProject({
|
||||
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git" },
|
||||
.args = depArgs,
|
||||
});
|
||||
Configuration* math = GitProject({
|
||||
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git" },
|
||||
.args = depArgs,
|
||||
});
|
||||
Configuration* asset = GitProject({
|
||||
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Asset.git" },
|
||||
.args = depArgs,
|
||||
});
|
||||
|
||||
Configuration cfg;
|
||||
cfg.path = "./";
|
||||
cfg.name = "Crafter.Graphics";
|
||||
cfg.outputName = "Crafter.Graphics";
|
||||
cfg.type = ConfigurationType::LibraryStatic;
|
||||
auto opts = ApplyStandardArgs(cfg, args);
|
||||
cfg.dependencies = { event, math, asset };
|
||||
|
||||
// Window backend follows the target triple. V1 had separate lib-wayland /
|
||||
// lib-win32 configurations; V2 picks the right one automatically based on
|
||||
// where the build is going. Cross-compile (`--target=...`) flips the
|
||||
// backend along with everything else.
|
||||
bool windows = cfg.target.find("windows") != std::string::npos
|
||||
|| cfg.target.find("mingw") != std::string::npos;
|
||||
if (windows) {
|
||||
cfg.defines.push_back({"CRAFTER_GRAPHICS_WINDOW_WIN32", ""});
|
||||
cfg.linkFlags.push_back("-lkernel32");
|
||||
cfg.linkFlags.push_back("-luser32");
|
||||
cfg.linkFlags.push_back("-lgdi32");
|
||||
} else {
|
||||
cfg.defines.push_back({"CRAFTER_GRAPHICS_WINDOW_WAYLAND", ""});
|
||||
cfg.linkFlags.push_back("-lwayland-client");
|
||||
cfg.linkFlags.push_back("-lxkbcommon");
|
||||
cfg.cFiles.push_back("lib/xdg-shell-protocol");
|
||||
cfg.cFiles.push_back("lib/wayland-xdg-decoration-unstable-v1-client-protocol");
|
||||
cfg.cFiles.push_back("lib/fractional-scale-v1");
|
||||
cfg.cFiles.push_back("lib/viewporter");
|
||||
}
|
||||
|
||||
// Renderer: --vulkan opts in (clones Vulkan-Headers + Vulkan-Utility-Libraries
|
||||
// for headers and links libvulkan); default is the software path.
|
||||
if (opts.Has("--vulkan")) {
|
||||
cfg.defines.push_back({"CRAFTER_GRAPHICS_RENDERER_VULKAN", ""});
|
||||
ExternalDependency& vkHeaders = cfg.externalDependencies.emplace_back();
|
||||
vkHeaders.name = "Vulkan-Headers";
|
||||
vkHeaders.source.url = "https://github.com/KhronosGroup/Vulkan-Headers.git";
|
||||
vkHeaders.builder = ExternalBuilder::None;
|
||||
vkHeaders.includeDirs = { "include" };
|
||||
ExternalDependency& vkUtility = cfg.externalDependencies.emplace_back();
|
||||
vkUtility.name = "Vulkan-Utility-Libraries";
|
||||
vkUtility.source.url = "https://github.com/KhronosGroup/Vulkan-Utility-Libraries.git";
|
||||
vkUtility.builder = ExternalBuilder::None;
|
||||
vkUtility.includeDirs = { "include" };
|
||||
cfg.linkFlags.push_back(windows ? "-lvulkan-1" : "-lvulkan");
|
||||
} else {
|
||||
cfg.defines.push_back({"CRAFTER_GRAPHICS_RENDERER_SOFTWARE", ""});
|
||||
}
|
||||
|
||||
if (opts.Has("--timing")) cfg.defines.push_back({"CRAFTER_TIMING", ""});
|
||||
|
||||
std::array<fs::path, 24> ifaces = {
|
||||
"interfaces/Crafter.Graphics",
|
||||
"interfaces/Crafter.Graphics-Animation",
|
||||
"interfaces/Crafter.Graphics-DescriptorHeapVulkan",
|
||||
"interfaces/Crafter.Graphics-Device",
|
||||
"interfaces/Crafter.Graphics-Font",
|
||||
"interfaces/Crafter.Graphics-ForwardDeclarations",
|
||||
"interfaces/Crafter.Graphics-GridElement",
|
||||
"interfaces/Crafter.Graphics-ImageVulkan",
|
||||
"interfaces/Crafter.Graphics-Mesh",
|
||||
"interfaces/Crafter.Graphics-MouseElement",
|
||||
"interfaces/Crafter.Graphics-PipelineRTVulkan",
|
||||
"interfaces/Crafter.Graphics-RenderingElement2D",
|
||||
"interfaces/Crafter.Graphics-RenderingElement2DBase",
|
||||
"interfaces/Crafter.Graphics-RenderingElement2DVulkan",
|
||||
"interfaces/Crafter.Graphics-RenderingElement3D",
|
||||
"interfaces/Crafter.Graphics-Rendertarget",
|
||||
"interfaces/Crafter.Graphics-SamplerVulkan",
|
||||
"interfaces/Crafter.Graphics-ShaderBindingTableVulkan",
|
||||
"interfaces/Crafter.Graphics-ShaderVulkan",
|
||||
"interfaces/Crafter.Graphics-Transform2D",
|
||||
"interfaces/Crafter.Graphics-Types",
|
||||
"interfaces/Crafter.Graphics-VulkanBuffer",
|
||||
"interfaces/Crafter.Graphics-VulkanTransition",
|
||||
"interfaces/Crafter.Graphics-Window",
|
||||
};
|
||||
std::array<fs::path, 7> impls = {
|
||||
"implementations/Crafter.Graphics-Device",
|
||||
"implementations/Crafter.Graphics-Font",
|
||||
"implementations/Crafter.Graphics-Mesh",
|
||||
"implementations/Crafter.Graphics-MouseElement",
|
||||
"implementations/Crafter.Graphics-RenderingElement3D",
|
||||
"implementations/Crafter.Graphics-Transform2D",
|
||||
"implementations/Crafter.Graphics-Window",
|
||||
};
|
||||
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
||||
|
||||
return cfg;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue