-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
69 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,88 @@ | ||
.PHONY: all | ||
.PHONY: all build build-dotnet6 build-dotnet-framework clean clean-build precommit restore test test-dotnet6 test-dotnet-framework run-examples help | ||
|
||
# Determine the operating system | ||
OS := $(shell uname) | ||
|
||
# Set the default .NET version to .NET 6.0 | ||
DOTNET_VERSION := net6.0 | ||
TEST_LOGGER_OPTIONS := --logger "console;verbosity=detailed" | ||
|
||
# Windows-specific settings | ||
# This tests if "NT" is in the OS string, which would indicate Windows. | ||
ifneq (,$(findstring NT,$(OS))) | ||
BUILD_TARGETS := build-dotnet6 build-dotnet-framework | ||
TEST_TARGETS := test-dotnet6 test-dotnet-framework | ||
else | ||
BUILD_TARGETS := build-dotnet6 | ||
TEST_TARGETS := test-dotnet6 | ||
endif | ||
|
||
# Enable gRPC-Web if requested | ||
GRPC_WEB_FLAG := | ||
ifeq ($(GRPC_WEB), true) | ||
GRPC_WEB_FLAG := -p:DefineConstants=USE_GRPC_WEB | ||
endif | ||
|
||
## Generate sync unit tests, format, lint, and test | ||
all: precommit | ||
|
||
|
||
.PHONY: build | ||
## Build project | ||
build: | ||
@dotnet build | ||
## Build the project (conditioned by OS) | ||
build: ${BUILD_TARGETS} | ||
|
||
|
||
## Build the project for .NET 6.0 | ||
build-dotnet6: | ||
@echo "Building the project for .NET 6.0..." | ||
@dotnet build -f ${DOTNET_VERSION} ${GRPC_WEB_FLAG} | ||
|
||
|
||
## Build the project on .NET Framework | ||
build-dotnet-framework: | ||
@echo "Building the project for .NET Framework 4.62..." | ||
@dotnet build -f net462 ${GRPC_WEB_FLAG} | ||
|
||
.PHONY: clean | ||
## Remove build files | ||
clean: | ||
@echo "Cleaning build artifacts..." | ||
@dotnet clean | ||
|
||
|
||
.PHONY: clean-build | ||
## Build project | ||
clean-build: clean restore build | ||
clean-build: clean restore ${BUILD_TARGETS} | ||
|
||
|
||
.PHONY: precommit | ||
## Run clean-build and test as a step before committing. | ||
precommit: clean-build test | ||
|
||
|
||
.PHONY: restore | ||
## Sync dependencies | ||
restore: | ||
@echo "Restoring dependencies..." | ||
@dotnet restore | ||
|
||
|
||
.PHONY: test | ||
## Run unit and integration tests | ||
test: | ||
@dotnet test | ||
## Run unit and integration tests (conditioned by OS) | ||
test: ${TEST_TARGETS} | ||
|
||
|
||
.PHONY: test-net6 | ||
## Run unit and integration tests on the .NET 6.0 runtime | ||
test-net6: | ||
@dotnet test -f net6.0 | ||
test-dotnet6: | ||
@echo "Running tests on .NET 6.0..." | ||
@dotnet test ${TEST_LOGGER_OPTIONS} -f ${DOTNET_VERSION} | ||
|
||
|
||
.PHONY: test-net-framework | ||
## Run unit and integration tests on the .NET Framework runtime | ||
test-net-framework: | ||
@dotnet test -f net462 | ||
## Run unit and integration tests on the .NET Framework runtime (Windows only) | ||
test-dotnet-framework: | ||
@echo "Running tests on .NET Framework 4.62 (Windows only)..." | ||
@dotnet test ${TEST_LOGGER_OPTIONS} -f net462 | ||
|
||
|
||
.PHONY: run-examples | ||
## Run example applications and snippets | ||
run-examples: | ||
@dotnet run --project examples/MomentoApplication | ||
@dotnet run --project examples/DocExampleApis | ||
|
||
# See <https://gist.github.com/klmr/575726c7e05d8780505a> for explanation. | ||
.PHONY: help | ||
help: | ||
@echo "$$(tput bold)Available rules:$$(tput sgr0)";echo;sed -ne"/^## /{h;s/.*//;:d" -e"H;n;s/^## //;td" -e"s/:.*//;G;s/\\n## /---/;s/\\n/ /g;p;}" ${MAKEFILE_LIST}|LC_ALL='C' sort -f|awk -F --- -v n=$$(tput cols) -v i=19 -v a="$$(tput setaf 6)" -v z="$$(tput sgr0)" '{printf"%s%*s%s ",a,-i,$$1,z;m=split($$2,w," ");l=n-i;for(j=1;j<=m;j++){l-=length(w[j])+1;if(l<= 0){l=n-i-length(w[j])-1;printf"\n%*s ",-i," ";}printf"%s ",w[j];}printf"\n";}'|more $(shell test $(shell uname) == Darwin && echo '-Xr') |