From c3ec8659c1f17554500421ab0ef2268dc0ce6c9b Mon Sep 17 00:00:00 2001 From: benny066567 <1292983376@qq.com> Date: Tue, 29 Oct 2024 21:35:46 +0800 Subject: [PATCH] add xtd repo (#5246) * add xtd repo * change wxwdigets deps gtk+3 to gtk3 * change the default backend of xtd * change configs * use pkg-config add wxwidgets to src dir * add gsound deps * add gsound to tunit * add gsound to tool * add uuid includedir to xtd.native.unix * add libuuid to packagedeps * ban the building with clang --- .../v0.1.2/add_wxwidgets_to_tools.patch | 87 +++++++++++++++++++ packages/x/xtd/xmake.lua | 66 ++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 packages/x/xtd/patches/v0.1.2/add_wxwidgets_to_tools.patch create mode 100644 packages/x/xtd/xmake.lua diff --git a/packages/x/xtd/patches/v0.1.2/add_wxwidgets_to_tools.patch b/packages/x/xtd/patches/v0.1.2/add_wxwidgets_to_tools.patch new file mode 100644 index 000000000..9d4548bf8 --- /dev/null +++ b/packages/x/xtd/patches/v0.1.2/add_wxwidgets_to_tools.patch @@ -0,0 +1,87 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index a01d814..595190c 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -5,6 +5,14 @@ project(src) + include(../scripts/cmake/xtd_commands.cmake) + include(../scripts/cmake/xtd_version.cmake) + ++find_package(PkgConfig) ++pkg_check_modules(WXWIDGETS wxwidgets) ++include_directories(${WXWIDGETS_INCLUDE_DIRS}) ++link_directories(${WXWIDGETS_LIBRARY_DIRS}) ++set(XTD_EXTRA_LIBS "${XTD_EXTRA_LIBS};${WXWIDGETS_LIBRARIES}") ++ ++add_references(${XTD_EXTRA_LIBS}) ++ + set(XTD_HEADER_FILE "xtd/include/xtd/xtd.h") + file(WRITE ${XTD_HEADER_FILE} + "// This code was generated by CMake script.\n" +diff --git a/src/xtd.forms.native.wxwidgets/CMakeLists.txt b/src/xtd.forms.native.wxwidgets/CMakeLists.txt +index 263a4ab..8d35497 100644 +--- a/src/xtd.forms.native.wxwidgets/CMakeLists.txt ++++ b/src/xtd.forms.native.wxwidgets/CMakeLists.txt +@@ -18,7 +18,7 @@ endif() + find_package(wxWidgets REQUIRED COMPONENTS base core xrc) + include(${wxWidgets_USE_FILE}) + add_include_directories(include) +-add_references(xtd.drawing xtd.forms.native ${wxWidgets_LIBRARIES} ${XTD_EXTRA_LIBS}) ++add_references(xtd.drawing xtd.forms.native) + add_sources( + include/xtd/xtd.forms.native.wxwidgets.h + include/xtd/xtd.forms.native.wxwidgets +diff --git a/src/xtd.forms/include/xtd/forms/button_renderer.h b/src/xtd.forms/include/xtd/forms/button_renderer.h +index 2bfe757..bca4d9b 100644 +--- a/src/xtd.forms/include/xtd/forms/button_renderer.h ++++ b/src/xtd.forms/include/xtd/forms/button_renderer.h +@@ -4,6 +4,7 @@ + #pragma once + #include + #include ++#include + #include + #include + #include +diff --git a/src/xtd.tunit/CMakeLists.txt b/src/xtd.tunit/CMakeLists.txt +index 651e875..4a2891a 100644 +--- a/src/xtd.tunit/CMakeLists.txt ++++ b/src/xtd.tunit/CMakeLists.txt +@@ -4,6 +4,15 @@ cmake_minimum_required(VERSION 3.20) + project(xtd.tunit) + include(../../scripts/cmake/xtd_commands.cmake) + include(../../scripts/cmake/xtd_version.cmake) ++ ++find_package(PkgConfig) ++pkg_check_modules(GSOUND REQUIRED gsound) ++include_directories(${GSOUND_INCLUDE_DIRS}) ++link_directories(${GSOUND_LIBRARY_DIRS}) ++set(XTD_EXTRA_LIBS "${XTD_EXTRA_LIBS};${GSOUND_LIBRARIES}") ++ ++add_references(${XTD_EXTRA_LIBS}) ++ + add_include_directories(include) + add_references(xtd.core) + add_sources( +diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt +index f993971..9b1d9c8 100644 +--- a/tools/CMakeLists.txt ++++ b/tools/CMakeLists.txt +@@ -5,6 +5,18 @@ project(tools) + include(../scripts/cmake/xtd_commands.cmake) + include(../scripts/cmake/xtd_version.cmake) + ++find_package(PkgConfig) ++pkg_check_modules(WXWIDGETS wxwidgets) ++include_directories(${WXWIDGETS_INCLUDE_DIRS}) ++link_directories(${WXWIDGETS_LIBRARY_DIRS}) ++set(XTD_EXTRA_LIBS ${WXWIDGETS_LIBRARIES}) ++ ++pkg_check_modules(GSOUND REQUIRED gsound) ++include_directories(${GSOUND_INCLUDE_DIRS}) ++link_directories(${GSOUND_LIBRARY_DIRS}) ++set(XTD_EXTRA_LIBS "${XTD_EXTRA_LIBS};${GSOUND_LIBRARIES}") ++add_references(${XTD_EXTRA_LIBS}) ++ + # Add projects + if (XTD_BUILD_TOOL_GUIDGEN_COMMAND_LINE) + add_projects(guidgen) diff --git a/packages/x/xtd/xmake.lua b/packages/x/xtd/xmake.lua new file mode 100644 index 000000000..3476634c6 --- /dev/null +++ b/packages/x/xtd/xmake.lua @@ -0,0 +1,66 @@ +package("xtd") + set_homepage("https://github.com/gammasoft71/xtd") + set_description("xtd is a modern C++17/20 framework to create console, GUI (forms like WinForms) and unit test applications on Microsoft Windows, Apple macOS, Linux, iOS and android (*).") + set_license("MIT") + + add_urls("https://github.com/gammasoft71/xtd/archive/refs/tags/$(version)-beta.zip", + "https://github.com/gammasoft71/xtd.git") + + add_versions("v0.1.2", "648f7e5e2252d0db4e9432d493cec0682c059605ae3dfded793884cbbf3d1bd5") + + add_configs("graphic_toolkit", {description = "Select xtd graphic toolkit.", default = "wxwidgets", type = "string", values = {"gtk3", "wxwidgets", "fltk", "gtk4", "qt5"}}) + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + -- when building the xtd shared library, it shows Cyclic dependencies error. I have summit a issue to xtd. + -- https://github.com/gammasoft71/xtd/issues/264#issue-2527671013 + + if is_plat("linux") then + add_patches("v0.1.2", "patches/v0.1.2/add_wxwidgets_to_tools.patch", "3ce364859341832be2a47452a727dbabf6b368a8b11f70849fb8818de200642b") + end + + -- regarding the problems when building with clang + -- https://github.com/gammasoft71/xtd/issues/268 + if on_check then + on_check(function (package) + if package:has_tool("cxx", "clang", "clang_cl") then + raise("package(xtd) unsupported clang toolchain") + end + end) + end + + add_deps("cmake","alsa-lib", "xorgproto", "glib", "gsound", "libuuid") + add_links("xtd", "xtd.core", "xtd.forms", "xtd.drawing", "xtd.tunit", "xtd.forms.native.wxwidgets", "xtd.3rdparty.call_stack", "xtd.core.native.unix", "xtd.drawing.native.wxwidgets") + + on_load("linux", function (package) + if package:config("graphic_toolkit") == "wxwidgets" then + package:add("deps", "wxwidgets") + elseif package:config("graphic_toolkit") == "gtk3" then + package:add("deps", "gtk3") + elseif package:config("graphic_toolkit") == "gtk4" then + package:add("deps", "gtk4") + elseif package:config("graphic_toolkit") == "fltk" then + package:add("deps", "fltk") + elseif package:config("graphic_toolkit") == "qt5" then + package:add("deps", "qt5base", "qt5core", "qt5gui", "qt5widgets") + end + end) + + on_install("linux", function (package) + local configs = {" --log-level=VERBOSE", "-DXTD_NATIVE_GRAPHIC_TOOLKIT=" .. package:config("graphic_toolkit"), "-DXTD_INSTALL_RESOURCES=OFF", "-DXTD_BUILD_TOOL_SLEEPFOR_COMMAND_LINE=OFF"} + table.insert(configs, "-DXTD_BUILD_SHARED_LIBRARIES=" .. (package:config("shared") and "ON" or "OFF")) + table.insert(configs, "-DXTD_INSTALL_EXAMPLES=OFF") + table.insert(configs, "-DXTD_BUILD_TOOL_GUIDGEN_GUI=OFF") + table.insert(configs, "-DXTD_BUILD_TOOL_GUIDGEN_COMMAND_LINE=OFF") + import("package.tools.cmake").install(package, configs, {packagedeps = {"libcanberra", "libuuid"}}) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + using namespace xtd; + static void test() { + console::background_color(console_color::blue); + console::foreground_color(console_color::white); + console::write_line("Hello, World!"); + } + ]]}, {configs = {languages = "c++20"}})) + end)