QEF home page
13. Arupdate: Library Magic

In this section we examine the tool arupdate, an important tool used in the maintenance of libraries.

Table of Contents
Previous Page
Next Page

The importance of the correct maintenance of libraries cannot be over valued. The approaches that many organizations use to maintain libraries fail to maintain the libraries correctly. At one organization, for two years builds used a library that contained a module, the source of which had been lost. But the loss was never noticed because the object module was contained in the library, thus links did not fail. The loss was not noticed until the library was reconstructed from scratch, hence no longer contained the lost module.

arupdate: The Archive Updater

QEF uses a program called arupdate to update and maintain libraries. To illustrate its use let's visit the appl/lib directory and rebuild the library.

% cd lib ; cats qeffile  # just a reminder

library -v -n appl @argv  @# Create appl library, add a
	version file

% qef -F  # -F forces the build
#{ -F @gobo 2003/07/20 06:06:48
# QEFHALTFILE: /g/dt/cook/obj/appl/lib/%qef32473b.hlt
+ cc -c -I.. -I/p/cook/s3.4/appl -I/g/dt/cook/dest/hdrs \
+ arupdate -V libappl -r libappl.a rtn.o
- mkvernum -blib -o _vlappl.c libappl
- cc -c _vlappl.c
- /usr/bin/ar qv libappl.a rtn.o _vlappl.o
a - rtn.o
a - _vlappl.o
- ranlib libappl.a
- rm _vlappl.c rtn.o _vlappl.o
#} E0 gobo@/g/dt/cook/obj/appl/lib 2003/07/20 06:06:52(4)

Note that arupdate invoked the mkvernum, the creation and compilation of the version file _vlappl.c, the ar, ranlib (if required), and rm commands.

One of the important features of arupdate is that its arguments name the complete list of files that are to be contained in the archive. This list can name files that are themselves list of files to be included. The list can also name archives whose elements are to be added to the new archive. arupdate builds the list of files that are to be in the archive and compares that list to the actual list of files in the library. It then builds and executes (if necessary) an ar -d command to remove any existing archive members that are not in the name list. Then arupdate builds and executes a command to add those elements in the list that exist and whose time-stamps differ from the time-stamp in the archive.

Adding a new module

Now let's create a new module, and rebuild:

% echo 'test(){}' > test.c; qef
#{ @gobo 2003/07/20 06:09:28
# QEFHALTFILE: /g/dt/cook/obj/appl/lib/%qef32504b.hlt
New:    /g/dt/cook/obj/appl/lib/test.c
+ cc -c -I.. -I/p/cook/s3.4/appl -I/g/dt/cook/dest/hdrs test.c
+ arupdate -V libappl -r libappl.a test.o rtn.o
- mkvernum -blib -o _vlappl.c libappl
- cc -c _vlappl.c
- /usr/bin/ar rv libappl.a test.o _vlappl.o
a - test.o
r - _vlappl.o
- ranlib libappl.a
- rm _vlappl.c test.o _vlappl.o
#} E0 gobo@/g/dt/cook/obj/appl/lib 2003/07/20 06:09:28(0)

Notice that the qeffile did not need to be modified to add the new file test.c to the build. That's because the qeffile uses @argv to name the files to be included in the library and that will be all the *.[cly] files in the current SrcPath.

Removing a module

Now let's remove test.c and rebuild the library:

% rm test.c ; qef
#{ @gobo 2003/07/20 06:16:59
# QEFHALTFILE: /g/dt/cook/obj/appl/lib/%qef32554b.hlt
Lost:   /g/dt/cook/obj/appl/lib/test.c
+ arupdate -V libappl -r libappl.a rtn.o
- /usr/bin/ar d libappl.a test.o
- mkvernum -blib -o _vlappl.c libappl
- cc -c _vlappl.c
- /usr/bin/ar rv libappl.a _vlappl.o
r - _vlappl.o
- ranlib libappl.a
- rm _vlappl.c _vlappl.o
#} E0 gobo@/g/dt/cook/obj/appl/lib 2003/07/20 06:16:59(0)

Note that arupdate removed test.o from the archive.

arupdate's ability to include an archive in its argument list has a major advantage when dealing with really big libraries that are spread across multiple directories. In such an instance, an arupdate command can be set up to include the developer's modules if they exist and extract the other required elements from the library constructed by the production group. That can result in a significant reduction in the amount of time the developer needs to build the library incorporating his/her changes, in that only those modules in directories changed by the developer need to be recompiled.

cook23.qh - 1.15 - 03/10/24 QEF home page Table of Contents Previous Page Next Page