-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up Makefile #21031
Clean up Makefile #21031
Changes from all commits
a6ab877
a1f140c
898462a
649d4e3
bf96ea4
3907851
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will change the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. However, we were setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I presume the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's kind of confusing to put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went to split this into MSBUILD_ARGS and DOTNET_ARGS, but then I found that the |
||
|
||
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) |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the distinction here between
=
and:=
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=
is lazy,:=
is strict.prints "hi one" "hi two"
prints "hi " "hi " (empty var).
The first behavior seems incredibly insane, so having the default for most variable assignments be
:=
is good style.Note it gets weird with recursive variables (e.g. our use of
MSBUILD_ARGS
):makes things get upset ("
Recursive variable 'MSBUILD_ARGS' references itself (eventually). Stop.
").There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(so the recursive case must use
:=
)Also, btw, in my list of changes, I listed this as "Use immediate sets instead of recursive sets in many places" (which is the documented name of each type of assignment - recursive is also called lazy, deferred, etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah ... def seems like we should be using
:=
then.