Kawac

Description

Compiles Kawa source files. There are two ways to specify the files to be compiled:

  1. use one or more explicit FileSets, or
  2. use an implicit FileSet in the style of <javac>.

In either case, the destination directory will be scanned for matching .class files, and only Kawa files without corresponding class files or which are newer than their class files will be compiled.

Note: Ant uses only the names of the source and class files to find the classes that need to be rebuilt. It will not scan the source and therefore will have no knowledge about nested classes, classes that are named different from the source file, and so on.

See the <javac> documentation for details on how to use the implicit file set.

This task can compile source code in any language understood by Kawa. A language can be specified using the language attribute. Valid values are:

Parameters

When the third column is left blank, that means it is not applicable to FileSet style.

Attribute Description Required for FileSet Style Required for Javac Style
srcdir Location of the Kawa files. Yes
destdir Location to store the class files. Yes No
includes Comma- or space-separated list of files (may be specified using wildcard patterns) that must be included; all Kawa source files are included when omitted No
includesfile The name of a file that contains a list of files to include (may be specified using wildcard patterns). No
excludes Comma- or space-separated list of files (may be specified using wildcard patterns) that must be excluded; no files (except default excludes) are excluded when omitted. No
excludesfile The name of a file that contains a list of files to exclude (may be specified using wildcard patterns). No
classpath The classpath to use. No No
classpathref The classpath to use, given as a reference to a path defined elsewhere. No No
target Generate class files for specific VM version (e.g. 1.5 or 1.6). No No
failonerror Indicates whether compilation errors will fail the build; defaults to true. No No
errorProperty The property to set (to the value "true") if compilation fails. No No
listfiles Indicates whether the source files to be compiled will be listed; defaults to no. (Note: kawa already lists files as they are compiled, so this will print them twice.) No No
updatedProperty The property to set (to the value "true") if compilation has taken place and has been successful. No No
includeDestClasses This attribute controls whether to include the destination classes directory in the classpath given to the compiler. The default value of this is "true" and this means that previously compiled classes are on the classpath for the compiler. No No
prefix Prefix to prepend to class names. Typically the package name with a trailing period. No No
main If true, Kawa will create a static main method. Defaults to false. No No
applet If true, Kawa will generate an applet. Defaults to false. No No
servlet If true, Kawa will generate a servlet. Defaults to false. No No
fulltailcalls If true, Kawa will use full tailcalls. Defaults to false. No No
modulestatic One of: yes or true or on to pass ‑‑module‑static, no or false or off to pass ‑‑no‑module‑static, or run to pass ‑‑module‑static‑run. No No
warnundefinedvariable If true, passes ‑‑warn‑undefined‑variable No No
warnaserror If true, passes ‑‑warn‑as‑error No No
language The Kawa language to use. Passes ‑‑<language> to the compiler. If a language is specified, then only source files for that language (as determined by file extension) will be compiled. Otherwise, all source files understood by Kawa will be eligible for compilation. (See the above list of valid languages.) No No

Parameters specified as nested elements

This task forms an implicit FileSet and supports most attributes of <fileset> (dir becomes srcdir) as well as the nested <include>, <exclude> and <patternset> elements.

srcdir and classpath

<kawac>’s srcdir and classpath attributes are path-like structures and can also be set via nested <src> (note the different name!) and <classpath> elements, respectively.

arg

To pass additional arguments to the compiler, use nested <arg> elements, which are specified like Command-line Arguments. For instance, to pass ‑‑warn‑unknown‑member, use <arg value="‑‑warn‑unknown‑member"/>.

fileset

To use the explicit FileSet style, use nested <fileset> elements.

Note: for files in src/com/example which are to be in the package com.example, the <fileset> must be defined in one of two ways with regards to its dir attribute in order for the uptodate mechanism to match source and class files:

  1. <fileset dir="src" includes="com/example/*.scm"/>, or
  2. <fileset dir="src/com/example" includes="*.scm"/>.

The relative path corresponding to the package name must either be entirely within the directory part, or entirely within the include filename part. This will not work:

<fileset dir="src/com" includes="example/*.scm"/>

Defining the <kawac> Task

The <kawac> task is implemented by the gnu.kawa.ant.Kawac class. To use it in your build.xml file, define the task with:

<taskdef name="kawac" classname="gnu.kawa.ant.Kawac" classpath="${build.tools}"/>

where ${build.tools} is the path to the Kawa tools directory.

Examples

The following examples all compile src/com/example/foo.scm to the class com.example.foo in the classes directory (i.e. to classes/com/example/foo.class).

Using an explicit FileSet:

  <kawac destdir="classes"
         language="scheme"
         prefix="com.example.">
    <fileset dir="src" includes="com/example/foo.scm"/>
  </kawac>

or

  <kawac destdir="classes"
         language="scheme"
         prefix="com.example.">
    <fileset dir="src/com/example" includes="foo.scm"/>
  </kawac>

Using the implicit FileSet:

  <kawac destdir="classes"
         srcdir="src"
         language="scheme"
         prefix="com.example."
         includes="com/example/foo.scm"/>

or

  <kawac destdir="classes"
         srcdir="src"
         language="scheme"
         prefix="com.example.">
    <include name="com/example/foo.scm"/>
  </kawac>