<?xml version="1.0" encoding="UTF-8"?>
<!--
  	ANT
 
  	Copyright 2012-2023 IS2T. All rights reserved.
	Modification and distribution is permitted under certain conditions.
  	IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->
<project name="soar" default="soarOnly" xmlns:unless="ant:unless">

	<!-- 
		Launch the SOAR on the Java application
		
		Output property:
			- soar.output.file: soar file  
	-->
	<import file="init.xml"/>
	<import file="soar2Definition.xml"/>
	<import file="activity.xml"/>
	
	<target name="activity/soar">		
		<!-- Display the capability-->
		<condition property="soar.activity.msg.capability" value="Mono-Sandbox">
			<or>
				<equals arg1="${com.microej.architecture.capability}" arg2="mono"/>
				<equals arg1="${com.microej.architecture.capability}" arg2="single"/>
			</or>
		</condition>
		<condition property="soar.activity.msg.capability" value="Multi-Sandbox">
			<equals arg1="${com.microej.architecture.capability}" arg2="multi"/>
		</condition>
		<condition property="soar.activity.msg.capability" value="Tiny-Sandbox">
			<equals arg1="${com.microej.architecture.capability}" arg2="tiny"/>
		</condition>
		<start.subactivity
			activity.id="${soar.activity.id}"
			message="${soar2.activity.msg} (${soar.activity.msg.capability})"
			parent.activity.id="${activity.root.id}"
		/>
	</target>
	
	<target name="soar/init" depends="activity/soar, soar/defaultProperties, soar/checkProperties"/>
		
	<target name="soar" depends="soar/init, soar2/do">
		<property name="soar.output.file" location="${soar.output.dir}/${soar.root.name}.o"/>
	</target>
	
	<!-- Target without dependencies that can be overridden -->
	<target name="soar2-r/do">
		<soar2-r/>	
	</target>

	<target name="soar2-o/do">
		<soar2-o/>		
	</target>
	
	<target name="soar2/do" depends="soar2-r/do,soar2-o/do">
	</target>
	
	<target name="soar/defaultProperties">
		<!-- Set default properties values -->
		<property name="soar.ni" value="true"/>
		<property name="application.allocation.policy.file" value=""/>
		<property name="soar.aot.compiler" value="false"/>
		<condition property="soar.disableStringCompaction" value="false" else="true">
			<contains string="${com.microej.architecture.capability}" substring="tiny" casesensitive="false"/>
		</condition>
		<property name="soar.expertMode" value="true"/>
		<property name="soar.debugMode" value="true"/>
		<condition property="soar.checkAPIs" value="true" else="false">
			<istrue value="${apis.check.enable}"/>
		</condition>
		<property name="soar.clinit.mode" value="strict"/>
		<property name="soar.legacyPropertiesLoad" value="false"/>
		<propertyset id="build.propertyset">
			<propertyset refid="init.build.properties"/>
		</propertyset>
		<property name="soar.bytecode.verifier" value="false"/>
		<property name="soar.generate.classnames" value="false"/>
		<!-- Legacy CLDC 1.3 compliance (disabled by default) -->
		<property name="cldc.13.compliance" value="false"/>
		<!-- Assertions Execution (disabled by default) -->
		<property name="core.assertions.emb.enabled" value="false"/>		
		<!-- Group all selected methods into a single ELF section -->
		<property name="com.microej.soar.groupMethods.enabled" value="false"/>	

		<!-- Define empty test options if not set by the testsuite module -->
		<property name="com.microej.soar.asmverify.file" value=""/>		
		<property name="com.microej.soar-r.errordescription.file" value=""/>		
		<property name="com.microej.soar-o.errordescription.file" value=""/>	
		<!-- '.debug.soar' section generation (enabled by default) -->
		<property name="com.microej.soar.debuginfos.enabled" value="true"/>		
		<!-- 
			Feature Portabilitiy Control options (disabled by default)
		-->
		<property name="com.microej.soar.kernel.featureportabilitycontrol.enabled" value="false"/>			
		<property name="com.microej.soar.kernel.featureportabilitycontrol.metadata.path" value=""/>	
		<condition property="soar.featureportabilitycontrol.metadata.path" value="${com.microej.soar.kernel.featureportabilitycontrol.metadata.path}" else="">
			<istrue value="${com.microej.soar.kernel.featureportabilitycontrol.enabled}"/>
		</condition>
		
		<condition property="com.microej.architecture.capability.multi" value="true" else="false">
			<equals arg1="${com.microej.architecture.capability}" arg2="multi"/>
		</condition>

		<!-- Set a default value without a warning for "com.microej.soar.kernel.featurecodechunk.size" when not in multi-sandbox -->
		<property name="com.microej.soar.kernel.featurecodechunk.size" value="0" unless:true="${com.microej.architecture.capability.multi}"/>
	
		<defineOption name="com.microej.soar.kernel.featurecodechunk.size" defaultValue="65536"/>
	</target>
	
	<target name="soar/checkProperties">
		<!-- Check properties -->
		
		<!-- If the AOT compiler is enable, the compiler.cpu property must be set.	-->
		<fail message="Please define the 'compiler.cpu' property">
			<condition>
			<and>
				<istrue value="${soar.aot.compiler}"/>
				<not><isset property="compiler.cpu"/></not>
			</and>
			</condition>
		</fail>
		<fail unless="arch.endianness" message="Please define the 'arch.endianness' property"/>
		<fail unless="arch.symbol.prefix" message="Please define the 'arch.symbol.prefix' property"/>
		<fail unless="decimal.impl" message="Please define the 'decimal.impl' property"/>
	</target>

	<!-- Intern entry point to stop just after SOAR execution -->
	<target name="soarOnly" depends="init, soar/init, soar2-r/do, soar2-o/do"/>

</project>
