<!--
 *
 * Eagle.Sample.targets -
 *
 * WARNING: Contains more evil MSBuild hacks than your doctor recommended.
 *
 * Copyright (c) 2007-2012 by Joe Mistachkin.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: $
 *
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!--
  ******************************************************************************
  **                          Load Per-User Settings                          **
  ******************************************************************************
  -->

  <!--
      NOTE: If the per-user settings file exists, import it now.  The contained
            settings, if any, will override the default ones provided below.
  -->
  <Import Condition="'$(EagleDir)' != '' And
                     !HasTrailingSlash('$(EagleDir)') And
                     Exists('$(EagleDir)\Targets\Eagle.Sample.targets.user')"
          Project="$(EagleDir)\Targets\Eagle.Sample.targets.user" />

  <!--
  ******************************************************************************
  **                           Eagle Sample Targets                           **
  ******************************************************************************
  -->

  <Import Condition="'$(EagleSampleTargets)' != 'false'"
          Project="Eagle.tasks" />

  <!--
  ******************************************************************************
  -->

  <Target Condition="'$(EagleSampleTargets)' != 'false'"
          Name="ProcessSampleScripts"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).ProcessSampleScripts.done">
    <!--
        NOTE: These scripts could do virtually anything.  Here we demonstrate
              something that cannot be easily accomplished by using MSBuild
              alone even though it is fairly trivial.
    -->
    <EvaluateExpression Text="2 + 2">
      <Output TaskParameter="Code" PropertyName="EvaluateExpressionCode" />
      <Output TaskParameter="Result" PropertyName="EvaluateExpressionResult" />
    </EvaluateExpression>

    <EvaluateScript Text="return [file version {$(TargetPath)}]">
      <Output TaskParameter="Code" PropertyName="EvaluateScriptCode" />
      <Output TaskParameter="Result" PropertyName="EvaluateScriptResult" />
    </EvaluateScript>

    <EvaluateFile Text="$(EagleLibraryDir)Tests\data\evaluate.eagle">
      <Output TaskParameter="Code" PropertyName="EvaluateFileCode" />
      <Output TaskParameter="Result" PropertyName="EvaluateFileResult" />
    </EvaluateFile>

    <SubstituteString Text="[file version {$(TargetPath)}]">
      <Output TaskParameter="Code" PropertyName="SubstituteStringCode" />
      <Output TaskParameter="Result" PropertyName="SubstituteStringResult" />
    </SubstituteString>

    <SubstituteFile Text="$(EagleLibraryDir)Tests\data\substitute.eagle">
      <Output TaskParameter="Code" PropertyName="SubstituteFileCode" />
      <Output TaskParameter="Result" PropertyName="SubstituteFileResult" />
    </SubstituteFile>

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).ProcessSampleScripts.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Condition="'$(EagleSampleTargets)' != 'false'"
          Name="ShowSampleScriptOutput"
          DependsOnTargets="ProcessSampleScripts"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).ShowSampleScriptOutput.done">
    <!--
        NOTE: Here, we simply display the output variables produced by the
              ProcessSampleScripts task.
    -->
    <Message Text="EvaluateExpression: $(EvaluateExpressionCode) $(EvaluateExpressionResult)" />
    <Message Text="EvaluateScript: $(EvaluateScriptCode) $(EvaluateScriptResult)" />
    <Message Text="SubstituteString: $(SubstituteStringCode) $(SubstituteStringResult)" />

    <Message Text="EvaluateFile: $(EvaluateFileCode) $(EvaluateFileResult)" />
    <Message Text="SubstituteFile: $(SubstituteFileCode) $(SubstituteFileResult)" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).ShowSampleScriptOutput.done" />
  </Target>
</Project>
