Skip to content

Commit 5a96fc8

Browse files
committed
prepare v1.48.4
2 parents e3e8737 + 904059d commit 5a96fc8

File tree

3 files changed

+667
-23
lines changed

3 files changed

+667
-23
lines changed

src/cmake/CMakeBuild.cpp

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,58 @@ namespace vix::cli::build
426426
currentProgressLine.clear();
427427
};
428428

429+
auto is_failed_line = [](const std::string &line) -> bool
430+
{
431+
return line.rfind("FAILED:", 0) == 0;
432+
};
433+
434+
auto looks_like_live_error_line = [&](const std::string &line) -> bool
435+
{
436+
if (line.empty())
437+
return false;
438+
439+
if (is_failed_line(line))
440+
return true;
441+
442+
if (line.rfind("ninja:", 0) == 0)
443+
return true;
444+
445+
if (line.find(": error:") != std::string::npos)
446+
return true;
447+
448+
if (line.find(" error: ") != std::string::npos)
449+
return true;
450+
451+
if (line.find("fatal error:") != std::string::npos)
452+
return true;
453+
454+
if (line.find("undefined reference to") != std::string::npos)
455+
return true;
456+
457+
if (line.find("collect2: error:") != std::string::npos)
458+
return true;
459+
460+
if (line.find("ld: error:") != std::string::npos)
461+
return true;
462+
463+
if (line.find("CMake Error") != std::string::npos)
464+
return true;
465+
466+
if (line.rfind("-->", 0) == 0)
467+
return true;
468+
469+
if (line == "code:")
470+
return true;
471+
472+
if (line.rfind("hint:", 0) == 0)
473+
return true;
474+
475+
if (line.rfind("at:", 0) == 0)
476+
return true;
477+
478+
return false;
479+
};
480+
429481
auto should_echo_line = [&](const std::string &line) -> bool
430482
{
431483
if (quiet)
@@ -437,6 +489,9 @@ namespace vix::cli::build
437489
if (!progressOnly)
438490
return true;
439491

492+
if (line == "ninja: build stopped: subcommand failed.")
493+
return false;
494+
440495
if (line == "ninja: no work to do.")
441496
return false;
442497

@@ -446,13 +501,7 @@ namespace vix::cli::build
446501
if (line.find("Copy compile_commands.json to project root") != std::string::npos)
447502
return false;
448503

449-
if (line.rfind("FAILED:", 0) == 0)
450-
return true;
451-
452-
if (line.rfind("ninja:", 0) == 0)
453-
return true;
454-
455-
return false;
504+
return looks_like_live_error_line(line);
456505
};
457506

458507
std::string buf(16 * 1024, '\0');

src/commands/BuildCommand.cpp

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,43 @@ namespace vix::commands::BuildCommand
647647
return util::file_exists(buildDir / "CMakeCache.txt");
648648
}
649649

650+
static void clean_local_build_dirs(
651+
const fs::path &projectDir,
652+
const std::string &targetTriple,
653+
bool quiet)
654+
{
655+
std::vector<fs::path> dirs = {
656+
projectDir / "build-dev",
657+
projectDir / "build-ninja",
658+
projectDir / "build-release"};
659+
660+
if (!targetTriple.empty())
661+
{
662+
dirs.push_back(projectDir / ("build-dev-" + targetTriple));
663+
dirs.push_back(projectDir / ("build-ninja-" + targetTriple));
664+
dirs.push_back(projectDir / ("build-release-" + targetTriple));
665+
}
666+
667+
for (const auto &dir : dirs)
668+
{
669+
if (!fs::exists(dir))
670+
continue;
671+
672+
std::error_code ec;
673+
fs::remove_all(dir, ec);
674+
675+
if (ec)
676+
{
677+
error("Failed to remove build directory: " + dir.string());
678+
hint(ec.message());
679+
throw std::runtime_error("clean failed");
680+
}
681+
682+
if (!quiet)
683+
step("removed " + dir.string());
684+
}
685+
}
686+
650687
static std::vector<std::pair<std::string, std::string>>
651688
build_cmake_vars(
652689
const process::Preset &p,
@@ -835,6 +872,18 @@ namespace vix::commands::BuildCommand
835872
plan_ = *planOpt;
836873
const fs::path globalPackagesFile = plan_.buildDir / "vix-global-packages.cmake";
837874

875+
if (opt_.clean)
876+
{
877+
try
878+
{
879+
clean_local_build_dirs(plan_.projectDir, opt_.targetTriple, opt_.quiet);
880+
}
881+
catch (const std::exception &)
882+
{
883+
return 1;
884+
}
885+
}
886+
838887
const bool verboseMode = opt_.verbose || opt_.cmakeVerbose;
839888
const bool defer = (!opt_.quiet && verboseMode);
840889
DeferredConsole out(defer);
@@ -1195,7 +1244,7 @@ namespace vix::commands::BuildCommand
11951244
out << " --sysroot <path> Sysroot for cross toolchain (optional)\n";
11961245
out << " --static Request static linking (VIX_LINK_STATIC=ON)\n";
11971246
out << " -j, --jobs <n> Parallel build jobs (default: CPU count, clamped)\n";
1198-
out << " --clean Force reconfigure (ignore cache/signature)\n";
1247+
out << " --clean Remove local build directories and reconfigure from scratch\n";
11991248
out << " --no-cache Disable signature cache shortcut\n";
12001249
out << " --fast Fast loop: if Ninja says up-to-date, exit immediately\n";
12011250
out << " --linker <mode> auto|default|mold|lld (auto prefers mold then lld)\n";

0 commit comments

Comments
 (0)