-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
367 lines (326 loc) · 14.3 KB
/
Copy pathMakefile
File metadata and controls
367 lines (326 loc) · 14.3 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# cpp26-systems-stack — developer workflows
#
# Usage:
# make help
# make # configure base + build + test
# make full # Folly + HPX
# make run
# make docs # list library guides
.PHONY: help all configure configure-folly configure-hpx configure-full \
build rebuild test run smoke examples bench \
folly hpx full clean distclean \
reconfigure compile-commands \
clion clion-index clion-test \
ninja-help configure-ninja build-ninja test-ninja run-ninja smoke-ninja \
examples-ninja ninja compile-commands-ninja \
wiki wiki-preview \
install-folly install-hpx install-industry deps-check docs
# ---------------------------------------------------------------------------
# Config
# ---------------------------------------------------------------------------
CMAKE ?= cmake
CTEST ?= ctest
BUILD_TYPE ?= Release
JOBS ?= $(shell sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 4)
HOMEBREW_PREFIX ?= $(shell brew --prefix 2>/dev/null || echo /opt/homebrew)
HPX_ROOT ?= $(HOME)/cpp-deps/hpx
# Separate build trees so option combos don't stomp each other
BUILD_DIR ?= build
BUILD_FOLLY ?= build_folly
BUILD_HPX ?= build_hpx
BUILD_FULL ?= build_full
# Isolated Ninja tree (do not mix generators in the same -B directory)
BUILD_NINJA ?= build_ninja
NINJA ?= ninja
CMAKE_COMMON = -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DCMAKE_PREFIX_PATH="$(HOMEBREW_PREFIX);$(HPX_ROOT)" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
# Default goal
all: configure build test
help:
@echo "cpp26-systems-stack — C++26 systems ecosystem"
@echo ""
@echo "Build / test"
@echo " make / make all Configure base, build, test"
@echo " make configure CMake base (no Folly/HPX)"
@echo " make build Build current BUILD_DIR ($(BUILD_DIR))"
@echo " make rebuild Clean + configure + build + test"
@echo " make test ctest in BUILD_DIR"
@echo " make run / smoke Run lib_smoke binary"
@echo " make examples Build+run ll + industry examples"
@echo " make bench Build+run Google Benchmark queue microbenches"
@echo " make clean Remove object files (keep CMake cache)"
@echo " make distclean Remove all build_* trees"
@echo ""
@echo "Optional stacks"
@echo " make folly Configure+build+test with Folly"
@echo " make hpx Configure+build+test with HPX"
@echo " make full Configure+build+test with Folly+HPX"
@echo " make configure-folly / configure-hpx / configure-full"
@echo ""
@echo "Dependencies"
@echo " make deps-check Show Homebrew + HPX + industry install status"
@echo " make install-folly brew install folly"
@echo " make install-hpx Build/install HPX to HPX_ROOT ($(HPX_ROOT))"
@echo " make install-industry brew: hwloc flatbuffers google-benchmark mimalloc"
@echo ""
@echo "CLion / IDE"
@echo " make clion Configure clion-debug preset + compile_commands.json"
@echo " make clion-index Build ide_index (full type surface for IntelliSense)"
@echo " make clion-test ctest in build/clion-debug"
@echo ""
@echo "Ninja generator (see docs/tutorials/ninja-build.md)"
@echo " make ninja-help Detail Ninja-related targets"
@echo " make ninja Configure+build+test with -G Ninja → $(BUILD_NINJA)/"
@echo " make configure-ninja / build-ninja / test-ninja / run-ninja"
@echo " make examples-ninja / compile-commands-ninja"
@echo ""
@echo "Docs / wiki"
@echo " make docs List library guides + blueprint + tutorials"
@echo " make wiki Publish docs/ → GitHub Wiki (see docs/WIKI.md)"
@echo " make wiki-preview Generate wiki pages under build/wiki-preview only"
@echo ""
@echo "Variables: BUILD_TYPE=$(BUILD_TYPE) JOBS=$(JOBS) BUILD_DIR=$(BUILD_DIR)"
@echo " BUILD_NINJA=$(BUILD_NINJA) HPX_ROOT=$(HPX_ROOT)"
@echo " HOMEBREW_PREFIX=$(HOMEBREW_PREFIX)"
# ---------------------------------------------------------------------------
# Configure
# ---------------------------------------------------------------------------
configure:
$(CMAKE) -S . -B $(BUILD_DIR) $(CMAKE_COMMON) \
-DLIB_SMOKE_WITH_FOLLY=OFF \
-DLIB_SMOKE_WITH_HPX=OFF
configure-folly:
$(CMAKE) -S . -B $(BUILD_FOLLY) $(CMAKE_COMMON) \
-DLIB_SMOKE_WITH_FOLLY=ON \
-DLIB_SMOKE_WITH_HPX=OFF
configure-hpx:
$(CMAKE) -S . -B $(BUILD_HPX) $(CMAKE_COMMON) \
-DLIB_SMOKE_WITH_FOLLY=OFF \
-DLIB_SMOKE_WITH_HPX=ON \
-DLIB_SMOKE_HPX_ROOT="$(HPX_ROOT)"
configure-full:
$(CMAKE) -S . -B $(BUILD_FULL) $(CMAKE_COMMON) \
-DLIB_SMOKE_WITH_FOLLY=ON \
-DLIB_SMOKE_WITH_HPX=ON \
-DLIB_SMOKE_HPX_ROOT="$(HPX_ROOT)"
reconfigure: configure
# ---------------------------------------------------------------------------
# Build / test / run
# ---------------------------------------------------------------------------
build:
@test -d $(BUILD_DIR) || $(MAKE) configure
$(CMAKE) --build $(BUILD_DIR) -j$(JOBS)
rebuild: distclean all
test:
@test -d $(BUILD_DIR) || $(MAKE) build
cd $(BUILD_DIR) && $(CTEST) --output-on-failure -j$(JOBS)
run smoke:
@test -x $(BUILD_DIR)/lib_smoke || $(MAKE) build
./$(BUILD_DIR)/lib_smoke
examples:
@test -d $(BUILD_DIR) || $(MAKE) configure
$(CMAKE) --build $(BUILD_DIR) -j$(JOBS) --target \
example_spsc example_arena example_memory_order example_tsc \
example_pmr example_hdr example_sbe_style example_industry_queues \
example_sbe_codegen example_numa_uring example_hdr_c example_kernel_bypass \
example_struct_pack
@echo "== example_spsc =="
./$(BUILD_DIR)/example_spsc
@echo "== example_arena =="
./$(BUILD_DIR)/example_arena
@echo "== example_memory_order =="
./$(BUILD_DIR)/example_memory_order
@echo "== example_tsc =="
./$(BUILD_DIR)/example_tsc
@echo "== example_pmr =="
./$(BUILD_DIR)/example_pmr
@echo "== example_hdr =="
./$(BUILD_DIR)/example_hdr
@echo "== example_sbe_style =="
./$(BUILD_DIR)/example_sbe_style
@echo "== example_industry_queues =="
./$(BUILD_DIR)/example_industry_queues
@echo "== example_sbe_codegen =="
./$(BUILD_DIR)/example_sbe_codegen
@echo "== example_numa_uring =="
./$(BUILD_DIR)/example_numa_uring
@echo "== example_hdr_c =="
./$(BUILD_DIR)/example_hdr_c
@echo "== example_kernel_bypass =="
./$(BUILD_DIR)/example_kernel_bypass
@echo "== example_struct_pack =="
./$(BUILD_DIR)/example_struct_pack
bench:
@test -d $(BUILD_DIR) || $(MAKE) configure
@if $(CMAKE) --build $(BUILD_DIR) -j$(JOBS) --target bench_queues 2>/dev/null; then \
./$(BUILD_DIR)/bench_queues --benchmark_min_time=0.1s; \
else \
echo "bench_queues not configured (brew install google-benchmark && reconfigure)"; \
exit 1; \
fi
# Convenience stacks (own build dirs)
folly: configure-folly
$(CMAKE) --build $(BUILD_FOLLY) -j$(JOBS)
cd $(BUILD_FOLLY) && $(CTEST) --output-on-failure -j$(JOBS)
./$(BUILD_FOLLY)/lib_smoke
hpx: configure-hpx
$(CMAKE) --build $(BUILD_HPX) -j$(JOBS)
cd $(BUILD_HPX) && $(CTEST) --output-on-failure -j$(JOBS)
./$(BUILD_HPX)/lib_smoke
full: configure-full
$(CMAKE) --build $(BUILD_FULL) -j$(JOBS)
cd $(BUILD_FULL) && $(CTEST) --output-on-failure -j$(JOBS)
./$(BUILD_FULL)/lib_smoke
compile-commands: configure
@ln -sfn $(BUILD_DIR)/compile_commands.json compile_commands.json
@echo "Linked compile_commands.json -> $(BUILD_DIR)/compile_commands.json"
# CLion: use CMake presets (CMakePresets.json) for a full IntelliSense model
clion:
$(CMAKE) --preset clion-debug
@ln -sfn build/clion-debug/compile_commands.json compile_commands.json
@echo "CLion preset ready: build/clion-debug"
@echo " Open repo in CLion → enable preset 'clion-debug' → Build target 'ide_index'"
@echo " Guide: docs/clion.md"
clion-index: clion
$(CMAKE) --build --preset ide-index -j$(JOBS)
@echo "ide_index built — reload CMake in CLion if types still unresolved"
clion-test:
@test -d build/clion-debug || $(MAKE) clion
$(CMAKE) --build build/clion-debug -j$(JOBS)
cd build/clion-debug && $(CTEST) --output-on-failure -j$(JOBS)
# ---------------------------------------------------------------------------
# Ninja generator (optional parallel path; does not change default make/build)
# Tutorial: docs/tutorials/ninja-build.md
# ---------------------------------------------------------------------------
ninja-help:
@echo "Ninja is a build system (not a compiler). CMake -G Ninja writes build.ninja;"
@echo "Ninja then invokes Clang/GCC. Isolated tree: $(BUILD_NINJA)/"
@echo ""
@echo " make configure-ninja cmake -S . -B $(BUILD_NINJA) -G Ninja …"
@echo " make build-ninja cmake --build $(BUILD_NINJA) -j$(JOBS)"
@echo " make test-ninja ctest in $(BUILD_NINJA)"
@echo " make run-ninja run $(BUILD_NINJA)/lib_smoke"
@echo " make examples-ninja build+run example_* targets"
@echo " make ninja configure + build + test"
@echo " make compile-commands-ninja link compile_commands.json → $(BUILD_NINJA)"
@echo ""
@echo "Requires: ninja on PATH (brew install ninja / apt install ninja-build)"
@echo "Guide: docs/tutorials/ninja-build.md"
@command -v $(NINJA) >/dev/null 2>&1 && \
echo "ninja: $$($(NINJA) --version 2>/dev/null | head -1) ($$(command -v $(NINJA)))" || \
echo "ninja: MISSING"
configure-ninja:
@command -v $(NINJA) >/dev/null 2>&1 || { \
echo "error: ninja not found on PATH. Install: brew install ninja OR apt install ninja-build"; \
exit 1; \
}
$(CMAKE) -S . -B $(BUILD_NINJA) -G Ninja $(CMAKE_COMMON) \
-DLIB_SMOKE_WITH_FOLLY=OFF \
-DLIB_SMOKE_WITH_HPX=OFF
@echo "Generator: Ninja binaryDir: $(BUILD_NINJA)/"
build-ninja:
@test -f $(BUILD_NINJA)/build.ninja || $(MAKE) configure-ninja
$(CMAKE) --build $(BUILD_NINJA) -j$(JOBS)
test-ninja:
@test -f $(BUILD_NINJA)/build.ninja || $(MAKE) build-ninja
cd $(BUILD_NINJA) && $(CTEST) --output-on-failure -j$(JOBS)
run-ninja smoke-ninja:
@test -x $(BUILD_NINJA)/lib_smoke || $(MAKE) build-ninja
./$(BUILD_NINJA)/lib_smoke
examples-ninja:
@test -f $(BUILD_NINJA)/build.ninja || $(MAKE) configure-ninja
$(CMAKE) --build $(BUILD_NINJA) -j$(JOBS) --target \
example_spsc example_arena example_memory_order example_tsc \
example_pmr example_hdr example_sbe_style example_industry_queues \
example_sbe_codegen example_numa_uring example_hdr_c example_kernel_bypass \
example_struct_pack
@echo "== example_spsc =="; ./$(BUILD_NINJA)/example_spsc
@echo "== example_arena =="; ./$(BUILD_NINJA)/example_arena
@echo "== example_memory_order =="; ./$(BUILD_NINJA)/example_memory_order
@echo "== example_tsc =="; ./$(BUILD_NINJA)/example_tsc
@echo "== example_pmr =="; ./$(BUILD_NINJA)/example_pmr
@echo "== example_hdr =="; ./$(BUILD_NINJA)/example_hdr
@echo "== example_sbe_style =="; ./$(BUILD_NINJA)/example_sbe_style
@echo "== example_industry_queues =="; ./$(BUILD_NINJA)/example_industry_queues
@echo "== example_sbe_codegen =="; ./$(BUILD_NINJA)/example_sbe_codegen
@echo "== example_numa_uring =="; ./$(BUILD_NINJA)/example_numa_uring
@echo "== example_hdr_c =="; ./$(BUILD_NINJA)/example_hdr_c
@echo "== example_kernel_bypass =="; ./$(BUILD_NINJA)/example_kernel_bypass
@echo "== example_struct_pack =="; ./$(BUILD_NINJA)/example_struct_pack
ninja: configure-ninja build-ninja test-ninja
@echo "Ninja path OK — binaries in $(BUILD_NINJA)/"
compile-commands-ninja:
@test -f $(BUILD_NINJA)/build.ninja || $(MAKE) configure-ninja
@ln -sfn $(BUILD_NINJA)/compile_commands.json compile_commands.json
@echo "Linked compile_commands.json -> $(BUILD_NINJA)/compile_commands.json"
# ---------------------------------------------------------------------------
# Clean
# ---------------------------------------------------------------------------
clean:
@if [ -d $(BUILD_DIR) ]; then $(CMAKE) --build $(BUILD_DIR) --target clean; fi
distclean:
rm -rf $(BUILD_DIR) $(BUILD_FOLLY) $(BUILD_HPX) $(BUILD_FULL) $(BUILD_NINJA)
rm -rf build/clion-debug build/clion-release build/clion-relwithdebinfo 2>/dev/null || true
rm -f compile_commands.json
# ---------------------------------------------------------------------------
# Dependencies
# ---------------------------------------------------------------------------
deps-check:
@echo "== Homebrew (base) =="
@brew --prefix >/dev/null 2>&1 && echo " brew: $(HOMEBREW_PREFIX)" || echo " brew: MISSING"
@for p in fmt spdlog tbb asio boost taskflow folly catch2 googletest \
nlohmann-json simdjson eigen protobuf grpc range-v3 abseil; do \
if brew list --versions $$p >/dev/null 2>&1; then \
printf " %-16s %s\n" "$$p" "$$(brew list --versions $$p)"; \
else \
printf " %-16s MISSING\n" "$$p"; \
fi; \
done
@echo "== Homebrew (industry / low-latency) =="
@for p in hwloc flatbuffers google-benchmark mimalloc jemalloc folly; do \
if brew list --versions $$p >/dev/null 2>&1; then \
printf " %-16s %s\n" "$$p" "$$(brew list --versions $$p)"; \
else \
printf " %-16s MISSING (make install-industry / brew install folly)\n" "$$p"; \
fi; \
done
@echo "== HPX (local) =="
@if [ -f "$(HPX_ROOT)/lib/cmake/HPX/HPXConfig.cmake" ]; then \
echo " installed: $(HPX_ROOT)"; \
else \
echo " not found at $(HPX_ROOT) (run: make install-hpx)"; \
fi
install-folly:
brew install folly
install-industry:
brew install hwloc flatbuffers google-benchmark mimalloc jemalloc
@echo "Optional: brew install folly # enables folly::ProducerConsumerQueue tests"
install-hpx:
@chmod +x scripts/install_hpx.sh
HPX_ROOT="$(HPX_ROOT)" ./scripts/install_hpx.sh
# ---------------------------------------------------------------------------
# Docs
# ---------------------------------------------------------------------------
docs:
@echo "Library guides (docs/libraries/):"
@ls -1 docs/libraries/*.md 2>/dev/null | sed 's|^| |' || echo " (none yet)"
@echo ""
@echo "Low-latency blueprint (docs/blueprint/):"
@ls -1 docs/blueprint/*.md 2>/dev/null | sed 's|^| |' || echo " (none yet)"
@echo ""
@echo "Tutorials (docs/tutorials/):"
@ls -1 docs/tutorials/*.md 2>/dev/null | sed 's|^| |' || echo " (none yet)"
@echo ""
@echo "Start here: docs/libraries/README.md"
@echo "LL audit: docs/blueprint/AUDIT.md"
@echo "Industry: docs/tutorials/industry-stack.md"
@echo "LL focus: docs/blueprint/README.md"
@echo "CLion IDE: docs/clion.md"
@echo "Ninja: docs/tutorials/ninja-build.md"
@echo "ARM/Intel: docs/tutorials/modern-cpp-tooling-arm-intel.md"
@echo "Wiki: https://github.com/Dmdv/cpp26-systems-stack/wiki (make wiki)"
wiki:
@python3 scripts/publish_wiki.py
wiki-preview:
@python3 scripts/publish_wiki.py --preview-only