Skip to content

Commit

Permalink
Guarantee order of generators execution (#15678)
Browse files Browse the repository at this point in the history
* Guarantee order of generator execution

* better way

* One last set
  • Loading branch information
AbrilRBS authored Feb 15, 2024
1 parent 0bad0d1 commit 02b7598
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion conan/api/subapi/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ def install_consumer(self, deps_graph, generators=None, source_folder=None, outp
base_folder = deploy_folder or conanfile.folders.base_build
do_deploys(self.conan_api, deps_graph, deploy, deploy_package, base_folder)

conanfile.generators = list(set(conanfile.generators).union(generators or []))
final_generators = []
# Don't use set for uniqueness because order matters
for gen in conanfile.generators:
if gen not in final_generators:
final_generators.append(gen)
for gen in (generators or []):
if gen not in final_generators:
final_generators.append(gen)
conanfile.generators = final_generators
app = ConanApp(self.conan_api)
write_generators(conanfile, app)
5 changes: 4 additions & 1 deletion conans/client/generators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def write_generators(conanfile, app):
# generators check that they are not present in the generators field,
# to avoid duplicates between the generators attribute and the generate() method
# They would raise an exception here if we don't invalidate the field while we call them
old_generators = set(conanfile.generators)
old_generators = []
for gen in conanfile.generators:
if gen not in old_generators:
old_generators.append(gen)
conanfile.generators = []
try:
for generator_name in old_generators:
Expand Down

0 comments on commit 02b7598

Please sign in to comment.