<project name="generator" basedir="/dev/null">
	<import file="build-definitions.xml"/>

	<!-- Compiles the Java generator source code -->
    <target name="-generate-common" description="Performs up for the generators and compiles common classes for the templates.">            
        <condition property="javac.args.debug" value="-Ageneratechecks" else="-Anogeneratechecks">
            <istrue value="${enable_debug}"/>
        </condition>

        <mkdir dir="${lwjgl.target.gen.java}/"/>
        <mkdir dir="${lwjgl.target.gen.classes}"/>

		<!-- Compile helper classes used by the templates -->
        <javac debug="yes" srcdir="${lwjgl.src.java}" destdir="${lwjgl.target.gen.classes}" source="1.8" target="1.8" taskname="generator">
			<compilerarg value="-sourcepath"/>
			<compilerarg value="${lwjgl.src.java}:${lwjgl.src.stubs}"/>
            <include name="org/lwjgl/PointerWrapper.java"/>
            <include name="org/lwjgl/PointerBuffer.java"/>
		</javac>
	</target>

	<!-- Proxy target to generate it all -->
	<target name="generate-all" depends="-generate-common" description="Generates java and native source">
		<parallel>
			<antcall target="generate-openal"/>
			<antcall target="generate-opengles"/>

			<sequential>
				<antcall target="-compile-opencl-helpers"/>

				<parallel>
					<antcall target="generate-opengl"/>
					<antcall target="generate-opencl"/>
				</parallel>
			</sequential>
		</parallel>
	</target>

	<!-- ********************************************************************************
		*********************************************************************************
											OPENAL
		*********************************************************************************
		****************************************************************************  -->

	<!-- Generate OpenAL -->
	<target name="generate-openal" description="Generates java and native source for AL">            
        <mkdir dir="${lwjgl.target.gen.native}/openal"/>

        <javac debug="yes" srcdir="${lwjgl.src.java}" destdir="${lwjgl.target.gen.classes}" source="1.8" target="1.8" includes="org/lwjgl/util/generator/**.java" taskname="generator">
			<compilerarg value="-sourcepath"/>
			<compilerarg value="${lwjgl.src.java}:${lwjgl.src.stubs}"/>
            <include name="org/lwjgl/util/generator/openal/**.java"/>
			<compilerarg value="-Xlint:none"/>
		</javac>

		<javac destdir="${lwjgl.target.gen.native}/openal" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.al}" fork="true" taskname="GeneratorProcessor+OpenAL">
            <compilerarg value="-proc:only"/>
            <compilerarg value="-processor"/>
            <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
			<compilerarg value="-processorpath"/>
            <compilerarg path="${lwjgl.target.gen.classes}"/>
            <compilerarg value="-cp"/>
            <compilerarg path="${lwjgl.target.gen.classes}"/>
            <compilerarg value="-s"/>
            <compilerarg path="${lwjgl.target.gen.java}"/>
            <compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
			<compilerarg value="-AgenNativePath=${lwjgl.target.gen.native}/openal"/>
            <compilerarg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
			<compilerarg value="${javac.args.debug}"/>
			<compilerarg value="-J-XX:CompileThreshold=1"/>
            <src>
                <fileset dir="${lwjgl.src.templates.al}">
                    <include name="${openal-template-pattern}"/>
                </fileset>
            </src>                        
        </javac>
	</target>

	<!-- ********************************************************************************
		*********************************************************************************
										OPENGL
		*********************************************************************************
		****************************************************************************  -->

	<!-- Generate OpenGL -->
	<target name="generate-opengl" description="Generates java and native source for GL">
        <mkdir dir="${lwjgl.target.gen.native}/opengl"/>

        <javac debug="yes" srcdir="${lwjgl.src.java}" destdir="${lwjgl.target.gen.classes}" source="1.8" target="1.8" includes="org/lwjgl/util/generator/**.java" taskname="generator">
			<compilerarg value="-sourcepath"/>
			<compilerarg value="${lwjgl.src.java}:${lwjgl.src.stubs}"/>
            <include name="org/lwjgl/util/generator/opengl/**.java"/>
			<compilerarg value="-Xlint:none"/>
		</javac>

        <!-- Compile helper classes used by the templates -->
        <javac debug="yes" srcdir="${lwjgl.src.java}" destdir="${lwjgl.target.gen.classes}" source="1.8" target="1.8" taskname="generator">
			<compilerarg value="-sourcepath"/>
			<compilerarg value="${lwjgl.src.java}:${lwjgl.src.stubs}"/>
			<include name="org/lwjgl/opengl/GLSync.java"/>
            <include name="org/lwjgl/opengl/AMDDebugOutputCallback.java"/>
            <include name="org/lwjgl/opengl/ARBDebugOutputCallback.java"/>
			<include name="org/lwjgl/opengl/KHRDebugCallback.java"/>
		</javac>

		<parallel>
			<javac destdir="${lwjgl.target.gen.native}/opengl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="GeneratorProcessor+OpenGL">
	            <compilerarg value="-proc:only"/>
	            <compilerarg value="-processor"/>
	            <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
				<compilerarg value="-processorpath"/>
	            <compilerarg path="${lwjgl.target.gen.classes}"/>
	            <compilerarg value="-cp"/>
			    <compilerarg path="${lwjgl.target.gen.classes}"/>
	            <compilerarg value="-s"/>
	            <compilerarg path="${lwjgl.target.gen.java}"/>
	            <compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
				<compilerarg value="-AgenNativePath=${lwjgl.target.gen.native}/opengl"/>
	            <compilerarg value="${javac.args.debug}"/>
	            <compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
	            <compilerarg value="-Acontextspecific"/>
			<compilerarg value="-J-XX:CompileThreshold=1"/>
		        <src>
	                <fileset dir="${lwjgl.src.templates.gl}">
	                    <include name="${opengl-template-pattern}"/>
	                </fileset>
	            </src>
	        </javac>

	        <!-- Generate OpenGL references -->
		    <javac destdir="${lwjgl.target.gen.native}/opengl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="GLReferencesGeneratorProcessor">
				<compilerarg value="-proc:only"/>
	            <compilerarg value="-processor"/>
	            <compilerarg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessor"/>
				<compilerarg value="-processorpath"/>
	            <compilerarg path="${lwjgl.target.gen.classes}"/>
	            <compilerarg value="-cp"/>
	            <compilerarg path="${lwjgl.target.gen.classes}"/>
	            <compilerarg value="-s"/>
	            <compilerarg path="${lwjgl.target.gen.java}"/>
	            <compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
			<compilerarg value="-J-XX:CompileThreshold=1"/>
	            <src>
	                <fileset dir="${lwjgl.src.templates.gl}">
	                    <include name="${opengl-template-pattern}"/>
	                </fileset>
	            </src>
	        </javac>

		    <!-- Generate OpenGL context capabilities -->
	        <javac destdir="${lwjgl.target.gen.native}/opengl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="GLGeneratorProcessor">
		        <compilerarg value="-proc:only"/>
			    <compilerarg value="-processor"/>
		        <compilerarg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessor"/>
				<compilerarg value="-processorpath"/>
	            <compilerarg path="${lwjgl.target.gen.classes}"/>
	            <compilerarg value="-cp"/>
	            <compilerarg path="${lwjgl.target.gen.classes}"/>
	            <compilerarg value="-s"/>
	            <compilerarg path="${lwjgl.target.gen.java}"/>
	            <compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
	            <compilerarg value="${javac.args.debug}"/>
	            <compilerarg value="-Acontextspecific"/>
			<compilerarg value="-J-XX:CompileThreshold=1"/>
	            <src>
	                <fileset dir="${lwjgl.src.templates.gl}">
	                    <include name="${opengl-template-pattern}"/>
	                </fileset>
	            </src>
			</javac>
		</parallel>
	</target>

	<!-- ********************************************************************************
		*********************************************************************************
											OPENGL ES
		*********************************************************************************
		****************************************************************************  -->

	<!-- Generate OpenGL ES -->
	<target name="generate-opengles" description="Generates java and native source for GL ES">
        <mkdir dir="${lwjgl.target.gen.native}/opengles"/>

        <javac debug="yes" srcdir="${lwjgl.src.java}" destdir="${lwjgl.target.gen.classes}" source="1.8" target="1.8" includes="org/lwjgl/util/generator/**.java" taskname="generator">
			<compilerarg value="-sourcepath"/>
			<compilerarg value="${lwjgl.src.java}:${lwjgl.src.stubs}"/>
			<include name="org/lwjgl/util/generator/opengles/**.java"/>
			<compilerarg value="-Xlint:none"/>
		</javac>

        <!-- Compile helper classes used by the templates -->
        <javac debug="yes" srcdir="${lwjgl.src.java}" destdir="${lwjgl.target.gen.classes}" source="1.8" target="1.8" taskname="generator">
			<compilerarg value="-sourcepath"/>
			<compilerarg value="${lwjgl.src.java}:${lwjgl.src.stubs}"/>
			<include name="org/lwjgl/opengles/EGLImageOES.java"/>
			<include name="org/lwjgl/opengles/KHRDebugCallback.java"/>
		</javac>

		<parallel>
        <javac destdir="${lwjgl.target.gen.native}/opengles" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="GeneratorProcessor+OpenGLES">
            <compilerarg value="-proc:only"/>
            <compilerarg value="-processor"/>
            <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
			<compilerarg value="-processorpath"/>
            <compilerarg path="${lwjgl.target.gen.classes}"/>
            <compilerarg value="-cp"/>
            <compilerarg path="${lwjgl.target.gen.classes}"/>
            <compilerarg value="-s"/>
            <compilerarg path="${lwjgl.target.gen.java}"/>
            <compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
			<compilerarg value="-AgenNativePath=${lwjgl.target.gen.native}/opengles"/>
            <compilerarg value="${javac.args.debug}"/>
            <!--<compilerarg value="-Acontextspecific"/>-->
            <compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
			<compilerarg value="-J-XX:CompileThreshold=1"/>
            <src> 
                <fileset dir="${lwjgl.src.templates.gles}">
                    <include name="${opengles-template-pattern}"/>
                </fileset>
            </src>
        </javac>

        <!-- Generate OpenGL ES context capabilities -->
        <javac destdir="${lwjgl.target.gen.native}/opengles" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="GLESGeneratorProcessor">
            <compilerarg value="-proc:only"/>
            <compilerarg value="-processor"/>
            <compilerarg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessor"/>
			<compilerarg value="-processorpath"/>
            <compilerarg path="${lwjgl.target.gen.classes}"/>
            <compilerarg value="-cp"/>
            <compilerarg path="${lwjgl.target.gen.classes}"/>
            <compilerarg value="-s"/>
            <compilerarg path="${lwjgl.target.gen.java}"/>
            <compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
            <compilerarg value="${javac.args.debug}"/>
            <!--<compilerarg value="-Acontextspecific"/>-->
			<compilerarg value="-J-XX:CompileThreshold=1"/>
            <src> 
                <fileset dir="${lwjgl.src.templates.gles}">
                    <include name="${opengles-template-pattern}"/>
                </fileset>
            </src>
        </javac>
		</parallel>
	</target>

	<!-- ********************************************************************************
		*********************************************************************************
											OPENCL
		*********************************************************************************
		****************************************************************************  -->

    <target name="-compile-opencl-helpers" description="Compiles java helpers for CL">
        <!-- Compile helper classes used by the templates -->
        <javac debug="yes" srcdir="${lwjgl.src.java}" destdir="${lwjgl.target.gen.classes}" source="1.8" target="1.8" taskname="generator">
			<compilerarg value="-sourcepath"/>
			<compilerarg value="${lwjgl.src.java}:${lwjgl.src.stubs}"/>
            <include name="org/lwjgl/opencl/CLPlatform.java"/>
            <include name="org/lwjgl/opencl/CLDevice.java"/>
            <include name="org/lwjgl/opencl/CLContext.java"/>
            <include name="org/lwjgl/opencl/CLCommandQueue.java"/>
            <include name="org/lwjgl/opencl/CLMem.java"/>
			<include name="org/lwjgl/opencl/CL*Callback.java"/>
            <include name="org/lwjgl/opencl/CLNativeKernel.java"/>
            <include name="org/lwjgl/opencl/CLFunctionAddress.java"/>
		</javac>
    </target>

    <target name="generate-opencl" description="Generates java and native source for CL">
        <mkdir dir="${lwjgl.target.gen.native}/opencl"/>

        <javac debug="yes" srcdir="${lwjgl.src.java}" destdir="${lwjgl.target.gen.classes}" source="1.8" target="1.8" includes="org/lwjgl/util/generator/**.java" taskname="generator">
			<compilerarg value="-sourcepath"/>
			<compilerarg value="${lwjgl.src.java}:${lwjgl.src.stubs}"/>
            <include name="org/lwjgl/util/generator/opencl/**.java"/>
			<compilerarg value="-Xlint:none"/>
		</javac>

		<parallel>
		<javac destdir="${lwjgl.target.gen.native}/opencl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="GeneratorProcessor+OpenCL">
            <compilerarg value="-proc:only"/>
            <compilerarg value="-processor"/>
            <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
			<compilerarg value="-processorpath"/>
            <compilerarg path="${lwjgl.target.gen.classes}"/>
            <compilerarg value="-cp"/>
            <compilerarg path="${lwjgl.target.gen.classes}"/>
            <compilerarg value="-s"/>
            <compilerarg path="${lwjgl.target.gen.java}"/>
            <compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
			<compilerarg value="-AgenNativePath=${lwjgl.target.gen.native}/opencl"/>
            <compilerarg value="${javac.args.debug}"/>
            <compilerarg value="-Acontextspecific"/>
            <compilerarg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
			<compilerarg value="-J-XX:CompileThreshold=1"/>
            <src>
                <fileset dir="${lwjgl.src.templates.cl}">
                    <include name="${opencl-template-pattern}"/>
                </fileset>
            </src>
        </javac>

        <!-- Generate OpenCL capabilities -->
        <javac destdir="${lwjgl.target.gen.native}/opencl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="CLGeneratorProcessor">
            <compilerarg value="-proc:only"/>
            <compilerarg value="-processor"/>
            <compilerarg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessor"/>
			<compilerarg value="-processorpath"/>
            <compilerarg path="${lwjgl.target.gen.classes}"/>
            <compilerarg value="-cp"/>
            <compilerarg path="${lwjgl.target.gen.classes}"/>
            <compilerarg value="-s"/>
            <compilerarg path="${lwjgl.target.gen.java}"/>
            <compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
            <compilerarg value="${javac.args.debug}"/>
            <compilerarg value="-Acontextspecific"/>
			<compilerarg value="-J-XX:CompileThreshold=1"/>
            <src>
                <fileset dir="${lwjgl.src.templates.cl}">
                    <include name="${opencl-template-pattern}"/>
                </fileset>
            </src>
        </javac>
		</parallel>
    </target>
</project>
