diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 000000000..5a003d17d --- /dev/null +++ b/.bazelignore @@ -0,0 +1 @@ +bazel/test/ diff --git a/.bazelrc b/.bazelrc index 240fd4c83..3a021aa0f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,4 +1,5 @@ common --enable_bzlmod +common --enable_workspace build --features=layering_check build --enable_bzlmod @@ -6,4 +7,4 @@ build --enable_bzlmod build --enable_platform_specific_config build:linux --cxxopt=-std=c++20 build:macos --cxxopt=-std=c++20 -build:windows --cxxopt=-std:c++20 +build:windows --cxxopt=/std:c++20 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e13402da1..3b34eecfe 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -56,6 +56,13 @@ jobs: CXX: ${{ matrix.cxx }} run: bazel test --test_output=all ... + - name: "Bazel Smoke test" + env: + CC: ${{ matrix.cc }} + CXX: ${{ matrix.cxx }} + run: bazel build //... --enable_bzlmod --override_module=ftxui=../.. + working-directory: bazel/test + test_cmake: name: "CMake, ${{ matrix.compiler }}, ${{ matrix.os }}" strategy: diff --git a/.gitignore b/.gitignore index 746cefc5f..c52241a77 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ out/ !BUILD.bazel !MODULE.bazel !.bazelrc +!.bazelignore # .github directory: !.github/**/*.yaml @@ -37,6 +38,10 @@ out/ # bazel directory: !bazel/**/*.bzl !.bcr/* +!bazel/test/*.bazel +!bazel/test/*.bazelrc +!bazel/test/*.cpp +!bazel/test/*.md # doc directory: !doc/**/Doxyfile.in diff --git a/BUILD.bazel b/BUILD.bazel index 9fd18cd0e..64ff3de45 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -15,13 +15,16 @@ load(":bazel/ftxui.bzl", "generate_examples") load(":bazel/ftxui.bzl", "windows_copts") # A meta target depending on all of the ftxui submodules. -# Note that component depends on dom and screen, so ftxui is just an alias for -# component. +# Note that component depends on dom and screen, so ftxui re-exports all headers. # ┌component──┐ # │┌dom──────┐│ # ││┌screen─┐││ # └┴┴───────┴┴┘ -alias(name = "ftxui", actual = ":component") +ftxui_cc_library( + name = "ftxui", + hdrs = glob(["include/ftxui/**/*.hpp"]), + deps = [":component"], +) # @ftxui:screen is a module that provides a screen buffer and color management # for terminal applications. A screen is a 2D array of cells, each cell can diff --git a/CHANGELOG.md b/CHANGELOG.md index c9d86f6df..698749a20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Next ``` Thanks @mikomikotaishi for PR #1015. - Remove dependency on 'pthread'. +- Bugfix: Bazel target @ftxui is now visible. Thanks @dskkato in #1157. ### Component - Feature: POSIX Piped Input Handling. diff --git a/README.md b/README.md index 49cc0f78f..3d46cafcb 100644 --- a/README.md +++ b/README.md @@ -425,9 +425,13 @@ cc_binary( name = "your_target", srcs = ["your_source.cc"], deps = [ + # Choose submodules "@ftxui//:component", "@ftxui//:dom", "@ftxui//:screen", + + # Or use the single ftxui target (includes all modules) + # "@ftxui//:ftxui", ], ) ``` diff --git a/bazel/test/.bazelrc b/bazel/test/.bazelrc new file mode 120000 index 000000000..c70ccda07 --- /dev/null +++ b/bazel/test/.bazelrc @@ -0,0 +1 @@ +../../.bazelrc \ No newline at end of file diff --git a/bazel/test/BUILD.bazel b/bazel/test/BUILD.bazel new file mode 100644 index 000000000..6d8590bdb --- /dev/null +++ b/bazel/test/BUILD.bazel @@ -0,0 +1,23 @@ +# Copyright 2025 Arthur Sonzogni. All rights reserved. +# Use of this source code is governed by the MIT license that can be found in +# the LICENSE file. + +# Test using individual submodules +cc_binary( + name = "smoke", + srcs = ["smoke.cpp"], + deps = [ + "@ftxui//:component", + "@ftxui//:dom", + "@ftxui//:screen", + ], +) + +# Test using the single ftxui target +cc_binary( + name = "smoke_single_dependency", + srcs = ["smoke.cpp"], + deps = [ + "@ftxui", + ], +) diff --git a/bazel/test/MODULE.bazel b/bazel/test/MODULE.bazel new file mode 100644 index 000000000..757e58d21 --- /dev/null +++ b/bazel/test/MODULE.bazel @@ -0,0 +1,9 @@ +# Copyright 2025 Arthur Sonzogni. All rights reserved. +# Use of this source code is governed by the MIT license that can be found in +# the LICENSE file. +module( + name = "ftxui_integration_test", + version = "0.0.1", +) + +bazel_dep(name = "ftxui", version = "6.1.9") diff --git a/bazel/test/README.md b/bazel/test/README.md new file mode 100644 index 000000000..0f223615b --- /dev/null +++ b/bazel/test/README.md @@ -0,0 +1,38 @@ +# FTXUI Bazel Integration Test + +This directory contains integration tests to verify that FTXUI can be properly consumed as an external dependency using Bazel with Bzlmod. + +## Purpose + +These tests ensure that: +- FTXUI's public API is correctly exposed to external projects +- Both single-target (`@ftxui//:ftxui`) and submodule-based dependencies work correctly +- Headers are properly re-exported and accessible from downstream projects + +## Build Instructions + +To build all targets: + +```bash +bazel build //... --enable_bzlmod --override_module=ftxui=../.. +``` + +To build individual targets: + +```bash +# Test using individual submodules +bazel build //:smoke --enable_bzlmod --override_module=ftxui=../.. + +# Test using the single ftxui target +bazel build //:smoke_single_dependency --enable_bzlmod --override_module=ftxui=../.. +``` + +## Run the Examples + +```bash +# Run the submodules version +./bazel-bin/smoke + +# Run the single-target version +./bazel-bin/smoke_single_dependency +``` diff --git a/bazel/test/WORKSPACE.bazel b/bazel/test/WORKSPACE.bazel new file mode 100644 index 000000000..867dbacc8 --- /dev/null +++ b/bazel/test/WORKSPACE.bazel @@ -0,0 +1,4 @@ +# Copyright 2025 Arthur Sonzogni. All rights reserved. +# Use of this source code is governed by the MIT license that can be found in +# the LICENSE file. +workspace(name = "ftxui_smoke_test") diff --git a/bazel/test/smoke.cpp b/bazel/test/smoke.cpp new file mode 100644 index 000000000..ebc94d30b --- /dev/null +++ b/bazel/test/smoke.cpp @@ -0,0 +1,16 @@ +// Copyright 2025 Arthur Sonzogni. All rights reserved. +// Use of this source code is governed by the MIT license that can be found in +// the LICENSE file. +#include +#include +#include +#include + +int main() { + using namespace ftxui; + auto screen = ScreenInteractive::TerminalOutput(); + auto component = Button("Quit", screen.ExitLoopClosure()); + screen.Loop(component); + return 0; +} +