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.

CCS/CCSTUDIO: Code Composer Studio generate files as pre build step

Part Number: CCSTUDIO

Tool/software: Code Composer Studio

I am trying to run a batch script to generate C/C++ files and running into issues with CCS. I can successfully execute the .bat file and generate the source files, but the issue I'm running into is that those generated files are not recognized by CCS until after the build fails (due to it not updating the files after already starting a build).

I have tried several things to no avail:

  1. Calling the .bat file in the Pre-build steps.
    1. I tried disabling parallel builds with this step too.

  2. Creating a separate project entirely with a custom builder that executes the .bat file and adding that project as a dependency in the CCS project (via Properties > CCS Build > Dependencies).
  3. Same as #1 but set the C/C++ General > Paths and Symbols > References to the generator project.
  4. Following the example in https://embeddedartistry.com/blog/2019/02/18/using-custom-build-steps-with-eclipse-auto-generated-makefiles/.

I haven't fully been able to get #4 working in order to say it doesn't work. What should my makefile.init file contain if I want ..\path\to\script.bat to execute before building?

I feel like I'm missing something obvious as I think this would be a common use case for projects. Is there something else I should be doing to do this?

  • Erich,

    The CCS auto-generated makefile is created as soon as you select "Build Project" and since the batch file generated C/C++ files are not in the project folder at that point in time, they are not included in the makefile/build.

    You could use your method #2 of having a separate project for generating the source files, however it cannot simply be a dependent project. The projects have to be built in sequence one after another, and the custom builder project should be set up to generate the source files in the main project folder (or copy them over between the two builds).

    For #4, using makefile.init, I would think you should be able to call the batch file from there. This page has some information on makefile.init that might help:
    https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_project-management.html#makefiles

    Lastly you could also allow CCS to auto-generate the makefile once, then disable auto-generation of makefile for future builds, and add custom pre-build steps to the makefile, as described in this post: https://e2e.ti.com/support/tools/ccs/f/81/p/733570/2712093#2712093 
    It is a bit of a hack, but should get the job done.

  • Ok, I finally was able to get #4 to actually generate and clean the generated files, but the same issue occurs with all the other methods I've tried... where CCS does not refresh the project files after it initiated a build. Thus the build will fail the first time through, which is not acceptable, particularly when trying to build on an automated CI server.

    For those interested, my makefile.init contains the following:

    all: parameter-database-generate
    clean: parameter-database-clean
    
    parameter-database-generate:
    	@echo Generating Parameter Database
    	@cmd $(shell pwd)/../../Parameter_Database/generate.bat
    
    parameter-database-clean:
    	@echo Cleaning Parameter Database
    	@cmd $(shell pwd)/../../Parameter_Database/clean.bat

    How does the syscfg stuff handle this? Because what I'm trying to do is (I think) exactly the same thing that, that does. Is it possible to add hooks into the syscfg generation process?

  • Ahh! I got it to work! What I did was #2, but without the separate project (although I'm sure I could've done it in a separate project).

    https://stackoverflow.com/questions/6819707/how-can-i-compile-auto-generated-c-files-in-pre-build#:~:text=Go%20to%20the%20project%20properties,files%20whenever%20it%20is%20run.

    Steps I did to make it work:

    1. In Project properties, click Show advanced settings.
    2. Builders > New...
    3. Select Program.
    4. In Main tab, enter ${project_loc}/../path/to/script.bat in the Location field.
    5. In Refresh tab, check Refresh resources upon completion. and select The project containing the selected resource.
    6. In Build Options tab, ensure After a "Clean" and During manual builds are checked (default).
    7. Click Apply and OK.
    8. Select the builder just created, and click the Up button to make it on above CDT Builder and Scanner Configuration Builder.