Using output of optional tools in post-build steps

When specified in a build configuration, the post-build command will be executed prior to calling the optional tools. 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 work around this issue, create and launch a sequence of two build configurations. The first configuration will produce secondary output (SREC, HEX and LST files), and the second configuration will execute the post-build command for these build targets.

To use secondary build targets in a post-build command:

  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.

    The post-build command has been executed