[llvm-commits] [Review request][Win] CMake & Lit: the new feature "LLVM_LIT_TOOLS_DIR"
NAKAMURA Takumi
geek4civic at gmail.com
Tue Dec 7 02:28:19 PST 2010
Good evening, guys!
You can run tests on Visual Studio without adding anything to %PATH%.
(to set LLVM_LIT_TOOLS_DIR and PYTHON_EXECUTABLE with CMake)
You can run tests with gnuwin32 on both Mingw and MSYS.
You can run tests on autoconf/MSYS with bash.
Please give me any comments for this feature!
This patch provides new features;
- Lit can pick up *sane* toolchain.
LitConfig.getToolsPath() can seek and pick up directory
where all of given commands [cmp, grep, sed] are in.
We ought never to meet C:/windows/system32/sort.exe etc.
- If the directory has "bash.exe", we can use bash shell for tests.
(even on Visual Studio! :p )
Even with configure, Lit can find bash.exe.
Note: Lit tests with MSYS have some issues.
You can work around it.
- You can specify LLVM_LIT_TOOLS_DIR.
Toolchain can be picked up from there.
Then you don't need to add gnuwin32 dir to %PATH%.
If MSYS bash.exe is there, bash tests will be executed.
[llvm]
* 0001-CMake-Add-the-new-option-LLVM_LIT_TOOLS_DIR.-It-.patch.txt
It adds the option "LLVM_LIT_TOOLS_DIR".
With CMake GUI, it can be set by directory chooser dialog.
It does nothing. It can be read from lit.config.lit_tools_dir.
* 0002-lit-Util.py-Add-two-functions-checkToolsPath-dir.patch.txt
It adds two functions to Util.
* 0003-lit-LitConfig.py-Add-the-new-method-getToolsPath.patch.txt
It adds a method to LitConfig. It depends to 0002.
* 0004-test-lit.cfg-Seek-sane-tools-and-bash-in-directo.patch.txt
It activates LLVM_LIT_TOOLS_DIR.
[clang]
* 0001-test-CMake-Be-aware-of-LLVM_LIT_TOOLS_DIR.patch.txt
It activates LLVM_LIT_TOOLS_DIR.
...Takumi
-------------- next part --------------
From 8a44363de50f4f06f79adc0081f43661d15a4e3a Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Tue, 9 Nov 2010 13:44:00 +0900
Subject: [PATCH 1/4] CMake: Add the new option LLVM_LIT_TOOLS_DIR. It can specify "Path to GnuWin32 tools".
---
CMakeLists.txt | 2 ++
test/lit.site.cfg.in | 1 +
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2d1f66b..2ce6301 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -110,6 +110,8 @@ endif()
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}"
CACHE STRING "Default options for lit")
+set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")
+
option(LLVM_ENABLE_THREADS "Use threads if available." ON)
if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index eb5fa8c..3588aa6 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -4,6 +4,7 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@"
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.llvmgcc_dir = "@LLVMGCCDIR@"
+config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.enable_shared = @ENABLE_SHARED@
--
1.7.1.GIT
-------------- next part --------------
From a8d3c34a9bf2699b863759606b439841578c36da Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Tue, 9 Nov 2010 13:51:28 +0900
Subject: [PATCH 2/4] lit/Util.py: Add two functions, checkToolsPath(dir,tools) and whichTools(tools,paths).
checkToolsPath(dir,tools):
return True if "dir" contains all "tools".
whichTools(tools,paths):
return a directory that contains all "tools" in "paths".
Or return None when all "tools" were not met.
---
utils/lit/lit/Util.py | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/utils/lit/lit/Util.py b/utils/lit/lit/Util.py
index 414b714..ad4adf2 100644
--- a/utils/lit/lit/Util.py
+++ b/utils/lit/lit/Util.py
@@ -75,6 +75,18 @@ def which(command, paths = None):
return None
+def checkToolsPath(dir, tools):
+ for tool in tools:
+ if not os.path.exists(os.path.join(dir, tool)):
+ return False;
+ return True;
+
+def whichTools(tools, paths):
+ for path in paths.split(os.pathsep):
+ if checkToolsPath(path, tools):
+ return path
+ return None
+
def printHistogram(items, title = 'Items'):
import itertools, math
--
1.7.1.GIT
-------------- next part --------------
From e2e9936554c1f84d085a17f9a107cdd9dfcb29ac Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Tue, 9 Nov 2010 13:57:11 +0900
Subject: [PATCH 3/4] lit/LitConfig.py: Add the new method getToolsPath(dir,paths,tools).
It seeks tools(eg. [cmp, grep, sed]) in same directory, to be sane.
It seeks "bash" only in the directory found at last time. Or bash would be insane (against other tools).
---
utils/lit/lit/LitConfig.py | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/utils/lit/lit/LitConfig.py b/utils/lit/lit/LitConfig.py
index 43ed6f1..7ca1b9c 100644
--- a/utils/lit/lit/LitConfig.py
+++ b/utils/lit/lit/LitConfig.py
@@ -85,6 +85,22 @@ class LitConfig:
return self.bashPath
+ def getToolsPath(self, dir, paths, tools):
+ import os, Util
+ if dir is not None and os.path.isabs(dir) and os.path.isdir(dir):
+ if not Util.checkToolsPath(dir, tools):
+ return None
+ else:
+ dir = Util.whichTools(tools, paths)
+
+ # bash
+ self.bashPath = Util.which('bash', dir)
+ if self.bashPath is None:
+ self.warning("Unable to find 'bash.exe'.")
+ self.bashPath = ''
+
+ return dir
+
def _write_message(self, kind, message):
import inspect, os, sys
--
1.7.1.GIT
-------------- next part --------------
From 168ff9417ddc9b79b0122cc2712dc836cdb50b01 Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Tue, 9 Nov 2010 14:12:36 +0900
Subject: [PATCH 4/4] test/lit.cfg: Seek sane tools(and bash) in directories and set to $PATH.
LitConfig.getBashPath() will not seek in $PATH after LitConfig.getToolsPath() was executed.
---
test/lit.cfg | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/test/lit.cfg b/test/lit.cfg
index 98f7209..ca55666 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -18,6 +18,18 @@ config.suffixes = []
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
+# Tweak PATH for Win32
+if sys.platform in ['win32']:
+ # Seek sane tools in directories and set to $PATH.
+ path = getattr(config, 'lit_tools_dir', None)
+ path = lit.getToolsPath(path,
+ config.environment['PATH'],
+ ['cmp.exe', 'grep.exe', 'sed.exe'])
+ if path is not None:
+ path = os.path.pathsep.join((path,
+ config.environment['PATH']))
+ config.environment['PATH'] = path
+
# test_exec_root: The root path where tests should be run.
llvm_obj_root = getattr(config, 'llvm_obj_root', None)
if llvm_obj_root is not None:
@@ -227,7 +239,7 @@ config.on_clone = on_clone
### Features
# Shell execution
-if sys.platform not in ['win32']:
+if sys.platform not in ['win32'] or lit.getBashPath() != '':
config.available_features.add('shell')
# Loadable module
--
1.7.1.GIT
-------------- next part --------------
From ff857b0367a9e02f59d28fda3dbe65e3a644c150 Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Tue, 9 Nov 2010 13:25:42 +0900
Subject: [PATCH] test: CMake: Be aware of LLVM_LIT_TOOLS_DIR.
---
test/lit.cfg | 12 ++++++++++++
test/lit.site.cfg.in | 1 +
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/test/lit.cfg b/test/lit.cfg
index 071284f..b9b815b 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -8,6 +8,18 @@ import platform
# name: The name of this test suite.
config.name = 'Clang'
+# Tweak PATH for Win32
+if platform.system() == 'Windows':
+ # Seek sane tools in directories and set to $PATH.
+ path = getattr(config, 'lit_tools_dir', None)
+ path = lit.getToolsPath(path,
+ config.environment['PATH'],
+ ['cmp.exe', 'grep.exe', 'sed.exe'])
+ if path is not None:
+ path = os.path.pathsep.join((path,
+ config.environment['PATH']))
+ config.environment['PATH'] = path
+
# testFormat: The test format to use to interpret tests.
#
# For now we require '&&' between commands, until they get globally killed and
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index 0d452ef..df90b81 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -4,6 +4,7 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@"
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.clang_obj_root = "@CLANG_BINARY_DIR@"
config.target_triple = "@TARGET_TRIPLE@"
--
1.7.1.GIT
More information about the llvm-commits
mailing list