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).

546code file generation 466+   (462 542)  468b  547
include $(PROJECTROOT)/Makefile.def
include Makefile.asfiles

Uses PROJECTROOT 350.

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
547code file generation 466+   (462 542)  546  548
# There should be no duplicates in SRCS!!!
SRCS=$(notdir $(ASFILES))
NOPREFIXFILES=Makefile
FILES=${NOPREFIXFILES} ${ASFILES:%=%.as}
DIRS =
include $(PROJECTROOT)/Makefile.inc

Uses ASFILES 466, DIRS 355a, FILES 355a, PROJECTROOT 350, and SRCS 468a.

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.

548code file generation 466+   (462 542)  547
# The sort removes duplicates.
vpath %.as.nw $(sort $(dir ${ASFILES}))
vpath %.al ${PROJECTROOT}/src
vpath %.a ${PROJECTROOT}/src

values for TCLIBRARYNAME and TCLIBPREFIX 541
${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 466, CODEFILES 436, NOTANGLE 352, NWESCAPE 437a, nwescape.pl 437a, PERL 431b, PROJECTROOT 350, SRCS 468a, TCLIBPREFIX 541, and TOOLS 428b.