From 2fdd100b55af061822c58b0fe375f076168b9d7a Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Wed, 7 May 2025 21:11:03 +0200 Subject: [PATCH] Address @robinlinden comments 2 --- .bazelrc | 5 +++++ .bcr/presubmit.yml | 48 ++++++++++++++++++++++++++++++--------------- BUILD.bazel | 3 +-- bazel/ftxui.bzl | 22 ++------------------- tools/test_bazel.sh | 8 +------- 5 files changed, 41 insertions(+), 45 deletions(-) diff --git a/.bazelrc b/.bazelrc index 796aaf51..711d581f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,2 +1,7 @@ build --features=layering_check build --enable_bzlmod + +build --enable_platform_specific_config +build:linux --cxxopt=-std=c++17 +build:macos --cxxopt=-std=c++17 +build:windows --cxxopt=-std:c++17 diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index bf102a7b..2d812d65 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml @@ -1,26 +1,42 @@ matrix: - # Note that gcc 9 and earlier aren't supported due to using --std=c++2a - # instead of --std=c++20 - platform: - - debian11 - - ubuntu2204 - - macos - - macos-arm64 - - windows bazel: - #- 6.x -> Build fails with bazel 6.x - - 7.x - - 8.x + - 7.x + - 8.x + - rolling + unix_platform: + - debian11 + - ubuntu2204 + - macos + - macos_arm64 + win_platform: + - windows + tasks: - verify_targets: - name: Build and test. - platform: ${{ platform }} + + unix_test: + name: Verify build targets on Unix + platform: ${{ unix_platform }} bazel: ${{ bazel }} + build_flags: + - --cxxopt=-std=c++17 build_targets: - - '@ftxui//:ftxui' - - '@ftxui//:screen' - '@ftxui//:dom' - '@ftxui//:component' + - '@ftxui//:screen' test_targets: - '@ftxui//:tests' + windows_test: + name: Verify build targets + platform: ${{ win_platform }} + bazel: ${{ bazel }} + build_flags: + - --cxxopt=/std:c++17 + build_targets: + - '@ftxui//:dom' + - '@ftxui//:component' + - '@ftxui//:screen' + test_targets: + - '@ftxui//:tests' + + diff --git a/BUILD.bazel b/BUILD.bazel index feb25b7e..5dfb8c13 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -12,7 +12,6 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load(":bazel/ftxui.bzl", "ftxui_cc_library") load(":bazel/ftxui.bzl", "generate_examples") -load(":bazel/ftxui.bzl", "cpp20") load(":bazel/ftxui.bzl", "windows_copts") load(":bazel/ftxui.bzl", "pthread_linkopts") @@ -258,7 +257,7 @@ cc_test( "include", "src", ], - copts = cpp20() + windows_copts(), + copts = windows_copts(), deps = [ ":screen", ":dom", diff --git a/bazel/ftxui.bzl b/bazel/ftxui.bzl index 099ba57c..e0de2e81 100644 --- a/bazel/ftxui.bzl +++ b/bazel/ftxui.bzl @@ -3,24 +3,6 @@ load("@rules_cc//cc:defs.bzl", "cc_library") load("@rules_cc//cc:defs.bzl", "cc_binary") -def cpp17(): - return select({ - "@rules_cc//cc/compiler:msvc-cl": ["/std:c++17"], - "@rules_cc//cc/compiler:clang-cl": ["/std:c++17"], - "@rules_cc//cc/compiler:clang": ["-std=c++17"], - "@rules_cc//cc/compiler:gcc": ["-std=c++17"], - "//conditions:default": ["-std=c++17"], - }) - -def cpp20(): - return select({ - "@rules_cc//cc/compiler:msvc-cl": ["/std:c++20"], - "@rules_cc//cc/compiler:clang-cl": ["/std:c++20"], - "@rules_cc//cc/compiler:clang": ["-std=c++20"], - "@rules_cc//cc/compiler:gcc": ["-std=c++20"], - "//conditions:default": ["-std=c++20"], - }) - # Microsoft terminal is a bit buggy ¯\_(ツ)_/¯ and MSVC uses bad defaults. def windows_copts(): MSVC_COPTS = [ @@ -90,7 +72,7 @@ def ftxui_cc_library( "include", "src", ], - copts = cpp17() + windows_copts(), + copts = windows_copts(), visibility = ["//visibility:public"], ) @@ -118,5 +100,5 @@ def generate_examples(): ":dom", ":screen", ], - copts = cpp20() + windows_copts(), + copts = windows_copts(), ) diff --git a/tools/test_bazel.sh b/tools/test_bazel.sh index f58c7c31..67d12cdb 100755 --- a/tools/test_bazel.sh +++ b/tools/test_bazel.sh @@ -1,14 +1,8 @@ # This script tests the project with different versions of Bazel and compilers # locally. This avoids waiting on the CI to run the tests. -# Version -# ------- -# - Version >= 7 are supported -# - Version <= 6 fail with the error: -# Error: -# external/googletest~1.14.0.bcr.1/googletest/include/gtest/internal/gtest-port.h:279:2: -# error: #error C++ versions less than C++14 are not supported. for ver in \ + "6.0.0" \ "7.0.0" \ "8.0.0" do