Skip to content

Commit e693cc2

Browse files
authored
Merge pull request #2373 from lalten/iox-2372
iox-#2372: Depend on @ncurses when building with Bazel
2 parents d628cb7 + 9d8ed97 commit e693cc2

File tree

9 files changed

+93
-2
lines changed

9 files changed

+93
-2
lines changed

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ bazel_dep(
1414
dev_dependency = True,
1515
)
1616
bazel_dep(name = "googletest", version = "1.15.2", dev_dependency = True)
17+
18+
bazel_dep(name = "ncurses", version = "6.4.20221231")

WORKSPACE.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ load_repositories()
2525
load("//bazel:setup_repositories.bzl", "setup_repositories")
2626

2727
setup_repositories()
28+
29+
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
30+
31+
# This sets up some common toolchains for building targets. For more details, please see
32+
# https://bazelbuild.github.io/rules_foreign_cc/0.12.0/flatten.html#rules_foreign_cc_dependencies
33+
rules_foreign_cc_dependencies()
34+
35+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
36+
37+
bazel_features_deps()

bazel/load_repositories.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ load("//bazel/bazelbuild:repositories.bzl", "load_com_github_bazelbuild_rules_cc
2020
load("//bazel/buildifier_prebuilt:repositories.bzl", "load_buildifier_prebuilt_repositories")
2121
load("//bazel/cpptoml:repositories.bzl", "load_cpptoml_repositories")
2222
load("//bazel/googletest:repositories.bzl", "load_googletest_repositories")
23+
load("//bazel/ncurses:repositories.bzl", "load_ncurses_repositories")
2324
load("//bazel/skylib:repositories.bzl", "load_bazel_skylib_repositories")
2425

2526
def load_repositories():
@@ -31,3 +32,4 @@ def load_repositories():
3132
load_buildifier_prebuilt_repositories()
3233
load_googletest_repositories()
3334
load_cpptoml_repositories()
35+
load_ncurses_repositories()

bazel/ncurses/BUILD.bazel

Whitespace-only changes.

bazel/ncurses/ncurses.BUILD

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright (c) 2024 by Fernride GmbH. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
18+
19+
filegroup(
20+
name = "all_srcs",
21+
srcs = glob(["**"]),
22+
)
23+
24+
configure_make(
25+
name = "ncurses",
26+
args = ["-j"],
27+
configure_options = [
28+
"--without-debug",
29+
"--without-ada",
30+
"--without-tests",
31+
"--enable-overwrite",
32+
],
33+
lib_source = ":all_srcs",
34+
out_static_libs = [
35+
"libncurses.a",
36+
"libcurses.a",
37+
],
38+
visibility = ["//visibility:public"],
39+
)

bazel/ncurses/repositories.bzl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) 2024 by Fernride GmbH. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
"""This module prepares the ncurses dependency."""
18+
19+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
20+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
21+
22+
def load_ncurses_repositories():
23+
maybe(
24+
http_archive,
25+
name = "rules_foreign_cc",
26+
sha256 = "a2e6fb56e649c1ee79703e99aa0c9d13c6cc53c8d7a0cbb8797ab2888bbc99a3",
27+
strip_prefix = "rules_foreign_cc-0.12.0",
28+
url = "https://github.com/bazelbuild/rules_foreign_cc/releases/download/0.12.0/rules_foreign_cc-0.12.0.tar.gz",
29+
)
30+
maybe(
31+
http_archive,
32+
name = "ncurses",
33+
url = "https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.3.tar.gz",
34+
sha256 = "97fc51ac2b085d4cde31ef4d2c3122c21abc217e9090a43a30fc5ec21684e059",
35+
strip_prefix = "ncurses-6.3",
36+
build_file = "//bazel/ncurses:ncurses.BUILD",
37+
)

doc/website/release-notes/iceoryx-unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
- Fix bazel build on macos [#2345](https://github.com/eclipse-iceoryx/iceoryx/issues/2345)
146146
- Fix Bzlmod module name typo [#2364](https://github.com/eclipse-iceoryx/iceoryx/issues/2364)
147147
- Add //:iceoryx Bazel alias [#2368](https://github.com/eclipse-iceoryx/iceoryx/issues/2368)
148+
- Depend on @ncurses when building with Bazel [#2372](https://github.com/eclipse-iceoryx/iceoryx/issues/2372)
148149

149150
**Refactoring:**
150151

tools/introspection/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ cc_library(
2323
"source/introspection_app.cpp",
2424
],
2525
hdrs = glob(["include/iceoryx_introspection/**"]),
26-
linkopts = ["-lncurses"],
2726
strip_include_prefix = "include",
2827
#Windows does not offer ncurses, therefore we do not build the lib
2928
target_compatible_with = select({
@@ -33,6 +32,7 @@ cc_library(
3332
visibility = ["//visibility:public"],
3433
deps = [
3534
"//iceoryx_posh",
35+
"@ncurses",
3636
],
3737
)
3838

tools/introspection/include/iceoryx_introspection/introspection_app.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include "iceoryx_platform/getopt.hpp"
2121
#include "iceoryx_posh/popo/subscriber.hpp"
2222

23+
#include <curses.h>
2324
#include <map>
24-
#include <ncurses.h>
2525
#include <vector>
2626

2727
namespace iox

0 commit comments

Comments
 (0)