-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
183 lines (159 loc) · 7.15 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# usage: make run|format|clean
#
# run - build and execute benchmarks
# format - use clang-format on all sources
# clean - remove curent build directory
#
MAKEFLAGS += --no-print-directory
SCRIPT := $(wildcard toolchains/*.cmake)
RECORD := $(patsubst toolchains/%.cmake,%,$(SCRIPT))
TARGET := $(patsubst %,build/%/native.dll,$(RECORD))
DEPEND := $(patsubst %,build/%/CMakeCache.txt,$(RECORD))
DELETE := $(patsubst %,delete/%,$(RECORD))
all: $(TARGET)
run: all $(RECORD)
$(RECORD): %: build/%/native.dll
cmake --build build/$* --target benchmark
$(DEPEND): build/%/CMakeCache.txt: toolchains/%.cmake toolchains/%/lib/benchmark.lib CMakeLists.txt
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$< -B build/$*
$(TARGET): build/%/native.dll: build/%/CMakeCache.txt src/main.cpp
cmake --build build/$*
format: toolchains/llvm/bin/clang.exe
cmake -P res/scripts/format.cmake
clean: $(DELETE)
cmake -E remove_directory toolchains/msvc
cmake -E remove_directory toolchains/llvm
cmake -E remove_directory build
$(DELETE): delete/%:
cmake -E remove_directory toolchains/src/$*-benchmark
cmake -E remove_directory toolchains/src/$*-libcxx
cmake -E remove_directory toolchains/src/$*-compiler-rt
cmake -E remove_directory toolchains/$*
toolchains/src/llvm:
git clone --depth 1 https://github.com/llvm/llvm-project toolchains/src/llvm
toolchains/src/llvm/llvm-patch.log: \
toolchains/src/llvm
cmake -P toolchains/src/llvm-patch.cmake
toolchains/src/llvm-build/CMakeCache.txt: \
toolchains/src/llvm/llvm-patch.log
cmake -GNinja -DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_INSTALL_PREFIX="$(CURDIR)/toolchains/llvm" \
-DLLVM_ENABLE_PROJECTS="lld;clang;clang-tools-extra" \
-DLLVM_TARGETS_TO_BUILD="X86" \
-DLLVM_ENABLE_UNWIND_TABLES=OFF \
-DLLVM_ENABLE_WARNINGS=OFF \
-DLLVM_ENABLE_RTTI=OFF \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_DOCS=OFF \
-DCLANG_DEFAULT_STD_C="c99" \
-DCLANG_DEFAULT_STD_CXX="cxx2a" \
-DCLANG_DEFAULT_CXX_STDLIB="libc++" \
-DCLANG_DEFAULT_RTLIB="compiler-rt" \
-DCLANG_DEFAULT_LINKER="lld" \
-B toolchains/src/llvm-build toolchains/src/llvm/llvm
toolchains/llvm/bin/clang.exe: \
toolchains/src/llvm-build/CMakeCache.txt
cmake --build toolchains/src/llvm-build -t \
install-clang-stripped \
install-clang-format-stripped \
install-clang-resource-headers \
install-llvm-ar-stripped \
install-llvm-ranlib-stripped \
install-lld-stripped \
install-LTO-stripped \
llvm-config
cmake -E remove -f "toolchains/llvm/bin/ld.lld.exe"
cmake -E remove -f "toolchains/llvm/bin/ld64.lld.exe"
cmake -E remove -f "toolchains/llvm/bin/lld.exe"
cmake -E remove -f "toolchains/llvm/bin/wasm-ld.exe"
cmake -E remove -f "toolchains/llvm/bin/clang++.exe"
cmake -E remove -f "toolchains/llvm/bin/clang-cl.exe"
cmake -E remove -f "toolchains/llvm/bin/clang-cpp.exe"
cmake -E remove -f "toolchains/llvm/bin/llvm-ranlib.exe"
cmd /c mklink "toolchains\llvm\bin\clang++.exe" "clang.exe"
cmd /c mklink "toolchains\llvm\bin\clang-cl.exe" "clang.exe"
cmd /c mklink "toolchains\llvm\bin\llvm-ranlib.exe" "llvm-ar.exe"
.PRECIOUS: toolchains/src/%-compiler-rt/CMakeCache.txt
toolchains/src/%-compiler-rt/CMakeCache.txt: \
toolchains/llvm/bin/clang.exe
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="$(CURDIR)/toolchains/$*.cmake" \
-DCMAKE_INSTALL_PREFIX="$(CURDIR)/toolchains/$*/lib/clang/10.0.0" \
-DLLVM_CONFIG_PATH="$(CURDIR)/toolchains/src/llvm-build/bin/llvm-config.exe" \
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
-DCOMPILER_RT_BUILD_XRAY=OFF \
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
-DCOMPILER_RT_BUILD_PROFILE=OFF \
-DCOMPILER_RT_INCLUDE_TESTS=OFF \
-B toolchains/src/$*-compiler-rt toolchains/src/llvm/compiler-rt
.PRECIOUS: toolchains/%/lib/clang/10.0.0/lib/windows/clang_rt.builtins-x86_64.lib
toolchains/%/lib/clang/10.0.0/lib/windows/clang_rt.builtins-x86_64.lib: \
toolchains/src/%-compiler-rt/CMakeCache.txt
cmake --build toolchains/src/$*-compiler-rt -t install-compiler-rt-stripped
.PRECIOUS: toolchains/src/%-libcxx/CMakeCache.txt
toolchains/src/%-libcxx/CMakeCache.txt: \
toolchains/%/lib/clang/10.0.0/lib/windows/clang_rt.builtins-x86_64.lib
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="$(CURDIR)/toolchains/$*.cmake" \
-DCMAKE_INSTALL_PREFIX="$(CURDIR)/toolchains/$*" \
-DLLVM_CONFIG_PATH="$(CURDIR)/toolchains/src/llvm-build/bin/llvm-config.exe" \
-DLIBCXX_STANDARD_VER="c++2a" \
-DLIBCXX_ENABLE_SHARED=OFF \
-DLIBCXX_ENABLE_STATIC=ON \
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \
-DLIBCXX_INCLUDE_BENCHMARKS=OFF \
-DLIBCXX_INCLUDE_TESTS=OFF \
-DLIBCXX_INCLUDE_DOCS=OFF \
-DLIBCXX_HAS_WIN32_THREAD_API=ON \
-B toolchains/src/$*-libcxx toolchains/src/llvm/libcxx
.PRECIOUS: toolchains/%/lib/libc++.lib
toolchains/%/lib/libc++.lib: \
toolchains/src/%-libcxx/CMakeCache.txt
cmake --build toolchains/src/$*-libcxx -t install-cxx-stripped
cmd /c mklink "toolchains\$*\lib\c++.lib" "libc++.lib"
.PRECIOUS: toolchains/src/llvm-cxx-%-benchmark/CMakeCache.txt
toolchains/src/llvm-cxx-%-benchmark/CMakeCache.txt: \
toolchains/llvm-cxx-%/lib/libc++.lib \
toolchains/src/benchmark-1.5.0
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="$(CURDIR)/toolchains/llvm-cxx-$*.cmake" \
-DCMAKE_INSTALL_PREFIX="$(CURDIR)/toolchains/llvm-cxx-$*" \
-DBENCHMARK_ENABLE_TESTING=OFF \
-DBENCHMARK_ENABLE_GTEST_TESTS=OFF \
-DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF \
-DBENCHMARK_ENABLE_EXCEPTIONS=OFF \
-B toolchains/src/llvm-cxx-$*-benchmark toolchains/src/benchmark-1.5.0
.PRECIOUS: toolchains/src/llvm-stl-%-benchmark/CMakeCache.txt
toolchains/src/llvm-stl-%-benchmark/CMakeCache.txt: \
toolchains/llvm/bin/clang.exe \
toolchains/src/benchmark-1.5.0
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="$(CURDIR)/toolchains/llvm-stl-$*.cmake" \
-DCMAKE_INSTALL_PREFIX="$(CURDIR)/toolchains/llvm-stl-$*" \
-DBENCHMARK_ENABLE_TESTING=OFF \
-DBENCHMARK_ENABLE_GTEST_TESTS=OFF \
-DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF \
-DBENCHMARK_ENABLE_EXCEPTIONS=OFF \
-B toolchains/src/llvm-stl-$*-benchmark toolchains/src/benchmark-1.5.0
.PRECIOUS: toolchains/src/msvc-stl-%-benchmark/CMakeCache.txt
toolchains/src/msvc-stl-%-benchmark/CMakeCache.txt: \
toolchains/src/benchmark-1.5.0
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="$(CURDIR)/toolchains/msvc-stl-$*.cmake" \
-DCMAKE_INSTALL_PREFIX="$(CURDIR)/toolchains/msvc-stl-$*" \
-DBENCHMARK_ENABLE_TESTING=OFF \
-DBENCHMARK_ENABLE_GTEST_TESTS=OFF \
-DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF \
-DBENCHMARK_ENABLE_EXCEPTIONS=OFF \
-B toolchains/src/msvc-stl-$*-benchmark toolchains/src/benchmark-1.5.0
.PRECIOUS: toolchains/%/lib/benchmark.lib
toolchains/%/lib/benchmark.lib: \
toolchains/src/%-benchmark/CMakeCache.txt
cmake --build toolchains/src/$*-benchmark -t install
toolchains/src/benchmark-1.5.0: toolchains/src/benchmark-1.5.0.zip
cd toolchains/src && cmake -E tar xf benchmark-1.5.0.zip
toolchains/src/benchmark-1.5.0.zip:
curl -L https://github.com/google/benchmark/archive/v1.5.0.zip -o $@
.PHONY: all run $(RECORD) format clean $(DELETE)