Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
444 changes: 444 additions & 0 deletions score/mw/com/deploy/BUILD

Large diffs are not rendered by default.

1,047 changes: 1,047 additions & 0 deletions score/mw/com/deploy/SYMBOL_INCLUSION_ANALYSIS.md

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions score/mw/com/deploy/copy_headers.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# *******************************************************************************
# Copyright (c) 2025 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 License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

"""Rule to copy headers with path stripping into an include directory."""

def _copy_headers_impl(ctx):
"""Copy headers from extracted headers into include/ directory structure.

Filters out headers from nlohmann, boost, and visitor top-level directories.
"""

# Define top-level directory names to exclude
exclude_top_level_dirs = [
"nlohmann",
#"boost", # could not remove this due to linux dependency.
"visitor",
]

input_headers = ctx.attr.headers.files.to_list()
output_headers = []

# Track unique output paths to avoid duplicate declarations
seen_paths = {}

for hdr in input_headers:
# Get the path and strip external repository prefixes
short_path = hdr.short_path

# Remove external repository prefix (e.g., "../communication~/" or "external/boost.core~/")
if short_path.startswith("../"):
parts = short_path.split("/")
if len(parts) >= 3:
# Skip ".." and "repo_name~", get the rest
relative_path = "/".join(parts[2:])
else:
relative_path = short_path
elif short_path.startswith("external/"):
parts = short_path.split("/")
if len(parts) >= 3:
# Skip "external" and "repo_name~", get the rest
relative_path = "/".join(parts[2:])
else:
relative_path = short_path
else:
relative_path = short_path

# Strip intermediate include/ directories from paths like:
# score/language/futurecpp/include/score/expected.hpp -> score/expected.hpp
# boost/include/boost/core.hpp -> boost/core.hpp
path_parts = relative_path.split("/")
if "include" in path_parts:
# Find the last occurrence of "include" and take everything after it
include_idx = len(path_parts) - 1 - path_parts[::-1].index("include")
relative_path = "/".join(path_parts[include_idx + 1:])
# Update path_parts after stripping include
path_parts = relative_path.split("/")

# Strip _virtual_includes directories from paths like:
# score/static_reflection/_virtual_includes/static_reflection/score/... -> score/...
if "_virtual_includes" in path_parts:
virtual_idx = path_parts.index("_virtual_includes")
if virtual_idx + 2 < len(path_parts):
relative_path = "/".join(path_parts[virtual_idx + 2:])
else:
relative_path = "/".join(path_parts[:virtual_idx] + path_parts[virtual_idx + 1:])
# Update path_parts after stripping _virtual_includes
path_parts = relative_path.split("/")

# NOW check the top-level directory AFTER all path processing
# Get the top-level directory name from the processed relative path
if len(path_parts) > 0:
top_level_dir = path_parts[0]
else:
top_level_dir = relative_path

# Check if top-level directory should be excluded
if top_level_dir in exclude_top_level_dirs:
# Skip this header - don't copy it
continue

# Create output file path
output_path = "include/" + relative_path

# Skip if we've already declared this output path
if output_path in seen_paths:
continue

seen_paths[output_path] = hdr

# Create output file in include/ directory
output_file = ctx.actions.declare_file(output_path)
output_headers.append(output_file)

# Copy the header
ctx.actions.run_shell(
inputs = [hdr],
outputs = [output_file],
command = "mkdir -p $(dirname {}) && rm -f {} && cp {} {}".format(output_file.path, output_file.path, hdr.path, output_file.path),
mnemonic = "CopyHeader",
)

return [DefaultInfo(files = depset(output_headers))]

copy_headers = rule(
implementation = _copy_headers_impl,
attrs = {
"headers": attr.label(
mandatory = True,
doc = "Target providing headers to copy",
),
},
doc = "Copies headers into an include/ directory with proper path structure",
)
79 changes: 79 additions & 0 deletions score/mw/com/deploy/extract_headers_for_deps.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# *******************************************************************************
# Copyright (c) 2025 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 License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

"""Rule to extract PUBLIC headers from cc_library targets."""

def _extract_public_headers_impl(ctx):
"""Implementation function to extract PUBLIC headers from CcInfo provider.

This extracts:
1. Direct public headers (from 'hdrs' attribute) of specified deps
2. Transitive public headers from all dependencies

It does NOT include:
- Private headers (from 'srcs' attribute with .h extension)
- Implementation files
"""

# Collect all public headers transitively
all_headers = []

print("=== extract_headers: Starting header extraction ===")
print("Number of deps:", len(ctx.attr.deps))

for dep in ctx.attr.deps:
if CcInfo not in dep:
print("Skipping dep (no CcInfo):", dep.label)
continue

print("Processing dep:", dep.label)
cc_info = dep[CcInfo]
compilation_context = cc_info.compilation_context

# headers: All headers needed for compilation (public + transitive)
headers_depset = compilation_context.headers
headers_list = headers_depset.to_list()
print(" Found", len(headers_list), "headers")

# Print first 10 headers as sample
for i, hdr in enumerate(headers_list[:10]):
print(" [", i, "]:", hdr.short_path)
if len(headers_list) > 10:
print(" ... and", len(headers_list) - 10, "more headers")

all_headers.append(headers_depset)

headers = depset(transitive = all_headers)
total_headers = len(headers.to_list())
print("=== Total headers extracted:", total_headers, "===")

return [DefaultInfo(files = headers)]

extract_headers = rule(
implementation = _extract_public_headers_impl,
attrs = {
"deps": attr.label_list(
providers = [CcInfo],
doc = "cc_library targets to extract public headers from (includes transitive deps)",
),
},
doc = """Extracts public headers from cc_library targets through CcInfo provider.

This rule extracts all headers that are part of the public API of the specified
cc_library targets, including their transitive dependencies. These are the headers
that consumers need to compile against these libraries.

Note: compilation_context.headers includes all headers needed for compilation,
which means it includes public headers from the target and all its transitive deps.
""",
)
7 changes: 7 additions & 0 deletions score/mw/com/example/ipc_bridge/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,11 @@ cc_library(

exports_files([
"etc/mw_com_config.json",
"assert_handler.cpp",
"assert_handler.h",
"datatype.cpp",
"datatype.h",
"sample_sender_receiver.cpp",
"sample_sender_receiver.h",
"main.cpp",
])
16 changes: 13 additions & 3 deletions score/mw/com/impl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl/tracing:__subpackages__",
],
deps = [
Expand All @@ -239,6 +240,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl/tracing:__subpackages__",
],
deps = [
Expand All @@ -257,6 +259,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl/methods:__pkg__",
"//score/mw/com/impl/mocking:__pkg__",
"//score/mw/com/impl/plumbing:__pkg__",
Expand Down Expand Up @@ -312,6 +315,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl:__subpackages__",
],
deps = [
Expand All @@ -337,6 +341,7 @@ cc_library(
],
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl:__pkg__",
"//score/mw/com/impl/rust:__pkg__",
],
Expand Down Expand Up @@ -375,6 +380,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl/bindings/lola:__pkg__",
"//score/mw/com/impl/bindings/mock_binding:__pkg__",
"//score/mw/com/impl/plumbing:__subpackages__",
Expand All @@ -400,6 +406,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl/bindings/lola:__pkg__",
"//score/mw/com/impl/bindings/mock_binding:__pkg__",
"//score/mw/com/impl/plumbing:__subpackages__",
Expand All @@ -425,6 +432,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl/bindings/lola:__pkg__",
"//score/mw/com/impl/bindings/mock_binding:__pkg__",
"//score/mw/com/impl/plumbing:__subpackages__",
Expand All @@ -449,6 +457,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl/bindings/lola:__pkg__",
"//score/mw/com/impl/bindings/mock_binding:__pkg__",
"//score/mw/com/impl/plumbing:__subpackages__",
Expand Down Expand Up @@ -478,6 +487,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl/bindings/lola:__pkg__",
"//score/mw/com/impl/bindings/mock_binding:__pkg__",
"//score/mw/com/impl/plumbing:__subpackages__",
Expand All @@ -501,7 +511,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com/impl:__subpackages__",
"//score/mw/com:__subpackages__",
],
deps = [
":instance_identifier",
Expand All @@ -517,7 +527,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com/impl:__subpackages__",
"//score/mw/com:__subpackages__",
],
deps = [
":error",
Expand All @@ -532,7 +542,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com/impl:__subpackages__",
"//score/mw/com:__subpackages__",
],
deps = [
":handle_type",
Expand Down
10 changes: 8 additions & 2 deletions score/mw/com/impl/bindings/lola/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl/bindings/lola/test:__pkg__",
"//score/mw/com/impl/plumbing:__pkg__",
],
Expand Down Expand Up @@ -257,6 +258,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl/bindings/lola/test:__pkg__",
"//score/mw/com/impl/bindings/lola/test_doubles:__pkg__",
],
Expand Down Expand Up @@ -330,7 +332,9 @@ cc_library(
],
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = ["//score/mw/com/impl/bindings/lola/test:__pkg__"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl/bindings/lola/test:__pkg__"],
deps = [
":event",
":event_control",
Expand Down Expand Up @@ -729,7 +733,9 @@ cc_library(
"//score/mw/com/impl/tracing:service_element_tracing_data",
],
tags = ["FFI"],
visibility = ["//score/mw/com/impl/bindings/lola:__subpackages__"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl/bindings/lola:__subpackages__"],
deps = [
"//score/mw/com/impl:binding_type",
"//score/mw/com/impl:runtime",
Expand Down
3 changes: 3 additions & 0 deletions score/mw/com/impl/plumbing/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ cc_library(
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl:__subpackages__",
],
deps = [
Expand Down Expand Up @@ -601,6 +602,7 @@ cc_library(
],
tags = ["FFI"],
visibility = [
"//score/mw/com:__subpackages__",
"//score/mw/com/impl:__subpackages__",
],
deps = [
Expand Down Expand Up @@ -846,6 +848,7 @@ cc_unit_test_suites_for_host_and_qnx(
rust_library(
name = "sample_ptr_rs",
srcs = ["sample_ptr.rs"],
tags = ["rust"],
visibility = [
"//score/mw/com:__subpackages__",
],
Expand Down
Loading