-
-
Notifications
You must be signed in to change notification settings - Fork 39.9k
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
Automatically include build.mk after rules.mk. #2046
Conversation
Looks like there are some merge conflicts here. Would you mind updating this? Especially, as I think we talked about this internally recently, and it is something that we may want to actually implement. |
So I had completely forgotten about this, and when I went to master and the patch wasn't there, I thought someone had removed the rules/build thing... But now I realize I just never got it merged. I can try to regenerate it. I do still want it, for exactly the same reason; it makes conditional inclusion of modules easier, and makes it possible for individual layouts to control presence of features. |
In some cases, you might want to have rules which are conditional on settings, but to allow later files to override the settings. For instance: FOO_ENABLE = no ifeq $($(strip $(FOO_ENABLE)),yes) SRC += foo.c endif if you override FOO_ENABLE elsewhere, nothing happens. So we split this into a rules.mk containing the setting, and a build.mk containing the build rules, then include every build.mk file *after* all the rules.mk files have been included. I made this change to ergodox_ez as an example. A call to include with no filename in an eval works harmlessly, so we don't have to do existence checks. Signed-off-by: seebs <[email protected]>
Updated. I haven't checked this out as carefully as I'd like, and actually it looks like something called i2c_master is getting compiled in anyway, but I don't actually understand the RGB_MATRIX_ENABLE setting. Checking with |
|
That helps for the i2c case, but it doesn't address the other issue I had, in my LCD branch, where I have source files that are only useful to add if a given feature is enabled, but I'd want to be able to control it in the keyboard config. So the updated patch is probably actually sane now, despite the i2c_master case being irrelevant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that @fredizzimo was trying to implement something along these lines, at one point.
I think this is probably a good change, but documentation for it would be ... useful.
I think there's a couple open questions to be answered before this is merged:
I'd also like to understand better why |
The |
@@ -0,0 +1,3 @@ | |||
ifeq ($(strip $(RGB_MATRIX_ENABLE)), no) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change isn't actually necessary anymore.
i2c is added via QUANTUM_LIB_SRC
which has some special handling that prevents conflicts with it being added multiple times (also, prevents LTO from being applied to it, as it can cause weird timing related issues)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, neat. that would indeed resolve this part. i'm not sure it also resolves the corresponding issue with the other optional modules, added in the later patch, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. There are still a number of use cases that would make this very useful still. Such as per-keyboard features/options, that can be adjusted by the keymaps. As well as by userspace, in general.
I suggest using a different name instead of build.mk. For example, prepare_build.mk, post_rules.mk, etc. |
A clearer name, or at least documentation of this would go a long way, I think. |
I think
From what I can tell, the Basically, all of this stuff would got into the "post" file: qmk_firmware/users/drashna/rules.mk Lines 7 to 54 in 46d0fe4
Also, it would allow for stuff like the helix's custom options to be properly processed, rather than what it's doing now: And it would allow for the userspace's rules.mk to be processed correctly, as opposed to what we have now, due to how the userspaces (such as mine) are set up. But yes, ideally, there should be some documentation on how to use this properly. Edit: Also, due to the qmk_firmware/layouts/community/ortho_4x12/drashna/rules.mk Lines 32 to 36 in cee8df3
Specifically, because PROTOCOL is populated AFTER the rules.mk files have all been read. Moving the mcu_selection.mk doesn't work, and re-including the rules.mk sounds like a very good way to break things. So, more and more, this is something that we may really need. |
We also need documentation. On the name I think |
Naming is hard. I'm more than open to whatever name. I'm just not sure which is best. |
So the fundamental distinction, I think, is between "things a layout should be able to override" and "things that need to be set in response to those overrides", although all the examples I can think of are file inclusions. Maybe Alternative notion: Can we do this with defines? Something like defining a thing that will expand to that ifeq/endif chain, but will expand to it and be processed after all the rules.mk get done? I think gnu make is insane enough to allow that, so you could do something like
|
Well, I know we already have |
We held a collaborator's meeting on this subject yesterday. We have new people on the team who have brought some fresh perspective here. I wish I could say we had a definitive answer on what the path forward is, but we don't yet. We have clarified a few issues, however. Our primary concern right now revolves around complexity and maintainability. We're worried that this will create a situation where one needs keyboard specific context to do any maintenance at all, and since the majority of keyboards in the tree do not have an active maintainer this will put a load on anyone doing maintenance programming. We think most of the use cases for this feature are addressed by #9058. The big open question right now is what use cases are not addressed by that PR. |
Most of my thoughts on what this feature could bring to the table moving forward are laid out in #9058 (comment). Here I'd just like to address the naming of the new file. While @skullydazed Could you elaborate a bit on what you mean by “create a situation where one needs keyboard specific context to do any maintenance at all”? |
This has been added in a different PR, in a different matter/naming. |
In some cases, you might want to have rules which are conditional
on settings, but to allow later files to override the settings.
For instance:
if you override FOO_ENABLE elsewhere, nothing happens.
So we split this into a rules.mk containing the setting, and
a build.mk containing the build rules, then include every
build.mk file after all the rules.mk files have been
included.
A call to include with no filename in an eval works
harmlessly, so we don't have to do existence checks.
Signed-off-by: seebs [email protected]