<?xml version="1.0" encoding="UTF-8"?>
<!--
  ANT Buildfile
 
  Copyright 2013-2023 IS2T. All rights reserved.
  IS2T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->
<project name="partialLinkKFInit">

	<!-- 
		Generate link file for KF
	-->

	<import file="${scripts.dir}/extension-init.xml" />
	<import file="${scripts.dir}/microejAntlib.xml" />
		
	<target name="initDefaultOptions" extensionOf="init/execution">
		<!-- Default options if not set -->
		<property name="apis.check.enable" value="true"/>
		
		<!-- Synchronize these values with KFConfiguration classe -->
		<property name="kf.rule.ignored" value="1"/>
		<property name="kf.rule.warning" value="2"/>
		<property name="kf.rule.error" value="3"/>
		<property name="kf.feature.call.within.kernel.monitor.mode" value="${kf.rule.ignored}"/>
	</target>
	
	<target name="createLinkFileKF" extensionOf="init/execution" if="onBoard">
		<!-- temporary link files -->
		<local name="link.files.dir"/>
		<microejtempfile deleteonexit="true" prefix="linkKF" property="link.files.dir"/>
		<mkdir dir="${link.files.dir}"/>
		
		<local name="link.sizes"/>
		<property name="link.sizes" value="${link.files.dir}/sizes.lscf" />
		
		
		<!-- 
			Set options default values if not set
			(in sync with XPF workbench extension default values)
		-->
		<property name="core.memory.feature.max.threads" value="5"/><!-- Number of maximum Feature threads by default if not set -->
		<!-- Number of dynamic features by default if not set -->
		<defineOption name="com.microej.runtime.kernel.dynamicfeatures.max" defaultValue="16">
			<deprecated name="core.memory.dynamic.features.size"/>
		</defineOption>
		
		<!-- 
			Enable or disable KF RAM Control.
			This property is normally set during VEE Port build and stored in the file '<vee_port_dir>/source/scripts/mjvm.properties'.
			Set to false by default.  
		-->
		<property name="com.microej.runtime.kf.ramcontrol.enabled" value="false"/>
		
		<condition property="com.microej.runtime.kf.ramcontrol.enabled.value" value="2" else="1">
			<equals arg1="${com.microej.runtime.kf.ramcontrol.enabled}" arg2="true" />
		</condition>

		<!-- /!\ These options are not available yet from the Workbench Extension -->
		<property name="core.dump.kernel.uncaught.exception" value="true"/> <!--By default if not set -->

		<!--
			 Symbol == 2 means enable the dump of the stacktrace of an exception thrown when 
			 a feature call a proxy or a kernel method and this exception is not caught by the kernel. 
			 Symbol != 2 means the dump of the stacktrace is disabled.
		-->
		<condition property="core.dump.kernel.uncaught.exception.value" value="2" else="1">
			<istrue value="${core.dump.kernel.uncaught.exception}"/>
		</condition>

		<!-- create the size file -->
		<echoxml file="${link.sizes}" append="false">
			<lscFragment>
				<defSymbol name="_java_max_nb_dynamic_features" value="${com.microej.runtime.kernel.dynamicfeatures.max}" rootSymbol="true"/>
				<defSymbol name="${arch.symbol.prefix}_java_feature_max_nb_threads" value="${core.memory.feature.max.threads}" rootSymbol="true"/>

				<!-- See linkSoarKF.lscf -->
				<defSymbol name="_java_kf_rule_conf_feature_call_within_kernel_monitor" value="${kf.feature.call.within.kernel.monitor.mode}" rootSymbol="true"/>
				
				<defSymbol name="${arch.symbol.prefix}_java_dump_kernel_uncaught_exception" value="${core.dump.kernel.uncaught.exception.value}" rootSymbol="true"/>
			
				<defSymbol name="${arch.symbol.prefix}_java_kf_ram_control_enabled" value="${com.microej.runtime.kf.ramcontrol.enabled.value}" rootSymbol="true"/>
				
			</lscFragment>
		</echoxml>
		
		<augment id="partialLink.lscf.path">
			<path location="${link.files.dir}"/>
		</augment>
	</target>
		
</project>
