-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #341 from elBoberido/iox2-329-bazel-for-c-and-cpp-…
…bindings [#329] Bazel support for C and C++ Bindings
- Loading branch information
Showing
27 changed files
with
712 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build --spawn_strategy=standalone --strategy=Genrule=standalone | ||
|
||
build:gcc --cxxopt="-std=c++17" | ||
build:clang --cxxopt="-std=c++17" | ||
build:msvc --cxxopt="/std:c++17" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ debug/ | |
.cache | ||
.idea | ||
build | ||
bazel-* | ||
MODULE.bazel* | ||
|
||
Cargo.lock | ||
**/*.rs.bk | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache Software License 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
# which is available at https://opensource.org/licenses/MIT. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") | ||
|
||
# | ||
# Config & Platform support | ||
# | ||
config_setting( | ||
name = "linux", | ||
constraint_values = ["@platforms//os:linux"], | ||
) | ||
|
||
config_setting( | ||
name = "win-gcc", | ||
constraint_values = ["@platforms//os:windows"], | ||
flag_values = {"@bazel_tools//tools/cpp:compiler": "mingw-gcc"}, | ||
) | ||
|
||
config_setting( | ||
name = "win-msvc", | ||
constraint_values = ["@platforms//os:windows"], | ||
flag_values = {"@bazel_tools//tools/cpp:compiler": "msvc-cl"}, | ||
) | ||
|
||
cmake( | ||
name = "iceoryx_platform", | ||
cache_entries = { | ||
"BUILD_SHARED_LIBS": "OFF", | ||
}, | ||
lib_source = "@iceoryx_platform//:all_srcs", | ||
out_static_libs = select({ | ||
"//:win-msvc": ["iceoryx_platform.lib"], | ||
"//conditions:default": ["libiceoryx_platform.a"], | ||
}), | ||
out_include_dir = "include/iceoryx/v2.95.0/", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cmake( | ||
name = "iceoryx_hoofs", | ||
cache_entries = { | ||
"BUILD_SHARED_LIBS": "OFF", | ||
}, | ||
lib_source = "@iceoryx_hoofs//:all_srcs", | ||
out_static_libs = select({ | ||
"//:win-msvc": ["iceoryx_hoofs.lib"], | ||
"//conditions:default": ["libiceoryx_hoofs.a"], | ||
}), | ||
out_include_dir = "include/iceoryx/v2.95.0/", | ||
deps = [ | ||
"//:iceoryx_platform", | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
alias( | ||
name = "iceoryx2-c", | ||
actual = "//iceoryx2-ffi/c:iceoryx2-c", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
alias( | ||
name = "iceoryx2-cxx", | ||
actual = "//iceoryx2-ffi/cxx:iceoryx2-cxx", | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache Software License 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
# which is available at https://opensource.org/licenses/MIT. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
workspace(name = "org_eclipse_iceoryx_iceoryx2") | ||
|
||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") | ||
|
||
http_archive( | ||
name = "rules_foreign_cc", | ||
sha256 = "4b33d62cf109bcccf286b30ed7121129cc34cf4f4ed9d8a11f38d9108f40ba74", | ||
strip_prefix = "rules_foreign_cc-0.11.1", | ||
url = "https://github.com/bazelbuild/rules_foreign_cc/releases/download/0.11.1/rules_foreign_cc-0.11.1.tar.gz", | ||
) | ||
|
||
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.11.1/flatten.html#rules_foreign_cc_dependencies | ||
rules_foreign_cc_dependencies() | ||
|
||
# Setup gtest | ||
GOOGLETEST_VERSION = "1.14.0" | ||
maybe( | ||
name = "googletest", | ||
repo_rule = http_archive, | ||
urls = ["https://github.com/google/googletest/archive/refs/tags/v{version}.zip".format(version = GOOGLETEST_VERSION)], | ||
sha256 = "1f357c27ca988c3f7c6b4bf68a9395005ac6761f034046e9dde0896e3aba00e4", | ||
strip_prefix = "googletest-{version}".format(version = GOOGLETEST_VERSION), | ||
) | ||
|
||
# TODO use http_archive once iceoyx v3.0 is release | ||
|
||
_ALL_CONTENT = """\ | ||
filegroup( | ||
name = "all_srcs", | ||
srcs = glob(["**"]), | ||
visibility = ["//visibility:public"], | ||
) | ||
""" | ||
|
||
git_repository( | ||
name = "iceoryx_platform", | ||
strip_prefix = "iceoryx_platform", | ||
build_file_content = _ALL_CONTENT, | ||
remote = "https://github.com/eclipse-iceoryx/iceoryx.git", | ||
tag = "v2.95.0", | ||
) | ||
|
||
git_repository( | ||
name = "iceoryx_hoofs", | ||
strip_prefix = "iceoryx_hoofs", | ||
build_file_content = _ALL_CONTENT, | ||
remote = "https://github.com/eclipse-iceoryx/iceoryx.git", | ||
tag = "v2.95.0", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache Software License 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
# which is available at https://opensource.org/licenses/MIT. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") | ||
|
||
cc_binary( | ||
name = "example_c_discovery", | ||
srcs = [ | ||
"src/main.c", | ||
], | ||
deps = [ | ||
"//:iceoryx2-c", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache Software License 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
# which is available at https://opensource.org/licenses/MIT. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") | ||
|
||
cc_binary( | ||
name = "example_c_event_listener", | ||
srcs = [ | ||
"src/listener.c", | ||
], | ||
deps = [ | ||
"//:iceoryx2-c", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "example_c_event_notifier", | ||
srcs = [ | ||
"src/notifier.c", | ||
], | ||
deps = [ | ||
"//:iceoryx2-c", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache Software License 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
# which is available at https://opensource.org/licenses/MIT. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") | ||
|
||
cc_binary( | ||
name = "example_c_publisher", | ||
srcs = [ | ||
"src/publisher.c", | ||
"src/transmission_data.h", | ||
], | ||
deps = [ | ||
"//:iceoryx2-c", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "example_c_subscriber", | ||
srcs = [ | ||
"src/subscriber.c", | ||
"src/transmission_data.h", | ||
], | ||
deps = [ | ||
"//:iceoryx2-c", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache Software License 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
# which is available at https://opensource.org/licenses/MIT. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") | ||
|
||
cc_binary( | ||
name = "example_c_with_user_header_publisher", | ||
srcs = [ | ||
"src/custom_header.h", | ||
"src/publisher.c", | ||
], | ||
deps = [ | ||
"//:iceoryx2-c", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "example_c_with_user_header_subscriber", | ||
srcs = [ | ||
"src/custom_header.h", | ||
"src/subscriber.c", | ||
], | ||
deps = [ | ||
"//:iceoryx2-c", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache Software License 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
# which is available at https://opensource.org/licenses/MIT. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") | ||
|
||
cc_binary( | ||
name = "example_cxx_complex_data_types", | ||
srcs = [ | ||
"src/complex_data_types.cpp", | ||
], | ||
deps = [ | ||
"//:iceoryx_hoofs", | ||
"//:iceoryx2-cxx", | ||
], | ||
) |
Oops, something went wrong.