Using HP Code Advisor in Application Builds: [HP Code Advisor] White Paper

7
Figure 4: Introducing a target to invoke the build through cadvise
The advantage of introducing a separate target is that the customized actions to suit projects and
teams can be implemented along with a build using cadvise.
For example, you can check number of diagnostics generated in the build before and after a code
change and check if the code quality has improved or degraded.
If the number of diagnostics increases, the build can fail, thereby forcing the developer to ensure that
the change is of bad quality. Figure 5 shows a basic implementation of this functionality in the
cadvise specific target, described above.
# This is a sample Makefile
# This is used to illustrate how Cadvise can be incorporated into
# application builds
# List of source code files
SOURCES = source1.c source2.c
# Create a list of the object files using macro substitutions
OBJECTS = $(SOURCES:.c=.o)
# Build tools and options
# Use aCC as the default C compiler
CC = aCC
# Flags
CFLAGS = -c -Ae -O -I.
# Use aCC as the linker
LD = aCC
LDFLAGS = -o
# Application target and dependencies
YourApplication: $(OBJECTS)
$(LD) $(LDFLAGS) $@ $(OBJECTS) $(LIBS)
# Introducing Cadvise specific target
Cadvise-YourApplication:
make CC=”cadvise –pdb YourApplication.pdb $(CC)” LD=$(CC) YourApplication
# .o files depend on .c files
$(OBJECTS): includes.h
$(CC) $(CFLAGS) $(SOURCES)
# Clean built files
clean:
rm -rf *.o *~ YourApplication core