mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-05-08 19:21:14 +08:00

* Bazel: general improvements. Improve the Bazel build. Attempt to fix previous errors recorded while trying to publish ftxui in the Bazel Central Registry: - https://github.com/bazelbuild/bazel-central-registry/pull/4485 - https://buildkite.com/bazel/bcr-presubmit/builds/13601#01968b61-f5b2-4d16-94d0-c87a03a1a23b Test against "recent" platforms ------------------------------- Previously, I got the error: ``` gcc: error: unrecognized command line option '-std-c++20'; did you mean '-std-c++2a'? ``` This was due to using old distribution like ubuntu 2004. Test against newer platforms only to avoid GCC version<-9.x.y Downgrade gtest version. ------------------------ I suspect this caused the Bazel Central Registry error: ``` file:///workdir/modules/googletest/1.15.2/MODULE.bazel:68:20: name 'use_repo_rule' is not defined ``` Specifying using bazelmod fixes the issue. Thanks @robinlinden Tag gtest as dev_dependency --------------------------- Presumably, this should avoid dependants to fetch it? Enable --features-layering_check -------------------------------- Aka clang `-Wprivate-header`. Fix the encountered errors. Use clang in the CI ------------------- The CI was defining clang/gcc in the matrix, but was not using it. Fix the bug.
105 lines
3.2 KiB
Python
105 lines
3.2 KiB
Python
# ftxui_common.bzl
|
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_library")
|
|
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
|
|
|
# Microsoft terminal is a bit buggy ¯\_(ツ)_/¯ and MSVC uses bad defaults.
|
|
def windows_copts():
|
|
MSVC_COPTS = [
|
|
# Microsoft Visual Studio must decode sources files as UTF-8.
|
|
"/utf-8",
|
|
|
|
# Microsoft Visual Studio must interpret the codepoint using unicode.
|
|
"/DUNICODE",
|
|
"/D_UNICODE",
|
|
|
|
# Fallback for Microsoft Terminal.
|
|
# This
|
|
# - Replace missing font symbols by others.
|
|
# - Reduce screen position pooling frequency to deals against a Microsoft
|
|
# race condition. This was fixed in 2020, but clients never not updated.
|
|
# - https://github.com/microsoft/terminal/pull/7583
|
|
# - https://github.com/ArthurSonzogni/FTXUI/issues/136
|
|
"/DFTXUI_MICROSOFT_TERMINAL_FALLBACK",
|
|
]
|
|
|
|
WINDOWS_COPTS = [
|
|
# Fallback for Microsoft Terminal.
|
|
# This
|
|
# - Replace missing font symbols by others.
|
|
# - Reduce screen position pooling frequency to deals against a Microsoft
|
|
# race condition. This was fixed in 2020, but clients are still using
|
|
# old versions.
|
|
# - https://github.com/microsoft/terminal/pull/7583
|
|
# - https://github.com/ArthurSonzogni/FTXUI/issues/136
|
|
"-DFTXUI_MICROSOFT_TERMINAL_FALLBACK",
|
|
];
|
|
|
|
return select({
|
|
# MSVC:
|
|
"@rules_cc//cc/compiler:msvc-cl": MSVC_COPTS,
|
|
"@rules_cc//cc/compiler:clang-cl": MSVC_COPTS,
|
|
"@platforms//os:windows": WINDOWS_COPTS,
|
|
"//conditions:default": [],
|
|
})
|
|
|
|
def pthread_linkopts():
|
|
return select({
|
|
# With MSVC, threading is already built-in (you don't need -pthread.
|
|
"@rules_cc//cc/compiler:msvc-cl": [],
|
|
"@rules_cc//cc/compiler:clang-cl": [],
|
|
"@rules_cc//cc/compiler:clang": ["-pthread"],
|
|
"@rules_cc//cc/compiler:gcc": ["-pthread"],
|
|
"//conditions:default": ["-pthread"],
|
|
})
|
|
|
|
def ftxui_cc_library(
|
|
name,
|
|
srcs = [],
|
|
hdrs = [],
|
|
linkopts = [],
|
|
deps = []):
|
|
|
|
cc_library(
|
|
name = name,
|
|
srcs = srcs,
|
|
hdrs = hdrs,
|
|
linkopts = linkopts,
|
|
deps = deps,
|
|
strip_include_prefix = "",
|
|
include_prefix = "",
|
|
includes = [
|
|
"include",
|
|
"src",
|
|
],
|
|
copts = windows_copts(),
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
# Compile all the examples in the examples/ directory.
|
|
# This is useful to check the Bazel is always synchronized against CMake
|
|
# definitions.
|
|
def generate_examples():
|
|
cpp_files = native.glob(["examples/**/*.cpp"])
|
|
|
|
for src in cpp_files:
|
|
# Skip failing examples due to the color_info_sorted_2d.ipp dependency.
|
|
if src == "examples/component/homescreen.cpp" or \
|
|
src == "examples/dom/color_info_palette256.cpp" or \
|
|
src == "examples/dom/color_gallery.cpp":
|
|
continue
|
|
|
|
# Turn "examples/component/button.cpp" → "example_component_button"
|
|
name = src.replace("/", "_").replace(".cpp", "")
|
|
|
|
cc_binary(
|
|
name = name,
|
|
srcs = [src],
|
|
deps = [
|
|
":component",
|
|
":dom",
|
|
":screen",
|
|
],
|
|
copts = windows_copts(),
|
|
)
|