From b0438fd2d85d6937b67db38c6138b0783962d8b2 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 5 Jan 2023 11:36:41 +0200 Subject: [PATCH] Avoid spurious dependency loop errors from side effects If the primary target depends on its own side effect (such as a generated source file including a header generated by the same command), this could cause the side effect's prepare() to be entered recursively. --- source/lib/target.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/lib/target.cpp b/source/lib/target.cpp index f99b0bc..d1aaf73 100644 --- a/source/lib/target.cpp +++ b/source/lib/target.cpp @@ -111,6 +111,9 @@ void Target::mark_rebuild(const string &reason) void Target::prepare() { + if(primary_target && primary_target->stateprepare(); + if(state>PREPARING) return; if(state==PREPARING) @@ -122,8 +125,6 @@ void Target::prepare() } state = PREPARING; - if(primary_target) - primary_target->prepare(); /* Prepare existing dependencies early, because their information may be needed to find other dependencies. */ for(Target *d: depends) -- 2.43.0