please
please copied to clipboard
Feature request: Support for "Configuration files"
In some languages, such as C, I have come across the convention of having a configuration file for libraries. This file contains some macro definitions and at times some small functions that are then used internally and provide a global configuration for the library.
With traditional build systems, usually all sources are available to all parts of a project and the configuration file is placed somewhere in the main project, separate from the library code (I believe cmake also supports some functionality, without all sources being visible at once). However, this approach does not work with please, especially when using sub-repositories.
Please does not provide a way for a sub-repo rule to access a rule in a parent repo (and it shouldn't), but because of this there is also no way to provide a sub-repo rule with any configuration, short of having a local copy of the repo and adding the file into it.
The request is to provide a mechanism that build definitions can use in order to provide a configuration file to sub-repos from a parent.
I think this is kind of meant to be solved with the plugin mechanism. Plugins provide build definitions along with a way to configure them through a section in the please config e.g. [Plugin "cc"]
.
Configuration values can be inherited from the host repo, or overridden by subrepos. For example, you may want to use the CC tool configuration from the host repo, however subrepos should not inherit the default namespace.
By the way, subrepos can access build targets from the host repo e.g. @//third_party/cc:gtest
. You'd usually do this through a config value though.
Oh I didn't know that you can use @
like that.
Using the plugin system to do configurations would work in most cases, but I have come across some environments where I would want to pass in generated files from a parent repo to a library. For instance, STM32 generates a bunch of files for hardware access, which libraries import and use.
In those cases, it would be useful if I could just tell a library rule to 'depend' or at least pass certain files to it directly. This would also keep the configs in the same language, which would help when migrating existing projects that use this mechanism to please.
After playing around with plugins quite a bit, I have come around on this issue.
Any configuration files can be provided with parameters on rules. To that effect, I think it might be cool if the subrepo rules got expanded, to allow passing in such files on repositories that don't have native please support. That would only be a quality of life thing.
For now, I think please supports enough to allow for the functionality I would envision by using things like clever custom rules or the patches in the subrepo rules.