summaryrefslogtreecommitdiff
path: root/tests/src/CLRTest.CrossGen.targets
blob: efbe05732bf8f4022ea445892c62af992ba7e359 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!--
***********************************************************************************************
CLRTest.Execute.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your projects from the command-line or the IDE.

This file contains the logic for providing Execution Script generation.

WARNING:   When setting properties based on their current state (for example:
           <Foo Condition="'$(Foo)'==''>Bar</Foo>).  Be very careful.  Another script generation
           target might be trying to do the same thing.  It's better to avoid this by instead setting a new property.
           
           Additionally, be careful with itemgroups.  Include will propagate outside of the target too!

***********************************************************************************************
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <BashScriptSnippetGen>$(BashScriptSnippetGen);GetCrossgenBashScript</BashScriptSnippetGen>
    <BatchScriptSnippetGen>$(BatchScriptSnippetGen);GetCrossgenBatchScript</BatchScriptSnippetGen>
  </PropertyGroup>
  <ItemGroup>
    <CLRTestBashEnvironmentVariable  Condition="'$(CrossGenTest)' == 'true'" Include = "export RunCrossGen=1"/>
    <CLRTestBatchEnvironmentVariable Condition="'$(CrossGenTest)' == 'true'" Include = "set RunCrossGen=1"/>
    <CLRTestBashEnvironmentVariable  Condition="'$(CrossGenTest)' == 'false'" Include = "unset RunCrossGen"/>
    <CLRTestBatchEnvironmentVariable Condition="'$(CrossGenTest)' == 'false'" Include = "set RunCrossGen="/>
  </ItemGroup>

  <!--
    This returns the portion of the execution script that generates the required lines to crossgen the test executable.
  -->
  <Target Name="GetCrossgenBashScript">
    
    <PropertyGroup>
      <CrossgenBashScript Condition="'$(CLRTestKind)' == 'BuildAndRun'">
        <![CDATA[
# CrossGen Script
if [ ! -z ${RunCrossGen+x} ]%3B then
    export COMPlus_ZapRequire=$(ZapRequire)
    export COMPlus_ZapRequireList=$(MSBuildProjectName)

    if [ -d IL ]%3B then
        echo Inconsistency, IL dir already exists, reinstall tests
        exit 1
    fi

    mkdir IL
    cp *.{dll,exe} IL/

    __Command="$CORE_ROOT/crossgen $CrossGenOptions /p $CORE_ROOT%3A$PWD/IL /in $PWD/IL/$(MSBuildProjectName).exe /out $PWD/$(MSBuildProjectName).ni.exe"

    echo "Running CrossGen: $__Command"
    $__Command
    __cgExitCode=$?
    if [ $__cgExitCode -ne 0 ]
    then
        mv IL/* .
        rm -rf $(MSBuildProjectName).ni.exe
        rm -rf IL
        echo Crossgen failed with exitcode: $__cgExitCode
        exit 1
    fi

    # Need to copy this to coreroot so that ni gets into TPA list (it's not loaded otherwise)
    mv $(MSBuildProjectName).ni.exe $CORE_ROOT
fi
        ]]>
      </CrossgenBashScript>

      <CrossgenCleanupBashScript Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(CrossGenTest)' != 'false'">
        <![CDATA[
if [ ! -z ${RunCrossGen+x} ] || [ ! -z ${RunCrossGen2+x} ]%3B then
    mv IL/* .
    rm -rf $CORE_ROOT/$(MSBuildProjectName).ni.exe
    rm -rf IL
fi
        ]]>
      </CrossgenCleanupBashScript>

      <BashCLRTestPreCommands>$(BashCLRTestPreCommands);$(CrossgenBashScript)</BashCLRTestPreCommands>
      <BashCLRTestPostCommands>$(BashCLRTestPostCommands);$(CrossgenCleanupBashScript)</BashCLRTestPostCommands>
    </PropertyGroup>
  </Target>

  <Target Name="GetCrossgenBatchScript">
    
    <PropertyGroup>
      <CrossgenBatchScript Condition="'$(CLRTestKind)' == 'BuildAndRun'">
        <![CDATA[

        ]]>
      </CrossgenBatchScript>

      <CLRTestBatchPreCommands>$(CLRTestBatchPreCommands);$(CrossgenBatchScript)</CLRTestBatchPreCommands>
    </PropertyGroup>
  </Target>



</Project>