fix: leave bin/ and build/ out of the include walk
GetCompileCommand put every directory named include in a dependency's tree on the include path, bin/ and build/ included, so what a build had left there came before the system's headers in every C++ and C compile built on the dependency. In this repository build.sh leaves glslang's CMake tree in build/glslang/build, and the `run flatpak` script leaves flatpak-builder's /app tree in build/flatpak/build-dir, whose include/ holds the bundled LLVM's headers, clang-c/ and libc++'s among them: crafter.build-lib's path is the repository's root, so crafter.build-exe and every test took them. The walk now leaves out every directory named bin or build, the names crafter-build gives what it writes, wherever it sits. Leaving out only the bin/ and build/ of the configurations in the compile's graph would not do: a dependency's tree holds the outputs of configurations outside it too, a program in a directory below it or a project of its own beside it, as Crafter.Graphics' examples are. Of the #include lines in the Crafter repositories and in the dependencies crafter-build has cloned, the one that needs a header found only under such a directory is glslang's own, in a source its CMake build compiles.
This commit is contained in:
parent
0cf2f629eb
commit
703c700dc0
1 changed files with 19 additions and 3 deletions
|
|
@ -380,12 +380,28 @@ CompileCommand Crafter::GetCompileCommand(const Configuration& config) {
|
|||
// -I propagation that's valid for both C and C++ compiles. Module-only
|
||||
// bits (-fprebuilt-module-path) stay on `command` only.
|
||||
{
|
||||
// bin/ and build/ hold what builds write for the configuration whose
|
||||
// path holds them: crafter-build's own outputs (BinDir(), BuildDir())
|
||||
// and whatever else a build leaves there, a CMake build tree or a
|
||||
// flatpak-builder /app tree among it, whose include/ holds another
|
||||
// library's or toolchain's headers and never the dependency's own.
|
||||
// The walk leaves out every directory of those names, not only the
|
||||
// graph's: a dependency's tree holds the outputs of configurations
|
||||
// outside the graph too, a program in a directory below it or a
|
||||
// project of its own beside it, as Crafter.Graphics' examples are.
|
||||
// Walked, they would have every compile built on the dependency take
|
||||
// those headers before the system's, and what compiled depend on
|
||||
// which builds had run.
|
||||
std::unordered_set<Configuration*> seen;
|
||||
std::function<void(Configuration*)> addFlags = [&](Configuration* dep) {
|
||||
if (!seen.insert(dep).second) return;
|
||||
for (const auto& entry : fs::recursive_directory_iterator(dep->path)) {
|
||||
if (entry.is_directory() && entry.path().filename() == "include") {
|
||||
out.includeFlags += std::format(" -I{}", entry.path().string());
|
||||
for (auto it = fs::recursive_directory_iterator(dep->path); it != fs::recursive_directory_iterator(); ++it) {
|
||||
if (!it->is_directory()) continue;
|
||||
const fs::path name = it->path().filename();
|
||||
if (name == "bin" || name == "build") {
|
||||
it.disable_recursion_pending();
|
||||
} else if (name == "include") {
|
||||
out.includeFlags += std::format(" -I{}", it->path().string());
|
||||
}
|
||||
}
|
||||
out.includeFlags += std::format(" -I{}", dep->path.string());
|
||||
|
|
|
|||
Loading…
Reference in a new issue