<?xml version="1.0" encoding="UTF-8"?>

<!--
  + Compile sleigh languages within this module.
  + Eclipse: right-click on this file and choose menu item "Run As->Ant Build"
  + From command line (requires ant install)
  +    - cd to data directory containing this file
  +    - run ant
  -->
                                     
<project name="privateBuildDeveloper" default="sleighCompile">
	
	<property name="sleigh.compile.class" value="ghidra.pcodeCPort.slgh_compile.SleighCompile"/>

	<property name="repo.dir" value="../../../.." />
	<property name="repo.marker.dir" value="${repo.dir}/.git" />
	
	<!--Import optional ant properties.  GhidraDev Eclipse plugin produces this so this file can find the Ghidra installation-->
	<import file="../.antProperties.xml" optional="true" />
	
	<condition property="devmode">
		<available file="${repo.marker.dir}" type="dir" />
	</condition>

	<target name="buildSleighClasspathDev" if="devmode">
		
		<property name="framework.path" value="${repo.dir}/../ghidra.git/Ghidra/Framework"/>
		<property name="libs.path" value="${repo.dir}/../ghidra.bin.git/ExternalLibraries/libsForRuntime"/>
		
		<path id="sleigh.class.path">
			<pathelement location="${framework.path}/SoftwareModeling/bin"/>
			<pathelement location="${framework.path}/Generic/bin"/>
			<pathelement location="${framework.path}/Utility/bin"/>
			<fileset dir="${libs.path}">
				<include name="*.jar"/>
			</fileset>
		</path>
			
		<available classname="${sleigh.compile.class}" classpathref="sleigh.class.path" property="sleigh.compile.exists"/>
			
	</target>
	
	<target name="buildSleighClasspathDist" unless="devmode">

		<!-- If language module is detached from installation, get Ghidra installation directory path from imported properties -->
		<condition property="framework.path" value="${ghidra.install.dir}/Ghidra/Framework" else="../../../Framework">
			<available file="${ghidra.install.dir}" type="dir" />
		</condition>
		
		<path id="sleigh.class.path">
			<fileset dir="${framework.path}/SoftwareModeling/lib">
				<include name="*.jar"/>
			</fileset>
			<fileset dir="${framework.path}/Generic/lib">
				<include name="*.jar"/>
			</fileset>
			<fileset dir="${framework.path}/Utility/lib">
				<include name="*.jar"/>
			</fileset>
		</path>
		<available classname="${sleigh.compile.class}" classpathref="sleigh.class.path" property="sleigh.compile.exists"/>
			
	</target>	
		
	<target name="sleighCompile" depends="buildSleighClasspathDist, buildSleighClasspathDev">
	    
		<fail unless="sleigh.compile.exists" />
		
		<java classname="${sleigh.compile.class}"
			classpathref="sleigh.class.path"
			fork="true"
			failonerror="true">
			<jvmarg value="-Xmx2048M"/>
			<arg value="-a"/>
			<arg value="./languages"/>
		</java>
		
 	</target>

</project>
