summaryrefslogtreecommitdiff
path: root/tests/src/CLRTest.Jit.targets
blob: 7364c7f20adcdce177c65370361fb0366b8e312d (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?xml version="1.0" encoding="utf-8"?>

<!--
***********************************************************************************************
CLRTest.Jit.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 generating command scripts for special GC tests.

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">

  <Target Name="GetJitDisasmBashScript"
          Returns="$(JitDisasmBashScript)">
    <PropertyGroup>
      <InputAssemblyName Condition="('$(CLRTestKind)' == 'RunOnly') and ('$(RunningOnUnix)' == 'true')">$([MSBuild]::MakeRelative($(OutputPath.Replace("/","\\")), $(_CLRTestToRunFileFullPath.Replace("/","\\"))).Replace("\\","/"))</InputAssemblyName>
      <InputAssemblyName Condition="('$(CLRTestKind)' == 'RunOnly') and ('$(RunningOnUnix)' != 'true')">$([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)).Replace("\","/"))</InputAssemblyName>
      <InputAssemblyName Condition="'$(CLRTestKind)' == 'BuildAndRun'">$(MSBuildProjectName).exe</InputAssemblyName>
      <JitDisasmOut Condition="'$(RunningOnUnix)' == 'true'">$([MSBuild]::MakeRelative($(OutputPath.Replace("/","\\")), $(BaseOutputPathWithConfig.Replace("/","\\"))dasm\$(BuildProjectRelativeDir.Replace("/","\\"))).Replace("\\","/"))</JitDisasmOut>
      <JitDisasmOut Condition="'$(RunningOnUnix)' != 'true'">$([MSBuild]::MakeRelative($(OutputPath), $(BaseOutputPathWithConfig)dasm\$(BuildProjectRelativeDir)).Replace("\","/"))</JitDisasmOut>
      <JitDisasmBashScript>
<![CDATA[
# JitDisasm Script
if [ ! -z $RunningJitDisasm ]
then
    echo $CORE_ROOT/corerun "$CORE_ROOT/jit-dasm.dll" --crossgen $CORE_ROOT/crossgen --platform $CORE_ROOT --output $(JitDisasmOut) $(InputAssemblyName)
    "$CORE_ROOT/corerun" "$CORE_ROOT/jit-dasm.dll" --crossgen $CORE_ROOT/crossgen --platform $CORE_ROOT --output $(JitDisasmOut) $(InputAssemblyName)
    _jdExitCode=$?
    if [ $_jdExitCode -ne 0 ]
    then
        echo EXECUTION OF JIT-DASM - FAILED $_jdExitCode
        exit 1
    fi
fi
]]>
      </JitDisasmBashScript>
    </PropertyGroup>
  </Target>

  <Target Name="GetJitDisasmBatchScript"
          Returns="$(JitDisasmBatchScript)">
    <PropertyGroup>
      <InputAssemblyName Condition="('$(CLRTestKind)' == 'RunOnly') and ('$(RunningOnUnix)' == 'true')">$([MSBuild]::MakeRelative($(OutputPath.Replace("/","\\")), $(_CLRTestToRunFileFullPath.Replace("/","\\"))).Replace("\\","/"))</InputAssemblyName>
      <InputAssemblyName Condition="('$(CLRTestKind)' == 'RunOnly') and ('$(RunningOnUnix)' != 'true')">$([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)))</InputAssemblyName>
      <InputAssemblyName Condition="'$(CLRTestKind)' == 'BuildAndRun'">$(MSBuildProjectName).exe</InputAssemblyName>
      <JitDisasmOut Condition="'$(RunningOnUnix)' == 'true'">$([MSBuild]::MakeRelative($(OutputPath.Replace("/","\\")), $(BaseOutputPathWithConfig.Replace("/","\\"))dasm\$(BuildProjectRelativeDir.Replace("/","\\"))).Replace("\\","/"))</JitDisasmOut>
      <JitDisasmOut Condition="'$(RunningOnUnix)' != 'true'">$([MSBuild]::MakeRelative($(OutputPath), $(BaseOutputPathWithConfig)dasm\$(BuildProjectRelativeDir)))</JitDisasmOut>
      <JitDisasmBatchScript>
<![CDATA[
REM JitDisasm Script
if defined RunningJitDisasm (
  echo %CORE_ROOT%\corerun %CORE_ROOT%\jit-dasm.dll --crossgen %CORE_ROOT%/crossgen.exe --platform %CORE_ROOT%%3B%25cd%25 --output $(JitDisasmOut) $(InputAssemblyName)
  %CORE_ROOT%\corerun %CORE_ROOT%\jit-dasm.dll --crossgen %CORE_ROOT%/crossgen.exe --platform %CORE_ROOT%%3B%25cd%25 --output $(JitDisasmOut) $(InputAssemblyName)
  IF NOT "!ERRORLEVEL!"=="0" (
    ECHO EXECUTION OF JIT-DASM - FAILED !ERRORLEVEL!
    Exit /b 1
  )
  Exit /b 0
)
    ]]>
      </JitDisasmBatchScript>
    </PropertyGroup>
  </Target>

  <Target
      Name="GetIlasmRoundTripBashScript"
      Returns="$(IlasmRoundTripBashScript)">
    <PropertyGroup>
      <InputAssemblyName Condition="('$(CLRTestKind)' == 'RunOnly') and ('$(RunningOnUnix)' == 'true')">$([MSBuild]::MakeRelative($(OutputPath.Replace("/","\\")), $(_CLRTestToRunFileFullPath.Replace("/","\\"))).Replace("\\","/"))</InputAssemblyName>
      <InputAssemblyName Condition="('$(CLRTestKind)' == 'RunOnly') and ('$(RunningOnUnix)' != 'true')">$([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)).Replace("\","/"))</InputAssemblyName>
      <InputAssemblyName Condition="'$(CLRTestKind)' == 'BuildAndRun'">$(MSBuildProjectName).exe</InputAssemblyName>
      <DisassemblyName>$(MSBuildProjectName).dasm.il</DisassemblyName>
      <TargetAssemblyName>$(MSBuildProjectName).asm.exe</TargetAssemblyName>

      <IlasmRoundTripBashScript>
        <![CDATA[
# IlasmRoundTrip Script

# Disable Ilasm round-tripping for Linker tests.
# Todo: Ilasm round-trip on linked binaries.

if [ -z "$DoLink" -a ! -z "$RunningIlasmRoundTrip" ];
then
    echo "$CORE_ROOT/ildasm" -raweh -out=$(DisassemblyName) $(InputAssemblyName)
    "$CORE_ROOT/ildasm" -raweh -out=$(DisassemblyName) $(InputAssemblyName)
    ERRORLEVEL=$?
    if [ $ERRORLEVEL -ne 0 ]
    then
      echo EXECUTION OF ILDASM - FAILED $ERRORLEVEL
      exit 1
    fi

    echo "$CORE_ROOT/ilasm" -output=$(TargetAssemblyName) $(_IlasmSwitches) $(DisassemblyName)
    "$CORE_ROOT/ilasm" -output=$(TargetAssemblyName) $(_IlasmSwitches) $(DisassemblyName)
    ERRORLEVEL=$?
    if [ $ERRORLEVEL -ne 0 ]
    then
      echo EXECUTION OF ILASM - FAILED $ERRORLEVEL
      exit 1
    fi
fi
        ]]>
      </IlasmRoundTripBashScript>
    </PropertyGroup>
  </Target>

  <Target Name="GetIlasmRoundTripBatchScript"
          Returns="$(IlasmRoundTripBatchScript);$(BatchIlrtTestLaunchCmds)">
    <PropertyGroup>
      <InputAssemblyName Condition="'$(CLRTestKind)' == 'RunOnly'">$([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)))</InputAssemblyName>
      <InputAssemblyName Condition="'$(CLRTestKind)' == 'BuildAndRun'">$(MSBuildProjectName).exe</InputAssemblyName>
      <DisassemblyName>$(MSBuildProjectName).dasm.il</DisassemblyName>
      <TargetAssemblyName>$(MSBuildProjectName).asm.exe</TargetAssemblyName>

      <!-- https://github.com/dotnet/coreclr/issues/2481. Delete /raweh to ildasm once it is resolved.-->
      <IlasmRoundTripBatchScript>
        <![CDATA[
REM IlasmRoundTrip Script

REM Disable Ilasm round-tripping for Linker tests.
REM Todo: Ilasm round-trip on linked binaries.
IF NOT DEFINED DoLink (
  IF DEFINED RunningIlasmRoundTrip (
    echo %CORE_ROOT%\ildasm.exe /raweh /out=$(DisassemblyName) $(InputAssemblyName)
    %CORE_ROOT%\ildasm.exe /raweh /out=$(DisassemblyName) $(InputAssemblyName)
    IF NOT "!ERRORLEVEL!"=="0" (
      ECHO EXECUTION OF ILDASM - FAILED !ERRORLEVEL!
      Exit /b 1
    )
    ECHO %CORE_ROOT%\ilasm.exe /output=$(TargetAssemblyName) $(_IlasmSwitches) $(DisassemblyName)
    %CORE_ROOT%\ilasm.exe /output=$(TargetAssemblyName) $(_IlasmSwitches) $(DisassemblyName)
    IF NOT "!ERRORLEVEL!"=="0" (
      ECHO EXECUTION OF ILASM - FAILED !ERRORLEVEL!
      Exit /b 1
    )
  )
)
        ]]>
      </IlasmRoundTripBatchScript>
      <BatchIlrtTestLaunchCmds><![CDATA[
IF NOT DEFINED DoLink (
  if defined RunningIlasmRoundTrip (
    ECHO %LAUNCHER% $(TargetAssemblyName) %CLRTestExecutionArguments% %Host_Args%
    %LAUNCHER% $(TargetAssemblyName) %CLRTestExecutionArguments% %Host_Args%

    IF NOT "!ERRORLEVEL!"=="%CLRTestExpectedExitCode%" (
      ECHO END EXECUTION OF IL{D}ASM BINARY - FAILED !ERRORLEVEL! vs %CLRTestExpectedExitCode%
      ECHO FAILED
      Exit /b 1
    )
  )
)
]]>
      </BatchIlrtTestLaunchCmds>
    </PropertyGroup>
  </Target>

  <PropertyGroup Condition="$(RunWithGcStress) != ''" >
    <CLRTestBatchPreCommands>
<![CDATA[
      $(CLRTestBatchPreCommands)
set COMPlus_GCStress=$(RunWithGcStress)
    ]]>
    </CLRTestBatchPreCommands>
    <BashCLRTestPreCommands>
<![CDATA[
      $(BashCLRTestPreCommands)
export COMPlus_GCStress=$(RunWithGcStress)
    ]]>
    </BashCLRTestPreCommands>
  </PropertyGroup>


</Project>