MSP430FR5969: Tutorial on how to extend the makefile functionality

Part Number: MSP430FR5969

Tool/software:

Hello,

I have seen the post related to the makefile modfiication to obtain the git tag version and use it as environment variable(Reference: e2e.ti.com/.../ccs-msp430fr5969-storing-a-symbol-value-before-building). I've been trying to set up the pre build steps but I amb not able to produce results. Would it be possible to get a tutorial on how to extend the make file to obtain the git tag version?

Regards,

David

  • I will move this thread to CCS topic. Hope they can help you find the answer.

  • Hello,

    Great, is there any update on the matter?

    David

  • Hi David,

    Would it be possible to get a tutorial on how to extend the make file to obtain the git tag version?

    I am not aware of any such tutorial on this. It is not something that we natively support in CCS. Perhaps someone from the community share a solution.

    ki

  • Hello Ki,

    I've been working on a bash script that could do the the task but I was not able to define properly thev git_tag symbols. I can obtain the git tag version and copy it to a txt but i am not able to define the desired syumbol, maybe you can help me with that?

    I am still learning on how to adjust the compiler options through .bat files but i believe it works fine until the compiler flags settings and the symbol defining.

    Regards,

    David

    @echo off
    setlocal enabledelayedexpansion
    
    REM Get Git version information
    for /f "tokens=*" %%i in ('git describe --long --dirty --tags 2^>nul') do set GIT_DESCRIBE=%%i
    
    REM Check if git describe command worked
    if "%GIT_DESCRIBE%"=="" (
        echo WARNING: Git command failed or no tags found. Using default values.
        set GIT_DESCRIBE=v0.0.0-0-dev-dirty
    )
    
    REM Split the git describe output into components
    set "version=%GIT_DESCRIBE:-= %"
    
    REM Extract components
    for /f "tokens=1,2,3,4" %%a in ("%version%") do (
        set VERSION_TAG=%%a
        set COMMITS_PAST=%%b
        set COMMIT=%%c
        set DIRTY=%%d
    )
    
    REM Initialize build info variables
    set "BUILD_INFO_COMMITS="
    set "BUILD_INFO_DIRTY="
    
    REM Add commits info if not zero
    if NOT "%COMMITS_PAST%"=="0" (
        set "BUILD_INFO_COMMITS=.%COMMITS_PAST%"
    )
    
    REM Add dirty marker if present
    if NOT "%DIRTY%"=="" (
        set "BUILD_INFO_DIRTY=+"
    )
    
    REM Combine build info
    set "BUILD_INFO=%COMMIT%%BUILD_INFO_COMMITS%%BUILD_INFO_DIRTY%"
    
    REM Get build environment information
    for /f "tokens=*" %%d in ('date /T') do set DATE=%%d
    for /f "tokens=*" %%t in ('time /T') do set TIME=%%t
    set "BUILD_DATE=%DATE%, %TIME%"
    for /f "tokens=*" %%u in ('echo %username%') do set USERNAME=%%u
    for /f "tokens=*" %%h in ('hostname') do set HOSTNAME=%%h
    set "BUILD_MACHINE=%USERNAME%@%HOSTNAME%"
    
    REM Display build information
    echo Build Time: %BUILD_DATE%
    echo Build Version: %VERSION_TAG%
    echo Build Info: %BUILD_INFO%
    
    REM Create compiler flags
    set "GEN_OPTS__FLAG=--define=VERSION_TAG=\"%VERSION_TAG%\" --define=VERSION_BUILD_INFO=\"%BUILD_INFO%\" --define=VERSION_BUILD_MACHINE=\"%BUILD_MACHINE%\" --define=VERSION_BUILD_DATE=\"%BUILD_DATE%\""
    
    REM Create a variables file that can be included in other batch files
    echo @echo off > version_vars.bat
    echo set "VERSION_TAG=%VERSION_TAG%" >> version_vars.bat
    echo set "BUILD_INFO=%BUILD_INFO%" >> version_vars.bat
    echo set "BUILD_MACHINE=%BUILD_MACHINE%" >> version_vars.bat
    echo set "BUILD_DATE=%BUILD_DATE%" >> version_vars.bat
    echo set "GEN_OPTS__FLAG=%GEN_OPTS__FLAG%" >> version_vars.bat
    
    REM Create a variables file for makefile inclusion
    echo VERSION_TAG=%VERSION_TAG% > version_vars.mk
    echo BUILD_INFO=%BUILD_INFO% >> version_vars.mk
    echo BUILD_MACHINE=%BUILD_MACHINE% >> version_vars.mk
    echo BUILD_DATE=%BUILD_DATE% >> version_vars.mk
    echo GEN_OPTS__FLAG=%GEN_OPTS__FLAG% >> version_vars.mk
    
    echo.
    echo Variables have been written to:
    echo - version_vars.bat (for batch files)
    echo - version_vars.mk (for makefiles)
    echo.
    echo To use in the current command prompt session, run:
    echo call version_vars.bat
    
    endlocal & (
        REM Export variables outside of the local scope
        set "VERSION_TAG=%VERSION_TAG%"
        set "BUILD_INFO=%BUILD_INFO%"
        set "BUILD_MACHINE=%BUILD_MACHINE%"
        set "BUILD_DATE=%BUILD_DATE%"
        set "GEN_OPTS__FLAG=%GEN_OPTS__FLAG%"
    )

  • I've been working on a bash script

    With bash you have to explicitly export things to a child process. If you don't do that then make will never see them. You can do it all in one go.

    Found hiding in my .bashrc:

    export MSP430_GCC_INCLUDE_DIR=/usr/ti/gcc/include

  • Hello David,

    Thank you for your response, can you please explain me further what would I accomplish with that command?

    Also, correct me if I am mistaken, the child proces should be the bnash script run by CCS, Therefore, should I have to export the symbols to the parent process isntead? I am using the prebuild steps, I believe it is like a separated make commands and I sohuld make an interconenction between the prebuild steps and the actual building procedure top ush the symbols to the compiler.

    Regards,

    David

  • I have no idea what CCS is doing but it is pretty much impossible for a child process to change the environment variables of a parent. You can finagle that a little as shown in a recent post on Hackaday. Although that is mostly about preventing bash from starting a child process to run a script.

**Attention** This is a public forum