Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom global generators in cache extensions/generators folder #13718

Merged
merged 2 commits into from
Apr 20, 2023

Conversation

memsharded
Copy link
Member

@memsharded memsharded commented Apr 19, 2023

Changelog: Feature: New global custom generators in cache "extensions/generators" that can be used by name.
Docs: conan-io/docs#3213

Close #13709

@memsharded memsharded added this to the 2.0.5 milestone Apr 19, 2023
@memsharded memsharded requested a review from AbrilRBS April 19, 2023 08:22
Copy link
Contributor

@System-Arch System-Arch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just one minor suggestion. Thanks

@@ -188,6 +188,10 @@ def settings_path(self):
def custom_commands_path(self):
return os.path.join(self.cache_folder, EXTENSIONS_FOLDER, CUSTOM_COMMANDS_FOLDER)

@property
def custom_generators_path(self):
return os.path.join(self.cache_folder, EXTENSIONS_FOLDER, "generators")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider defining GENERATORS_EXTENSION_FOLDER analogous to DEPLOYERS_EXTENSION_FOLDER at line 30. Also, if it is not too late, it would read better if DEPLOYERS_EXTENSION_FOLDER was defined to be "deployers" rather than "deploy". Lastly, this code might be more logically placed at line 211.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid that it would be better not to change the deploy folders, as we are aware of some users already using them, and it would be breaking, probably not worth it.

Regarding GENERATORS_EXTENSION_FOLDER I am tempted to go in the other direction, if no one else in the whole codebase uses the constant, then, tit is better encapsulated in the custom_generators_path, so I was tempted to remove the CUSTOM_COMMANDS_FOLDER global const, and make it an implementation detail over custom_commands_path, which is the abstraction to use, not the constant. I will double check that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, most of those consts, defined as public in the global module scope are unused in the rest of the codebase. I typically prefer to provide the less possible scope and indirection when it is artificial/unused/premature, so I'd probably propose an internal simplification PR for that (but I'll do it in another PR to keep this one minimal).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @memsharded,
Thanks for the additional insights. Regarding "deploy" vs. "deployers", would it be possible to look in both "deployers" and "deploy" but issues a deprecation warning for any files found in the older one? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[question] How to custom generator for conan 2.x
5 participants