41.3 Code File Generation For Tests

The variable ASFILES (as given through the file test/Makefile.asfiles) specifies the source files with extension .as.nw that are considered to build the libraries. As in the case of the src directory there will be two versions of .as files.

  1. One .as file that lies in the same directory as the corresponding .as.nw file. This version is used to generate the .signatures.as file, the dependencies via tools/dependencies.pl.nw and the file test/TestSuite.as via tools/generateTestSuite.pl.nw. Here the indentation of the code is as specified by the .as.nw file.
  2. The second version of the .as file comes with line numbers added and will be generated (with prefix TCLIBPREFIX) into the directory test. That is why the variable SRCS should not contain duplicates.

    These files are used by the ALDOR compiler for the build of the testcases libraries. Here line numbers of the form

    #line LINENUMBER "FILENAME"

    are generated into the .as file. This is done by means of the ’-L’ option of NOTANGLE. The ’-L’ option, however, copies the indentation directly from the .as.nw file. There is no nested indentation as in the first case.

Both versions differ only in indentation and the fact that the second version will have the line numbers from the .as.nw file added.

The reason for the generation of two versions is that it is easier to generate the dependencies from the source files that have a proper indentation (first version).

544code file generation 462+   (458 539)  464b  545
include $(PROJECTROOT)/Makefile.def
include Makefile.asfiles

Uses PROJECTROOT 346.

The file test/Makefile.asfiles is generated by tools/asfiles.pl.nw (see Section 29.3) and looks as follows.

# Generated via  
# /home/hemmecke/SVK/HOME/trunk/projects/Software/allprose/tools/asfiles.pl \  
#   /home/hemmecke/SVK/HOME/trunk/projects/Software/allprose \  
#   myalps \  
#   test  
ASFILES=\  
  myalps/binpow
545code file generation 462+   (458 539)  544  546
# There should be no duplicates in SRCS!!!
SRCS=$(notdir $(ASFILES))
NOPREFIXFILES=Makefile
FILES=${NOPREFIXFILES} ${ASFILES:%=%.as}
DIRS =
include $(PROJECTROOT)/Makefile.inc

Uses ASFILES 462, DIRS 351a, FILES 351a, PROJECTROOT 346, and SRCS 464a.

In order to avoid to specify the paths of the .as.nw files, we use the vpath directive.

Note that we also make the directory PROJECTROOT/src available, because that is where the generated project library is before installation.

The generation of the .as files with prefix is given below. The generation of the .as files without prefix is the standard one as described in Section 29.4.

546code file generation 462+   (458 539)  545
# The sort removes duplicates.
vpath %.as.nw $(sort $(dir ${ASFILES}))
vpath %.al ${PROJECTROOT}/src
vpath %.a ${PROJECTROOT}/src

values for TCLIBRARYNAME and TCLIBPREFIX 538
${TCLIBPREFIX}%.as: %.as.nw $(TOOLS)/nwescape.pl
        $(PERL) $(TOOLS)/aldordoc2codechunk.pl $< |\
        $(NWESCAPE) | $(NOTANGLE) -L’#line %L "$<"%N’ > $@

#redefine CODEFILES from Makefile.inc
CODEFILES += $(SRCS:%=$(TCLIBPREFIX)%.as)

Uses ASFILES 462, CODEFILES 432, NOTANGLE 348, NWESCAPE 433a, nwescape.pl 433a, PERL 427b, PROJECTROOT 346, SRCS 464a, TCLIBPREFIX 538, and TOOLS 423b.