IBM SC34-4499-03 manual Writing a simple build script, Writing an executable le for a build script

Models: SC34-4499-03

1 356
Download 356 pages 55.74 Kb
Page 173
Image 173

Writing a simple build script

This kind of build script is written into the Script attribute of the builder. When you create or modify the builder, you specify in this attribute the name of the transformation tool to be invoked.

For example, suppose you want to create a builder that compiles a C source ®le into a

.exe ®le using IBM's VisualAge C++ compiler. You specify the following attributes for the builder:

Build script

icc

Parameters

"$(TC_INPUT) /Fe$(TC_OUTPUT)"

You can create this builder using the following command:

teamc builder -create c_builder -env OS2 -script icc -none -parameters "$(TC_INPUT) /Fe$(TC_OUTPUT)"

If you use this builder to create hello.exe from hello.c, the command actually issued during the build process is the following:

"icc hello.c /Fehello.exe"

Writing an executable ®le for a build script

Suppose you need to build a C application and you want to specify at build time whether to use debug information. To do this, you de®ne in the builder parameters a variable called debug and set the variable when you start the build. In this case, you need a build script that is a separate executable ®le to pass the debug parameter after the variable substitution.

For a build script of this form, you ®rst write a program or command ®le; this ®le is stored in the TeamConnection database when you create the builder. When a build is performed, this build script ®le is extracted from the database and run. It interprets the parameters passed to it and then invokes the actual transformation tool, such as the compiler.

Our earlier example describes a builder that compiles a C source ®le into a .obj ®le using IBM's VisualAge C++ compiler. Using this builder, you can specify at build time whether to use debug information. Here is the complete build script for such a builder, written in IBM's REXX language (it could just as easily have been written in C or COBOL).

/* sample C Build Script using debug flag */ parse arg parms

environ

= ©OS2ENVIRONMENT©

input

= VALUE(©TC_INPUT©,,environ)

output

= VALUE(©TC_OUTPUT©,,environ)

Chapter 12. Working with build scripts and builders 153

Page 173
Image 173
IBM SC34-4499-03 manual Writing a simple build script, Writing an executable le for a build script