[Tizen] Add support for gbs build for i586, x86_64, armv7l, armv7hl, aarch64 (includi...
[platform/upstream/dotnet/runtime.git] / src / tests / Common / 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
26   <!--
27     This returns the portion of the execution script that generates the required lines to crossgen the test executable.
28
29     Tests can opt out of ahead-of-time (AOT) compilation from crossgen / crossgen2 by setting this property in their project:
30
31       <CrossGenTest>false</CrossGenTest>
32   -->
33   <Target Name="GetCrossgenBashScript">
34
35     <PropertyGroup>
36       <CrossgenBashScript Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(CrossGenTest)' != 'false'">
37         <![CDATA[
38 # CrossGen Script
39 if [ ! -z ${RunCrossGen+x} ]%3B then
40     export COMPlus_ZapRequire=$(ZapRequire)
41     export COMPlus_ZapRequireList=$(MSBuildProjectName)
42
43     if [ -d IL ]%3B then
44       echo Inconsistency, IL dir already exists, reinstall tests
45       exit 1
46     fi
47
48     mkdir IL
49     mv *.dll IL/
50
51     for file in `find $PWD/IL -name "*.dll"`%3B do
52       filename=`basename $file`
53       outfile="$PWD/$filename"
54
55       __Command="$CORE_ROOT/crossgen $CrossGenOptions /p $CORE_ROOT%3A$PWD/IL /in $file /out $outfile"
56
57       echo "Running CrossGen: $__Command"
58       COMPlus_MultiCoreJitProfile= $__Command
59       __cgExitCode=$?
60       if [ $__cgExitCode -ne 0 ]
61       then
62         mv IL/* .
63         rm -rf IL
64         echo Crossgen failed for $file with exitcode: $__cgExitCode
65         exit 1
66       fi
67     done
68 fi
69
70 # CrossGen2 Script
71 if [ ! -z ${RunCrossGen2+x} ]%3B then
72     if [ -d IL ]%3B then
73       echo Inconsistency, IL dir already exists, reinstall tests
74       exit 1
75     fi
76
77     mkdir IL
78     mv *.dll IL/
79
80     refs=""
81     for file in `find $CORE_ROOT -maxdepth 1 -name "*.dll" | grep -v ".ni.dll" | grep -v "xunit" `%3B do
82         refs="${refs} -r:$file"
83     done
84     for file in `find $PWD/IL -name "*.dll"`%3B do
85         refs="${refs} -r:$file"
86     done
87
88     extraCrossGen2Args="$(CrossGen2TestExtraArguments)"
89
90     for file in `find $PWD/IL -name "*.dll"`%3B do
91       filename=`basename $file`
92       outfile="$PWD/$filename"
93
94       __Command="$CORE_ROOT/corerun $CORE_ROOT/crossgen2/crossgen2.dll $CrossGen2Options $extraCrossGen2Args -o%3A$outfile $file ${refs}"
95
96       echo "Running CrossGen2: $__Command"
97       COMPlus_MultiCoreJitProfile= $__Command
98       __cg2ExitCode=$?
99       if [ $__cg2ExitCode -ne 0 ]
100       then
101         mv IL/* .
102         rm -rf IL
103         echo Crossgen2 failed for $file with exitcode: $__cg2ExitCode
104         exit 1
105       fi
106     done
107 fi
108         ]]>
109       </CrossgenBashScript>
110
111       <CrossgenCleanupBashScript Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(CrossGenTest)' != 'false'">
112         <![CDATA[
113   if [ ! -z ${RunCrossGen+x} ] || [ ! -z ${RunCrossGen2+x} ]%3B then
114       mv IL/* .
115       rm -rf IL
116   fi
117         ]]>
118       </CrossgenCleanupBashScript>
119
120       <BashCLRTestPreCommands>$(BashCLRTestPreCommands);$(CrossgenBashScript)</BashCLRTestPreCommands>
121       <BashCLRTestPostCommands>$(BashCLRTestPostCommands);$(CrossgenCleanupBashScript)</BashCLRTestPostCommands>
122     </PropertyGroup>
123   </Target>
124
125   <Target Name="GetCrossgenBatchScript">
126     <PropertyGroup>
127       <CrossgenBatchScript Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(CrossGenTest)' != 'false'">
128         <![CDATA[
129
130         ]]>
131       </CrossgenBatchScript>
132
133       <CLRTestBatchPreCommands>$(CLRTestBatchPreCommands);$(CrossgenBatchScript)</CLRTestBatchPreCommands>
134     </PropertyGroup>
135   </Target>
136
137 </Project>