MDK-Packs / CB_Lab4Layer

CMSIS-Build Lab with Layers
4 stars 9 forks source link

##suggestion## File paths in clayers #2

Open tarek-bochkati opened 3 years ago

tarek-bochkati commented 3 years ago

Hi,

Starting to prototype using cbuild 0.9.0-b. (not tested yet with 0.10.0-b), I noticed that file paths should be valid and relative the composed .cprj.

This implies that, when writing the .clayer, we should know and respect the cprj generation location (sometimes we are not sure about it).

Another scenario, if a .clayer could be used in several cprjs with different locations: in this case we should create different clayers with different relative paths.

We suggest to add some option in the cbuildgen when composing the cprj to relativise the paths coming from clayers. This could be straight-forward for files but may present some difficulties for includes and maybe some items that I have forgotten.

Please advise.

Thank you in advance, Regards, Tarek

brondani commented 3 years ago

Hi Tarek,

When composing a new project, files must be explicitly listed as <file/> xml elements in the .clayer in order to be copied into the destination filetree, which is done preserving their relative paths.

Take for example a layer with the following files:

C:/Layer/App.clayer
C:/Layer/RelativeDirectory/foo.c
C:/Layer/RelativeDirectory/bar.h

When using it to compose a C:/Project/Project.cprj, the files will be copied here:

C:/Project/Project.cprj
C:/Project/RelativeDirectory/foo.c
C:/Project/RelativeDirectory/bar.h

The entries in both App.clayer and Project.cprj shall look like this:

<files>
  <group name="App">
    <file category="sourceC" layer="App" name="./RelativeDirectory/foo.c"/>
    <file category="header" layer="App" name="./RelativeDirectory/bar.h"/>
  </group>
</files>

Please note we purposely don't execute any semantic operation inside compiler/linker/assembler flags, aka <cflags/> <cxxflags/> <ldflags/> <asflags/>. The flags are copied "as they are".

Can this explain the behaviour you have observed? If not, can you please give us a real example?

Thanks Daniel