Building off of D37756, the next step is to take all the common, reusable stuff that is copied across the various LLVM projects, and centralize it.
I've identified two key areas that I'm tackling with this patch:
- Stuff that can be done automatically for every single LLVM project. For example, almost every test starts with 6-7 lines of copied code to add GnuWin32 to the path on Windows. Those that don't, probably should. Similarly, most of the projects add some common "features" that can be checked by tests. All of these features now get added automatically.
Caveat: In some cases this is introducing *new* features to projects that didn't currently have these features before. This is a change, but I think it's worth doing, as I only chose the most common, generic not-project-specific ones for this purpose.
- Adding some convenience functions that reduce the amount of code required to do various common things. For example, a lot of projects need to run llvm-config in various ways in order to determine if certain features are enabled. This involves duplicating the same 10 lines of code multiple times. Now, by using this helper function, it's 1 line.
At a high level, the way this works is to add a new llvm-specific submodule to lit. Then, you have your site config put the magic configure-like replacement and configure automatically imports and initializes this module for you. Then, in your main config, an object magically appears that you can just use.
With this patch I'm only introducing this into LLVM's lit.cfg. The idea is to get feedback on the high level ideas. I can go through and cleanup the remainder of the projects later.
It might make sense to move this into the LLVMConfig class, so you don't have to keep passing lit_config.
It also looks like this is always called with attributes on config, so you could roll in the getattr()s here as well.