<?xml version="1.0" encoding="UTF-8"?>
<!--
  	ANT
 
	Copyright 2012-2024 MicroEJ Corp. All rights reserved.
	This library is provided in source code for use, modification and test, subject to license terms.
	Any modification of the source code will break MicroEJ Corp. warranties on the whole library.
-->
<project name="application">

	<import file="${ant.file.application}/../../extension-init.xml" />
	<import file="${ant.file.application}/../../microejAntlib.xml" />

		
	<target name="init/application" extensionOf="init/execution" depends="resources, immutables, requires, classpath, buildProperties">
		<echo message="Application init" level="verbose"/>
		
		<!-- MicroEJ 3 backward compatible for jpf.property.header prefix -->
		<local name="appinit.jpf.property.header"/>
		<condition property="appinit.jpf.property.header" value="${jpf.property.header}" else="">
			<isset property="jpf.property.header"/>
		</condition>
		
		<!-- 
			Default properties if the MemPage isn't provided by the Workbench Extension (pure simJPF)
		-->
		<property name="${appinit.jpf.property.header}core.memory.javaheapsum.size" value="0"/>
			
		<nestedProperty output="jpf.core.memory.javaheapsum.size" input="${appinit.jpf.property.header}core.memory.javaheapsum.size" />
	</target>
		
		
	<target name="dyninit/application" extensionOf="dyninit/execution" depends="resources, immutables, requires, classpath"/>

	<target name="classpath">
		<!-- add application classpath to global one -->
		<augment id="init.application.classpath">
			<path path="${application.classpath}"/>
		</augment>
	</target>
		
	<target name="requires" if="application.require">
		<!-- add application requires to global ones -->
		<augment id="init.requires">
			<string value="${application.require}"/>
		</augment>
	</target>

	<target name="resources" if="application.resources">
		<!-- add application resources to global ones -->
		<augment id="init.resources">
			<string value="${application.resources}"/>
		</augment>
	</target>
		
	<target name="immutables" if="application.immutables">
		<!-- add application immutables to global ones -->
		<augment id="init.immutables">
			<string value="${application.immutables}"/>
		</augment>
	</target>
	
	<target name="buildProperties">
		<!-- add platform idenfification properties to build properties -->
		<augment id="init.build.properties">
			<propertyref name="com.microej.platform.edition"/>
			<propertyref name="com.microej.platform.architecture"/>
			<propertyref name="com.microej.platform.hardwarePartNumber"/>
			<propertyref name="com.microej.platform.toolchain"/>
			<propertyref name="com.microej.platform.name"/>
			<propertyref name="com.microej.platform.provider"/>
			<propertyref name="com.microej.platform.version"/>
			<propertyref name="com.microej.platform.baseline"/>
			<propertyref name="com.microej.platform.licenseTag"/>
			<propertyref name="com.microej.platform.level"/>
			<mapper type="glob" from="com.microej.*" to="*"/>
		</augment>
	</target>

</project>