-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (50 loc) · 2.08 KB
/
Copy pathMakefile
File metadata and controls
61 lines (50 loc) · 2.08 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
# ──────────────────────────────────────────────────────────────
# MiniDB-main Makefile
# builds:
# - main (cpp/main.cpp + cpp/database.cpp)
# - test (Catch2 tests in cpp/tests + database.cpp)
# - benchmark_insert (benchmarks/benchmark_insert.cpp + database.cpp)
# - stress_test (benchmarks/stress_test.cpp + database.cpp)
# targets:
# all = main + test + benchmarks
# test = build & run the Catch2 suite
# clean = remove all binaries
# ──────────────────────────────────────────────────────────────
CXX := g++
CXXFLAGS := -std=c++17 -Wall -Wextra -pthread
INC_TEST := -Icpp/tests
# Executables:
MAIN := main
TEST_BIN := test
BENCH_INS_BIN := benchmark_insert
STRESS_BIN := stress_test
# Source files:
MAIN_SRCS := cpp/main.cpp \
cpp/database.cpp
TEST_SRCS := cpp/tests/test_database.cpp \
cpp/database.cpp
BENCH_INS_SRCS := benchmarks/benchmark_insert.cpp \
cpp/database.cpp
STRESS_SRCS := benchmarks/stress_test.cpp \
cpp/database.cpp
# Default: build everything
all: $(MAIN) $(TEST_BIN) $(BENCH_INS_BIN) $(STRESS_BIN)
# 1) Main DB CLI
$(MAIN): $(MAIN_SRCS) cpp/database.hpp
$(CXX) $(CXXFLAGS) -o $@ $(MAIN_SRCS)
# 2) Unit tests (requires catch.hpp in cpp/tests/)
$(TEST_BIN): $(TEST_SRCS) cpp/database.hpp cpp/tests/catch.hpp
$(CXX) $(CXXFLAGS) $(INC_TEST) -o $@ $(TEST_SRCS)
# 3) Benchmark: insertion
$(BENCH_INS_BIN): $(BENCH_INS_SRCS) cpp/database.hpp
$(CXX) $(CXXFLAGS) -o $@ $(BENCH_INS_SRCS)
# 4) Stress test
$(STRESS_BIN): $(STRESS_SRCS) cpp/database.hpp
$(CXX) $(CXXFLAGS) -o $@ $(STRESS_SRCS)
# Run the Catch2 tests
test: $(TEST_BIN)
./$(TEST_BIN)
# Clean up all generated binaries
clean:
rm -f $(MAIN) $(TEST_BIN) $(BENCH_INS_BIN) $(STRESS_BIN)
.PHONY: all test clean