fix(bazel): ensure FTXUI is publicly accessible and add external smoke test (#1157)

- Set `visibility = ["//visibility:public"]` on the top-level `:ftxui` alias
  so the library can be consumed from external Bazel workspaces.
- Add `bazel_integration/` minimal external workspace to validate
  external usage via Bzlmod.
- Introduce `smoke` target that depends on `@ftxui//:ftxui`.
- Add CI job to build the smoke target using:
    --enable_bzlmod
    --override_module=ftxui=..
  This prevents regressions in visibility or public API changes.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
Daisuke Kato
2025-12-14 03:49:42 +09:00
committed by GitHub
parent c8fbef03c9
commit 117417e841
13 changed files with 117 additions and 4 deletions

1
.bazelignore Normal file
View File

@@ -0,0 +1 @@
bazel/test/

View File

@@ -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

View File

@@ -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:

5
.gitignore vendored
View File

@@ -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

View File

@@ -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

View File

@@ -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.

View File

@@ -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",
],
)
```

1
bazel/test/.bazelrc Symbolic link
View File

@@ -0,0 +1 @@
../../.bazelrc

23
bazel/test/BUILD.bazel Normal file
View File

@@ -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",
],
)

9
bazel/test/MODULE.bazel Normal file
View File

@@ -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")

38
bazel/test/README.md Normal file
View File

@@ -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
```

View File

@@ -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")

16
bazel/test/smoke.cpp Normal file
View File

@@ -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 <ftxui/dom/elements.hpp>
#include <ftxui/screen/screen.hpp>
#include <ftxui/component/component.hpp>
#include <ftxui/component/screen_interactive.hpp>
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::TerminalOutput();
auto component = Button("Quit", screen.ExitLoopClosure());
screen.Loop(component);
return 0;
}