<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements. See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License. You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<document>

    <properties>
        <title>Harmony Development Kit for the Apache Harmony</title>
        <author email="dev@harmony.apache.org">Harmony Documentation Team</author>
    </properties>

    <body>

        <section name="Harmony Development Kit for the Apache Harmony">
            <p>
                The Harmony Development Kit (HDK) allows a Harmony developer to
                rebuild any module of the Harmony Classlib or DRLVM in a standalone way by providing all the
                necessary supplementary binaries and header files. 
                HDK bundles are available for download as a standard part of regular Harmony builds
                (nightly, stable, etc).
                This document describes the layout of such an HDK and its contents.
            </p>

            <subsection name="Layout of the HDK">
                <p>
                    An HDK contains all the header files and binaries, both native and Java, required
                    for a Harmony developer to build against. The directory structure for an
                    HDK is as follows:
<pre>&lt;hdkbase&gt;
    |
    |---build
    |     |---make
    |     |---patternsets
    |     \---test
    |
    |---jdk
    |    |---jre
    |    \---include
    |
    |---include
    |
    \---lib</pre>

                    The directories laid out above are used in the following manner:

                    <ul>
                        <li>
                            <code>&lt;hdkbase&gt;/build/make</code> - this directory contains include
                            files used by native makefiles.
                        </li>

                        <li>
                            <code>&lt;hdkbase&gt;/build/patternsets</code> - this directory contains
                            patternsets describing jar content.
                        </li>

                        <li>
                            <code>&lt;hdkbase&gt;/build/test</code> - this directory contains test
                            support classes, bundled up into a jar file.
                        </li>

                        <li>
                            <code>&lt;hdkbase&gt;/jdk/jre</code> - this directory contains the standard
                            jre layout, including <code>bin</code> and <code>lib</code> directories.
                        </li>

                        <li>
                            <code>&lt;hdkbase&gt;/jdk/include</code> - this directory contains the standard
                            jdk header files. For example, jni.h is held here.
                        </li>

                        <li>
                            <code>&lt;hdkbase&gt;/include</code> - this directory contains header files that
                            are Harmony specific and are used across multiple Harmony modules.
                        </li>

                        <li>
                            <code>&lt;hdkbase&gt;/lib</code> - this directory is used in HDKs on Windows for
                            .lib files and on Linux for .a files necessary for linking during compilation of
                            Harmony natives.
                        </li>
                    </ul>
                </p>
            </subsection>
            <subsection name="Building Classlib Against an HDK">
                <p class="note">Note</p>
                <p class="notetext">The HDK and relevant build system changes are work in progress.
                        Not all of the Ant targets/properties described exist yet, and thus not
                        all of what is described below currently works. This disclaimer will be
                        removed once work on the HDK is completed.</p>
                    <p>
                    The Harmony Class Library can be built at the global or modular level.
                    At the modular level, there are three ways to build:</p>
                    <ul>
                        <li>
                            <b>Building the default target</b> - An HDK is not required here, and the class
                            library is built against and into the default (deploy) directory. This is the
                            standard way to build, and is what happens when you just run <code>ant</code> at the
                            command line.
                        </li>
                        <li>
                            <b>Building against an HDK</b> - The location of an HDK must be specified at
                            the Ant command line, and the output will be built into the default (deploy)
                            directory. The command line for this is <code><nobr>ant -Dhy.hdk=path/to/HDK</nobr></code>.
                        </li>
                        <li>
                            <b>Building against an HDK and into a target directory (TBD)</b> - The location of
                            an HDK and of a target directory must be specified on the Ant command line.
                            The Class Library code will be compiled against the libraries contained in
                            the HDK, and the output of those compiles will be placed into the specified
                            target directory. The command line for this is <code><nobr>ant -Dhy.hdk=path/to/HDK
                            -DHY.TARGET=path/to/target</nobr>
                            </code>.
                        </li>
                    </ul>
                    <p class="example">Example</p>
                    <p class="exampletext">
                   If you wanted to build only the luni module against
                    an HDK, and put the resulting artifacts into a separate target directory,
                    do the following:
                    <ol>
                        <li>Checkout the luni module</li>
                        <li>cd into the root directory of the module</li>
                        <li>Execute <code>
                            <nobr>ant -Dhy.hdk=path/to/hdk -DHY.TARGET=path/to/target</nobr>
                        </code></li>
                    </ol></p>
                    <p>The luni Java and native code will be built against the HDK location
                    specified, and all produced binaries placed under the target directory, laid
                    out in the HDK structure described at the top of this page.
                </p>
            </subsection>
        </section>
    </body>
</document>
