File tree Expand file tree Collapse file tree
include/vix/cli/errors/build Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3939
4040# debug information files
4141* .dwo
42- build /
42+ build- * /
4343.vscode /
4444vix.log
4545cmd.md
Original file line number Diff line number Diff line change 1+ /* *
2+ *
3+ * @file BuildErrorDetectors.hpp
4+ * @author Gaspard Kirira
5+ *
6+ * Copyright 2025, Gaspard Kirira. All rights reserved.
7+ * https://github.com/vixcpp/vix
8+ * Use of this source code is governed by a MIT license
9+ * that can be found in the License file.
10+ *
11+ * Vix.cpp
12+ *
13+ */
14+ #ifndef VIX_BUILD_ERROR_DETECTORS_HPP
15+ #define VIX_BUILD_ERROR_DETECTORS_HPP
16+
17+ #include < string_view>
18+
19+ namespace vix ::cli::errors::build
20+ {
21+ bool handleBuildErrors (std::string_view log);
22+ }
23+
24+ #endif
Original file line number Diff line number Diff line change 1+ /* *
2+ *
3+ * @file CMakeBuildErrors.hpp
4+ * @author Gaspard Kirira
5+ *
6+ * Copyright 2025, Gaspard Kirira. All rights reserved.
7+ * https://github.com/vixcpp/vix
8+ * Use of this source code is governed by a MIT license
9+ * that can be found in the License file.
10+ *
11+ * Vix.cpp
12+ *
13+ */
14+ #ifndef VIX_CMAKE_BUILD_ERRORS_HPP
15+ #define VIX_CMAKE_BUILD_ERRORS_HPP
16+
17+ #include < string_view>
18+
19+ namespace vix ::cli::errors::build
20+ {
21+ bool handleCMakeBuildError (std::string_view log);
22+ }
23+
24+ #endif
Original file line number Diff line number Diff line change 1111 * Vix.cpp
1212 *
1313 */
14- #include " vix/cli/ErrorHandler.hpp"
15-
16- #include " vix/cli/errors/ClangGccParser.hpp"
17- #include " vix/cli/errors/CompilerError.hpp"
18- #include " vix/cli/errors/ErrorContext.hpp"
19- #include " vix/cli/errors/ErrorPipeline.hpp"
20- #include " vix/cli/errors/RawLogDetectors.hpp"
21- #include " vix/cli/errors/CodeFrame.hpp"
14+ #include < vix/cli/ErrorHandler.hpp>
15+
16+ #include < vix/cli/errors/ClangGccParser.hpp>
17+ #include < vix/cli/errors/CompilerError.hpp>
18+ #include < vix/cli/errors/ErrorContext.hpp>
19+ #include < vix/cli/errors/ErrorPipeline.hpp>
20+ #include < vix/cli/errors/RawLogDetectors.hpp>
21+ #include < vix/cli/errors/CodeFrame.hpp>
22+ #include < vix/cli/errors/build/BuildErrorDetectors.hpp>
2223#include < vix/utils/Env.hpp>
24+
2325#include < iostream>
2426#include < sstream>
2527#include < unordered_map>
@@ -218,6 +220,9 @@ namespace vix::cli
218220 if (RawLogDetectors::handleLinkerOrSanitizer (cleanedLog, sourceFile, contextMessage))
219221 return ;
220222
223+ if (vix::cli::errors::build::handleBuildErrors (cleanedLog))
224+ return ;
225+
221226 error (contextMessage + " (see compiler output below):" );
222227 std::cerr << cleanedLog << " \n " ;
223228 return ;
Original file line number Diff line number Diff line change 1+ #include < vix/cli/errors/build/BuildErrorDetectors.hpp>
2+ #include < vix/cli/errors/build/CMakeBuildErrors.hpp>
3+
4+ namespace vix ::cli::errors::build
5+ {
6+ bool handleBuildErrors (std::string_view log)
7+ {
8+ if (handleCMakeBuildError (log))
9+ return true ;
10+
11+ return false ;
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ /* *
2+ *
3+ * @file CMakeBuildErrors.hpp
4+ * @author Gaspard Kirira
5+ *
6+ * Copyright 2025, Gaspard Kirira. All rights reserved.
7+ * https://github.com/vixcpp/vix
8+ * Use of this source code is governed by a MIT license
9+ * that can be found in the License file.
10+ *
11+ * Vix.cpp
12+ *
13+ */
14+ #include < vix/cli/errors/build/CMakeBuildErrors.hpp>
15+
16+ #include < iostream>
17+ #include < string>
18+
19+ #include < vix/cli/Style.hpp>
20+
21+ using namespace vix ::cli::style;
22+
23+ namespace vix ::cli::errors::build
24+ {
25+ bool handleCMakeBuildError (std::string_view log)
26+ {
27+ const bool cacheDirMismatch =
28+ log.find (" The current CMakeCache.txt directory" ) != std::string_view::npos;
29+
30+ const bool sourceMismatch =
31+ log.find (" does not match the source" ) != std::string_view::npos &&
32+ log.find (" used to generate cache" ) != std::string_view::npos;
33+
34+ if (!cacheDirMismatch && !sourceMismatch)
35+ return false ;
36+
37+ error (" CMake configure failed: stale build cache detected." );
38+ hint (" Your build directory was generated from another project location." );
39+ hint (" Remove the old build directory and reconfigure." );
40+ hint (" Recommended: vix build --clean" );
41+ hint (" Manual fix: rm -rf build-ninja build-dev build-release" );
42+
43+ return true ;
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments