interpreter: Report correct number of targets in subprojects - #16117
Conversation
|
I'm not so sure this makes the reported number of targets easier to grok. With this, each subprojects reports the number of targers in itself and all of its subprojects, however, the log output is not super clear regarding the tree structure of the subprojects. Maybe this needs some more thinking. |
| mlog.log('Build targets in project:', mlog.bold(str(len(self.build.targets)))) | ||
| # When executing a subproject, only report the targets added by | ||
| # the subproject as the number of build targets in the project. | ||
| mlog.log('Build targets in project:', mlog.bold(str(len(self.build.targets) - n_existing_targets))) |
There was a problem hiding this comment.
Could we write this as something like len(x for x in self.build.targets if x.subproject == self.subproject and x.for_machine == self.for_machine) (Can't remember exactly which attributes we have here)
There was a problem hiding this comment.
Sure, but the interpreter does not have a for_machine attribute for the machine type of the subproject being processed. The only way I see of getting to it is to use the last entry in self.subproject_stack and special handling the root project. Or should I add Interpreter.for_machine?
There was a problem hiding this comment.
Given in the future there could be more ways to invoke the subproject (depending on how Meson introduces the possibility to invoke subprojects with different machine maps) that approach seems more complex than the subtraction here. Another possibility is to add a variable with the count and adjust it in add_target; but this PR looks good to me, if it's decided this was a bug and not just a badly worded message.
There was a problem hiding this comment.
I am not happy with the count reported with the subtraction approach. This approach still reports the current subproject targets plus all the targets in subprojects called from it. This is a bit less confusing that the cumulative number, but still not great. The approach suggested by @dcbaker would give the least surprising number.
Another possibility is to add a variable with the count and adjust it in add_target
I am not sure this would help. The problem would then become when to reset this new variable to 0. Subprojects are organised as a tree, thus the count would need to be stored as a stack, similarly to Intepreter.subproject_stack (or an entry would need to be added to this stack).
Given in the future there could be more ways to invoke the subproject (depending on how Meson introduces the possibility to invoke subprojects with different machine maps) that approach seems more complex than the subtraction here.
Wouldn't this require to switch from storing the for_machine information to storing the machine_map information in the targets? If so, the count problem would be solved filtering for (subproject, machine_map) instead than for (subproject, for_machine). But I am not familiar with this code at all, thus I may be missing something.
There was a problem hiding this comment.
The problem would then become when to reset this new variable to 0.
Each Interpreter would have its own copy, starting at zero.
There was a problem hiding this comment.
I eeworked it in this way. PTAL
9500e16 to
4d4b534
Compare
Fixes #16116