Skip to main content

IAR Embedded Workbench for RISC-V 3.40

Adding an external tool

In this section:

The following example demonstrates how to add the tool Flex to the toolchain. The same procedure can also be used for other tools.

In the example, Flex takes the file myFile.lex as input. The two files myFile.c and myFile.h are generated as output.

  1. Add the file you want to work with to your project, for example myFile.lex.

  2. Select this file in the Workspace window and choose Project>Options. Select Custom Build from the list of categories.

  3. In the Filename extensions field, type the filename extension .lex. Remember to specify the leading period (.).

  4. In the Command line field, type the command line for executing the external tool, for example:

    flex $FILE_PATH$ -o$FILE_BNAME$.c

    During the build process, this command line is expanded to:

    flex myFile.lex -omyFile.c

    Note the usage of argument variables and specifically the use of $FILE_BNAME$ which gives the base name of the input file, in this example appended with the c extension to provide a C source file in the same directory as the input file foo.lex. For more information about these variables, see Argument variables.

  5. In the Output files field, describe the output files that are relevant for the build. In this example, the tool Flex would generate two files—one source file and one header file. The text in the Output files text box for these two files would look like this:

    $FILE_BPATH$.c
    $FILE_BPATH$.h
  6. If the external tool uses any additional files during the build, these should be added in the Additional input files field, for instance:

    $TOOLKIT_DIR$\inc\stdio.h

    This is important, because if the dependency files change, the conditions will no longer be the same and the need for a rebuild is detected.

  7. Click OK.

  8. To build your application, choose Project>Make.