diff --git a/Makefile b/Makefile index c00e72729f700..7b5f261b99c61 100644 --- a/Makefile +++ b/Makefile @@ -1,69 +1,84 @@ -SHELL = /usr/bin/env bash -OS_NAME = $(shell uname -s) -BUILD_CONFIGURATION = Debug -BINARIES_PATH = $(shell pwd)/Binaries -SRC_PATH = $(shell pwd)/src -BOOTSTRAP_PATH = $(BINARIES_PATH)/Bootstrap -BUILD_LOG_PATH = -HOME_DIR = $(shell cd ~ && pwd) -DOTNET_VERSION = 1.0.1 -DOTNET = $(BINARIES_PATH)/dotnet-cli/dotnet -TARGET_FX = netcoreapp1.1 +SHELL := /usr/bin/env bash +OS_NAME := $(shell uname -s) +BUILD_CONFIGURATION := Debug +# $(dir) ends with slash +THIS_MAKEFILE_PATH := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) +BINARIES_PATH := $(THIS_MAKEFILE_PATH)Binaries +SRC_PATH := $(THIS_MAKEFILE_PATH)src +BOOTSTRAP_PATH := $(BINARIES_PATH)/Bootstrap +BUILD_LOG_PATH := +DOTNET_VERSION := 1.0.1 +DOTNET_PATH := $(BINARIES_PATH)/dotnet-cli +DOTNET := $(DOTNET_PATH)/dotnet +export PATH := $(DOTNET_PATH):$(PATH) -MSBUILD_ADDITIONALARGS := /v:m /fl /fileloggerparameters:Verbosity=normal /p:Configuration=$(BUILD_CONFIGURATION) +# Workaround, see https://github.com/dotnet/roslyn/issues/10210 +ifeq ($(origin HOME), undefined) + # Note that while ~ usually refers to $HOME, in the case where $HOME is unset, + # it looks up the current user's home dir, which is what we want. + # https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html + export HOME := $(shell cd ~ && pwd) +endif ifeq ($(OS_NAME),Linux) - RUNTIME_ID := $(shell . /etc/os-release && echo $$ID.$$VERSION_ID)-x64 + RUNTIME_ID := $(shell . /etc/os-release && echo $$ID.$$VERSION_ID)-x64 else ifeq ($(OS_NAME),Darwin) - RUNTIME_ID := osx.10.12-x64 + RUNTIME_ID := osx.10.12-x64 +else + $(error "Unknown OS_NAME: $(OS_NAME)") endif +MSBUILD_ARGS := /nologo '/consoleloggerparameters:Verbosity=minimal;summary' /p:Configuration=$(BUILD_CONFIGURATION) + ifneq ($(BUILD_LOG_PATH),) - MSBUILD_ADDITIONALARGS := $(MSBUILD_ADDITIONALARGS) /fileloggerparameters:LogFile=$(BUILD_LOG_PATH) + MSBUILD_ARGS += /filelogger '/fileloggerparameters:Verbosity=normal;logFile=$(BUILD_LOG_PATH)' endif +MSBUILD_MAIN_ARGS := $(MSBUILD_ARGS) +MSBUILD_BOOTSTRAP_ARGS := $(MSBUILD_ARGS) + +MSBUILD_BOOTSTRAP_ARGS += /p:RuntimeIdentifier=$(RUNTIME_ID) + +# This gets a bit complex. There are two cases here: +# BOOTSTRAP=false: +# Things proceed simply. The "all" target does not depend on the bootstrap +# target, so bootstrap is never built, and BootstrapBuildPath is unspecified. +# BOOTSTRAP=true: +# BOOTSTRAP_DEPENDENCY is set to "bootstrap", making the "all" target depend +# on it, and so the bootstrap compiler gets built. Additionally, +# BootstrapBuildPath is specified, but *only* for the main build, *not* the +# bootstrap build. ifeq ($(BOOTSTRAP),true) - MSBUILD_ARGS = $(MSBUILD_ADDITIONALARGS) /p:CscToolPath=$(BOOTSTRAP_PATH)/csc /p:CscToolExe=csc /p:VbcToolPath=$(BOOTSTRAP_PATH)/vbc /p:VbcToolExe=vbc + # MSBUILD_MAIN_ARGS += /p:BootstrapBuildPath=$(BOOTSTRAP_PATH) + MSBUILD_MAIN_ARGS += /p:CscToolPath=$(BOOTSTRAP_PATH)/csc /p:CscToolExe=csc /p:VbcToolPath=$(BOOTSTRAP_PATH)/vbc /p:VbcToolExe=vbc + BOOTSTRAP_DEPENDENCY := bootstrap else - MSBUILD_ARGS = $(MSBUILD_ADDITIONALARGS) + BOOTSTRAP_DEPENDENCY := endif -BUILD_CMD = dotnet build $(MSBUILD_ARGS) - -.PHONY: all bootstrap test toolset +.PHONY: all bootstrap test restore -all: restore - @export PATH="$(BINARIES_PATH)/dotnet-cli:$(PATH)" ; \ - export HOME="$(HOME_DIR)" ; \ - $(BUILD_CMD) CrossPlatform.sln +all: restore $(BOOTSTRAP_DEPENDENCY) + @echo Building CrossPlatform.sln + dotnet build $(THIS_MAKEFILE_PATH)CrossPlatform.sln $(MSBUILD_MAIN_ARGS) bootstrap: restore - export HOME="$(HOME_DIR)" ; \ - export PATH="$(BINARIES_PATH)/dotnet-cli:$(PATH)" ; \ - $(BUILD_CMD) src/Compilers/CSharp/CscCore && \ - $(BUILD_CMD) src/Compilers/VisualBasic/VbcCore && \ - mkdir -p $(BOOTSTRAP_PATH)/csc && mkdir -p $(BOOTSTRAP_PATH)/vbc && \ - dotnet publish -c $(BUILD_CONFIGURATION) -r $(RUNTIME_ID) src/Compilers/CSharp/CscCore -o $(BOOTSTRAP_PATH)/csc && \ - dotnet publish -c $(BUILD_CONFIGURATION) -r $(RUNTIME_ID) src/Compilers/VisualBasic/VbcCore -o $(BOOTSTRAP_PATH)/vbc - rm -rf Binaries/$(BUILD_CONFIGURATION) + @echo Building Bootstrap + dotnet publish $(SRC_PATH)/Compilers/CSharp/CscCore -o $(BOOTSTRAP_PATH)/csc $(MSBUILD_BOOTSTRAP_ARGS) + dotnet publish $(SRC_PATH)/Compilers/VisualBasic/VbcCore -o $(BOOTSTRAP_PATH)/vbc $(MSBUILD_BOOTSTRAP_ARGS) + rm -rf $(BINARIES_PATH)/$(BUILD_CONFIGURATION) test: - @export PATH="$(BINARIES_PATH)/dotnet-cli:$(PATH)" ; \ - export HOME="$(HOME_DIR)" ; \ - dotnet publish -r $(RUNTIME_ID) src/Test/DeployCoreClrTestRuntime -o $(BINARIES_PATH)/$(BUILD_CONFIGURATION)/CoreClrTest -p:RoslynRuntimeIdentifier=$(RUNTIME_ID) && \ - build/scripts/tests.sh $(BUILD_CONFIGURATION) + dotnet publish $(SRC_PATH)/Test/DeployCoreClrTestRuntime -o $(BINARIES_PATH)/$(BUILD_CONFIGURATION)/CoreClrTest -r $(RUNTIME_ID) -p:RoslynRuntimeIdentifier=$(RUNTIME_ID) $(MSBUILD_MAIN_ARGS) + $(THIS_MAKEFILE_PATH)build/scripts/tests.sh $(BUILD_CONFIGURATION) restore: $(DOTNET) - export PATH="$(BINARIES_PATH)/dotnet-cli:$(PATH)" ; \ - ./build/scripts/restore.sh + dotnet restore -v Minimal --disable-parallel $(THIS_MAKEFILE_PATH)build/ToolsetPackages/BaseToolset.csproj + dotnet restore -v Minimal --disable-parallel $(THIS_MAKEFILE_PATH)CrossPlatform.sln $(DOTNET): - mkdir -p $(BINARIES_PATH) ; \ - pushd $(BINARIES_PATH) ; \ - curl -O https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.sh && \ - chmod +x dotnet-install.sh && \ - ./dotnet-install.sh --version "$(DOTNET_VERSION)" --install-dir "$(BINARIES_PATH)/dotnet-cli" - + curl https://raw.githubusercontent.com/dotnet/cli/rel/$(DOTNET_VERSION)/scripts/obtain/dotnet-install.sh | \ + $(SHELL) -s -- --version "$(DOTNET_VERSION)" --install-dir "$(DOTNET_PATH)" clean: - @rm -rf Binaries + rm -rf $(BINARIES_PATH) diff --git a/build/scripts/restore.sh b/build/scripts/restore.sh deleted file mode 100755 index d9ee45a7c5562..0000000000000 --- a/build/scripts/restore.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -# Workaround, see https://github.com/dotnet/roslyn/issues/10210 -export HOME=$(cd ~ && pwd) - -echo "Restoring toolset packages" - -dotnet restore -v Minimal --disable-parallel $(pwd)/build/ToolsetPackages/BaseToolset.csproj - -echo "Restore CrossPlatform.sln" - -dotnet restore $(pwd)/CrossPlatform.sln diff --git a/build/scripts/tests.sh b/build/scripts/tests.sh index 2db9437ca5f4c..0cb0a7ddbc5c5 100755 --- a/build/scripts/tests.sh +++ b/build/scripts/tests.sh @@ -2,9 +2,6 @@ BUILD_CONFIGURATION=$1 -# This function will update the PATH variable to put the desired -# version of Mono ahead of the system one. - cd Binaries/$BUILD_CONFIGURATION/CoreClrTest chmod +x ./corerun diff --git a/cibuild.sh b/cibuild.sh index 7781ddb5f0c9f..c30cb8ae1d916 100755 --- a/cibuild.sh +++ b/cibuild.sh @@ -10,7 +10,6 @@ usage() echo " --debug Build Debug (default)" echo " --release Build Release" echo " --skiptest Do not run tests" - echo " --skipcrossgen Do not crossgen the bootstrapped compiler" echo " --skipcommitprinting Do not print commit information" echo " --nocache Force download of toolsets" } @@ -18,7 +17,6 @@ usage() BUILD_CONFIGURATION=Debug USE_CACHE=true SKIP_TESTS=false -SKIP_CROSSGEN=false SKIP_COMMIT_PRINTING=false MAKE="make" @@ -59,10 +57,6 @@ do SKIP_TESTS=true shift 1 ;; - --skipcrossgen) - SKIP_CROSSGEN=true - shift 1 - ;; --skipcommitprinting) SKIP_COMMIT_PRINTING=true shift 1 @@ -74,8 +68,6 @@ do esac done -MAKE_ARGS="BUILD_CONFIGURATION=$BUILD_CONFIGURATION SKIP_CROSSGEN=$SKIP_CROSSGEN" - if [ "$CLEAN_RUN" == "true" ]; then echo Clean out the enlistment git clean -dxf . @@ -86,13 +78,10 @@ if [ "$SKIP_COMMIT_PRINTING" == "false" ]; then git show --no-patch --pretty=raw HEAD fi -echo Building Bootstrap -$MAKE bootstrap $MAKE_ARGS - -echo Building CrossPlatform.sln -$MAKE all $MAKE_ARGS BOOTSTRAP=true BUILD_LOG_PATH=Binaries/Build.log +MAKE_TARGET="all" if [ "$SKIP_TESTS" == "false" ]; then - $MAKE test $MAKE_ARGS + MAKE_TARGET="$MAKE_TARGET test" fi +$MAKE $MAKE_TARGET BUILD_CONFIGURATION=$BUILD_CONFIGURATION BOOTSTRAP=true BUILD_LOG_PATH=Binaries/Build.log