Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for variables in flags #766

Closed
jlonnberg opened this issue Feb 23, 2023 · 13 comments
Closed

Support for variables in flags #766

jlonnberg opened this issue Feb 23, 2023 · 13 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@jlonnberg
Copy link
Contributor

Is there any support for using cmake-flags in the .cprj file?

The use case might be that one want's to generate a map file placed alongside the binary. This means adding
<ldflags add="--map=${OUT_DIR}/MyProject.map" compiler="IAR"/>
to the defintion. However, the usage of "$" is limited to variable expansion for parts of packs so the code generates a ACCSEQDELIM error.

@jlonnberg
Copy link
Contributor Author

jlonnberg commented Feb 23, 2023

A possible solution would be to introduce an escape-sign for $, perhaps
$$
to copy ninja.
This allows for the usage of $ i commandlines as well

@jkrech
Copy link
Member

jkrech commented Feb 28, 2023

Hi @jlonnberg, sorry for the late response.
Rather than looking at extending the cprj input format for cbuildgen we should focus on the csolution yml input format, because the longer term expectation is that we will remove cprj as an interim format.
Therefore it would be good to take a look at the handling of linker flags and the use of access sequences and see whether using an access sequence in a misc flag is actually supported and if not, how this functionality needs to be added.
A first experiment I did, seems to indicate that the access sequence is not correctly processed today (Version 1.5.0).

@jkrech jkrech added bug Something isn't working enhancement New feature or request labels Feb 28, 2023
@jlonnberg
Copy link
Contributor Author

@jkrech In which future is the .cprj expected to be replaced by the yml file? Will this mean that csolution is integrated into cbuildgen or vice versa, i.e., the workflow is expected to be yml->cmake rather than yml->cprj->cmake?

@VGRSTM
Copy link
Contributor

VGRSTM commented Feb 28, 2023

@jkrech In which future is the .cprj expected to be replaced by the yml file? Will this mean that csolution is integrated into cbuildgen or vice versa, i.e., the workflow is expected to be yml->cmake rather than yml->cprj->cmake?

My understanding about future is yml -> yml -> cmake
More in details (csolution.yml + *.cproject.yml + *.clayer.yml) -> *.cbuild.yml -> *.cmake

@jkrech
Copy link
Member

jkrech commented Mar 1, 2023

After reaching CMSIS-Toolbox 2.0 milestone, we plan to start eliminating the cprj format.

(csolution.yml + *.cproject.yml + *.clayer.yml) => (cbuild-idx.yml + *.cbuild.yml) => *.cmake

At that point we want to generate a hierarchy of cmake files which allow us to build configurations including:
a) inter-project dependencies
b) pre- and post-build steps

@jlonnberg
Copy link
Contributor Author

jlonnberg commented Mar 1, 2023

Take this example for csolution.yml:

solution:
  build-types:
    - type: Debug
      compiler: IAR
    - type: Release
      compiler: IAR

  packs:
    - pack: ARM::CMSIS@5.9.0

  projects:
    - project: ./project.cproject.yml

  output-dirs:
    intdir: $OutDir(project)$/$TargetType$

  misc:
    - for-compiler: IAR
      Link:
        - --map=$OutDir(project)$/test.map

This tries to place a map file in the given output directory during the build. However, running csolution expands the $OutDir(...)$ variable. Secondly, the cbuildgen offers me to specify the output directory explicitly which I then would expect to override the previously supplied $OutDir(...)$.

@jkrech
Copy link
Member

jkrech commented Mar 3, 2023

Instead of overriding the output directory with cbuildgen this will need to happen using csolution, since after csolution only cmake and e.g. ninja would be executed.

@jlonnberg
Copy link
Contributor Author

I.e, remove the outdir option for cbuildgen?

@brondani
Copy link
Collaborator

In the sight of cprj deprecation also cbuildgen should be strongly simplified or even removed.

@brondani
Copy link
Collaborator

brondani commented Jun 7, 2023

@jlonnberg The map file generation should now be covered in the cdefault.yml file that is shipped in the CMSIS-Toolbox 2.0.0-dev1, for example:

default:
   - for-compiler: IAR
     Link:
       - --map=$elf()$.map

Does it meet your expectations?
Please note as mentioned previously cbuildgen --outdir will be removed once the cprj handling replacement will be complete.

@jlonnberg
Copy link
Contributor Author

@brondani Looks good to me! Will there be anyway for a user to access the output directories, e.g., dir of .o files and similar?

@brondani
Copy link
Collaborator

`> Will there be anyway for a user to access the output directories, e.g., dir of .o files and similar?

The output directory with build artifacts can be accessed with the OutDir() access sequence:
https://github.com/Open-CMSIS-Pack/devtools/blob/main/tools/projmgr/docs/Manual/YML-Input-Format.md#access-sequences
Object files (*.o) are seen as intermediate files rather than output files.

@jkrech
Copy link
Member

jkrech commented Jun 15, 2023

Please raise a new issue in case you see a use case scenario where access to intermediate/tmp files (e.g. *.o) is needed.

@jkrech jkrech closed this as completed Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants