[Tizen] Add updated scripts to run tests
[platform/upstream/coreclr.git] / tests / src / CLRTest.CrossGen.targets
1 <!--
2 ***********************************************************************************************
3 CLRTest.Execute.targets
4
5 WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
6           created a backup copy.  Incorrect changes to this file will make it
7           impossible to load or build your projects from the command-line or the IDE.
8
9 This file contains the logic for providing Execution Script generation.
10
11 WARNING:   When setting properties based on their current state (for example:
12            <Foo Condition="'$(Foo)'==''>Bar</Foo>).  Be very careful.  Another script generation
13            target might be trying to do the same thing.  It's better to avoid this by instead setting a new property.
14            
15            Additionally, be careful with itemgroups.  Include will propagate outside of the target too!
16
17 ***********************************************************************************************
18 -->
19 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
20
21   <PropertyGroup>
22     <BashScriptSnippetGen>$(BashScriptSnippetGen);GetCrossgenBashScript</BashScriptSnippetGen>
23     <BatchScriptSnippetGen>$(BatchScriptSnippetGen);GetCrossgenBatchScript</BatchScriptSnippetGen>
24   </PropertyGroup>
25   <ItemGroup>
26     <CLRTestBashEnvironmentVariable  Condition="'$(CrossGenTest)' == 'true'" Include = "export RunCrossGen=1"/>
27     <CLRTestBatchEnvironmentVariable Condition="'$(CrossGenTest)' == 'true'" Include = "set RunCrossGen=1"/>
28     <CLRTestBashEnvironmentVariable  Condition="'$(CrossGenTest)' == 'false'" Include = "unset RunCrossGen"/>
29     <CLRTestBatchEnvironmentVariable Condition="'$(CrossGenTest)' == 'false'" Include = "set RunCrossGen="/>
30   </ItemGroup>
31
32   <!--
33     This returns the portion of the execution script that generates the required lines to crossgen the test executable.
34   -->
35   <Target Name="GetCrossgenBashScript">
36     
37     <PropertyGroup>
38       <CrossgenBashScript Condition="'$(CLRTestKind)' == 'BuildAndRun'">
39         <![CDATA[
40 # CrossGen Script
41 if [ ! -z ${RunCrossGen+x} ]%3B then
42     export COMPlus_ZapRequire=$(ZapRequire)
43     export COMPlus_ZapRequireList=$(MSBuildProjectName)
44
45     if [ -d IL ]%3B then
46         echo Inconsistency, IL dir already exists, reinstall tests
47         exit 1
48     fi
49
50     mkdir IL
51     cp *.{dll,exe} IL/
52
53     __Command="$CORE_ROOT/crossgen $CrossGenOptions /p $CORE_ROOT%3A$PWD/IL /in $PWD/IL/$(MSBuildProjectName).exe /out $PWD/$(MSBuildProjectName).ni.exe"
54
55     echo "Running CrossGen: $__Command"
56     $__Command
57     __cgExitCode=$?
58     if [ $__cgExitCode -ne 0 ]
59     then
60         mv IL/* .
61         rm -rf $(MSBuildProjectName).ni.exe
62         rm -rf IL
63         echo Crossgen failed with exitcode: $__cgExitCode
64         exit 1
65     fi
66
67     # Need to copy this to coreroot so that ni gets into TPA list (it's not loaded otherwise)
68     mv $(MSBuildProjectName).ni.exe $CORE_ROOT
69 fi
70         ]]>
71       </CrossgenBashScript>
72
73       <CrossgenCleanupBashScript Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(CrossGenTest)' != 'false'">
74         <![CDATA[
75 if [ ! -z ${RunCrossGen+x} ] || [ ! -z ${RunCrossGen2+x} ]%3B then
76     mv IL/* .
77     rm -rf $CORE_ROOT/$(MSBuildProjectName).ni.exe
78     rm -rf IL
79 fi
80         ]]>
81       </CrossgenCleanupBashScript>
82
83       <BashCLRTestPreCommands>$(BashCLRTestPreCommands);$(CrossgenBashScript)</BashCLRTestPreCommands>
84       <BashCLRTestPostCommands>$(BashCLRTestPostCommands);$(CrossgenCleanupBashScript)</BashCLRTestPostCommands>
85     </PropertyGroup>
86   </Target>
87
88   <Target Name="GetCrossgenBatchScript">
89     
90     <PropertyGroup>
91       <CrossgenBatchScript Condition="'$(CLRTestKind)' == 'BuildAndRun'">
92         <![CDATA[
93
94         ]]>
95       </CrossgenBatchScript>
96
97       <CLRTestBatchPreCommands>$(CLRTestBatchPreCommands);$(CrossgenBatchScript)</CLRTestBatchPreCommands>
98     </PropertyGroup>
99   </Target>
100
101
102
103 </Project>