@@ -102,9 +102,6 @@ set(TEST_STUBS_TO_COMPILE
102102 futures
103103)
104104
105- # Remove the helper function - we want to try compiling even if files might not exist
106- # The build will fail if they don't, which tells us generation failed
107-
108105# Collect source files that should exist after generation
109106set (STUB_SOURCES "" )
110107set (STUB_HEADERS "" )
@@ -130,6 +127,9 @@ add_library(test-stubs-compiled STATIC EXCLUDE_FROM_ALL
130127 ${STUB_SOURCES}
131128)
132129
130+ # This library depends on stub generation
131+ add_dependencies (test -stubs-compiled generate-test-stubs )
132+
133133# Link against cmcpp
134134target_link_libraries (test -stubs-compiled
135135 PRIVATE cmcpp
@@ -162,18 +162,20 @@ elseif(MSVC)
162162 )
163163endif ()
164164
165- # This library depends on stub generation
166- add_dependencies (test -stubs-compiled generate-test-stubs )
167-
168165# ===== Target: validate-test-stubs =====
169166# Validates stub generation by attempting to compile them
167+ # Uses ninja's parallel compilation (determined by CMAKE_BUILD_PARALLEL_LEVEL or -j flag)
170168add_custom_target (validate-test-stubs
171- COMMAND ${CMAKE_COMMAND} -E echo "Validating generated stubs by compilation..."
172- COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target test -stubs-compiled
173- COMMENT "Compiling generated stubs to validate code generation"
169+ COMMAND ${CMAKE_COMMAND} -E echo "Validating generated stubs by compilation (parallel build)..."
170+ COMMAND ${CMAKE_COMMAND} -E echo "Note: Using system default parallelism. Set CMAKE_BUILD_PARALLEL_LEVEL to override."
171+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target test -stubs-compiled --parallel > ${CMAKE_BINARY_DIR} /stub_compilation.log 2>&1 || ${CMAKE_COMMAND} -E true
172+ COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR} /summarize_stub_compilation.py"
173+ --log-file "${CMAKE_BINARY_DIR} /stub_compilation.log" || ${CMAKE_COMMAND} -E true
174+ COMMENT "Compiling generated stubs in parallel to validate code generation"
175+ BYPRODUCTS ${CMAKE_BINARY_DIR} /stub_compilation.log
174176 VERBATIM
175177)
176- add_dependencies (validate-test-stubs test -stubs-compiled )
178+ add_dependencies (validate-test-stubs generate- test-stubs )
177179
178180# ===== Target: validate-test-stubs-basic =====
179181# Validate only basic types (should always pass)
@@ -262,7 +264,7 @@ add_custom_target(clean-test-stubs
262264# ===== Summary =====
263265message (STATUS "Stub generation test targets configured:" )
264266message (STATUS " generate-test-stubs - Generate C++ stubs from WIT test files" )
265- message (STATUS " validate-test-stubs - Compile ALL stubs (full validation)" )
267+ message (STATUS " validate-test-stubs - Compile ALL stubs (full validation, parallel )" )
266268message (STATUS " validate-test-stubs-basic - Compile only basic types (should pass)" )
267269message (STATUS " validate-test-stubs-composite - Compile only composite types" )
268270message (STATUS " validate-test-stubs-async - Compile only async types (likely fails)" )
@@ -275,6 +277,7 @@ message(STATUS " WIT test directory: ${WIT_TEST_DIR}")
275277message (STATUS " Output directory: ${STUB_OUTPUT_DIR} " )
276278message (STATUS " Python interpreter: ${Python3_EXECUTABLE} " )
277279message (STATUS " Test samples: ${CMAKE_CURRENT_LIST_LENGTH} test files" )
280+ message (STATUS " Parallel build: Enabled (use CMAKE_BUILD_PARALLEL_LEVEL or -j to control)" )
278281message (STATUS "" )
279282message (STATUS "IMPORTANT: Compilation failures are EXPECTED and USEFUL!" )
280283message (STATUS " They indicate bugs in wit-codegen that need to be fixed." )
@@ -287,3 +290,7 @@ message(STATUS " 3. Fix any issues found")
287290message (STATUS " 4. cmake --build build --target validate-test-stubs-async" )
288291message (STATUS " 5. Fix async issues" )
289292message (STATUS " 6. cmake --build build --target validate-test-stubs (full test)" )
293+ message (STATUS "" )
294+ message (STATUS "To control parallelism:" )
295+ message (STATUS " CMAKE_BUILD_PARALLEL_LEVEL=8 cmake --build build --target validate-test-stubs" )
296+ message (STATUS " or: ninja -j8 validate-test-stubs" )
0 commit comments