[PATCH] D37778: [lit] Add a shared llvm configuration library, and use it in llvm

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 16:09:29 PDT 2017


zturner created this revision.
Herald added a subscriber: mgorny.
Herald added a reviewer: modocache.

Building off of https://reviews.llvm.org/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:

1. 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.

2. 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.


https://reviews.llvm.org/D37778

Files:
  llvm/cmake/modules/AddLLVM.cmake
  llvm/test/lit.cfg
  llvm/test/lit.site.cfg.in
  llvm/utils/lit/lit/llvm/__init__.py
  llvm/utils/lit/lit/llvm/config.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37778.114933.patch
Type: text/x-patch
Size: 17229 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170912/c1626c7a/attachment.bin>


More information about the llvm-commits mailing list