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.

how do I pass a #DEFINE via command line

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: CCSTUDIO

Tool/software: Code Composer Studio

According to http://software-dl.ti.com/ccs/esd/documents/ccs_projects-command-line.html, to build project, we can use 

eclipsec -noSplash -data "C:\myWorkspace" -application com.ti.ccstudio.apps.projectBuild -ccs.projects newProject -ccs.configuration release

My project is the base of many products, each product has a different #DEFINE, e.g. #DEFINE PRODUCT1 builds the first project....

so I would like to use a batch file to build them all at the same time.

build firstproject #DEFINE PRODUCT1

build firstproject #DEFINE PRODUCT2

build firstproject #DEFINE PRODUCT3

...

how do I pass a #DEFINE in the above command line?

  • David,

    David Chance said:
    My project is the base of many products, each product has a different #DEFINE, e.g. #DEFINE PRODUCT1 builds the first project

    How is your project set up to use these defines? Typically a project is set up with multiple build configurations so each configuration can have a custom set of #defines or other options. In this case, the command line build can either build a specific build configuration or multiple build configurations.

    If I misunderstood the question please let me know.

  • I guess that was my personal preference, since I don't want to keep track of a lot of build configuration, and each one also has release and debug


    If there is no way to go my route, I will have to bite the bullet and go yours
  • I guess I'm not clear on how you are differentiating between them if not with build configurations. Are you keeping them as separate projects altogether?

    Build configurations are typically how this is handled, but if I can better understand how you have currently set them up I might be able to offer other suggestions.

    David Chance said:
    and each one also has release and debug

    You can always delete the default Debug and Release configurations if you do not wish to use them.

  • David Chance said:
    how do I pass a #DEFINE in the above command line?

    CCS can read the values of environment variables inside the project properties.

    E.g. with CCS 9 I added a predefine symbol containing PRODUCT$(PRODUCT_NUM) where PRODUCT_NUM is the name of the Environment variable:

    By setting the environment variable before performing a command line build then causes the build to create a define name based upon the environment variable value.

    E.g. perform a build for PRODUCT3 by setting the PRODUCT_NUM environment variable to 3:

    $ export PRODUCT_NUM=3 ; ./eclipse -noSplash -data ~/workspace_v9/ -application -application com.ti.ccstudio.apps.projectBuild -ccs.workspace -ccs.buildType full
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    CCS headless build starting... [Thu Apr 04 23:42:11 BST 2019] 
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    <snip>
    Building file: "../main.cpp"
    Invoking: MSP430 Compiler
    "/home/mr_halfword/ti/ccs900/ccs/tools/compiler/ti-cgt-msp430_18.12.1.LTS/bin/cl430" -vmspx --data_model=restricted --use_hw_mpy=F5 --include_path="/home/mr_halfword/ti/ccs900/ccs/ccs_base/msp430/include" --include_path="/home/mr_halfword/workspace_v9/MSP430_global_destructor" --include_path="/home/mr_halfword/ti/ccs900/ccs/tools/compiler/ti-cgt-msp430_18.12.1.LTS/include" --advice:power=all --advice:hw_config=all --define=__MSP430FR5989__ --define=PRODUCT3 --define=_MPU_ENABLE -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --preproc_with_compile --preproc_dependency="main.d_raw"  "../main.cpp"
    "../main.cpp", line 12: remark #1535-D: (ULP 8.1) variable "test_dtor" is used as a constant. Recommend declaring variable as either 'static const' or 'const'
    warning #10420-D: For FRAM devices, at start up, the GPIO power-on default high-impedance mode needs to be disabled to activate previously configured port settings. This can be done by clearing the LOCKLPM5 bit in PM5CTL0 register.
    Finished building: "../main.cpp"
    
    <snip>
    CCS headless build complete! 0 out of 1 projects have errors.
    

    Followed by performing a build for PRODUCT5 by setting the PRODUCT_NUM environment variable to 5:

    $ export PRODUCT_NUM=5 ; ./eclipse -noSplash -data ~/workspace_v9/ -application -application com.ti.ccstudio.apps.projectBuild -ccs.workspace -ccs.buildType full
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    CCS headless build starting... [Thu Apr 04 23:42:28 BST 2019] 
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    <snip>
    Invoking: MSP430 Compiler
    "/home/mr_halfword/ti/ccs900/ccs/tools/compiler/ti-cgt-msp430_18.12.1.LTS/bin/cl430" -vmspx --data_model=restricted --use_hw_mpy=F5 --include_path="/home/mr_halfword/ti/ccs900/ccs/ccs_base/msp430/include" --include_path="/home/mr_halfword/workspace_v9/MSP430_global_destructor" --include_path="/home/mr_halfword/ti/ccs900/ccs/tools/compiler/ti-cgt-msp430_18.12.1.LTS/include" --advice:power=all --advice:hw_config=all --define=__MSP430FR5989__ --define=PRODUCT5 --define=_MPU_ENABLE -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --preproc_with_compile --preproc_dependency="main.d_raw"  "../main.cpp"
    
    <snip>
    CCS headless build complete! 0 out of 1 projects have errors.
    

    The output from the compiler shows the define has been built based upon the environment variable set prior to starting the CCS headless build. I used CCS running under Linux for this test, but hopefully should also work for CCS running under Windows.