move more rules from mono/mono
authorEgorBo <egorbo@gmail.com>
Fri, 31 Jan 2020 18:12:26 +0000 (21:12 +0300)
committerEgorBo <egorbo@gmail.com>
Fri, 31 Jan 2020 18:12:26 +0000 (21:12 +0300)
src/mono/netcore/Makefile

index 358cc5a..f0b6672 100644 (file)
@@ -1,6 +1,7 @@
-
-DOTNET=../../../.dotnet/dotnet
+DOTNET_DIR=../../../.dotnet
+DOTNET=$(DOTNET_DIR)/dotnet
 TESTHOST_PATH=../../../artifacts/bin/testhost/
+BOOTSTRAP_RUNTIME = $(shell ls $(DOTNET_DIR)/shared/Microsoft.NETCore.App | tail -1)
 
 TARGET_FRAMEWORK=
 CONFIGURATION=
@@ -12,12 +13,18 @@ PLATFORM=
 # otherwise you have to set these variables for desired config
 ifeq ($(words $(wildcard $(TESTHOST_PATH)/*)), 1)
        TESTHOST_CFG := $(subst -, ,$(notdir $(wildcard $(TESTHOST_PATH)/*)))
-       CONFIGURATION := $(word 3,$(TESTHOST_CFG))
-       OS := $(word 2,$(TESTHOST_CFG))
        TARGET_FRAMEWORK := $(word 1,$(TESTHOST_CFG))
+       OS := $(word 2,$(TESTHOST_CFG))
+       CONFIGURATION := $(word 3,$(TESTHOST_CFG))
        PLATFORM := $(word 4,$(TESTHOST_CFG))
 endif
 
+ifeq ($(OS), OSX)
+       NATIVE_EXT := .dylib
+else
+       NATIVE_EXT := .so
+endif
+
 check-config:
        @if test -z "$(CONFIGURATION)"; then echo "CONFIGURATION is not set"; exit 1; fi
 
@@ -26,3 +33,25 @@ run-sample: check-config
 
 runtime:
        $(DOTNET) msbuild /t:Build ../mono.proj
+
+# temp: makes $(DOTNET) to use mono runtime (to run real-world apps using '$(DOTNET) run')
+patch-local-dotnet: check-config
+       cp ../../../artifacts/obj/mono/$(OS).$(PLATFORM).$(CONFIGURATION)/mono/mini/.libs/libmonosgen-2.0$(NATIVE_EXT) $(DOTNET_DIR)/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME)/libcoreclr$(NATIVE_EXT)
+       cp ../../../artifacts/bin/mono/$(OS).$(PLATFORM).$(CONFIGURATION)/System.Private.CoreLib.* $(DOTNET_DIR)/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME)
+
+# Precompile BCL libs in $(DOTNET) using LLVM (requires `--enable-llvm` build)
+patch-local-dotnet-aot-llvm: patch-local-dotnet
+       for assembly in $(DOTNET_DIR)/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME)/*.dll; do \
+               echo "[AOT] $$assembly"; \
+               PATH="../llvm/usr/bin/:$(PATH)" \
+               MONO_ENV_OPTIONS="--aot=llvm,mcpu=native" \
+               $(DOTNET) $$assembly ; \
+       done; \
+
+# run 'dotnet/performance' benchmarks
+# e.g. 'make run-benchmarks DOTNET_PERF_REPO=/prj/performance'
+# you can append BDN parameters at the end, e.g. ` -- --filter Burgers --keepFiles`
+run-benchmarks: patch-local-dotnet
+       @if test -z "$(DOTNET_PERF_REPO)"; then echo "DOTNET_PERF_REPO is not set"; exit 1; fi
+       cd $(DOTNET_PERF_REPO)/src/benchmarks/micro/ && \
+       $(DOTNET) run -c Release -f netcoreapp5.0 --cli $(CURDIR)/../.dotnet/dotnet
\ No newline at end of file