Skip to content

cfg5_generate component based includes wrong #23

@SimonReinbold

Description

@SimonReinbold

Description of the bug:

The provided CcInfo include paths in the component specific generation does not match the actual folder structure on linux.
I did not test it on windows.

--

Here an example when depending on the CanTp component:

With the cfg5 generation

cfg5_generate_rt(
    name = "microsar",
    components = project_components,
    config_files = project_config,
    dpa_file = "MyEcu.dpa",
    # ...
)

when depending on the component specific outputs

cc_library(
    name = "CanTp",
    srcs = [
        ":microsar_CanTp",
        # ...
    ],
    hdrs = [
        # ...
    ],
    implementation_deps = [
        ":microsar_CanTp",
        # ...
    ],
    copts = some_options_wo_include_paths,
)

with a toolchain config that prepends -I on the include paths,
creates the following compile options:

-Ibazel-out/.../path/to/pacakge/microsar/generated_headers_CanTp/GenData
-Ibazel-out/.../path/to/pacakge/microsar/generated_headers_CanTp/GenData/Components
-Ibazel-out/.../path/to/pacakge/microsar/generated_headers

But the actual generation directory structure is:

bazel-out/.../path/to/pacakge/microsar
    |- generated_headers            (<- at least in my use-case no files directly in here, only in the sub directories)
        |- GenData
            |- Components
    |- generated_headers_CanTp      (<- No subdirectory GenData)
    |- ...

I am missing the following include paths, as the moved files reside there:

-Ibazel-out/.../path/to/pacakge/microsar/generated_headers_CanTp
-Ibazel-out/.../path/to/pacakge/microsar/generated_headers/GenData
-Ibazel-out/.../path/to/pacakge/microsar/generated_headers/GenData/Components

Either the Filtering files action should create the GenData and GenData/Components subdirectories and preserve the relative file location when moving the generated output, or the _cfg5_generate implementation must at least add the actual folder. Additionally the unmapped folder with its sub directories must be added or the Filtering files action should discard relative paths:

if ctx.attr.private_is_windows:
    component_includes = [
        component_headers_dirs[i].path,
        headers_dir.path,
    ]
else:
    component_includes = [
        component_headers_dirs[i].path,                                     #(<- Seems like this needs to be added as in the windows use case)
        component_headers_dirs[i].path + "/" + gen_dir,                     #(<- This could be removed)
        component_headers_dirs[i].path + "/" + gen_dir + "/Components",     #(<- This could be removed)
        headers_dir.path,                                                   #(<- No files in this directory, only in subdirectories GenData and GenData/Components, probably can be removed)
        headers_dir.path + "/" + gen_dir,                                   #(<- There are files in here, this must be added)
        headers_dir.path + "/" + gen_dir + "/Components",                   #(<- There are files in here, this must be added)
    ]

I can successfully compile if I change this code snippet to the following. All required include paths are then correctly created:

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

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

- Only tested on linux -

In any library/binary that requires generated output and does not have the include path added in any other manner,
only depend on the generated component, not the unmapped output.

What are the involved Vector tools and their versions?

Tool Version
SIP R33
DaVinci Configurator Classic 5.30.40 SP3
DaVinci Developer Classic 4.17.30 (SP1)

Which operating system are you running Bazel on?

Ubuntu 22.04.4 LTS

What is the output of bazel mod graph --verbose --depth 1?

<root> (@_)
├───bazel-diff@12.0.0 
├───googletest@1.17.0 
├───platforms@1.0.0 
├───rules_cc@0.2.16 
└───rules_cfg5@0.0.3 

What is the output of bazel info release?

release 8.4.2

Have you found anything relevant by searching the web?

-

Any other information, logs, or outputs that you want to share?

-

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions