diff --git a/implementations/Crafter.Build-Clang.cpp b/implementations/Crafter.Build-Clang.cpp index 85b860c..88aca5a 100644 --- a/implementations/Crafter.Build-Clang.cpp +++ b/implementations/Crafter.Build-Clang.cpp @@ -792,6 +792,22 @@ namespace { fs::remove(written, ec); return failed; } + + // `argument` as one argument in a response file, the file of further + // arguments a command names with @. clang and llvm-ar split such a file + // at whitespace, keep what stands in quotes together, and take a + // backslash to quote the character after it, inside quotes as well. + // That last is why this is not ShellQuote: the shell keeps a backslash + // in single quotes as it is. + std::string ResponseFileArgument(std::string_view argument) { + std::string quoted = "\""; + for (const char c : argument) { + if (c == '"' || c == '\\') quoted.push_back('\\'); + quoted.push_back(c); + } + quoted.push_back('"'); + return quoted; + } } BuildResult Crafter::Build(Configuration& config, std::unordered_map>& depResults, std::mutex& depMutex) { @@ -1146,7 +1162,9 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map objects; std::set libSet; std::set runtimeSet; std::set publicFlagSet; @@ -1204,8 +1222,8 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_mapCheck(pcmDir, externalFloor)) { buildResult.repack = true; } - files += std::format(" {}/{}.o", buildDir.string(), interface->path.filename().string()); + objects.push_back(buildDir / std::format("{}.o", interface->path.filename().string())); for(std::unique_ptr& part : interface->partitions) { - files += std::format(" {}/{}.o", buildDir.string(), part->path.filename().string()); + objects.push_back(buildDir / std::format("{}.o", part->path.filename().string())); } } @@ -1410,7 +1428,7 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map(recorded)), std::istreambuf_iterator()); - if (previous != linkCommand) buildResult.repack = true; + if (previous != linked) buildResult.repack = true; } if(buildResult.repack) { @@ -1633,6 +1669,26 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map