[SOLVED] Embedding build dates and build version in the code: emScript?

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

  • [SOLVED] Embedding build dates and build version in the code: emScript?

    I am trying to embed some build-time versions into the binary I create for a production build. So far I am not coming up with any great ideas. I could modify a .h file each time with major, minor version numbers and date 20210305 each time, check this into source control and build but seems there should be a way to make his more automatic.

    I am looking into the use of emScript at build time with a pre-build directive but the ecmascript language supported seems too limited

    My idea is to make a versions.h_template file and do string replacement like:

    #define MAJOR_VERSION %major_version%
    #define MINOR_VERSION %minor_version%
    #define BUILD_DATE %build_date%

    major_version and minor_version would come from a .properties file, .yml file or some such thing. build_date would be autogenerated like 20210320 by the build script.

    the ecmascript v3 interpreter of emScript doesn't seem to do text replacements or date math with any ease.

    Can you suggest the best way to do this?
  • Hello,

    Thank you for your inquiry.
    If I understand you correctly you are looking to do something like this:
    [SOLVED] Automatic versioning with preprocessor macros


    Best regards,
    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.