Skip to content

Instantly share code, notes, and snippets.

@khyperia
Created October 9, 2017 05:23
Show Gist options
  • Save khyperia/570093c14c5d6c37a331f7bfe44a50d8 to your computer and use it in GitHub Desktop.
Save khyperia/570093c14c5d6c37a331f7bfe44a50d8 to your computer and use it in GitHub Desktop.
Timing of Makefile vs. dotnet msbuild
# PROJECTS=$(shell find src -iname '*test*' -prune -o -name '*.csproj' -printf '%h ')
# TARGETS=$(addprefix Binaries/,$(addsuffix .dll,$(PROJECTS)))
#
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
.PHONY: all
# Do not delete "intermediate" files
.SECONDARY:
#all: $(TARGETS)
all: Binaries/Compilers/CSharp/csc/csc.dll
.SECONDEXPANSION:
Binaries/%.dll: $$(call rwildcard,$$(dir src/%),*.cs)
mkdir -p $(dir $@)
@echo "csc $@"
@csc /t:Library /define:NETCOREAPP2_0 /define:COMPILERCORE /unsafe /langversion:7.1 $(subst `,\`,$(patsubst %.dll,/r:%.dll,$^)) /out:$@
# Project-to-project dependencies
Binaries/Compilers/CSharp/Portable/CSharpCodeAnalysis.dll: Binaries/Compilers/Core/Portable/CodeAnalysis.dll
Binaries/Compilers/CSharp/csc/csc.dll: Binaries/Compilers/CSharp/Portable/CSharpCodeAnalysis.dll
Binaries/Compilers/CSharp/csc/csc.dll: Binaries/Compilers/Core/Portable/CodeAnalysis.dll
# Nuget dependencies
Binaries/Compilers/Core/Portable/CodeAnalysis.dll: nuget/netstandard.dll
Binaries/Compilers/Core/Portable/CodeAnalysis.dll: nuget/System.Collections.Immutable.dll
Binaries/Compilers/Core/Portable/CodeAnalysis.dll: nuget/System.Reflection.Metadata.dll
Binaries/Compilers/Core/Portable/CodeAnalysis.dll: nuget/System.Text.Encoding.CodePages.dll
Binaries/Compilers/CSharp/Portable/CSharpCodeAnalysis.dll: nuget/netstandard.dll
Binaries/Compilers/CSharp/Portable/CSharpCodeAnalysis.dll: nuget/System.Collections.Immutable.dll
Binaries/Compilers/CSharp/Portable/CSharpCodeAnalysis.dll: nuget/System.Reflection.Metadata.dll
Binaries/Compilers/CSharp/csc/csc.dll: nuget/System.Security.AccessControl.dll
Binaries/Compilers/CSharp/csc/csc.dll: nuget/System.Text.Encoding.CodePages.dll
Binaries/Compilers/CSharp/csc/csc.dll: nuget/System.Security.Principal.Windows.dll
# Generated files
Binaries/Compilers/Core/Portable/CodeAnalysis.dll: generated/ivt/CSharpCodeAnalysis.cs
Binaries/Compilers/Core/Portable/CodeAnalysis.dll: generated/ivt/csc.cs
Binaries/Compilers/CSharp/Portable/CSharpCodeAnalysis.dll: generated/ivt/csc.cs
# Derpy shared files
Binaries/Compilers/Core/Portable/CodeAnalysis.dll: src/Dependencies/PooledObjects/*.cs
Binaries/Compilers/Core/Portable/CodeAnalysis.dll: src/Dependencies/CodeAnalysis.Debugging/*.cs
Binaries/Compilers/Core/Portable/CodeAnalysis.dll: src/Compilers/Core/AnalyzerDriver/*.cs
Binaries/Compilers/Core/Portable/CodeAnalysis.dll: src/Compilers/Shared/DesktopShim.cs
Binaries/Compilers/CSharp/Portable/CSharpCodeAnalysis.dll: src/Compilers/CSharp/CSharpAnalyzerDriver/*.cs
Binaries/Compilers/CSharp/csc/csc.dll: nuget/netstandard.dll
Binaries/Compilers/CSharp/csc/csc.dll: src/Compilers/Core/CommandLine/*.cs
Binaries/Compilers/CSharp/csc/csc.dll: src/Compilers/Shared/BuildClient.cs
Binaries/Compilers/CSharp/csc/csc.dll: src/Compilers/Shared/BuildServerConnection.cs
Binaries/Compilers/CSharp/csc/csc.dll: src/Compilers/Shared/CoreClrAnalyzerAssemblyLoader.cs
Binaries/Compilers/CSharp/csc/csc.dll: src/Compilers/Shared/CoreClrBuildClient.cs
Binaries/Compilers/CSharp/csc/csc.dll: src/Compilers/Shared/Csc.cs
Binaries/Compilers/CSharp/csc/csc.dll: src/Compilers/Shared/DesktopAnalyzerAssemblyLoader.cs
Binaries/Compilers/CSharp/csc/csc.dll: src/Compilers/Shared/DesktopBuildClient.cs
Binaries/Compilers/CSharp/csc/csc.dll: src/Compilers/Shared/ExitingTraceListener.cs
# super special weird path, so super special rule
nuget/netstandard.dll: | nuget/NETStandard.Library.nupkg.extract
ln -s NETStandard.Library.nupkg.extract/build/netstandard2.0/ref/netstandard.dll $@
nuget:
mkdir -p nuget
nuget/%.nupkg: | nuget
curl -L "https://www.nuget.org/api/v2/package/$*" -o $@
nuget/%.nupkg.extract: nuget/%.nupkg
unzip $< -d $@
nuget/%.dll: nuget/%.nupkg.extract
cp nuget/$*.nupkg.extract/lib/netstandard2.0/$*.dll $@
generated/ivt/%.cs:
mkdir -p $(dir $@)
echo '[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("$*")]' > $@
time make
make 36.75s user 2.67s system 245% cpu 16.039 total
time bash <<< "dotnet restore build/ToolsetPackages/BaseToolset.csproj; dotnet build src/Compilers/CSharp/csc/csc.csproj"
bash <<< 45.38s user 3.55s system 93% cpu 52.303 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment