xmake.lua 2.6 KB

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