-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
225 lines (199 loc) Β· 8.42 KB
/
Makefile
File metadata and controls
225 lines (199 loc) Β· 8.42 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
# FreshLogger Makefile
# Author: Γmer Bulut
# Compiler and flags (can be overridden by environment)
CXX ?= clang++
CXXFLAGS ?= -std=c++17 -Wall -Wextra -O2 -g
CLANG_FLAGS = -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic \
-Wno-global-constructors -Wno-exit-time-destructors \
-Wno-padded -Wno-covered-switch-default \
-Wno-unused-exception-parameter -Wno-unused-lambda-capture \
-Wno-unsafe-buffer-usage -Wno-sign-conversion -Wno-newline-eof
INCLUDES = -I.
LIBS = -lspdlog -lfmt -lpthread
# Detect compiler and set appropriate flags
ifeq ($(findstring clang,$(CXX)),clang)
CXXFLAGS += $(CLANG_FLAGS)
endif
# Source files
SOURCES = example.cpp
TEST_SOURCES = LoggerTest.cpp
SIMPLE_TEST_SOURCES = SimpleLoggerTest.cpp
PERFORMANCE_TEST_SOURCES = PerformanceTest.cpp
STRESS_TEST_SOURCES = StressTest.cpp
EDGE_TEST_SOURCES = EdgeCaseTests.cpp
MACRO_TEST_SOURCE = MacroTest.cpp
# Executables
EXAMPLE_EXECUTABLE = example
UNIT_TEST_EXECUTABLE = unit_tests
SIMPLE_TEST_EXECUTABLE = simple_tests
PERFORMANCE_TEST_EXECUTABLE = performance_tests
STRESS_TEST_EXECUTABLE = stress_tests
EDGE_TEST_EXECUTABLE = edge_case_tests
MACRO_TEST_EXECUTABLE = macro_tests
# Phase 2: Advanced CI/CD Features
PHASE2_TARGETS = parallel-test cache-init cache-stats perf-baseline perf-regression
# Default target
all: $(EXAMPLE_EXECUTABLE) $(UNIT_TEST_EXECUTABLE) $(SIMPLE_TEST_EXECUTABLE) \
$(PERFORMANCE_TEST_EXECUTABLE) $(STRESS_TEST_EXECUTABLE) $(EDGE_TEST_EXECUTABLE) \
$(MACRO_TEST_EXECUTABLE)
# Main example
$(EXAMPLE_EXECUTABLE): $(SOURCES)
@echo "π± Building FreshLogger example..."
@echo "Using compiler: $(CXX) with flags: $(CXXFLAGS)"
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ $^ $(LIBS)
@echo "β
Example built successfully!"
# Unit tests
$(UNIT_TEST_EXECUTABLE): $(TEST_SOURCES)
@echo "π§ͺ Building unit tests..."
@echo "Using compiler: $(CXX) with flags: $(CXXFLAGS)"
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ $^ $(LIBS) -lgtest -lgtest_main
@echo "β
Unit tests built successfully!"
# Simple tests
$(SIMPLE_TEST_EXECUTABLE): $(SIMPLE_TEST_SOURCES)
@echo "π¬ Building simple tests..."
@echo "Using compiler: $(CXX) with flags: $(CXXFLAGS)"
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ $^ $(LIBS) -lgtest -lgtest_main
@echo "β
Simple tests built successfully!"
# Performance tests
$(PERFORMANCE_TEST_EXECUTABLE): $(PERFORMANCE_TEST_SOURCES)
@echo "β‘ Building performance tests..."
@echo "Using compiler: $(CXX) with flags: $(CXXFLAGS)"
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ $^ $(LIBS) -lgtest -lgtest_main
@echo "β
Performance tests built successfully!"
# Stress tests
$(STRESS_TEST_EXECUTABLE): $(STRESS_TEST_SOURCES)
@echo "π₯ Building stress tests..."
@echo "Using compiler: $(CXX) with flags: $(CXXFLAGS)"
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ $^ $(LIBS) -lgtest -lgtest_main
@echo "β
Stress tests built successfully!"
# Edge case tests
$(EDGE_TEST_EXECUTABLE): $(EDGE_TEST_SOURCES)
@echo "π Building edge case tests..."
@echo "Using compiler: $(CXX) with flags: $(CXXFLAGS)"
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ $^ $(LIBS) -lgtest -lgtest_main
@echo "β
Edge case tests built successfully!"
# Macro tests
$(MACRO_TEST_EXECUTABLE): $(MACRO_TEST_SOURCE)
@echo "π§ Building macro tests..."
@echo "Using compiler: $(CXX) with flags: $(CXXFLAGS)"
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ $^ $(LIBS) -lgtest -lgtest_main
@echo "β
Macro tests built successfully!"
# Enterprise test suite (Phase 1)
enterprise-test: all
@echo "π Running Enterprise Test Suite..."
@echo "=================================="
@mkdir -p test_logs
@echo ""
@echo "π§ͺ Unit Tests:"
./$(UNIT_TEST_EXECUTABLE) --gtest_output=xml:test_logs/unit_results.xml
@echo ""
@echo "π¬ Simple Tests:"
./$(SIMPLE_TEST_EXECUTABLE) --gtest_output=xml:test_logs/simple_results.xml
@echo ""
@echo "β‘ Performance Tests:"
./$(PERFORMANCE_TEST_EXECUTABLE) --gtest_output=xml:test_logs/performance_results.xml
@echo ""
@echo "π₯ Stress Tests:"
./$(STRESS_TEST_EXECUTABLE) --gtest_output=xml:test_logs/stress_results.xml
@echo ""
@echo "π Edge Case Tests:"
./$(EDGE_TEST_EXECUTABLE) --gtest_output=xml:test_logs/edge_results.xml
@echo ""
@echo "π§ Macro Tests:"
./$(MACRO_TEST_EXECUTABLE) --gtest_output=xml:test_logs/macro_results.xml
@echo ""
@echo "β
Enterprise Test Suite completed!"
# Phase 2: Parallel Testing
parallel-test: all
@echo "π Running Parallel Test Suite (Phase 2)..."
@echo "=========================================="
@echo "Max Parallel Jobs: 4"
@echo "Timeout per Test: 60s (reduced for CI/CD)"
@echo ""
TIMEOUT_SECONDS=60 MAX_PARALLEL_JOBS=4 ./scripts/parallel_test_runner.sh || echo "β οΈ Some tests failed or timed out (continuing...)"
@echo ""
@echo "β
Parallel Test Suite completed!"
# Phase 2: Cache Management
cache-init:
@echo "π§ Initializing Build Cache (Phase 2)..."
./scripts/build_cache_manager.sh init
@echo "β
Build cache initialized!"
cache-stats:
@echo "π Build Cache Statistics (Phase 2)..."
./scripts/build_cache_manager.sh stats
@echo "β
Cache statistics displayed!"
cache-cleanup:
@echo "π§Ή Cleaning Build Cache (Phase 2)..."
./scripts/build_cache_manager.sh cleanup
@echo "β
Build cache cleaned up!"
# Phase 2: Performance Regression Detection
perf-baseline:
@echo "π Creating Performance Baseline (Phase 2)..."
./scripts/performance_regression_detector.sh baseline
@echo "β
Performance baseline created!"
perf-regression:
@echo "π Detecting Performance Regressions (Phase 2)..."
./scripts/performance_regression_detector.sh run
@echo "β
Performance regression detection completed!"
perf-report:
@echo "π Generating Performance Report (Phase 2)..."
./scripts/performance_regression_detector.sh report
@echo "β
Performance report generated!"
# Phase 2: Complete CI/CD Pipeline
phase2-pipeline: all parallel-test cache-stats perf-regression
@echo "π― Phase 2 CI/CD Pipeline completed!"
@echo "===================================="
@echo "β
All tests built successfully"
@echo "β
Parallel test execution completed"
@echo "β
Cache statistics collected"
@echo "β
Performance regression detection completed"
@echo ""
@echo "π Reports available in:"
@echo " - parallel_test_reports/"
@echo " - current_performance/"
@echo " - .build_cache/"
# Clean build artifacts
clean:
@echo "π§Ή Cleaning build artifacts..."
rm -f $(EXAMPLE_EXECUTABLE) $(UNIT_TEST_EXECUTABLE) $(SIMPLE_TEST_EXECUTABLE) \
$(PERFORMANCE_TEST_EXECUTABLE) $(STRESS_TEST_EXECUTABLE) $(EDGE_TEST_EXECUTABLE) \
$(MACRO_TEST_EXECUTABLE)
rm -rf bin/ logs/ test_logs/ stress_logs/ stress_temp/ edge_test_logs/
@echo "β
Cleaned build artifacts"
# Clean everything including Phase 2 artifacts
clean-all: clean
@echo "π§Ή Cleaning Phase 2 artifacts..."
rm -rf parallel_test_reports/ parallel_test_logs/ .build_cache/ \
performance_baselines/ current_performance/
@echo "β
Cleaned all artifacts including Phase 2"
# Show help
help:
@echo "π§ FreshLogger Makefile - Available Targets"
@echo "=========================================="
@echo ""
@echo "Build Targets:"
@echo " ${YELLOW}all${NC} - Build all executables and tests"
@echo " ${YELLOW}clean${NC} - Clean build artifacts"
@echo " ${YELLOW}clean-all${NC} - Clean everything including Phase 2"
@echo ""
@echo "Phase 1 - Enterprise Testing:"
@echo " ${YELLOW}enterprise-test${NC} - Run complete enterprise test suite"
@echo ""
@echo "Phase 2 - Advanced CI/CD:"
@echo " ${YELLOW}parallel-test${NC} - Run tests in parallel"
@echo " ${YELLOW}cache-init${NC} - Initialize build cache"
@echo " ${YELLOW}cache-stats${NC} - Show cache statistics"
@echo " ${YELLOW}cache-cleanup${NC} - Clean up build cache"
@echo " ${YELLOW}perf-baseline${NC} - Create performance baseline"
@echo " ${YELLOW}perf-regression${NC} - Detect performance regressions"
@echo " ${YELLOW}perf-report${NC} - Generate performance report"
@echo " ${YELLOW}phase2-pipeline${NC} - Complete Phase 2 pipeline"
@echo ""
@echo "Examples:"
@echo " ${YELLOW}make all${NC} - Build everything"
@echo " ${YELLOW}make enterprise-test${NC} - Run Phase 1 tests"
@echo " ${YELLOW}make phase2-pipeline${NC} - Run Phase 2 pipeline"
@echo " ${YELLOW}CXX=g++ make all${NC} - Use GCC instead of Clang"
# Phony targets
.PHONY: all clean clean-all enterprise-test parallel-test cache-init cache-stats \
cache-cleanup perf-baseline perf-regression perf-report phase2-pipeline help