Skip to content
Merged
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
1 change: 0 additions & 1 deletion bcr-modules/modules/rules_cfg5/0.0.2/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pkg_files(
srcs = [
"//bcr-modules/modules/rules_cfg5/srcs:BUILD.bazel",
"//bcr-modules/modules/rules_cfg5/srcs:MODULE.bazel",
"//bcr-modules/modules/rules_cfg5/srcs:README.md",
"//bcr-modules/modules/rules_cfg5/srcs:defs.bzl",
"//bcr-modules/modules/rules_cfg5/srcs:generate.bzl",
],
Expand Down
1 change: 0 additions & 1 deletion bcr-modules/modules/rules_cfg5/0.0.3/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pkg_files(
srcs = [
"//bcr-modules/modules/rules_cfg5/srcs:BUILD.bazel",
"//bcr-modules/modules/rules_cfg5/srcs:MODULE.bazel",
"//bcr-modules/modules/rules_cfg5/srcs:README.md",
"//bcr-modules/modules/rules_cfg5/srcs:defs.bzl",
"//bcr-modules/modules/rules_cfg5/srcs:generate.bzl",
],
Expand Down
67 changes: 67 additions & 0 deletions bcr-modules/modules/rules_cfg5/0.0.4/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("//bcr-modules/macros:module_macro.bzl", "module")
load("//bcr-modules/macros:upload_macro.bzl", "module_upload")

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

module_upload(
name = "upload",
archive = ":rules_cfg5",
upload_module_name = "rules_cfg5",
version = "0.0.4",
)

pkg_files(
name = "private",
srcs = [
"//bcr-modules/modules/rules_cfg5/srcs:private/generate.bzl",
"//bcr-modules/modules/rules_cfg5/srcs:private/start.bzl",
"//bcr-modules/modules/rules_cfg5/srcs:private/toolchains.bzl",
],
prefix = "private",
)

pkg_files(
name = "private_common",
srcs = [
"//bcr-modules/modules/rules_cfg5/srcs:private/common/component_refs.bzl",
],
prefix = "private/common",
)

pkg_files(
name = "private_templates",
srcs = [
"//bcr-modules/modules/rules_cfg5/srcs:private/templates/filter_linux.sh.tpl",
"//bcr-modules/modules/rules_cfg5/srcs:private/templates/filter_windows.ps1.tpl",
],
prefix = "private/templates",
)

pkg_files(
name = "public",
srcs = [
"//bcr-modules/modules/rules_cfg5/srcs:BUILD.bazel",
"//bcr-modules/modules/rules_cfg5/srcs:MODULE.bazel",
"//bcr-modules/modules/rules_cfg5/srcs:defs.bzl",
"//bcr-modules/modules/rules_cfg5/srcs:generate.bzl",
],
)

module(
name = "rules_cfg5",
additional_dependencies = [
"ape@1.0.1",
"bazel_skylib@1.7.1",
"rules_cc@0.1.1",
"rules_common@0.2.0",
# "rules_vtt@0.0.1",
],
module_version = "0.0.4",
pkg_files_targets = [
"public",
"private",
"private_common",
"private_templates",
],
)
1 change: 1 addition & 0 deletions bcr-modules/modules/rules_cfg5/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module_bcr_dir(
versions = [
"0.0.2",
"0.0.3",
"0.0.4",
],
visibility = ["//visibility:public"],
)
15 changes: 12 additions & 3 deletions bcr-modules/modules/rules_cfg5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@ The output directory for GenData in the .dpa file must be set to:

When `components` list is provided, the rule creates separate targets for each component:
- Main target: `{name}` - All generated code
- Component targets: `{name}_{ComponentName}` - Component-specific code
- Unmapped target: `{name}_unmapped` - Shared headers without component-specific directories
- Component targets: `{name}_{ComponentName}` - Component-specific code with includes

The unmapped target provides access to shared generated headers (GenData directory) that are not filtered to any component-specific header directories. This is useful for Gendata, that cannot be filtered that easily.

Example:
```python
Expand All @@ -353,10 +356,16 @@ cfg5_generate_rt(

# Creates targets:
# - :bsw (all code)
# - :bsw_CanIf (CanIf only)
# - :bsw_Com (Com only)
# - :bsw_unmapped (shared headers only)
# - :bsw_CanIf (CanIf headers and sources)
# - :bsw_Com (Com headers and sources)
```

**Include Path Behavior:**
- **Main target** (`bsw`): Provides all headers and all component-specific include directories
- **Unmapped target** (`bsw_unmapped`): Provides only shared GenData includes (no component-specific directories)
- **Component targets** (`bsw_CanIf`, `bsw_Com`): Each provides its own component headers plus shared GenData includes

### File Filtering

Control which files are included/excluded from generation:
Expand Down
2 changes: 1 addition & 1 deletion bcr-modules/modules/rules_cfg5/srcs/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

module(
name = "rules_cfg5",
version = "0.0.3",
version = "0.0.4",
compatibility_level = 0,
)

Expand Down
2 changes: 1 addition & 1 deletion bcr-modules/modules/rules_cfg5/srcs/generate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,5 @@ def cfg5_generate_rt(name, components = [], **kwargs):
extract_component_cc_info(
name = name + "_unmapped",
src = ":" + name,
component = "main", # "main" contains all unmapped files
component = "unmapped", # Unmapped files with restricted includes
)
48 changes: 29 additions & 19 deletions bcr-modules/modules/rules_cfg5/srcs/private/generate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ def _cfg5_generate(ctx, dpa_path, dpa_folder, inputs, template, additional_genar

compilation_context = cc_common.create_compilation_context(
headers = depset(
[headers_dir] + component_headers_dirs,
[headers_dir],
),
includes = depset(
[headers_dir.path] + [comp_hdr_dir.path for comp_hdr_dir in component_headers_dirs],
[headers_dir.path],
),
)

Expand Down Expand Up @@ -276,24 +276,31 @@ def _cfg5_generate(ctx, dpa_path, dpa_folder, inputs, template, additional_genar
# Main CcInfo containing all generated files (for backward compatibility)
main_cc_info = CcInfo(compilation_context = compilation_context)

# Create unmapped CcInfo with only headers_dir (no component-specific dirs)
if ctx.attr.private_is_windows:
unmapped_includes = [headers_dir.path]
else:
unmapped_includes = [
headers_dir.path + "/" + gen_dir,
headers_dir.path + "/" + gen_dir + "/Components",
]

unmapped_compilation_context = cc_common.create_compilation_context(
headers = depset([headers_dir]),
includes = depset(unmapped_includes),
)
unmapped_cc_info = CcInfo(compilation_context = unmapped_compilation_context)

# Create component-specific CcInfo providers only for actual components
component_cc_infos = {}
for i, component in enumerate(actual_components):
if i < len(component_headers_dirs):
# Include both component-specific and main headers for proper include resolution
component_headers = [component_headers_dirs[i], headers_dir]

if ctx.attr.private_is_windows:
component_includes = [
component_headers_dirs[i].path,
headers_dir.path,
]
else:
component_includes = [
component_headers_dirs[i].path + "/" + gen_dir,
component_headers_dirs[i].path + "/" + gen_dir + "/Components",
headers_dir.path,
]
component_includes = [
component_headers_dirs[i].path,
]

component_compilation_context = cc_common.create_compilation_context(
headers = depset(component_headers),
Expand All @@ -305,13 +312,16 @@ def _cfg5_generate(ctx, dpa_path, dpa_folder, inputs, template, additional_genar
# Collect all output directories for DefaultInfo
all_output_dirs = [sources_dir, headers_dir] + component_sources_dirs + component_headers_dirs

# Add unmapped to components dict
component_cc_infos["unmapped"] = unmapped_cc_info

return [
DefaultInfo(files = depset(additional_output_file_artifacts + all_output_dirs + [dvcfg5_report_file, dvcfg5_log_file])),
main_cc_info,
MultipleCcInfo(
main = main_cc_info,
components = component_cc_infos,
component_names = actual_components,
component_names = actual_components + ["unmapped"],
),
]

Expand Down Expand Up @@ -375,11 +385,11 @@ def _extract_component_cc_info_impl(ctx):
multiple_cc_info = ctx.attr.src[MultipleCcInfo]
component_name = ctx.attr.component

if component_name in multiple_cc_info.components or component_name == "main":
if component_name == "main":
# For unmapped files, use main CcInfo and main directories (which contain unmapped files after component files are moved)
component_cc_info = ctx.attr.src[CcInfo] # Use the main CcInfo from the source target
directory_suffix = "" # Main directories don't have suffix
if component_name in multiple_cc_info.components:
if component_name == "unmapped":
# For unmapped files, use the unmapped-specific CcInfo with only headers_dir
component_cc_info = multiple_cc_info.components["unmapped"]
directory_suffix = "" # Unmapped files are in main directories without suffix
else:
component_cc_info = multiple_cc_info.components[component_name]
directory_suffix = "_" + component_name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module(
name = "rules_cfg5",
version = "0.0.4",
compatibility_level = 1,
)

bazel_dep(name = "ape", version = "1.0.1")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "rules_common", version = "0.2.0")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"url": "https://github.com/vectorgrp/bazel-rules/releases/download/rules_cfg5/0.0.4/rules_cfg5.tar.gz",
"integrity": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"repository": [],
"versions": [
"0.0.2",
"0.0.3"
"0.0.3",
"0.0.4"
],
"yanked_versions": { }
}
Loading