[SOLVED] User defined macros expansion

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] User defined macros expansion

    Hello,

    I'm developing a nRF53832 project with SES. As part of the compile/debug workflow, I need to execute a batch file after the build, to create an additional file for jLink to flash. I'm using the project option "user build step" to launch the batch file and "additional load file" to flash the hex file. So far, so good, it all works.

    The batch file used to create the additional hex file needs the app version as a parameter. Currently I invoke it as "$(SolutionDir)/scripts/SES_Postbuild_DBG.bat 1234" (no quotes, and 1234 is my app version number). The version number 1234 is used in multiple places in the app, and defined as a preprocessor definition "APP_VER=1234", then used in my code as appropriate

    Is there a way to pass APP_VER to the batch file as if it were a macro? In reality I have multiple configurations executing different batch files depending on build options, and the only way to ensure all the app version numbers are in sync is to document each use and ensure that all members of the team remember to select all the configurations and manually ensure everything is in sync (or "open solution in editor" and do a search&replace there)

    Being able to pass a user defined macro/preprocessor option to my batch file would be a much more elegant solution, but I don't see a way to do it. Is there a trick I'm not aware of?
  • Hello,

    Thank you for your inquiry.
    For such a setup custom global macros can be used.
    You can set them under Tools->Options->Building->Global macros

    How to utilize the is explained here:
    studio.segger.com/ide_project_macros.htm

    So one setup could be that you set the APP_VER macro as global macro which then you can use as the CL argument for the post build step and pass it to another preprocessor define.
    That way both options will reference the same macro.

    Is this what you are looking for?

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Thanks for the reply Nino. Yes, I'm familiar with custom global macros, but those are on a per-machine basis.

    I'm setting up a project for a team, and ideally all the settings for a specific project should be inside the project file itself, so that it can be checked into Github and everyone enlisting will be ready to go.

    Documenting the need to change a value in more than one place is acceptable, I just thought it would be good to have the equivalent of global macros for a project, too. I wanted to know if it was supported, that's all. It's a "nice to have" feature at some point in the future
  • Hello,

    Thank you for your explanation.
    Sorry I understood you incorrectly before. For such deployment setups you can use project macros the same way as you would use the global macros with the difference that it is saved on project level and thus protable. For more information see the documentation linked in my last post.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • I'm sorry, I must be missing something. I cannot find any "General tab" in the project properties (see attached picture). I can see a General tab under the Solution properties, but it only contains Environment Variables

    According to the documentation you pointed me to, project macros would be exactly what I need (below), but I cannot seem to find them in release 4.52a od SES


    Project macros
    To define a project macro:


    To set the project macros:
    1. Select the appropriate solution/project in the Project Explorer.
    2. Use Project > Options to show the project options dialog.
    3. In the Project Options dialog's General Options group, select the Macros option.
    4. Click the ellipsis button on the right.
    5. Set the macro using the syntax name = replacement text.
    Images
    • SeggerMacros.PNG

      47.59 kB, 609×1,026, viewed 411 times
  • Hi,

    It appears that the documentation is not accurate anymore. Sorry for that.
    You can find it in project options under Code->Build->Project Macros.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.