Merge branch 'master' into ffast-math
[mono-project.git] / netcore / Makefile
blob22a4f77fd16ea9516e96a869e43e5e5b26c9c1d3
1 ifneq ($(wildcard config.make),)
3 include config.make
5 NETCORETESTS_VERSION := $(shell cat ../eng/Versions.props | sed -n 's/.*MicrosoftPrivateCoreFxNETCoreAppVersion>\(.*\)<\/MicrosoftPrivateCoreFxNETCoreAppVersion.*/\1/p' )
6 NETCOREAPP_VERSION := $(shell cat ../eng/Versions.props | sed -n 's/.*MicrosoftNETCoreAppVersion>\(.*\)<\/MicrosoftNETCoreAppVersion.*/\1/p' )
7 ROSLYN_VERSION:= $(shell cat ../eng/Versions.props | sed -n 's/.*MicrosoftNetCompilersVersion>\(.*\)<\/MicrosoftNetCompilersVersion.*/\1/p' )
9 # Extracted from https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/master/latest.version
10 ASPNETCOREAPP_VERSION := 3.0.0-preview-18614-0151
12 # runtime version used by $(DOTNET) - local .net core sdk to bootstrap stuff
13 # it doesn't match NETCOREAPP_VERSION
14 BOOTSTRAP_RUNTIME = $(shell ls ../.dotnet/shared/Microsoft.NETCore.App)
16 ifeq ($(HOST_PLATFORM),win32)
17 PLATFORM_AOT_SUFFIX := .dll
18 PLATFORM_AOT_PREFIX :=
19 NETCORESDK_EXT = zip
20 UNZIPCMD = python -c "import zipfile,sys; zipfile.ZipFile(sys.argv[1], 'r').extractall()"
21 XUNIT_FLAGS = -notrait category=nonwindowstests @../../../../CoreFX.issues_windows.rsp
22 TESTS_PLATFORM = Windows_NT.x64
23 ON_RUNTIME_EXTRACT = chmod -R 755 {host,shared,./dotnet}
24 DOTNET := $(shell powershell -ExecutionPolicy Bypass -Command "./init-tools.ps1")/dotnet.exe
25 DOTNET := "$(subst \,/,$(DOTNET))"
26 endif
28 ifeq ($(HOST_PLATFORM),macos)
29 PLATFORM_AOT_SUFFIX := .dylib
30 PLATFORM_AOT_PREFIX := lib
31 NETCORESDK_EXT = tar.gz
32 UNZIPCMD = tar -xvf
33 XUNIT_FLAGS = -notrait category=nonosxtests
34 TESTS_PLATFORM = OSX.x64
35 DOTNET := $(shell ./init-tools.sh | tail -1)
36 endif
38 ifeq ($(HOST_PLATFORM),linux)
39 PLATFORM_AOT_SUFFIX := .so
40 PLATFORM_AOT_PREFIX := lib
41 NETCORESDK_EXT = tar.gz
42 UNZIPCMD = tar -xvf
43 XUNIT_FLAGS = -notrait category=nonlinuxtests @../../../../CoreFX.issues_linux.rsp
44 ifeq ($(COREARCH), arm64)
45 XUNIT_FLAGS += @../../../../CoreFX.issues_linux_arm64.rsp
46 endif
47 TESTS_PLATFORM = Linux.x64
48 DOTNET := $(shell ./init-tools.sh | tail -1)
49 endif
51 NETCORESDK_FILE := dotnet-runtime-$(NETCOREAPP_VERSION)-$(RID).$(NETCORESDK_EXT)
52 ASPNETCORESDK_FILE := aspnetcore-runtime-$(ASPNETCOREAPP_VERSION)-$(RID).$(NETCORESDK_EXT)
53 NETCORE_URL := https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$(NETCOREAPP_VERSION)/$(NETCORESDK_FILE)
54 ASPNETCORE_URL := https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/$(ASPNETCOREAPP_VERSION)/$(ASPNETCORESDK_FILE)
55 FEED_BASE_URL := https://dotnetfeed.blob.core.windows.net/dotnet-core
56 TEST_ASSETS_PATH := corefx-tests/$(NETCORETESTS_VERSION)/$(TESTS_PLATFORM)/netcoreapp/corefx-test-assets.xml
58 # used to calculate exact version number for generating nupkg
59 BLAME = $(shell git blame ../configure.ac | grep AC_INIT | cut -f1 -d' ')
60 VERSTUB = .$(shell git rev-list --count $(BLAME)..HEAD)
62 all: bcl
64 $(NETCORESDK_FILE):
65 curl $(NETCORE_URL) --output $(NETCORESDK_FILE)
66 rm -rf shared/Microsoft.NETCore.App
67 $(UNZIPCMD) $(NETCORESDK_FILE)
68 $(ON_RUNTIME_EXTRACT)
70 # AspNetCoreApp contains its own .NET Core Runtime but we don't need it so let's remove it
71 # and update version in Microsoft.AspNetCore.App.runtimeconfig.json to NETCOREAPP_VERSION
72 $(ASPNETCORESDK_FILE):
73 curl $(ASPNETCORE_URL) --output $(ASPNETCORESDK_FILE)
74 $(UNZIPCMD) $(ASPNETCORESDK_FILE)
75 sed -e 's/.*version.*/\"version\": \"$(NETCOREAPP_VERSION)\"/' < shared/Microsoft.AspNetCore.App/$(ASPNETCOREAPP_VERSION)/Microsoft.AspNetCore.App.runtimeconfig.json > 2 && mv 2 shared/Microsoft.AspNetCore.App/$(ASPNETCOREAPP_VERSION)/Microsoft.AspNetCore.App.runtimeconfig.json
77 update-corefx: corefx/.stamp-dl-corefx-$(NETCORETESTS_VERSION)
79 corefx/.stamp-dl-corefx-$(NETCORETESTS_VERSION): corefx-restore.csproj
80 $(DOTNET) build corefx-restore.csproj --runtime $(RID) --packages corefx/packages -p:MicrosoftPrivateCoreFxNETCoreAppVersion=$(NETCORETESTS_VERSION) -p:OutputPath=corefx/restore/
81 touch $@
83 update-roslyn: roslyn/packages/microsoft.net.compilers.toolset/$(ROSLYN_VERSION)/microsoft.net.compilers.toolset.nuspec
85 roslyn/packages/microsoft.net.compilers.toolset/$(ROSLYN_VERSION)/microsoft.net.compilers.toolset.nuspec:
86 $(DOTNET) restore roslyn-restore.csproj -p:RoslynVersion=$(ROSLYN_VERSION) --packages roslyn/packages -p:OutputPath=roslyn/restore/
88 run-sample: prepare
89 $(DOTNET) build sample/HelloWorld
90 MONO_ENV_OPTIONS="--debug" COMPlus_DebugWriteToStdErr=1 ./dotnet --fx-version "$(NETCOREAPP_VERSION)" sample/HelloWorld/bin/netcoreapp3.0/HelloWorld.dll
92 run-sample-dbg: prepare
93 $(DOTNET) build sample/HelloWorld
94 MONO_ENV_OPTIONS="--debug --debugger-agent=transport=dt_socket,address=127.0.0.1:1235,server=y,suspend=y" COMPlus_DebugWriteToStdErr=1 ./dotnet --fx-version "$(NETCOREAPP_VERSION)" sample/HelloWorld/bin/netcoreapp3.0/HelloWorld.dll
96 run-sample-coreclr:
97 cd sample/HelloWorld && $(DOTNET) run
99 run-aspnet-sample: prepare
100 rm -rf sample/AspNetCore/{bin,obj}
101 $(DOTNET) publish sample/AspNetCore -c Debug -r $(RID)
102 cp ../mono/mini/.libs/libmonosgen-2.0$(PLATFORM_AOT_SUFFIX) sample/AspNetCore/bin/Debug/netcoreapp3.0/$(RID)/publish/$(PLATFORM_AOT_PREFIX)coreclr$(PLATFORM_AOT_SUFFIX)
103 cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.dll sample/AspNetCore/bin/Debug/netcoreapp3.0/$(RID)/publish/
104 COMPlus_DebugWriteToStdErr=1 ./dotnet --fx-version "$(ASPNETCOREAPP_VERSION)" sample/AspNetCore/bin/Debug/netcoreapp3.0/$(RID)/publish/AspNetCore.dll
106 # makes $(DOTNET) to use mono runtime (to run real-world apps using '$(DOTNET) run')
107 patch-local-dotnet: prepare
108 cp ../mono/mini/.libs/libmonosgen-2.0$(PLATFORM_AOT_SUFFIX) ../.dotnet/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME)/$(PLATFORM_AOT_PREFIX)coreclr$(PLATFORM_AOT_SUFFIX)
109 cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.dll ../.dotnet/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME)
110 cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.pdb ../.dotnet/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME)
112 # Precompile BCL libs in $(DOTNET) using LLVM (requires `--enable-llvm` build)
113 patch-local-dotnet-aot-llvm: patch-local-dotnet
114 for assembly in ../.dotnet/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME)/*.dll; do \
115 echo "[AOT] $$assembly"; \
116 PATH="../llvm/usr/bin/:$(PATH)" \
117 MONO_ENV_OPTIONS="--aot=llvm,llvmllc=\"-mcpu=native\"" \
118 $(DOTNET) $$assembly ; \
119 done; \
121 # run HelloWorld using --aot=llvm (requires `--enable-llvm` build)
122 run-sample-local-dotnet-llvm: patch-local-dotnet
123 $(DOTNET) build -c Release sample/HelloWorld
124 PATH="../llvm/usr/bin/:$(PATH)" \
125 MONO_ENV_OPTIONS="--aot=llvm,llvmllc=\"-mcpu=native\"" \
126 $(DOTNET) sample/HelloWorld/bin/netcoreapp3.0/HelloWorld.dll
127 $(DOTNET) sample/HelloWorld/bin/netcoreapp3.0/HelloWorld.dll
129 # COREHOST_TRACE=1
130 SHAREDRUNTIME := shared/Microsoft.NETCore.App/$(NETCOREAPP_VERSION)
132 System.Private.CoreLib/src/System/Environment.Mono.cs: System.Private.CoreLib/src/System/Environment.Mono.in config.make
133 test -n '$(MONO_CORLIB_VERSION)'
134 sed -e 's,@''MONO_CORLIB_VERSION@,$(MONO_CORLIB_VERSION),' $< > $@
136 bcl: update-roslyn System.Private.CoreLib/src/System/Environment.Mono.cs
137 $(DOTNET) build $(CORETARGETS) $(CORLIB_BUILD_FLAGS) -p:BuildArch=$(COREARCH) \
138 -p:OutputPath=bin/$(COREARCH) \
139 -p:RoslynPropsFile="../roslyn/packages/microsoft.net.compilers.toolset/$(ROSLYN_VERSION)/build/Microsoft.Net.Compilers.Toolset.props" \
140 System.Private.CoreLib/System.Private.CoreLib.csproj
142 debug-bcl:
143 $(MAKE) bcl CORLIB_BUILD_FLAGS="-c Debug"
145 runtime:
146 $(MAKE) -C ../mono
148 link-mono: $(SHAREDRUNTIME)/.stamp-link-mono
150 $(SHAREDRUNTIME)/.stamp-link-mono: ../mono/mini/.libs/libmonosgen-2.0$(PLATFORM_AOT_SUFFIX) System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.dll System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.pdb
151 cp ../mono/mini/.libs/libmonosgen-2.0$(PLATFORM_AOT_SUFFIX) $(SHAREDRUNTIME)/$(PLATFORM_AOT_PREFIX)coreclr$(PLATFORM_AOT_SUFFIX)
152 cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.dll $(SHAREDRUNTIME)
153 cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.pdb $(SHAREDRUNTIME)
154 touch $@
156 prepare: $(ASPNETCORESDK_FILE) $(NETCORESDK_FILE) update-corefx update-roslyn link-mono
158 nupkg:
159 $(DOTNET) pack roslyn-restore.csproj -p:IsPackable=true -p:NuspecFile=runtime.nuspec -p:NuspecProperties=\"RID=$(RID)\;VERSION=$(VERSION)$(VERSTUB)\;PLATFORM_AOT_SUFFIX=$(PLATFORM_AOT_SUFFIX)\;COREARCH=$(COREARCH)\;PLATFORM_AOT_PREFIX=$(PLATFORM_AOT_PREFIX)\" --output ../artifacts/ --no-build
160 $(DOTNET) pack roslyn-restore.csproj -p:IsPackable=true -p:NuspecFile=metapackage.nuspec -p:NuspecProperties=\"RID=$(RID)\;VERSION=$(VERSION)$(VERSTUB)\;PLATFORM_AOT_SUFFIX=$(PLATFORM_AOT_SUFFIX)\;COREARCH=$(COREARCH)\;PLATFORM_AOT_PREFIX=$(PLATFORM_AOT_PREFIX)\" --output ../artifacts/ --no-build
162 clean:
163 rm -rf .configured ../.dotnet sdk shared host dotnet tests obj corefx roslyn LICENSE.txt ThirdPartyNotices.txt $(NETCORESDK_FILE) $(ASPNETCORESDK_FILE)
166 update-tests-corefx: corefx/.stamp-dl-corefx-tests-$(NETCORETESTS_VERSION)
168 corefx/.stamp-dl-corefx-tests-$(NETCORETESTS_VERSION):
169 rm -rf corefx/tests
170 $(DOTNET) msbuild corefx-tests-restore.proj -m -t:DownloadAllTests -p:TEST_ASSETS_PATH="$(TEST_ASSETS_PATH)" -p:FEED_BASE_URL="$(FEED_BASE_URL)"
171 rm -rf corefx/tests/extracted/System.Utf8String.Experimental.Tests
172 touch $@
175 # Running CoreFX tests
177 # You can run either individual test assembly or run all CoreFX tests. The tests are automatically downloaded
178 # from the shared location and built locally.
180 # Running all test: `make run-tests-corefx`
182 # Running individual test: MONO_ENV_OPTIONS="--debug" make run-tests-corefx-System.Collections.Tests
185 run-tests-corefx: update-tests-corefx
186 for testdir in corefx/tests/extracted/*; do \
187 $(MAKE) run-tests-corefx-$$(basename $${testdir}) || true; \
188 done; \
189 $(MAKE) xunit-summary
191 run-tests-corefx-%: prepare update-tests-corefx
192 @echo ""
193 @echo "***************** $* *********************"
194 @cp corefx/restore/corefx-restore.deps.json corefx/tests/extracted/$*/xunit.console.deps.json
195 @cp corefx/restore/corefx-restore.deps.json corefx/tests/extracted/$*/Microsoft.DotNet.RemoteExecutorHost.deps.json
196 @cp corefx/restore/corefx-restore.runtimeconfig.dev.json corefx/tests/extracted/$*/$*.runtimeconfig.dev.json
197 @cp corefx/restore/corefx-restore.dll corefx/tests/extracted/$*/corefx-restore.dll
198 @sed -i -e 's/5.0.0\"/$(NETCOREAPP_VERSION)\"/g' corefx/tests/extracted/$*/*.runtimeconfig.json
199 cd corefx/tests/extracted/$* && \
200 COMPlus_DebugWriteToStdErr=1 $(CURDIR)/./dotnet exec --runtimeconfig $*.runtimeconfig.json --fx-version "$(NETCOREAPP_VERSION)" xunit.console.dll $*.dll \
201 -html ../../TestResult-$*.html -xml ../../TestResult-$*-netcore-xunit.xml \
202 $(XUNIT_FLAGS) @../../../../CoreFX.issues.rsp \
203 $(FIXTURE)
205 # build a test assembly in COREFX_ROOT (path to a fully built corefx repo) and copy it to corefx/tests/extracted
206 # e.g. `make build-test-corefx-System.Runtime COREFX_ROOT=/prj/corefx-master`
207 build-test-corefx-%:
208 cd $(COREFX_ROOT)/src/$*/tests && $(DOTNET) msbuild /p:OutputPath=tmp
209 cp $(COREFX_ROOT)/src/$*/tests/tmp/$*.Tests.{dll,pdb} $(CURDIR)/corefx/tests/extracted/$*.Tests/
210 rm -rf $(COREFX_ROOT)/src/$*/tests/tmp
212 xunit-summary:
213 ./xunit-summary.py "corefx/tests"
215 endif
217 distdir: