Lit: Allow overriding llvm tool paths+arguments, make -D an alias for --param
authorMatthias Braun <matze@braunis.de>
Mon, 4 May 2015 21:36:36 +0000 (21:36 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 4 May 2015 21:36:36 +0000 (21:36 +0000)
These changes allow usages where you want to pass an additional
commandline option to all invocations of a specific llvm tool. Example:

> llvm-lit -Dllc=llc -enable-misched -verify-machineinstrs

Differential Revision: http://reviews.llvm.org/D9487

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236461 91177308-0d34-0410-b5e6-96231b3b80d8

docs/CommandGuide/lit.rst
test/lit.cfg
utils/lit/lit/main.py

index 9c63848a76dfa7d95db9fb660e639b6f6f75f338..1f97bc31dd7f99431a3dfa02b54559d80565036c 100644 (file)
@@ -56,7 +56,7 @@ GENERAL OPTIONS
  Search for :file:`{NAME}.cfg` and :file:`{NAME}.site.cfg` when searching for
  test suites, instead of :file:`lit.cfg` and :file:`lit.site.cfg`.
 
-.. option:: --param NAME, --param NAME=VALUE
+.. option:: -D NAME, -D NAME=VALUE, --param NAME, --param NAME=VALUE
 
  Add a user defined parameter ``NAME`` with the given ``VALUE`` (or the empty
  string if not given).  The meaning and use of these parameters is test suite
index 059af8914e3eb953dfb25afb96302973d1e44755..939fb459132f2c3643bdce267976f1ae197769a8 100644 (file)
@@ -267,8 +267,12 @@ for pattern in [r"\bbugpoint\b(?!-)",
                           pattern)
     tool_pipe = tool_match.group(2)
     tool_name = tool_match.group(4)
-    tool_path = lit.util.which(tool_name, llvm_tools_dir)
-    if not tool_path:
+    # Did the user specify the tool path + arguments? This allows things like
+    # llvm-lit "-Dllc=llc -enable-misched -verify-machineinstrs"
+    tool_path = lit_config.params.get(tool_name)
+    if tool_path is None:
+        tool_path = lit.util.which(tool_name, llvm_tools_dir)
+    if tool_path is None:
         # Warn, but still provide a substitution.
         lit_config.note('Did not find ' + tool_name + ' in ' + llvm_tools_dir)
         tool_path = llvm_tools_dir + '/' + tool_name
index f2aedc906bb152d923fa9a6194a52ea5b71b5c24..e3722674f63f2820e70302ddb334d0589e98ba65 100755 (executable)
@@ -146,7 +146,7 @@ def main(builtinParameters = {}):
     parser.add_option("", "--config-prefix", dest="configPrefix",
                       metavar="NAME", help="Prefix for 'lit' config files",
                       action="store", default=None)
-    parser.add_option("", "--param", dest="userParameters",
+    parser.add_option("-D", "--param", dest="userParameters",
                       metavar="NAME=VAL",
                       help="Add 'NAME' = 'VAL' to the user defined parameters",
                       type=str, action="append", default=[])