xmake.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package("ftxui")
  2. set_homepage("https://github.com/ArthurSonzogni/FTXUI")
  3. set_description(":computer: C++ Functional Terminal User Interface. :heart:")
  4. set_license("MIT")
  5. add_urls("https://github.com/ArthurSonzogni/FTXUI/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/ArthurSonzogni/FTXUI.git")
  7. add_versions("v6.0.2", "ace3477a8dd7cdb911dbc75e7b43cdcc9cf1d4a3cc3fb41168ecc31c06626cb9")
  8. add_versions("v5.0.0", "a2991cb222c944aee14397965d9f6b050245da849d8c5da7c72d112de2786b5b")
  9. add_versions("v4.1.1", "9009d093e48b3189487d67fc3e375a57c7b354c0e43fc554ad31bec74a4bc2dd")
  10. add_versions("v3.0.0", "a8f2539ab95caafb21b0c534e8dfb0aeea4e658688797bb9e5539729d9258cc1")
  11. add_deps("cmake")
  12. if is_plat("windows") then
  13. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  14. elseif is_plat("linux", "bsd") then
  15. add_syslinks("pthread")
  16. end
  17. add_links("ftxui-component", "ftxui-dom", "ftxui-screen")
  18. on_install("linux", "windows", "macosx", "bsd", "mingw", "cross", function (package)
  19. local configs = {"-DFTXUI_BUILD_DOCS=OFF", "-DFTXUI_BUILD_EXAMPLES=OFF"}
  20. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  21. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  22. import("package.tools.cmake").install(package, configs)
  23. end)
  24. on_test(function (package)
  25. assert(package:check_cxxsnippets({test = [[
  26. #include <memory>
  27. #include <string>
  28. #include "ftxui/component/captured_mouse.hpp"
  29. #include "ftxui/component/component.hpp"
  30. #include "ftxui/component/component_base.hpp"
  31. #include "ftxui/component/screen_interactive.hpp"
  32. #include "ftxui/dom/elements.hpp"
  33. using namespace ftxui;
  34. void test() {
  35. int value = 50;
  36. auto buttons = Container::Horizontal({
  37. Button("Decrease", [&] { value--; }),
  38. Button("Increase", [&] { value++; }),
  39. });
  40. auto component = Renderer(buttons, [&] {
  41. return vbox({
  42. text("value = " + std::to_string(value)),
  43. separator(),
  44. gauge(value * 0.01f),
  45. separator(),
  46. buttons->Render(),
  47. }) |
  48. border;
  49. });
  50. auto screen = ScreenInteractive::FitComponent();
  51. screen.Loop(component);
  52. }
  53. ]]}, {configs = {languages = "c++17"}}))
  54. end)