diff --git a/MODULE.bazel b/MODULE.bazel index 9be233fda6..81fe691d9b 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -14,3 +14,5 @@ bazel_dep( dev_dependency = True, ) bazel_dep(name = "googletest", version = "1.15.2", dev_dependency = True) + +bazel_dep(name = "ncurses", version = "6.4.20221231") diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index cf307cf179..bc07fe8d9c 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -25,3 +25,13 @@ load_repositories() load("//bazel:setup_repositories.bzl", "setup_repositories") setup_repositories() + +load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") + +# This sets up some common toolchains for building targets. For more details, please see +# https://bazelbuild.github.io/rules_foreign_cc/0.12.0/flatten.html#rules_foreign_cc_dependencies +rules_foreign_cc_dependencies() + +load("@bazel_features//:deps.bzl", "bazel_features_deps") + +bazel_features_deps() diff --git a/bazel/load_repositories.bzl b/bazel/load_repositories.bzl index 7e81e86af4..94547fe2a1 100644 --- a/bazel/load_repositories.bzl +++ b/bazel/load_repositories.bzl @@ -20,6 +20,7 @@ load("//bazel/bazelbuild:repositories.bzl", "load_com_github_bazelbuild_rules_cc load("//bazel/buildifier_prebuilt:repositories.bzl", "load_buildifier_prebuilt_repositories") load("//bazel/cpptoml:repositories.bzl", "load_cpptoml_repositories") load("//bazel/googletest:repositories.bzl", "load_googletest_repositories") +load("//bazel/ncurses:repositories.bzl", "load_ncurses_repositories") load("//bazel/skylib:repositories.bzl", "load_bazel_skylib_repositories") def load_repositories(): @@ -31,3 +32,4 @@ def load_repositories(): load_buildifier_prebuilt_repositories() load_googletest_repositories() load_cpptoml_repositories() + load_ncurses_repositories() diff --git a/bazel/ncurses/BUILD.bazel b/bazel/ncurses/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/bazel/ncurses/ncurses.BUILD b/bazel/ncurses/ncurses.BUILD new file mode 100644 index 0000000000..820432c972 --- /dev/null +++ b/bazel/ncurses/ncurses.BUILD @@ -0,0 +1,39 @@ +# Copyright (c) 2024 by Fernride GmbH. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make") + +filegroup( + name = "all_srcs", + srcs = glob(["**"]), +) + +configure_make( + name = "ncurses", + args = ["-j"], + configure_options = [ + "--without-debug", + "--without-ada", + "--without-tests", + "--enable-overwrite", + ], + lib_source = ":all_srcs", + out_static_libs = [ + "libncurses.a", + "libcurses.a", + ], + visibility = ["//visibility:public"], +) diff --git a/bazel/ncurses/repositories.bzl b/bazel/ncurses/repositories.bzl new file mode 100644 index 0000000000..3ef3e5a6dc --- /dev/null +++ b/bazel/ncurses/repositories.bzl @@ -0,0 +1,37 @@ +# Copyright (c) 2024 by Fernride GmbH. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +"""This module prepares the ncurses dependency.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +def load_ncurses_repositories(): + maybe( + http_archive, + name = "rules_foreign_cc", + sha256 = "a2e6fb56e649c1ee79703e99aa0c9d13c6cc53c8d7a0cbb8797ab2888bbc99a3", + strip_prefix = "rules_foreign_cc-0.12.0", + url = "https://github.com/bazelbuild/rules_foreign_cc/releases/download/0.12.0/rules_foreign_cc-0.12.0.tar.gz", + ) + maybe( + http_archive, + name = "ncurses", + url = "https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.3.tar.gz", + sha256 = "97fc51ac2b085d4cde31ef4d2c3122c21abc217e9090a43a30fc5ec21684e059", + strip_prefix = "ncurses-6.3", + build_file = "//bazel/ncurses:ncurses.BUILD", + ) diff --git a/doc/website/release-notes/iceoryx-unreleased.md b/doc/website/release-notes/iceoryx-unreleased.md index 50b5b00586..4c289a6500 100644 --- a/doc/website/release-notes/iceoryx-unreleased.md +++ b/doc/website/release-notes/iceoryx-unreleased.md @@ -145,6 +145,7 @@ - Fix bazel build on macos [#2345](https://github.com/eclipse-iceoryx/iceoryx/issues/2345) - Fix Bzlmod module name typo [#2364](https://github.com/eclipse-iceoryx/iceoryx/issues/2364) - Add //:iceoryx Bazel alias [#2368](https://github.com/eclipse-iceoryx/iceoryx/issues/2368) +- Depend on @ncurses when building with Bazel [#2372](https://github.com/eclipse-iceoryx/iceoryx/issues/2372) **Refactoring:** diff --git a/tools/introspection/BUILD.bazel b/tools/introspection/BUILD.bazel index 3a1a136bf3..1cc8f97244 100644 --- a/tools/introspection/BUILD.bazel +++ b/tools/introspection/BUILD.bazel @@ -23,7 +23,6 @@ cc_library( "source/introspection_app.cpp", ], hdrs = glob(["include/iceoryx_introspection/**"]), - linkopts = ["-lncurses"], strip_include_prefix = "include", #Windows does not offer ncurses, therefore we do not build the lib target_compatible_with = select({ @@ -33,6 +32,7 @@ cc_library( visibility = ["//visibility:public"], deps = [ "//iceoryx_posh", + "@ncurses", ], ) diff --git a/tools/introspection/include/iceoryx_introspection/introspection_app.hpp b/tools/introspection/include/iceoryx_introspection/introspection_app.hpp index 653266877c..b2e53e05b1 100644 --- a/tools/introspection/include/iceoryx_introspection/introspection_app.hpp +++ b/tools/introspection/include/iceoryx_introspection/introspection_app.hpp @@ -20,8 +20,8 @@ #include "iceoryx_platform/getopt.hpp" #include "iceoryx_posh/popo/subscriber.hpp" +#include #include -#include #include namespace iox