Using output of optional tools in post-build steps

When specified in a build configuration, the post-build command will be executed after generating the ELF file and before calling the optional tools (for example, generating the SREC file). For this reason, when you try to use a file produced by an optional tool in a post-build command, you get the error message “No such file or directory”.

To use secondary outputs in a post-build command, you can do one of the following:

Using a custom makefile

  1. Create the makefile.targets file in the project root.
  2. Open this file in the editor and specify the target name, for example, user_all. It should build the default all target and then execute your post build commands.
    user_all: all post_buid_step
  3. Create the post_build_step rule. It should be executed only if the optional tool output exists. In case of the SREC file, makefile defines the SECONDARY_FLASH variable for the output:


    makefile srec

    post_build_step: $(SECONDARY_FLASH)
  4. Add the post-build commands.


    custom makefile

  5. In the project properties, click C/C++ Build and open the Behavior tab.
  6. In the Build (Incremental build) field, specify your custom target instead of the default one.


    custom makefile

Using a sequence of two build configurations

  1. In the project properties, go to C/C++ Build > Settings. Select the first build configuration, click Cross Settings, and select optional tools to be used for building the project.

    For instance, select the Create flash image option to use the Standard S32DS Create Flash Image tool. Then go to Standard S32DS Create Flash Image > General and configure the tool.

  2. To create the second configuration, click Manage Configurations in the project properties, then click New in the pop-up dialog box. Specify the name of the second configuration. Choose to copy settings from the existing configuration and select the first configuration from the Existing configuration list. Click OK.


    Create a new build configuration

    Then select the just created configuration in the pop-up dialog box and click Set Active. Click OK.
  3. In the project properties, go to C/C++ General > Path and Symbols. Make sure the second configuration is selected in the Configuration field. On the Reference tab, expand the <project_name> list and flag the first configuration.
    When you run the second configuration, this reference will call the first configuration prior to the second one.


    Reference the first build configuration

  4. In the project properties, go to C/C++ Build > Settings > Build Steps. Select the second configuration in the Configuration field and specify the post-build command that uses secondary output created by the first configuration.
    For instance, save a copy of the SREC file in the project folder where output of the second configuration is stored:


    Add a post-build command

  5. Run the second configuration.
    This command launches the first build configuration that creates all specified build targets, including secondary output. Then the second configuration executes the post-build command.