]> git.tdb.fi Git - builder.git/commitdiff
Avoid spurious dependency loop errors from side effects
authorMikko Rasa <tdb@tdb.fi>
Thu, 5 Jan 2023 09:36:41 +0000 (11:36 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 5 Jan 2023 13:58:51 +0000 (15:58 +0200)
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

index f99b0bc4165d1f4c342ebf9c9127159b90ca4bd2..d1aaf73be578c3836b48cf251536a4a4d446612b 100644 (file)
@@ -111,6 +111,9 @@ void Target::mark_rebuild(const string &reason)
 
 void Target::prepare()
 {
+       if(primary_target && primary_target->state<PREPARING)
+               primary_target->prepare();
+
        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)