mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-06-25 00:52:09 +08:00
Add documentation about Bazel
This commit is contained in:
parent
5cfed50702
commit
e0622f0df8
70
README.md
70
README.md
@ -42,15 +42,25 @@ A simple cross-platform C++ library for terminal based user interfaces!
|
|||||||
* No dependencies
|
* No dependencies
|
||||||
* **Cross platform**: Linux/MacOS (main target), WebAssembly, Windows (Thanks to contributors!).
|
* **Cross platform**: Linux/MacOS (main target), WebAssembly, Windows (Thanks to contributors!).
|
||||||
* Learn by [examples](#documentation), and [tutorials](#documentation)
|
* 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...
|
* Good practices: documentation, tests, fuzzers, performance tests, automated CI, automated packaging, etc...
|
||||||
|
|
||||||
## Documentation
|
## 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/)
|
- [Documentation](https://arthursonzogni.github.io/FTXUI/)
|
||||||
- [Examples (WebAssembly)](https://arthursonzogni.github.io/FTXUI/examples/)
|
- [Examples (WebAssembly)](https://arthursonzogni.github.io/FTXUI/examples/)
|
||||||
- [Build using CMake](https://arthursonzogni.github.io/FTXUI/#build-cmake)
|
- [Build using CMake](https://arthursonzogni.github.io/FTXUI/#build-cmake)
|
||||||
|
- [Build using Bazel](https://arthursonzogni.github.io/FTXUI/#build-bazel)
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
~~~cpp
|
~~~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)
|
- [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)
|
- [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.
|
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
|
```cmake
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
FetchContent_Declare(ftxui
|
FetchContent_Declare(ftxui
|
||||||
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
|
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
|
||||||
GIT_TAG v6.1.9
|
GIT_TAG v6.1.9
|
||||||
)
|
)
|
||||||
|
FetchContent_MakeAvailable(ftxui)
|
||||||
|
|
||||||
FetchContent_GetProperties(ftxui)
|
target_link_libraries(your_target PRIVATE
|
||||||
if(NOT ftxui_POPULATED)
|
# Chose a submodule
|
||||||
FetchContent_Populate(ftxui)
|
ftxui::component
|
||||||
add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
|
ftxui::dom
|
||||||
endif()
|
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:
|
If you don't, FTXUI may be used from the following packages:
|
||||||
- [bazel](...)
|
- CMake [FetchContent]([https://bewagner.net/programming/2020/05/02/cmake-fetchcontent/](https://cmake.org/cmake/help/latest/module/FetchContent.html)) (preferred),
|
||||||
- [vcpkg](https://vcpkgx.com/details.html?package=ftxui)
|
- [Bazel](https://registry.bazel.build/modules/ftxui),
|
||||||
- [Arch Linux PKGBUILD](https://aur.archlinux.org/packages/ftxui-git/).
|
- [vcpkg](https://vcpkg.link/ports/ftxui),
|
||||||
- [conan.io](https://conan.io/center/ftxui)
|
- [Conan](https://conan.io/center/recipes/ftxui)
|
||||||
- [openSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/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),
|
||||||
[](https://repology.org/project/libftxui/versions)
|
[](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.
|
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
|
```bash
|
||||||
g++ . . . -lftxui-component -lftxui-dom -lftxui-screen . . .
|
g++ . . . -lftxui-component -lftxui-dom -lftxui-screen . . .
|
||||||
|
@ -103,6 +103,35 @@ make
|
|||||||
./main
|
./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}
|
# List of modules. {#modules}
|
||||||
|
|
||||||
The project is comprised of 3 modules:
|
The project is comprised of 3 modules:
|
||||||
|
Loading…
Reference in New Issue
Block a user