Skip to content

Commit

Permalink
[eclipse-iceoryx#439] Fix cbindgen generation in fully sandboxed builds
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed Oct 11, 2024
1 parent 89c4666 commit 375f594
Show file tree
Hide file tree
Showing 27 changed files with 153 additions and 20 deletions.
2 changes: 0 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
build --spawn_strategy=standalone --strategy=Genrule=standalone

build --enable_platform_specific_config
build:linux --cxxopt="-std=c++17"
build:windows --cxxopt="/std:c++17"
Expand Down
35 changes: 27 additions & 8 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

package(default_visibility = ["//visibility:public"])

exports_files([
"LICENSE-APACHE",
"LICENSE-MIT",
Expand Down Expand Up @@ -62,21 +64,38 @@ alias(
filegroup(
name = "all_srcs",
srcs = glob([
"benchmarks/**",
"config/**",
"examples/**",
"iceoryx2-bb/**",
"iceoryx2-cal/**",
"iceoryx2-cli/**",
"iceoryx2-ffi/**",
"iceoryx2-pal/**",
"iceoryx2/**",
"*.bazel",
"*.lock",
"*.toml",
"*.txt",
"*.md",
"LICENSE-*",
]),
]) + [
"//benchmarks/event:all_srcs",
"//benchmarks/publish-subscribe:all_srcs",
"//iceoryx2:all_srcs",
"//iceoryx2-bb/container:all_srcs",
"//iceoryx2-bb/derive-macros:all_srcs",
"//iceoryx2-bb/elementary:all_srcs",
"//iceoryx2-bb/lock-free:all_srcs",
"//iceoryx2-bb/log:all_srcs",
"//iceoryx2-bb/memory:all_srcs",
"//iceoryx2-bb/posix:all_srcs",
"//iceoryx2-bb/system-types:all_srcs",
"//iceoryx2-bb/testing:all_srcs",
"//iceoryx2-bb/threadsafe:all_srcs",
"//iceoryx2-bb/trait-tests:all_srcs",
"//iceoryx2-cal:all_srcs",
"//iceoryx2-cli:all_srcs",
"//iceoryx2-ffi/ffi:all_srcs",
"//iceoryx2-ffi/c:all_srcs",
"//iceoryx2-ffi/cxx:all_srcs",
"//iceoryx2-ffi/ffi-macros:all_srcs",
"//iceoryx2-pal/concurrency-sync:all_srcs",
"//iceoryx2-pal/configuration:all_srcs",
"//iceoryx2-pal/posix:all_srcs",
],
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ maybe(
"//:benchmarks/event/Cargo.toml",
"//:benchmarks/publish-subscribe/Cargo.toml",
"//:examples/Cargo.toml",
"//:iceoryx2/Cargo.toml",
"//:iceoryx2-bb/container/Cargo.toml",
"//:iceoryx2-bb/derive-macros/Cargo.toml",
"//:iceoryx2-bb/elementary/Cargo.toml",
Expand All @@ -102,7 +103,6 @@ maybe(
"//:iceoryx2-cal/Cargo.toml",
"//:iceoryx2-cli/Cargo.toml",
"//:iceoryx2-ffi/ffi-macros/Cargo.toml",
"//:iceoryx2/Cargo.toml",
"//:iceoryx2-ffi/ffi/Cargo.toml",
"//:iceoryx2-pal/concurrency-sync/Cargo.toml",
"//:iceoryx2-pal/configuration/Cargo.toml",
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/event/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_binary")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_binary(
name = "benchmark-event",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/publish-subscribe/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_binary")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_binary(
name = "benchmark-event",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-bb/container/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-bb-container",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-bb/derive-macros/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_proc_macro")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_proc_macro(
name = "iceoryx2-bb-derive-macros",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-bb/elementary/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-bb-elementary",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-bb/lock-free/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-bb-lock-free",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-bb/log/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-bb-log",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-bb/memory/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-bb-memory",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-bb/posix/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-bb-posix",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-bb/system-types/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-bb-system-types",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-bb/testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-bb-testing",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-bb/threadsafe/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-bb-threadsafe",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-bb/trait-tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test_suite")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_test_suite(
name = "iceoryx2-bb-trait-tests",
srcs = glob(["tests/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-cal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-cal",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-cli/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-cli",
srcs = glob(["lib/src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-ffi/c/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

package(default_visibility = ["//visibility:public"])

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

alias(
name = "iceoryx2-c-shared",
actual = "//iceoryx2-ffi/ffi:iceoryx2-ffi-shared",
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-ffi/cxx/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

cc_library(
name = "iceoryx2-cxx-shared",
srcs = glob(
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-ffi/cxx/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

load("@rules_cc//cc:defs.bzl", "cc_test")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

cc_test(
name = "iceoryx2-cxx-tests",
srcs = glob([
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-ffi/ffi-macros/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_proc_macro")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_proc_macro(
name = "iceoryx2-ffi-macros",
srcs = glob(["src/**/*.rs"]),
Expand Down
19 changes: 10 additions & 9 deletions iceoryx2-ffi/ffi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ package(default_visibility = ["//visibility:public"])
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_rust//rust:defs.bzl", "rust_shared_library", "rust_static_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

filegroup(
name = "cbindgen-cli",
srcs = ["@cbindgen//file"],
Expand All @@ -23,12 +28,13 @@ filegroup(
genrule(
name = "iceoryx2-ffi-cbindgen",
srcs = glob(["src/**/*.rs"]) + [
"//:all_srcs",
"Cargo.toml",
"cbindgen.toml",
":cbindgen-cli",
"src"
],
outs = ["include/iox2/iceoryx2.h"],
cmd = "$(execpath :cbindgen-cli) --config $(location cbindgen.toml) --output $(OUTS) $(location src)/..",
cmd = "$(execpath :cbindgen-cli) $$(dirname $(location Cargo.toml)) --quiet --config $(location cbindgen.toml) --output $(OUTS)",
)

rust_shared_library(
Expand Down Expand Up @@ -74,6 +80,7 @@ cc_library(
hdrs = [ "include/iox2/iceoryx2.h" ],
includes = [ "include" ],
deps = [
":iceoryx2-ffi-cbindgen",
":iceoryx2-ffi-shared-rust",
],
linkstatic = False,
Expand All @@ -84,16 +91,10 @@ cc_library(
hdrs = [ "include/iox2/iceoryx2.h" ],
includes = [ "include" ],
deps = [
":iceoryx2-ffi-cbindgen",
":iceoryx2-ffi-static-rust",
],
linkstatic = True,
)

# TODO: [349] add tests

# NOTE: the following lines can be removed once 'rules_foreign_cc' is retired from building the C and C++ bindings

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)
5 changes: 5 additions & 0 deletions iceoryx2-pal/concurrency-sync/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-pal-concurrency-sync",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-pal/configuration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ package(default_visibility = ["//visibility:public"])

load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

rust_library(
name = "iceoryx2-pal-configuration",
srcs = glob(["src/**/*.rs"]),
Expand Down
5 changes: 5 additions & 0 deletions iceoryx2-pal/posix/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
load("@rules_rust//rust:defs.bzl", "rust_library")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

# Generate the binding lib
cc_library(
name = "iceoryx2-pal-posix-c-lib",
Expand Down
Loading

0 comments on commit 375f594

Please sign in to comment.