From e0622f0df86990f9ed7dd47865c87db8808bb831 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Thu, 8 May 2025 12:29:54 +0200 Subject: [PATCH] Add documentation about Bazel --- README.md | 70 ++++++++++++++++++++++++++++++++++++++----------- doc/mainpage.md | 29 ++++++++++++++++++++ 2 files changed, 84 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 19abcb63..df5badc5 100644 --- a/README.md +++ b/README.md @@ -42,15 +42,25 @@ A simple cross-platform C++ library for terminal based user interfaces! * No dependencies * **Cross platform**: Linux/MacOS (main target), WebAssembly, Windows (Thanks to contributors!). * Learn by [examples](#documentation), and [tutorials](#documentation) - * Multiple packages: CMake [FetchContent]([https://bewagner.net/programming/2020/05/02/cmake-fetchcontent/](https://cmake.org/cmake/help/latest/module/FetchContent.html)) (preferred),Bazel, vcpkg, pkgbuild, conan. + * Multiple packages: + - CMake [FetchContent]([https://bewagner.net/programming/2020/05/02/cmake-fetchcontent/](https://cmake.org/cmake/help/latest/module/FetchContent.html)) (preferred), + - [Bazel](https://registry.bazel.build/modules/ftxui), + - [vcpkg](https://vcpkg.link/ports/ftxui), + - [Conan](https://conan.io/center/recipes/ftxui) + - [Debian package](https://tracker.debian.org/pkg/ftxui), + - [Ubuntu package](https://launchpad.net/ubuntu/+source/ftxui), + - [Arch Linux](https://aur.archlinux.org/packages/ftxui/), + - [OpenSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui), * Good practices: documentation, tests, fuzzers, performance tests, automated CI, automated packaging, etc... ## Documentation -- [Starter example project](https://github.com/ArthurSonzogni/ftxui-starter) +- [Starter CMake](https://github.com/ArthurSonzogni/ftxui-starter) +- [Starter Bazel](https://github.com/ArthurSonzogni/ftxui-bazel) - [Documentation](https://arthursonzogni.github.io/FTXUI/) - [Examples (WebAssembly)](https://arthursonzogni.github.io/FTXUI/examples/) - [Build using CMake](https://arthursonzogni.github.io/FTXUI/#build-cmake) +- [Build using Bazel](https://arthursonzogni.github.io/FTXUI/#build-bazel) ## Example ~~~cpp @@ -365,33 +375,63 @@ Several games using the FTXUI have been made during the Game Jam: - [smoothlife](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/smoothlife.md) - [Consu](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/consu.md) -## Utilization +## Build using CMake It is **highly** recommended to use CMake FetchContent to depend on FTXUI so you may specify which commit you would like to depend on. ```cmake include(FetchContent) - FetchContent_Declare(ftxui GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui GIT_TAG v6.1.9 ) +FetchContent_MakeAvailable(ftxui) -FetchContent_GetProperties(ftxui) -if(NOT ftxui_POPULATED) - FetchContent_Populate(ftxui) - add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL) -endif() +target_link_libraries(your_target PRIVATE + # Chose a submodule + ftxui::component + ftxui::dom + ftxui::screen +) ``` +# Build using Bazel + +**MODULE.bazel** +```starlark +bazel_dep( + name = "ftxui", + version = "v6.1.9", +) +``` + +**BUILD.bazel** +```starlark +cc_binary( + name = "your_target", + srcs = ["your_source.cc"], + deps = [ + "@ftxui//:ftxui_component", + "@ftxui//:ftxui_dom", + "@ftxui//:ftxui_screen", + ], +) +``` + + +# Build with something else: +```bash If you don't, FTXUI may be used from the following packages: -- [bazel](...) -- [vcpkg](https://vcpkgx.com/details.html?package=ftxui) -- [Arch Linux PKGBUILD](https://aur.archlinux.org/packages/ftxui-git/). -- [conan.io](https://conan.io/center/ftxui) -- [openSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui) -- +- CMake [FetchContent]([https://bewagner.net/programming/2020/05/02/cmake-fetchcontent/](https://cmake.org/cmake/help/latest/module/FetchContent.html)) (preferred), +- [Bazel](https://registry.bazel.build/modules/ftxui), +- [vcpkg](https://vcpkg.link/ports/ftxui), +- [Conan](https://conan.io/center/recipes/ftxui) +- [Debian package](https://tracker.debian.org/pkg/ftxui), +- [Ubuntu package](https://launchpad.net/ubuntu/+source/ftxui), +- [Arch Linux](https://aur.archlinux.org/packages/ftxui/), +- [OpenSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui), [![Packaging status](https://repology.org/badge/vertical-allrepos/libftxui.svg)](https://repology.org/project/libftxui/versions) + If you choose to build and link FTXUI yourself, `ftxui-component` must be first in the linking order relative to the other FTXUI libraries, i.e. ```bash g++ . . . -lftxui-component -lftxui-dom -lftxui-screen . . . diff --git a/doc/mainpage.md b/doc/mainpage.md index 27f6c18b..9923c435 100644 --- a/doc/mainpage.md +++ b/doc/mainpage.md @@ -103,6 +103,35 @@ make ./main ``` +### Using Bazel + +See [ftxui module](https://registry.bazel.build/modules/ftxui) from the Bazel +Central Registry. + +See also this [starter](https://github.com/ArthurSonzogni/ftxui-bazel) project. + +**Module.bazel** +```starlark +bazel_dep( + name = "ftxui", + version = "6.1.9", +) +``` + +**BUILD.bazel** +```starlark +cc_binary( + name = "main", + srcs = ["main.cpp"], + deps = [ + # Choose one of the following: + "@ftxui//:dom", + "@ftxui//:screen", + "@ftxui//:component", + ], +) +``` + # List of modules. {#modules} The project is comprised of 3 modules: