12.8.11. Customizing the build

To output a message during the build:

  1. Select Project → Project Properties... to display the Project Properties window.

  2. Right-click on the *COMPILE=arm group in the List of Entries pane, and select Make New... from the context menu to display the Group Type/Name selector dialog box.

  3. Highlight CUSTOM in the Group Type display list.

  4. Type MY_GROUP in the Group Name field.

  5. Click OK to close the Group Type/Name selector dialog box.

  6. Select the *CUSTOM=MY_GROUP group in the List of Entries pane, and select Explore from the context menu.

  7. Click on the Message setting, in the Settings Values pane, and select Edit Value from the context menu.

  8. Type Writing version to version file and then press Enter to confirm the value.

    This string is output every time you build or rebuild the application.

  9. Right-click on the Files setting, in the Settings Values pane, and select Edit Value from the context menu.

  10. Type version.txt and then press Enter to confirm the value.

  11. Right-click on the Depends_on setting, in the Settings Values pane, and select Edit Value from the context menu.

  12. Type $(MAKENAME) and then press Enter to confirm the value. Ensure that you do not include any spaces in the entry.

    This entry means that output file is dependent on the makefile so you rebuild version.txt each time the makefile is updated. Usually, dependent files are inputs to a build but this example illustrates the method.

    Do not make the executable file, dhrystone.axf, the dependent because that does not work. Instead, you must use postlink commands as shown in Adding prelink and postlink commands.

  13. Right-click on the Command setting, in the Settings Values pane, and select Edit Value from the context menu.

  14. Type +echo ‘version = 1.00 >$@‘ and then press Enter to confirm the value.

    This command writes the message to the text file defined previously. You might use a command to run another program or to output the date.

    Preceding the command with a plus sign means that the command is a built-in operating system shell command. Do not put a plus sign in the command when running normal applications. If you do not want the command to be shown while it is running, then put an at (@) sign in front of the command string.

    The Project Properties window is shown in Figure 12.9.

    Figure 12.9. Customizing the build

    Customizing the build
  15. Select File → Save and Close to regenerate the makefile(s) for the project, and close the Project Properties window.

  16. Select Tools → Build... to rebuild the application.

Running the build

You can control the build using the Use_as settings value, shown in Figure 12.9. Right-click on the setting to see the available options:

link_dependent

RealView Debugger ensures that it is up-to-date when building the application. This is the default.

link_input

Creates an object file or library which is then linked to the application built by the project.

named_target

Makes the file a named target. This means that other files must be dependent on it for it to be used. Use this option to create a header or source file, that is a .c or .asm file, that is then compiled or assembled in a COMPILE or ASSEMBLE group. The make knows to build the header or source file before building the application with it. You can also layer custom projects in this way with the output of one project used as the input of another.

post_link

Specifies that the file is built only after linking.

Note

You can force a CUSTOM rule to run every time that you build the application by referring to a file that does not exist. For example, in the steps in Customizing the build, you could have specified that the file was called version but still written to version.txt. This causes the CUSTOM rule to be executed each time you build the application because make decides that the file version does not exist and so tries to build it.

To undo this change and restore the build model:

  1. Select Project → Project Properties... to display the Project Properties window.

  2. Right-click on the *CUSTOM=MY_GROUP group in the List of Entries pane, and select Delete from the context menu.

  3. Select File → Save and Close to regenerate the makefile(s) for the project, and close the Project Properties window.

  4. Select Tools → Build... to rebuild the application.

Copyright © 2003, 2004 ARM Limited. All rights reserved.ARM DUI 0234B
Non-Confidential