Move -s MAIN_MODULE=1 to all configurations
[mono-project.git] / netcore / Makefile
blob4fc34bf6fd1c5fb9921c125a78fb5f0dd3977575
1 include ../mcs/build/config.make
4 # NETCORETESTS_VERSION and NETCOREAPP_VERSION must be updated in sync, we are using coreclr repo for that but that's fine for now
7 # Extracted MicrosoftPrivateCoreFxNETCoreAppVersion from https://github.com/dotnet/coreclr/blob/master/eng/Versions.props#L12
8 NETCORETESTS_VERSION := 4.6.0-preview6.19229.1
10 # Extracted MicrosoftNETCoreAppVersion from https://github.com/dotnet/coreclr/blob/master/eng/Versions.props#L14
11 NETCOREAPP_VERSION := 3.0.0-preview5-27620-01
13 # Extracted from https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/master/latest.version
14 ASPNETCOREAPP_VERSION := 3.0.0-preview-18614-0151
16 include roslyn.make
18 ifeq ($(HOST_PLATFORM),win32)
19 NETCORESDK_EXT = zip
20 UNZIPCMD = python -c "import zipfile,sys; zipfile.ZipFile(sys.argv[1], 'r').extractall()"
21 XUNIT_FLAGS =
22 endif
24 ifeq ($(HOST_PLATFORM),macos)
25 NETCORESDK_EXT = tar.gz
26 UNZIPCMD = tar -xvf
27 XUNIT_FLAGS = -notrait category=nonosxtests
28 endif
30 ifeq ($(HOST_PLATFORM),linux)
31 NETCORESDK_EXT = tar.gz
32 UNZIPCMD = tar -xvf
33 XUNIT_FLAGS = -notrait category=nonlinuxtests
34 endif
36 NETCORESDK_FILE := dotnet-runtime-$(NETCOREAPP_VERSION)-$(RID).$(NETCORESDK_EXT)
37 ASPNETCORESDK_FILE := aspnetcore-runtime-$(ASPNETCOREAPP_VERSION)-$(RID).$(NETCORESDK_EXT)
38 NETCORE_URL := https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$(NETCOREAPP_VERSION)/$(NETCORESDK_FILE)
39 ASPNETCORE_URL := https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/$(ASPNETCOREAPP_VERSION)/$(ASPNETCORESDK_FILE)
40 FEED_BASE_URL := https://dotnetfeed.blob.core.windows.net/dotnet-core
41 TEST_ASSETS_URL = $(FEED_BASE_URL)/corefx-tests/$(NETCORETESTS_VERSION)/OSX.x64/netcoreapp/corefx-test-assets.xml
43 # used to calculate exact version number for generating nupkg
44 BLAME = $(shell git blame ../configure.ac | grep AC_INIT | cut -f1 -d' ')
45 VERSTUB = .$(shell git rev-list --count $(BLAME)..HEAD)
47 $(NETCORESDK_FILE):
48 curl $(NETCORE_URL) --output $(NETCORESDK_FILE)
49 rm -rf shared/Microsoft.NETCore.App
50 $(UNZIPCMD) $(NETCORESDK_FILE)
52 # AspNetCoreApp contains its own .NET Core Runtime but we don't need it so let's remove it
53 # and update version in Microsoft.AspNetCore.App.runtimeconfig.json to NETCOREAPP_VERSION
54 $(ASPNETCORESDK_FILE):
55 curl $(ASPNETCORE_URL) --output $(ASPNETCORESDK_FILE)
56 $(UNZIPCMD) $(ASPNETCORESDK_FILE)
57 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
59 update-corefx: corefx/.stamp-dl-corefx-$(NETCORETESTS_VERSION)
61 corefx/.stamp-dl-corefx-$(NETCORETESTS_VERSION): corefx-restore.csproj
62 dotnet build corefx-restore.csproj --runtime $(RID) --packages corefx/packages -p:MicrosoftPrivateCoreFxNETCoreAppVersion=$(NETCORETESTS_VERSION) -p:OutputPath=corefx/restore/
63 touch $@
65 update-roslyn: roslyn-restore.csproj roslyn.make
66 dotnet restore roslyn-restore.csproj -p:RoslynVersion=$(ROSLYN_VERSION) --packages roslyn/packages -p:OutputPath=roslyn/restore/
68 update-corefx-tests: corefx/.stamp-dl-corefx-tests-$(NETCORETESTS_VERSION)
70 corefx/.stamp-dl-corefx-tests-$(NETCORETESTS_VERSION):
71 curl $(TEST_ASSETS_URL) --output corefx-test-assets.xml
72 python dl-test-assets.py corefx-test-assets.xml $(FEED_BASE_URL) corefx/tests
73 touch $@
75 run-sample:
76 dotnet build sample/HelloWorld
77 COMPlus_DebugWriteToStdErr=1 ./dotnet --fx-version "$(NETCOREAPP_VERSION)" sample/HelloWorld/bin/Debug/netcoreapp3.0/HelloWorld.dll
79 run-aspnet-sample: prepare
80 rm -rf sample/AspNetCore/{bin,obj}
81 dotnet publish sample/AspNetCore -c Debug -r $(RID)
82 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)
83 cp ../mcs/class/System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.dll sample/AspNetCore/bin/Debug/netcoreapp3.0/$(RID)/publish/
84 COMPlus_DebugWriteToStdErr=1 ./dotnet --fx-version "$(ASPNETCOREAPP_VERSION)" sample/AspNetCore/bin/Debug/netcoreapp3.0/$(RID)/publish/AspNetCore.dll
86 # COREHOST_TRACE=1
87 SHAREDRUNTIME := shared/Microsoft.NETCore.App/$(NETCOREAPP_VERSION)
89 bcl:
90 $(MAKE) -C ../mcs/build/ common/Consts.cs
91 $(MAKE) -C ../mcs/class/System.Private.CoreLib
92 cp ../mcs/class/System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.dll $(SHAREDRUNTIME)
94 runtime:
95 $(MAKE) -C ../mono
96 cp ../mono/mini/.libs/libmonosgen-2.0$(PLATFORM_AOT_SUFFIX) $(SHAREDRUNTIME)/$(PLATFORM_AOT_PREFIX)coreclr$(PLATFORM_AOT_SUFFIX)
98 link-mono:
99 cp ../mono/mini/.libs/libmonosgen-2.0$(PLATFORM_AOT_SUFFIX) $(SHAREDRUNTIME)/$(PLATFORM_AOT_PREFIX)coreclr$(PLATFORM_AOT_SUFFIX)
100 cp ../mcs/class/System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.{dll,pdb} $(SHAREDRUNTIME)
102 prepare: $(ASPNETCORESDK_FILE) $(NETCORESDK_FILE) update-corefx update-roslyn link-mono
104 nupkg:
105 nuget pack runtime.nuspec -properties VERSION=$(VERSION)$(VERSTUB)\;RID=$(RID)\;PLATFORM_AOT_SUFFIX=$(PLATFORM_AOT_SUFFIX)\;COREARCH=$(COREARCH) -OutputDirectory ../artifacts/
107 clean:
108 rm -rf sdk shared host dotnet tests obj corefx roslyn LICENSE.txt ThirdPartyNotices.txt $(NETCORESDK_FILE) $(ASPNETCORESDK_FILE)
111 # Running tests:
113 # We have two modes to run then with xtest-Foo.Test to be the prefered one because it runs all tests and simple runner
114 # with rules like tes-Foo which runs limited set of test
117 # e.g. `make xtest-System.Collections.Tests`
118 # '-parallel none -verbose' for debug, `-parallel all` to run all tests in parallel
119 xtest-%: prepare update-corefx-tests
120 echo -n "***************** $* *********************"
121 cp corefx/restore/corefx-restore.deps.json corefx/tests/extracted/$*/xunit.console.deps.json
122 cp corefx/restore/corefx-restore.deps.json corefx/tests/extracted/$*/Microsoft.DotNet.RemoteExecutorHost.deps.json
123 cp corefx/restore/corefx-restore.runtimeconfig.dev.json corefx/tests/extracted/$*/xunit.console.runtimeconfig.dev.json
124 cp corefx/restore/corefx-restore.runtimeconfig.dev.json corefx/tests/extracted/$*/Microsoft.DotNet.RemoteExecutorHost.runtimeconfig.dev.json
125 cp corefx/restore/corefx-restore.dll corefx/tests/extracted/$*/corefx-restore.dll
126 sed -i -e 's/9.9.9/$(NETCOREAPP_VERSION)/g' corefx/tests/extracted/$*/*.runtimeconfig.json
127 cd corefx/tests/extracted/$* && \
128 COMPlus_DebugWriteToStdErr=1 $(CURDIR)/./dotnet --fx-version "$(NETCOREAPP_VERSION)" xunit.console.dll $*.dll \
129 -notrait category=outerloop -notrait category=nonosxtests -notrait category=failing \
130 -notrait category=nonnetcoreapptests -notrait category=nonmonotests \
131 -html ../../TestResult-$*.html -nunit ../../TestResult-$*-netcore-xunit.xml \
132 $(shell if [ -a $(CURDIR)/excludes-$*.rsp ]; then grep -v '^#\|^$$' $(CURDIR)/excludes-$*.rsp; fi;) \
133 $(FIXTURE) || true
135 # these tests won't be included in `xtestall`
136 EXCLUDED_COREFX_TESTS = \
137 System.Utf8String.Experimental.Tests \
138 System.ComponentModel.Composition.Registration.Tests
140 # Tests suites which do pass yet
141 EXCLUDED_COREFX_TESTS_NOT_PASSING = \
142 $(EXCLUDED_COREFX_TESTS) \
143 System.ComponentModel.Composition.Tests \
144 System.Composition.TypedParts.Tests \
145 System.Console.Tests \
146 System.Data.Common.Tests \
147 System.Data.SqlClient.Tests \
148 System.Diagnostics.StackTrace.Tests \
149 System.Drawing.Common.Tests \
150 System.Numerics.Vectors.Tests \
151 System.Reflection.Context.Tests \
152 System.Reflection.CoreCLR.Tests \
153 System.Reflection.Emit.ILGeneration.Tests \
154 System.Reflection.Emit.Lightweight.Tests \
155 System.Reflection.Metadata.Tests \
156 System.Reflection.MetadataLoadContext.Tests \
157 System.Reflection.TypeExtensions.CoreCLR.Tests \
158 System.Reflection.TypeExtensions.Tests \
159 System.Runtime.Extensions.Tests \
160 System.Runtime.InteropServices.Tests \
161 System.Runtime.Loader.DefaultContext.Tests \
162 System.Runtime.Loader.RefEmitLoadContext.Tests \
163 System.Runtime.Loader.Tests \
164 System.Runtime.Serialization.Formatters.Tests \
165 System.Threading.Overlapped.Tests \
166 System.Xml.Xsl.XslTransformApi.Tests
168 xtestall: update-corefx-tests $(foreach workingtest, $(foreach test, $(wildcard corefx/tests/extracted/*), \
169 $(filter-out $(EXCLUDED_COREFX_TESTS), $(notdir $(test)))), $(addprefix xtest-, $(workingtest)))
171 xtestpass: update-corefx-tests $(foreach workingtest, $(foreach test, $(wildcard corefx/tests/extracted/*), \
172 $(filter-out $(EXCLUDED_COREFX_TESTS_NOT_PASSING), $(notdir $(test)))), $(addprefix xtest-, $(workingtest)))
174 build-local-corefx-test-%: check-env
175 cd $(COREFX_ROOT)/src/$*/tests && dotnet build -o "$(CURDIR)/corefx/tests/extracted/tmp"
176 cp $(CURDIR)/corefx/tests/extracted/tmp/$*.Tests.{dll,pdb} $(CURDIR)/corefx/tests/extracted/$*.Tests/
177 rm -rf $(CURDIR)/corefx/tests/extracted/tmp
180 # console test runner (obsolete)
182 TEST_SUITES = \
183 System.Runtime.Tests \
184 System.Runtime.CompilerServices.Unsafe.Tests \
185 System.Collections.Tests
187 # The binary directory under $(COREFIX_BINDIR)
188 System.Runtime.CompilerServices.Unsafe.Tests_PROFILE = netstandard-Debug
189 System.Runtime.Tests_PROFILE = netcoreapp-Unix-Debug
190 System.Runtime.Tests_XUNIT_ARGS = @../excludes-System.Runtime.Tests.rsp
191 System.Collections.Tests_PROFILE = netcoreapp-Debug
192 System.Reflection.Emit.Tests_PROFILE = netcoreapp-Debug
193 System.Reflection.Emit.Tests_XUNIT_ARGS = @../excludes-System.Reflection.Emit.Tests.rsp
194 System.Reflection.Emit.ILGeneration.Tests_PROFILE = netcoreapp-Debug
195 System.Reflection.Emit.Lightweight.Tests_PROFILE = netcoreapp-Debug
196 System.Threading.Tests_PROFILE = netcoreapp-Debug
197 System.Threading.Thread.Tests_PROFILE = netcoreapp-Debug
199 COREFX_BINDIR=$(COREFX_ROOT)/artifacts/bin
201 check-env:
202 @if [ "x$(COREFX_ROOT)" == "x" ]; then echo "Set COREFX_ROOT to the root of the fully built corefx repo."; exit 1; fi
204 build-%: check-env
205 cd gen-xunit-runner && dotnet run ../tests $(COREFX_ROOT) $(COREFX_BINDIR)/$*/$($*_PROFILE)/$*.dll -notrait category=nonosxtests -notrait category=failing -notrait category=Outerloop -notrait category=nonnetcoreapptests $($*_XUNIT_ARGS) $(XUNIT_ARGS)
206 cp $(COREFX_BINDIR)/RemoteExecutorConsoleApp/netstandard-Debug/RemoteExecutorConsoleApp.* tests/$*
207 cp $(COREFX_BINDIR)/System.Runtime.Tests/netcoreapp-Unix-Debug/TestLoadAssembly.dll tests/$*
208 sed -e 's/9.9.9/$(VERSION)/g' < tests/$*/RemoteExecutorConsoleApp.runtimeconfig.json > 2 && mv 2 tests/$*/RemoteExecutorConsoleApp.runtimeconfig.json
209 cd tests/$* && dotnet build
211 run-%: check-env
212 cd tests/$* && MONO_PATH=bin/Debug/netcoreapp3.0 MONO_ENV_OPTIONS="--debug --explicit-null-checks" COMPlus_DebugWriteToStdErr=1 ../../dotnet bin/Debug/netcoreapp3.0/$*-runner.dll
214 build-base: $(addprefix build-, $(TEST_SUITES))
216 check: $(addprefix run-, $(TEST_SUITES))
218 distdir: