mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-11-04 13:38:14 +08:00 
			
		
		
		
	Add documentation about Bazel (#1045)
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (cl, cl, windows-latest) (push) Has been cancelled
				
			
		
			
				
	
				Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, macos-latest) (push) Has been cancelled
				
			
		
			
				
	
				Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, ubuntu-latest) (push) Has been cancelled
				
			
		
			
				
	
				Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, macos-latest) (push) Has been cancelled
				
			
		
			
				
	
				Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, ubuntu-latest) (push) Has been cancelled
				
			
		
			
				
	
				Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Has been cancelled
				
			
		
			
				
	
				Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Has been cancelled
				
			
		
			
				
	
				Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Has been cancelled
				
			
		
			
				
	
				Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Has been cancelled
				
			
		
			
				
	
				Documentation / documentation (push) Has been cancelled
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (cl, cl, windows-latest) (push) Has been cancelled
				
			Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, macos-latest) (push) Has been cancelled
				
			Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, ubuntu-latest) (push) Has been cancelled
				
			Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, macos-latest) (push) Has been cancelled
				
			Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, ubuntu-latest) (push) Has been cancelled
				
			Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Has been cancelled
				
			Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Has been cancelled
				
			Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Has been cancelled
				
			Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Has been cancelled
				
			Documentation / documentation (push) Has been cancelled
				
			This commit is contained in:
		
							
								
								
									
										68
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										68
									
								
								README.md
									
									
									
									
									
								
							@@ -42,15 +42,24 @@ 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 +374,62 @@ 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:
 | 
			
		||||
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),
 | 
			
		||||
[](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 . . .
 | 
			
		||||
 
 | 
			
		||||
@@ -81,7 +81,7 @@ include(FetchContent)
 | 
			
		||||
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
 | 
			
		||||
FetchContent_Declare(ftxui
 | 
			
		||||
  GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
 | 
			
		||||
  GIT_TAG main # Important: Specify a version or a commit hash here.
 | 
			
		||||
  GIT_TAG 6.1.9
 | 
			
		||||
)
 | 
			
		||||
FetchContent_MakeAvailable(ftxui)
 | 
			
		||||
 | 
			
		||||
@@ -94,13 +94,33 @@ target_link_libraries(ftxui-starter
 | 
			
		||||
)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Build
 | 
			
		||||
### Using Bazel {#build-bazel}
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
mkdir build && cd build
 | 
			
		||||
cmake ..
 | 
			
		||||
make
 | 
			
		||||
./main
 | 
			
		||||
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}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user