Generating ImportAll.hx with Ant

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Generating ImportAll.hx with Ant

François Rey
In order to create a swf library with haxe one has to create a class file that
imports all other classes to be placed within the swf and then compile that
class.

Using regular Ant I was able to dynamically generate such class file.
Here is a copy of that target in case it might interest others

<property name="import-all.filename" value="ImportAll.hx"/>
<target name="gen-import-all"
                description="Generates dummy class importing all other classes">
        <pathconvert property="import.statements"
                                pathsep="${line.separator}">
                <fileset dir="${src.dir}">
                        <include name="**/*.hx"/>
                        <exclude name="${import-all.filename}"/>
                </fileset>
                <packagemapper from="${basedir}/${src.dir}/*.hx" to="import *;"/>
        </pathconvert>
        <echo message="${import.statements}"
                file="${src.dir}/${import-all.filename}"/>
</target>
               


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Generating ImportAll.hx with Ant

François Rey
On Saturday 03 April 2010 00:15:07 François Rey wrote:
> In order to create a swf library with haxe one has to create a class file
> that imports all other classes to be placed within the swf and then
> compile that class.
>
> Using regular Ant I was able to dynamically generate such class file.
> Here is a copy of that target in case it might interest others

Here is a version that also works on windows.
Adapt to your needs.

# Use ${file.separator} instead of / or \ within all properties
# used by packagemapper from element.
# Otherwise packagemapper won't work on all systems
<property name="src.subdir" value="${src.dir}${file.separator}src-subdir"/>
<property name="import-all.filename" value="ImportAll.hx"/>
<target name="flash-std-gen-import-all"
                description="Generates dummy class importing all other classes">
        <pathconvert property="import.flash.standard.classes"
                        pathsep="${line.separator}">
                <fileset dir="${src.subdir}">
                        <include name="**/*.hx"/>
                        <exclude name="${import-all.filename}"/>
                </fileset>
                <packagemapper
                       
from="${basedir}${file.separator}${src.subdir}${file.separator}*.hx"
                        to="import *;"/>
        </pathconvert>
        <echo message="${import.flash.standard.classes}"
                file="${src.subdir}/${import-all.filename}"/>
</target>
               

--
haXe - an open source web programming language
http://haxe.org