Makefile 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. ifneq ($(wildcard config.make),)
  2. include config.make
  3. NETCORETESTS_VERSION := $(shell cat ../eng/Versions.props | sed -n 's/.*MicrosoftPrivateCoreFxNETCoreAppVersion>\(.*\)<\/MicrosoftPrivateCoreFxNETCoreAppVersion.*/\1/p' )
  4. NETCOREAPP_VERSION := $(shell cat ../eng/Versions.props | sed -n 's/.*MicrosoftNETCoreAppVersion>\(.*\)<\/MicrosoftNETCoreAppVersion.*/\1/p' )
  5. ROSLYN_VERSION:= $(shell cat ../eng/Versions.props | sed -n 's/.*MicrosoftNetCompilersVersion>\(.*\)<\/MicrosoftNetCompilersVersion.*/\1/p' )
  6. # Extracted from https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/master/latest.version
  7. ASPNETCOREAPP_VERSION := 3.0.0-preview-18614-0151
  8. # runtime version used by $(DOTNET) - local .net core sdk to bootstrap stuff
  9. # it doesn't match NETCOREAPP_VERSION
  10. BOOTSTRAP_RUNTIME = $(shell ls ../.dotnet/shared/Microsoft.NETCore.App)
  11. ifeq ($(HOST_PLATFORM),win32)
  12. PLATFORM_AOT_SUFFIX := .dll
  13. PLATFORM_AOT_PREFIX :=
  14. NETCORESDK_EXT = zip
  15. UNZIPCMD = python -c "import zipfile,sys; zipfile.ZipFile(sys.argv[1], 'r').extractall()"
  16. XUNIT_FLAGS = -notrait category=nonwindowstests @../../../../CoreFX.issues_windows.rsp
  17. TESTS_PLATFORM = Windows_NT.x64
  18. ON_RUNTIME_EXTRACT = chmod -R 755 {host,shared,./dotnet}
  19. DOTNET := $(shell powershell -ExecutionPolicy Bypass -Command "./init-tools.ps1")/dotnet.exe
  20. DOTNET := "$(subst \,/,$(DOTNET))"
  21. endif
  22. ifeq ($(HOST_PLATFORM),macos)
  23. PLATFORM_AOT_SUFFIX := .dylib
  24. PLATFORM_AOT_PREFIX := lib
  25. NETCORESDK_EXT = tar.gz
  26. UNZIPCMD = tar -xvf
  27. XUNIT_FLAGS = -notrait category=nonosxtests
  28. TESTS_PLATFORM = OSX.x64
  29. DOTNET := $(shell ./init-tools.sh | tail -1)
  30. endif
  31. ifeq ($(HOST_PLATFORM),linux)
  32. PLATFORM_AOT_SUFFIX := .so
  33. PLATFORM_AOT_PREFIX := lib
  34. NETCORESDK_EXT = tar.gz
  35. UNZIPCMD = tar -xvf
  36. XUNIT_FLAGS = -notrait category=nonlinuxtests @../../../../CoreFX.issues_linux.rsp
  37. ifeq ($(COREARCH), arm64)
  38. XUNIT_FLAGS += @../../../../CoreFX.issues_linux_arm64.rsp
  39. endif
  40. TESTS_PLATFORM = Linux.x64
  41. DOTNET := $(shell ./init-tools.sh | tail -1)
  42. endif
  43. NETCORESDK_FILE := dotnet-runtime-$(NETCOREAPP_VERSION)-$(RID).$(NETCORESDK_EXT)
  44. ASPNETCORESDK_FILE := aspnetcore-runtime-$(ASPNETCOREAPP_VERSION)-$(RID).$(NETCORESDK_EXT)
  45. NETCORE_URL := https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$(NETCOREAPP_VERSION)/$(NETCORESDK_FILE)
  46. ASPNETCORE_URL := https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/$(ASPNETCOREAPP_VERSION)/$(ASPNETCORESDK_FILE)
  47. FEED_BASE_URL := https://dotnetfeed.blob.core.windows.net/dotnet-core
  48. TEST_ASSETS_PATH := corefx-tests/$(NETCORETESTS_VERSION)/$(TESTS_PLATFORM)/netcoreapp/corefx-test-assets.xml
  49. # used to calculate exact version number for generating nupkg
  50. BLAME = $(shell git blame ../configure.ac | grep AC_INIT | cut -f1 -d' ')
  51. VERSTUB = .$(shell git rev-list --count $(BLAME)..HEAD)
  52. all: bcl
  53. $(NETCORESDK_FILE):
  54. curl $(NETCORE_URL) --output $(NETCORESDK_FILE)
  55. rm -rf shared/Microsoft.NETCore.App
  56. $(UNZIPCMD) $(NETCORESDK_FILE)
  57. $(ON_RUNTIME_EXTRACT)
  58. # AspNetCoreApp contains its own .NET Core Runtime but we don't need it so let's remove it
  59. # and update version in Microsoft.AspNetCore.App.runtimeconfig.json to NETCOREAPP_VERSION
  60. $(ASPNETCORESDK_FILE):
  61. curl $(ASPNETCORE_URL) --output $(ASPNETCORESDK_FILE)
  62. $(UNZIPCMD) $(ASPNETCORESDK_FILE)
  63. 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
  64. update-corefx: corefx/.stamp-dl-corefx-$(NETCORETESTS_VERSION)
  65. corefx/.stamp-dl-corefx-$(NETCORETESTS_VERSION): corefx-restore.csproj
  66. $(DOTNET) build corefx-restore.csproj --runtime $(RID) --packages corefx/packages -p:MicrosoftPrivateCoreFxNETCoreAppVersion=$(NETCORETESTS_VERSION) -p:OutputPath=corefx/restore/
  67. touch $@
  68. update-roslyn: roslyn/packages/microsoft.net.compilers.toolset/$(ROSLYN_VERSION)/microsoft.net.compilers.toolset.nuspec
  69. roslyn/packages/microsoft.net.compilers.toolset/$(ROSLYN_VERSION)/microsoft.net.compilers.toolset.nuspec:
  70. $(DOTNET) restore roslyn-restore.csproj -p:RoslynVersion=$(ROSLYN_VERSION) --packages roslyn/packages -p:OutputPath=roslyn/restore/
  71. run-sample: prepare
  72. $(DOTNET) build sample/HelloWorld
  73. MONO_ENV_OPTIONS="--debug" COMPlus_DebugWriteToStdErr=1 ./dotnet --fx-version "$(NETCOREAPP_VERSION)" sample/HelloWorld/bin/netcoreapp3.0/HelloWorld.dll
  74. run-sample-coreclr:
  75. cd sample/HelloWorld && $(DOTNET) run
  76. run-aspnet-sample: prepare
  77. rm -rf sample/AspNetCore/{bin,obj}
  78. $(DOTNET) publish sample/AspNetCore -c Debug -r $(RID)
  79. 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)
  80. cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.dll sample/AspNetCore/bin/Debug/netcoreapp3.0/$(RID)/publish/
  81. COMPlus_DebugWriteToStdErr=1 ./dotnet --fx-version "$(ASPNETCOREAPP_VERSION)" sample/AspNetCore/bin/Debug/netcoreapp3.0/$(RID)/publish/AspNetCore.dll
  82. # makes $(DOTNET) to use mono runtime (to run real-world apps using '$(DOTNET) run')
  83. patch-local-dotnet: prepare
  84. cp ../mono/mini/.libs/libmonosgen-2.0$(PLATFORM_AOT_SUFFIX) ../.dotnet/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME)/$(PLATFORM_AOT_PREFIX)coreclr$(PLATFORM_AOT_SUFFIX)
  85. cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.dll ../.dotnet/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME)
  86. cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.pdb ../.dotnet/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME)
  87. # COREHOST_TRACE=1
  88. SHAREDRUNTIME := shared/Microsoft.NETCore.App/$(NETCOREAPP_VERSION)
  89. System.Private.CoreLib/src/System/Environment.Mono.cs: System.Private.CoreLib/src/System/Environment.Mono.in config.make
  90. test -n '$(MONO_CORLIB_VERSION)'
  91. sed -e 's,@''MONO_CORLIB_VERSION@,$(MONO_CORLIB_VERSION),' $< > $@
  92. bcl: update-roslyn System.Private.CoreLib/src/System/Environment.Mono.cs
  93. $(DOTNET) build $(CORETARGETS) $(CORLIB_BUILD_FLAGS) -p:BuildArch=$(COREARCH) \
  94. -p:OutputPath=bin/$(COREARCH) \
  95. -p:RoslynPropsFile="../roslyn/packages/microsoft.net.compilers.toolset/$(ROSLYN_VERSION)/build/Microsoft.Net.Compilers.Toolset.props" \
  96. System.Private.CoreLib/System.Private.CoreLib.csproj
  97. debug-bcl:
  98. $(MAKE) bcl CORLIB_BUILD_FLAGS="-c Debug"
  99. runtime:
  100. $(MAKE) -C ../mono
  101. link-mono: $(SHAREDRUNTIME)/.stamp-link-mono
  102. $(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
  103. cp ../mono/mini/.libs/libmonosgen-2.0$(PLATFORM_AOT_SUFFIX) $(SHAREDRUNTIME)/$(PLATFORM_AOT_PREFIX)coreclr$(PLATFORM_AOT_SUFFIX)
  104. cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.dll $(SHAREDRUNTIME)
  105. cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.pdb $(SHAREDRUNTIME)
  106. touch $@
  107. prepare: $(ASPNETCORESDK_FILE) $(NETCORESDK_FILE) update-corefx update-roslyn link-mono
  108. nupkg:
  109. $(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
  110. $(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
  111. clean:
  112. rm -rf .configured ../.dotnet sdk shared host dotnet tests obj corefx roslyn LICENSE.txt ThirdPartyNotices.txt $(NETCORESDK_FILE) $(ASPNETCORESDK_FILE)
  113. update-tests-corefx: corefx/.stamp-dl-corefx-tests-$(NETCORETESTS_VERSION)
  114. corefx/.stamp-dl-corefx-tests-$(NETCORETESTS_VERSION):
  115. rm -rf corefx/tests
  116. $(DOTNET) msbuild corefx-tests-restore.proj -m -t:DownloadAllTests -p:TEST_ASSETS_PATH="$(TEST_ASSETS_PATH)" -p:FEED_BASE_URL="$(FEED_BASE_URL)"
  117. rm -rf corefx/tests/extracted/System.Utf8String.Experimental.Tests
  118. touch $@
  119. #
  120. # Running CoreFX tests
  121. #
  122. # You can run either individual test assembly or run all CoreFX tests. The tests are automatically downloaded
  123. # from the shared location and built locally.
  124. #
  125. # Running all test: `make run-tests-corefx`
  126. #
  127. # Running individual test: MONO_ENV_OPTIONS="--debug" make run-tests-corefx-System.Collections.Tests
  128. #
  129. run-tests-corefx: update-tests-corefx
  130. for testdir in corefx/tests/extracted/*; do \
  131. $(MAKE) run-tests-corefx-$$(basename $${testdir}) || true; \
  132. done; \
  133. $(MAKE) xunit-summary
  134. run-tests-corefx-%: prepare update-tests-corefx
  135. @echo ""
  136. @echo "***************** $* *********************"
  137. @cp corefx/restore/corefx-restore.deps.json corefx/tests/extracted/$*/xunit.console.deps.json
  138. @cp corefx/restore/corefx-restore.deps.json corefx/tests/extracted/$*/Microsoft.DotNet.RemoteExecutorHost.deps.json
  139. @cp corefx/restore/corefx-restore.runtimeconfig.dev.json corefx/tests/extracted/$*/$*.runtimeconfig.dev.json
  140. @cp corefx/restore/corefx-restore.dll corefx/tests/extracted/$*/corefx-restore.dll
  141. @sed -i -e 's/5.0.0\"/$(NETCOREAPP_VERSION)\"/g' corefx/tests/extracted/$*/*.runtimeconfig.json
  142. cd corefx/tests/extracted/$* && \
  143. COMPlus_DebugWriteToStdErr=1 $(CURDIR)/./dotnet exec --runtimeconfig $*.runtimeconfig.json --fx-version "$(NETCOREAPP_VERSION)" xunit.console.dll $*.dll \
  144. -html ../../TestResult-$*.html -xml ../../TestResult-$*-netcore-xunit.xml \
  145. $(XUNIT_FLAGS) @../../../../CoreFX.issues.rsp \
  146. $(FIXTURE)
  147. # build a test assembly in COREFX_ROOT (path to a fully built corefx repo) and copy it to corefx/tests/extracted
  148. # e.g. `make build-test-corefx-System.Runtime COREFX_ROOT=/prj/corefx-master`
  149. build-test-corefx-%:
  150. cd $(COREFX_ROOT)/src/$*/tests && $(DOTNET) msbuild /p:OutputPath=tmp
  151. cp $(COREFX_ROOT)/src/$*/tests/tmp/$*.Tests.{dll,pdb} $(CURDIR)/corefx/tests/extracted/$*.Tests/
  152. rm -rf $(COREFX_ROOT)/src/$*/tests/tmp
  153. xunit-summary:
  154. ./xunit-summary.py "corefx/tests"
  155. endif
  156. distdir: