forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mono.proj
202 lines (178 loc) · 12.2 KB
/
mono.proj
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<Project>
<Import Project="Directory.Build.props" />
<Import Project="Directory.Build.targets" />
<PropertyGroup>
<MonoObjDir>$(ArtifactsObjDir)mono/$(PlatformConfigPathPart)/</MonoObjDir>
<MonoEnableLLVM Condition="'$(MonoEnableLLVM)' == ''">false</MonoEnableLLVM>
<MonoLLVMDir Condition="'$(MonoEnableLLVM)' == 'true' and '$(MonoLLVMDir)' == ''">$(MonoObjDir)llvm</MonoLLVMDir>
<DotNetExec Condition="'$(OS)' == 'Windows_NT'">dotnet.exe</DotNetExec>
<DotNetExec Condition="'$(DotNetExec)' == ''">dotnet</DotNetExec>
<LocalDotnetDir>$(RepoRoot).dotnet</LocalDotnetDir>
<LocalDotnet>$(LocalDotnetDir)\$(DotNetExec)</LocalDotnet>
<LocalMonoDotnetDir>$(RepoRoot).dotnet-mono</LocalMonoDotnetDir>
<LocalMonoDotnet>$(LocalMonoDotnetDir)\$(DotNetExec)</LocalMonoDotnet>
<ScriptExt Condition="'$(OS)' == 'Windows_NT'">.cmd</ScriptExt>
<ScriptExt Condition="'$(OS)' != 'Windows_NT'">.sh</ScriptExt>
<_CoreClrFileName Condition="'$(TargetsWindows)' == 'true'">coreclr.dll</_CoreClrFileName>
<_CoreClrFileName Condition="'$(TargetsOSX)' == 'true'">libcoreclr.dylib</_CoreClrFileName>
<_CoreClrFileName Condition="'$(_CoreClrFileName)' == ''">libcoreclr.so</_CoreClrFileName>
<CoreClrTestConfig Condition="'$(CoreClrTestConfig)' == ''">$(Configuration)</CoreClrTestConfig>
<CoreClrTestCoreRoot>$(ArtifactsDir)tests\coreclr\$(OSGroup).$(Platform).$(CoreClrTestConfig)\Tests\Core_Root</CoreClrTestCoreRoot>
</PropertyGroup>
<!-- OSX/Linux Mono runtime build -->
<Target Name="ConfigureMonoRuntimeUnix" Condition="'$(OS)' != 'Windows_NT'" Inputs="$(MonoProjectRoot)configure.ac" Outputs="$(MonoObjDir)config.h">
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<_MonoExtraCFLAGS>-O0 -ggdb3 -fno-omit-frame-pointer</_MonoExtraCFLAGS>
<_MonoExtraCXXFLAGS>-O0 -ggdb3 -fno-omit-frame-pointer -D_GLIBCXX_USE_CXX11_ABI=0</_MonoExtraCXXFLAGS>
<_MonoConfigureParams>--enable-checked-build=private_types</_MonoConfigureParams>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<_MonoExtraCFLAGS>-O2 -g</_MonoExtraCFLAGS>
<_MonoExtraCXXFLAGS>-O2 -g -D_GLIBCXX_USE_CXX11_ABI=0</_MonoExtraCXXFLAGS>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetArchitecture)' == 'arm64' ">
<_MonoTuple>aarch64-linux-gnu</_MonoTuple>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetArchitecture)' == 'arm' ">
<_MonoTuple>arm-linux-gnueabihf</_MonoTuple>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetArchitecture)' == 'arm' Or '$(TargetArchitecture)' == 'arm64' ">
<_MonoCrossDir>$(ROOTFS_DIR)</_MonoCrossDir>
<_MonoExtraCFLAGS>$(_MonoExtraCFLAGS) --sysroot=$(_MonoCrossDir) --target=$(_MonoTuple)</_MonoExtraCFLAGS>
<_MonoExtraCXXFLAGS>$(_MonoExtraCXXFLAGS) --sysroot=$(_MonoCrossDir) --target=$(_MonoTuple)</_MonoExtraCXXFLAGS>
<_MonoExtraLDFLAGS>$(_MonoExtraLDFLAGS) --sysroot=$(_MonoCrossDir) --target=$(_MonoTuple)</_MonoExtraLDFLAGS>
<_MonoExtraCCLDFLAGS>$(_MonoExtraCCLDFLAGS) -XCClinker --target=$(_MonoTuple)</_MonoExtraCCLDFLAGS>
<_MonoConfigureParams>$(_MonoConfigureParams) --host=$(_MonoTuple) --target=$(_MonoTuple)</_MonoConfigureParams>
<_MonoConfigureParams>$(_MonoConfigureParams) RANLIB=$(_MonoTuple)-ranlib</_MonoConfigureParams>
<_MonoConfigureParams>$(_MonoConfigureParams) LD=$(_MonoTuple)-ld</_MonoConfigureParams>
<_MonoConfigureParams>$(_MonoConfigureParams) AS=$(_MonoTuple)-as</_MonoConfigureParams>
<_MonoConfigureParams>$(_MonoConfigureParams) AR=$(_MonoTuple)-ar</_MonoConfigureParams>
<_MonoConfigureParams>$(_MonoConfigureParams) STRIP=$(_MonoTuple)-strip</_MonoConfigureParams>
</PropertyGroup>
<PropertyGroup>
<_MonoConfigureParams Condition="'$(MonoEnableLLVM)' == 'true'">$(_MonoConfigureParams) --with-llvm=$(MonoLLVMDir) </_MonoConfigureParams>
<_MonoConfigureParams>$(_MonoConfigureParams) --enable-maintainer-mode --enable-compile-warnings --with-core=only </_MonoConfigureParams>
<_MonoConfigureParams>$(_MonoConfigureParams) CFLAGS="$(_MonoExtraCFLAGS)" CXXFLAGS="$(_MonoExtraCXXFLAGS)" LDFLAGS="$(_MonoExtraLDFLAGS)" CCLDFLAGS="$(_MonoExtraCCLDFLAGS)"</_MonoConfigureParams>
</PropertyGroup>
<Message Text="Configuring Mono with '$(_MonoConfigureParams)'" Importance="High" />
<MakeDir Directories="$(MonoObjDir)" />
<Exec Command="NOCONFIGURE=1 $(MonoProjectRoot)autogen.sh" />
<Exec Command="bash -c 'source $(RepositoryEngineeringDir)native/init-compiler.sh $(Platform) clang && $(MonoProjectRoot)configure $(_MonoConfigureParams)'" WorkingDirectory="$(MonoObjDir)" />
<Touch Files="$(MonoObjDir)config.h" />
</Target>
<Target Name="BuildMonoRuntimeUnix" Condition="'$(OS)' != 'Windows_NT'" DependsOnTargets="ConfigureMonoRuntimeUnix">
<Exec Command="make -j8" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)" />
</Target>
<!-- Windows Mono runtime build -->
<Target Name="BuildMonoRuntimeWindows" Condition="'$(OS)' == 'Windows_NT'">
<PropertyGroup>
<_MonoBuildParams>/p:MONO_BUILD_DIR_PREFIX=""$(MonoObjDir)"" /p:MONO_ENABLE_NETCORE=true /p:CL_MPCount=8 /v:minimal</_MonoBuildParams>
<_MonoBuildParams Condition="$(MonoEnableLLVM) == true">/p:MONO_ENABLE_LLVM=true $(_MonoBuildParams)</_MonoBuildParams>
<_MonoBuildPlatform Condition="'$(Platform)' == 'x64'">x64</_MonoBuildPlatform>
<_MonoBuildPlatform Condition="'$(Platform)' == 'x86'">win32</_MonoBuildPlatform>
</PropertyGroup>
<Exec Command="msvc\run-msbuild.bat build $(_MonoBuildPlatform) $(Configuration) sgen "$(_MonoBuildParams)" msvc\mono-netcore.sln" IgnoreStandardErrorWarningFormat="true" />
</Target>
<Target Name="BuildCoreLib">
<MSBuild Projects="$(MonoProjectRoot)netcore\System.Private.CoreLib\System.Private.CoreLib.csproj"
Properties="Configuration=$(Configuration)"
Targets="Build" />
</Target>
<!-- General targets -->
<Target Name="Build" DependsOnTargets="BuildMonoRuntimeUnix;BuildMonoRuntimeWindows">
<PropertyGroup>
<_MonoRuntimeFilePath Condition="'$(TargetsWindows)' == 'true' and '$(Platform)' == 'x64'">$(MonoObjDir)x64\Bin\$(Configuration)\mono-2.0-sgen.dll</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(TargetsWindows)' == 'true' and '$(Platform)' == 'x86'">$(MonoObjDir)Win32\Bin\$(Configuration)\mono-2.0-sgen.dll</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(TargetsOSX)' == 'true'">$(MonoObjDir)mono\mini\.libs\libmonosgen-2.0.dylib</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(_MonoRuntimeFilePath)' == ''">$(MonoObjDir)mono\mini\.libs\libmonosgen-2.0.so</_MonoRuntimeFilePath>
</PropertyGroup>
<!-- Copy Mono runtime files to artifacts directory -->
<ItemGroup>
<_MonoRuntimeArtifacts Include="$(_MonoRuntimeFilePath)">
<Destination>$(BinDir)$(_CoreClrFileName)</Destination>
</_MonoRuntimeArtifacts>
</ItemGroup>
<Copy SourceFiles="@(_MonoRuntimeArtifacts)"
DestinationFiles="%(_MonoRuntimeArtifacts.Destination)"
SkipUnchangedFiles="true" />
<Exec Condition="'$(TargetsOSX)' == 'true'" Command="install_name_tool -id @rpath/$(_CoreClrFileName) %(_MonoRuntimeArtifacts.Destination)" />
</Target>
<Target Name="Restore">
<MSBuild Projects="$(MonoProjectRoot)netcore\nuget\packages.builds" Targets="Restore" />
<MSBuild Condition="'$(MonoEnableLLVM)' == 'true' and '$(MonoLLVMDir)' == '$(MonoObjDir)llvm'" Projects="$(MonoProjectRoot)llvm\llvm-init.proj" Targets="Restore" Properties="MonoObjDir=$(MonoObjDir);MonoLLVMDir=$(MonoLLVMDir)" />
</Target>
<Target Name="Pack">
<MSBuild Projects="$(MonoProjectRoot)netcore\nuget\packages.builds" Targets="Build" />
</Target>
<Target Name="Test" />
<!-- Copy Mono runtime bits to $(Destination) -->
<Target Name="CopyMonoRuntimeFilesFromArtifactsToDestination">
<ItemGroup>
<_MonoRuntimeArtifacts Include="$(BinDir)\*.*" />
</ItemGroup>
<Error Condition="'$(Destination)' == ''" Text="Destination should not be empty" />
<Error Condition="@(_MonoRuntimeArtifacts->Count()) < 2" Text="Mono artifacts were not found at $(BinDir)" />
<Message Text="Copying Mono Runtime artifacts from '$(BinDir)' to '$(Destination)'.'" Importance="High" />
<Copy SourceFiles="@(_MonoRuntimeArtifacts)"
DestinationFolder="$(Destination)"
OverwriteReadOnlyFiles="true" />
</Target>
<Target Name="CloneLocalDotnet" DependsOnTargets="ValidateLocalDotnet">
<ItemGroup>
<_LocalDotnetFiles Include="$(LocalDotnetDir)\**\*.*" />
</ItemGroup>
<!-- copy .dotnet to .dotnet-mono if it doesn't exist -->
<Copy SourceFiles="@(_LocalDotnetFiles)"
DestinationFolder="$(LocalMonoDotnetDir)\%(RecursiveDir)"
SkipUnchangedFiles="true" />
</Target>
<!-- Copy Mono runtime bits to the local .dotnet-mono (clone of .dotnet) dir for local experiments (temp solution) -->
<Target Name="PatchLocalMonoDotnet" DependsOnTargets="CloneLocalDotnet">
<MSBuild Projects ="$(MSBuildProjectFullPath)"
Properties="Destination=$([System.IO.Directory]::GetDirectories('$(LocalMonoDotnetDir)\shared\Microsoft.NETCore.App')[0])"
Targets="CopyMonoRuntimeFilesFromArtifactsToDestination" />
</Target>
<!-- Copy Mono runtime bits to the coreclr's Core_Root in order to run runtime tests -->
<Target Name="PatchCoreClrCoreRoot" DependsOnTargets="ValidateLocalDotnet">
<PropertyGroup>
<Destination>$(CoreClrTestCoreRoot)</Destination>
</PropertyGroup>
<CallTarget Targets="CopyMonoRuntimeFilesFromArtifactsToDestination" />
</Target>
<!-- Copy Coreclr runtime bits back to Core_Root -->
<Target Name="RestoreCoreClrCoreRoot" DependsOnTargets="ValidateLocalDotnet">
<Copy SourceFiles="$(CoreCLRArtifactsPath)\System.Private.CoreLib.dll"
DestinationFiles="$(CoreClrTestCoreRoot)\System.Private.CoreLib.dll" />
<Copy SourceFiles="$(CoreCLRArtifactsPath)\$(_CoreClrFileName)"
DestinationFiles="$(CoreClrTestCoreRoot)\$(_CoreClrFileName)" />
</Target>
<!-- Run netcore\sample\HelloWorld sample using Mono Runtime -->
<Target Name="RunSample" DependsOnTargets="PatchLocalMonoDotnet">
<PropertyGroup>
<EnvVars Condition="'$(OS)' != 'Windows_NT'"><![CDATA[
COMPlus_DebugWriteToStdErr=1 \
MONO_ENV_OPTIONS="" \
]]>
</EnvVars>
</PropertyGroup>
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="$(EnvVars) $(LocalMonoDotnet) run -c $(Configuration) -p $(MonoProjectRoot)netcore/sample/HelloWorld" />
<Exec Condition="'$(OS)' != 'Windows_NT'" Command="$(EnvVars) $(LocalMonoDotnet) run -c $(Configuration) -p $(MonoProjectRoot)netcore\sample\HelloWorld" />
</Target>
<!-- Run CoreCLR runtime test using testhost -->
<Target Name="RunCoreClrTest" DependsOnTargets="ValidateLocalDotnet;PatchCoreClrCoreRoot">
<Error Condition="$(CoreClrTest) == ''" Text="'CoreClrTest' is not set. E.g. set it to `$(ArtifactsDir)tests/coreclr/$(OSGroup).$(Platform).$(CoreClrTestConfig)/JIT/opt/InstructionCombining/DivToMul/DivToMul$(ScriptExt)` in order to run DivToMul test." />
<Exec Command="$(CoreClrTest) -coreroot="$(CoreClrTestCoreRoot)""/>
</Target>
<!-- Run coreclr tests using runtest.py -->
<Target Name="RunCoreClrTests" DependsOnTargets="ValidateLocalDotnet;PatchCoreClrCoreRoot">
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="$(MonoProjectRoot)..\coreclr\tests\runtest.cmd $(CoreClrTestConfig)" ContinueOnError="ErrorAndContinue" />
<Exec Condition="'$(OS)' != 'Windows_NT'" Command="$(MonoProjectRoot)../coreclr/tests/./runtest.sh $(CoreClrTestConfig)" ContinueOnError="ErrorAndContinue" />
</Target>
<Target Name="RunBenchmarks" DependsOnTargets="PatchLocalMonoDotnet">
<Error Condition="$(BenchmarksRepo) == ''" Text="BenchmarksRepo variable is not set" />
<Exec WorkingDirectory="$(BenchmarksRepo)\src\benchmarks\micro" Command="$(LocalDotnet) run -c Release -f $(NetCoreAppCurrent) --cli $(LocalMonoDotnet)" />
</Target>
<Target Name="ValidateLocalDotnet">
<Error Condition="!Exists('$(LocalDotnet)')" Text="'$(LocalDotnet)' doesn't exist." />
</Target>
</Project>