[SOLVED] EMBuild -D option

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

  • [SOLVED] EMBuild -D option

    Does the -D option to EMBuild make the macro visible to the precompiler while my project is being built?I'm trying to automate a build of my SES project for a Nordic nRF52 processor on a custom board. I can build the project from the command line using EMBuild. I'm adding a -D APP_VER="b92662f" option to the command. But this doesn't appear to take effect in my code.

    Here's my call:
    embuild -config "Release" -D APP_VER="b92662f" E:\corp\Code\buildDir\app\app.emProject


    Here's the code in my project. When building using embuild as called above, I would expect APP_VER to be defined as "b92662f":

    #ifndef APP_VER
    #define APP_VER "DVLPMNT"
    #endif

    Thanks.
  • Hello,

    Thank you for your inquiry.
    The -D option will only create a project macro. To make it visible to your application you need to add it under "Preprocessor Definitions" as well.
    You can find that entry in the project settings under Preprocessor-> Preprocessor Definitions.

    When you mark that entry you will also get a short description of the functionality.
    Does that solve the issue?

    Best regards,
    Nino
    Please read the forum rules before posting: Forum Rules

    Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
    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 contact us per e-mail.
    The following contact form can be used for this: Contact Us

  • Hi NINO - that doesn't solve my problem exactly. I'm trying to inject the pre-proc define in at build time, from the command line script. I think what you describe is a change to the emProject file from the command line or the GUI.

    If I can add a preprocessor definition into the call to EMBuild, that would work.

    In the meantime, I'm working around it by modifying a project source file. There are those who object to the idea of pulling the code from source control, then modifying it before build. I don't know if injecting a pre-proc define from the command line is that much different, anyway.

    The big picture is that I'm trying to automate the build and build the version control commit ID into the app.
  • Hi,

    With emBuild it is not possible to add preprocessor definitions, you can only modify them.
    But that seems to be what you will need.

    In the project options preprocessor definitions add APP_VER=$(EXT_APP_VER)
    and then call embuild -config "Release" -D EXT_APP_VER="b92662f" E:\corp\Code\buildDir\app\app.emProject
    That will resolve $(EXT_APP_VER) to "b92662f" and you can use it through APP_VER in your application.

    Regards
    Johannes