Building Lightfoot applications with ANT

In addition to using make to build Lightfoot application, you can also use Ant, available from ant.apache.org. Ant is almost a standard mechanism for building Java based applications and the Lightfoot SDK provides a number of tasks and default build files that allow you to build Java applications and libraries.
There are a number of examples that show how to build libraries (KXMLRPC) and applications (MP3Player).

Using ANT to build applications

The easiest way to use ANT to build an application is to use the lightfootJavaApp.xml build file found in the etc directory of the SDK. The following build file, taken from the MP3Player example shows how to use this.

<?xml version="1.0" ?>
<!DOCTYPE project [
    <!ENTITY standard SYSTEM "file:../ant_setup.xml">
]>

<project name="mp3player" default="build">
    <!-- Define various properties -->
    <property environment="env"/>
    <property name="project" value="mp3player"/>
    <property name="java_main" value="com/dctl/mp3/Player"/>
    <property name="java_libraries" value="dct_cldc,dct_midp,java_hardware,jreceiver,kxmlrpc,kxml,jar"/>
    <property name="extra_bsps" value="vs2000_evb_da:1.0"/>
    <property name="extra_libraries" value="xlcd"/>
    <property name="extra_librarypath" value=""/>
    <property name="debug.hw" value="no"/>
    <property environment="env"/>
    <property name="buildfile" value="${env.LF_HOME}/etc/lightfootJavaApp.xml"/>
   
    <!-- Initialisation task - these are things that take longer to run and
        not needed for a clean
    -->
    <target name="init">
        <!-- Define the name of files to convert into asm files for -->
        <property name="bytefiles.ref" value="bytefiles"/>
        <property name="bytefiles.classname" value="com.dctl.mp3.gui.ImageData"/>
        <property name="bytefiles.prefix" value="get"/>
        <property name="bytefiles.postfix" value="Data"/>
        <path id="bytefiles">
            <fileset dir="${basedir}">
                <include name="*.png"/>
            </fileset>
        </path>
    </target>

    &standard;   
</project>

There are a number of different sections in this file.

ant_setup.xml

The ant_setup.xml file found in the examples directory contains everything that is needed to invoke the lightfootJavaApp.xml build file. This file needs to be included in your application's build file. This is included using the '&standard;' line.

Properties

You need to define a number of properties to get your application to build. As a minimum, you must define the following properties
Property
Description
project
Name of the project. This is used to name output files
java_main
Java class containing the main method
java_libraries
The java libraries to use.
buildfile
The name of the file to use for building, for an application it should be ${env.LF_HOME}/etc/lightfootJavaApp.xml

A full list of properties can be found here.

Initialisation task

You must provide an initialisation task to build any additional files required. Most applications should just have a blank task, but the MP3Player has to create assembler files from PNG icon files and must initialise the properties to cause this to happen.

Using ANT to build libraries

The easiest way to use ANT to build a library is to use the lightfootJavaLib.xml build file found in the etc directory of the SDK. The following build file, taken from the KXMLRPC example shows how to use this.

<?xml version="1.0" ?>
<!DOCTYPE project [
    <!ENTITY standard SYSTEM "file:../ant_setup.xml">
]>

<project name="java_watchdog" default="build">
    <!-- Define various properties -->
    <property name="library" value="kxmlrpc"/>
    <property name="java_libraries" value="dct_cldc,kxml"/>
    <property name="debug" value="yes"/>
    <property environment="env"/>
    <property name="buildfile" value="${env.LF_HOME}/etc/lightfootJavaLib.xml"/>
   
    <!-- non clean initialisation -->
    <target name="init">
    </target>
   
    &standard;
</project>

This is very similar to building a Java application, but for libraries, the following properties must be set.
Property
Description
library
Name of the library. This is used to name output files
java_libraries
The java libraries to reference while building
buildfile
The name of the file to use for building, for a library it should be ${env.LF_HOME}/etc/lightfootJavaLib.xml

A full list of properties can be found here.

Lightfoot ANT properties

The complete list of ANT properties that can be set is shown below
Property
Description
project
Name of the project and used to name output files
java_main
Main class in an application
java_libraries
Java libraries used
debug
Set to yes to build a debug application
debug.libs
Set to yes to link with debug libraries
debug.bsp
Set to yes to link with a debug BSP
extra_bsps
Any additional BSPs to use. This is a comma separated list, with the BSP name and version number colon separated
extra_libraries
Additional libraries to use
extra_librarypath
Search path for any additional libraries
extra_classes
Names of additional classes to include with the application
debug.hw
Set to yes to build with hardware debug support
xip.enabled
Set to yes to execute in place
xip.romsize
Set to the size of the ROM/Flash memory
xip.romoffset
Set to the offset to start the ROM/Flash memory at
buildfile
Name of the main build file
bytefiles.ref
Name of the reference that lists all files to convert to bytes. These files are converted to assembler files and made available as native methods in the class specified by bytefiles.classname. The methods are named 'byte[] <bytefiles.prefix><filename><bytefiles.postfix>()'.
The file name is capitalised
bytefiles.classname
Name of the class that contains the bytefilles
bytefiles.prefix
Prefix for the bytefiles methods
bytefiles.postfix
Prefix for the bytefiles methods


Lightfoot ANT tasks

The following ANT tasks are available.