From 3221dfdb09bb5f00d7e2a571959a7da879c7a481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 7 May 2021 13:40:32 +0200 Subject: [PATCH] xmake: Add support for shader editor --- tools/xmake.lua | 24 ++++++++++ .../n/nodeeditor/patches/2.1.3/fix_qt.patch | 34 ++++++++++++++ xmake-repo/packages/n/nodeeditor/xmake.lua | 46 +++++++++++++++++++ xmake.lua | 4 ++ 4 files changed, 108 insertions(+) create mode 100644 tools/xmake.lua create mode 100644 xmake-repo/packages/n/nodeeditor/patches/2.1.3/fix_qt.patch create mode 100644 xmake-repo/packages/n/nodeeditor/xmake.lua diff --git a/tools/xmake.lua b/tools/xmake.lua new file mode 100644 index 000000000..402101d41 --- /dev/null +++ b/tools/xmake.lua @@ -0,0 +1,24 @@ + +add_requires("nodeeditor", {debug = is_mode("debug"), optional = true}) + +target("NazaraShaderNodes") + set_group("Tools") + set_kind("binary") + add_rules("qt.console", "qt.moc") + + add_deps("NazaraShader") + add_frameworks("QtCore", "QtGui", "QtWidgets") + add_packages("nodeeditor") + + add_includedirs("../src") + add_headerfiles("../src/ShaderNode/**.hpp", "../src/ShaderNode/**.inl") + add_files("../src/ShaderNode/**.cpp") + + on_load(function (target) + import("detect.sdks.find_qt") + + if (not has_package("nodeeditor") or not find_qt()) then + -- Disable building by default if nodeeditor or Qt is not found + target:set("default", false) + end + end) diff --git a/xmake-repo/packages/n/nodeeditor/patches/2.1.3/fix_qt.patch b/xmake-repo/packages/n/nodeeditor/patches/2.1.3/fix_qt.patch new file mode 100644 index 000000000..943f9612d --- /dev/null +++ b/xmake-repo/packages/n/nodeeditor/patches/2.1.3/fix_qt.patch @@ -0,0 +1,34 @@ +diff --git a/include/nodes/internal/NodePainterDelegate.hpp b/include/nodes/internal/NodePainterDelegate.hpp +index d532619..f22496c 100644 +--- a/include/nodes/internal/NodePainterDelegate.hpp ++++ b/include/nodes/internal/NodePainterDelegate.hpp +@@ -1,6 +1,6 @@ + #pragma once + +-#include ++#include + + #include "NodeGeometry.hpp" + #include "NodeDataModel.hpp" +diff --git a/include/nodes/internal/QStringStdHash.hpp b/include/nodes/internal/QStringStdHash.hpp +index 3d47a3f..cc5eb68 100644 +--- a/include/nodes/internal/QStringStdHash.hpp ++++ b/include/nodes/internal/QStringStdHash.hpp +@@ -1,5 +1,11 @@ + #pragma once + ++#include ++ ++#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) ++ ++// As of 5.14 there is a specialization std::hash ++ + #include + + #include +@@ -17,3 +23,5 @@ struct hash + } + }; + } ++ ++#endif diff --git a/xmake-repo/packages/n/nodeeditor/xmake.lua b/xmake-repo/packages/n/nodeeditor/xmake.lua new file mode 100644 index 000000000..07c447faa --- /dev/null +++ b/xmake-repo/packages/n/nodeeditor/xmake.lua @@ -0,0 +1,46 @@ +package("nodeeditor") + + set_homepage("https://github.com/paceholder/nodeeditor") + set_description("Qt Node Editor. Dataflow programming framework") + set_license("BSD-3") + + set_urls("https://github.com/paceholder/nodeeditor/archive/refs/tags/$(version).tar.gz", + "https://github.com/paceholder/nodeeditor.git") + add_versions("2.1.3", "4e3194a04ac4a2a2bf4bc8eb6cc27d5cc154923143c1ecf579ce7f0115a90585") + add_patches("2.1.3", path.join(os.scriptdir(), "patches", "2.1.3", "fix_qt.patch"), "804ee98d47b675c578981414ed25a745f1b12d0cd8b03ea7d7b079c7e1ce1ea9") + + add_deps("cmake") + + on_load(function (package) + if package:config("shared") then + package:add("defines", "NODE_EDITOR_SHARED") + else + package:add("defines", "NODE_EDITOR_STATIC") + end + end) + + on_install("windows", "linux", "mingw", "macosx", function (package) + import("detect.sdks.find_qt") + local qt = find_qt() + + local configs = {"-DBUILD_EXAMPLES=OFF", "-DBUILD_TESTING=OFF"} + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) + if qt then + table.insert(configs, "-DQt5_DIR=" .. path.join(qt.libdir, "cmake", "Qt5")) + end + import("package.tools.cmake").install(package, configs) + end) + + on_test(function (package) + do + -- Disable test until I can test with Qt + return + end + assert(package:check_cxxsnippets({test = [[ + void test() { + QtNodes::FlowScene scene(std::make_shared()); + QtNodes::FlowView view(&scene); + } + ]]}, {configs = {languages = "c++11"}, includes = {"nodes/FlowScene", "nodes/FlowView"}})) + end) diff --git a/xmake.lua b/xmake.lua index acf4745c4..71331d5a2 100644 --- a/xmake.lua +++ b/xmake.lua @@ -84,6 +84,8 @@ local modules = { } } +add_repositories("local-repo xmake-repo") + add_requires("chipmunk2d", "freetype", "libsndfile", "libsdl") add_requires("newtondynamics", { debug = is_mode("debug") }) @@ -163,9 +165,11 @@ for name, module in pairs(modules) do end end +includes("tools/xmake.lua") includes("plugins/*/xmake.lua") includes("examples/*/xmake.lua") +-- Adds -d as a debug suffix rule("debug_suffix") on_load(function (target) if target:kind() ~= "binary" then