This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Build variable sourced from macro or vice versa?

Hi all,

I am looking into a way to link a build variable and a C macro in CCS. What I want to achieve is to have the binary image renamed using the firmware version, which is also embedded in the firmware itself. Thus to avoid having to define the firmware version separately for the renaming and for the C source, I was wondering if I can have a build variable sourced from a macro. I would to prefer the single place for defining the value to be a header file (to keep the source code self contained) and have a build variable use it, but the other way can work too.

Any thoughts appreciated

Giannis

  • Giannis,

    I could not find a way to modify a build variable starting from a C macro (I suspect this was asked before, but I can't find the thread).

    I could find the other way around - i.e., specifying the version as a build variable and using it in the code itself. Something reported in the thread below:
    stackoverflow.com/.../using-build-variables-in-c-code-with-eclipse-4-4-2

    (I tested the method in the thread above mentions and CCSv6.1.3 does not show the issue reported).

    I will keep investigating, but perhaps other developers found a way to use the build variables this way and may comment further.

    Regards,
    Rafael
  • Hi Rafael,

    thank you for the response.

    I did some testing with the trick mentioned in the stackoverflow thread and found it to work but only if you define the build variable in the project properties. I was hoping to be able to source the build variables from a human-readable text file but the closest to this is using a macros.ini to set the build variables when importing the project. Once imported the macros.ini file is not used and the only way to change the variables is by going into project properties.

    Specifically, what I did was:

    • In the Compiler Advanced Options -> Predefined Symbols I created a macro sourced by a build variable:

    FIRMWARE_REV_0=${FIRMWARE_REV_0_VAR}

    • I created macros.ini in the project root where the initial value of the build variable is set:

    [string] FIRMWARE_REV_0_VAR=6

    (note the space after [string], it is required)

    • I imported macros.ini in the project by going to CCS build options, Variables tab. Once this is done once the variable values are saved in project properties and macros.ini is ignored.

    I will not be adopting this as going into CCS project properties is much less transparent than defining the relative macros in a global pre-included header file as I do now. Still, this means that I will have to manually rename the firmware images to included the version number in the name.

    I will keep looking for a way to solve this using a simple text file (if not a C header) to allow clear diffs etc.

    Thank you for the hint though, it may come handy elsewhere.

    Giannis

  • Giannis,

    I was wondering if you were able to find a way to change your build variables from a file instead of having to go through the project properties to get to them. Through i might have stumbled onto something in the past year. Just checking. Thanks!

    -Greg w.