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

  Copyright 2017-2025 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="trace.mock-init">

	<import file="${scripts.dir}/extension-init.xml" />

	<!-- Default values for properties set by the MicroEJ launcher -->
	<property name="core.trace.enabled" value="false"/>
	<property name="core.trace.autostart" value="false"/>
		
	<!--
		Add the mock trace classpath in HIL or S3 classpath.
		By default, update HIL classpath (== run mock trace with HIL)
		Set property ${mocktrace.runWithS3} in a 'init/context' target to run mock trace with S3.
		(note: this property must be only set when ${onS3} is set)
	-->	
	
	<target name="init/trace.mock-sim/exec" if="onS3">
		<echo message="Mock Trace init" level="verbose" />
		
		<!-- checks two properties actually: ${mocktrace.runWithS3} AND ${onS3} -->
		<condition property="mocktrace.runWithHIL">
			<not><isset property="mocktrace.runWithS3"/></not>
		</condition>
		
		<property name="trace.mock.enabled" value="${core.trace.enabled}"/>
		<property name="trace.mock.autoStart" value="${core.trace.autostart}"/>
	</target>
	
	<target name="init/trace.mock-sim/hil" extensionOf="init/execution" depends="init/trace.mock-sim/exec" if="mocktrace.runWithHIL">
		<augment id="hil.main.classpath">
			<fileset dir="${platform.dir}/mocks" includes="mocktrace-mock.jar"/>
		</augment>
		<augment id="hil.main.properties">
			<propertyref name="trace.mock.enabled"/>
			<propertyref name="trace.mock.autoStart"/>
		</augment>
	</target>
	
	<target name="init/trace.mock-sim/s3" extensionOf="init/execution" depends="init/trace.mock-sim/exec" if="mocktrace.runWithS3">
		<augment id="s3.mock.includes">
			<fileset dir="${platform.dir}/mocks" includes="mocktrace-mock.jar"/>
		</augment>
	</target>
	
</project>