4.5   Working With Build Specifications

The project facility allows you to create, modify, and select specifications for any number of builds. A default build specification is defined when you create your project. While a BSP is usually designed for one CPU, you can create build specifications for different image types and optimization levels, specifications for builds that include debugging information and builds that don't, and so on.

4.5.1   Changing a Build Specification

Each build specification consists of a set of options that define the VxWorks image type (for VxWorks and bootable application projects), makefile rules, macros, as well as compiler, assembler, and linker options.


*

NOTE: For detailed information about compiler, assembler, and linker options, see the GNU Toolkit User's Guide.

You can change default or other previously defined build options by double-clicking on the build name in the Builds view of the workspace window. The build's property sheet appears (Figure 4-34),

You can use the property sheet to modify:

  • build targets

  • makefile rules

  • makefile macros for the compiler and linker

  • compiler options

  • assembler options

  • linker options

For information about build targets for downloadable applications, see Build Specifications. For information about build targets for bootable applications, see 4.3.4 Selecting the VxWorks Image Type. Other features of the build property sheet are covered in the following sections.


*

WARNING: As of this release the project facility does not note changes in build options when you attempt to rebuild a project, and it will report that the build is up to date. If the only changes you have made are to the build options, you must select Rebuild All from the context menu to start a build with the new options.

Custom Makefile Rules

The buttons at the bottom of the build property sheet allow you to create, edit, or delete makefile rules (default project entries cannot be deleted; only those created by a user can be deleted). When you click the New/Edit button The Create or Edit Rule dialog box appears (Figure 4-35). Once you have created or edited an entry, click OK. Note that the default is to invoke the rule before building the project (see the checkbox). If the default is not selected, the rule is only invoked if it is the rule currently selected for the build (with the drop-down list in the Rules page of the build property sheet). New rules are added to the projectName.wpj file and written to the makefile prior to a build.

Makefile Macros

Select the Macros tab of the build specification property sheet to view the makefile macros associated with the current project, build specification, and rules (Figure 4-36).

You can use the Macros page to modify the values of existing makefile macros, as well as to create new rules to be executed at the end of the build. Use the Delete button to delete a macro from the build. To add a macro, change the name and value of an existing macro, and click the Add/Set button. To change an existing macro, modify the value and click the Add/Set button.

The recommended way to link library (archive) files to your project is to add the libraries to the list defined by the LIBS macro.

Compiler Options

The C/C++ compiler page of the build specification property sheet displays compiler options. You can edit the options displayed in the text box (Figure 4-37).


*

WARNING: The default compiler options include -g for debugging information. Using -g with the optimization option -O set to anything but zero may produce unpredictable results. Selecting Include debug info automatically sets optimization to zero. This can be changed by editing the option.

You can override the default compiler flags for individual files by right-clicking on the file name in the Files view, selecting Properties from the context menu, and specifying a new set of options in the Build page of the property sheet. Un-checking the Use default build rule for this file box allows you to edit the fields in this page (Figure 4-38).

If the file should be used only when building a ROM-based image, check the Build for ROM images only box. See 4.3.4 Selecting the VxWorks Image Type.

Assembler Options

Select the assembler tab of the build specification property sheet to view assembler options. You can edit the options displayed in the text box (Figure 4-39).

Link Order Options

Select the Link Order tab of the build specification property sheet to view module link order (Figure 4-40). You can change the link order using the Down and Up buttons to ensure that static C++ constructors and destructors are invoked in the correct order.

Linker Options

Select the linker tab of the build specification property sheet to view linker options. You can edit the options displayed in the text box (Figure 4-41).

To link an object file with a project, list the full path to the file. The recommended way to link library (archive) files is to add the libraries to the list defined by the LIBS macro (see Makefile Macros).


*

WARNING: You cannot link another project object file (projectName.out) with the project you are building. You must compile the other project as a library (Build Specifications), and then link it with the current project.

4.5.2   Creating New Build Specifications

You can create new build specifications for a project with the Add New Build Specification window, which is displayed with the New Build option on the context menu. For example, one build specification can be created that includes debug information, and another that does not; specifications can be created for different image types, optimization levels, and so on. You can create a new build specification by copying from an existing specification, or by creating it as a default specification for a given toolchain (Figure 4-42).

Once you have created a new build specification, use the build specification property sheet to define it (see 4.5.1 Changing a Build Specification).


*

NOTE: For downloadable applications, it is often useful to create a build specification for the target simulator, and another for the real target hardware. For bootable applications and custom VxWorks images, you are usually restricted to the toolchains that support the CPU required by the BSP. But you can still create different build specifications (for example, with different optimization levels or rules).

4.5.3   Selecting a Specification for the Current Build

When you want to build your project, select the build specification from the Build Spec drop-down list (Figure 4-43).

Binaries produced by a build are created in the buildName subdirectory of your project directory.