[lldb] Get rid of LLDB_LIB_DIR and LLDB_IMPLIB_DIR in dotest

This patch removes the rather confusing LLDB_LIB_DIR and LLDB_IMPLIB_DIR
environment variables. They are confusing because LLDB_LIB_DIR would
point to the bin subdirectory in the build root while LLDB_IMPLIB_DIR
would point to the lib subdirectory. The reason far this was
LLDB.framework, which gets build under bin.

This patch replaces their uses with configuration.lldb_framework_path
and configuration.lldb_libs_dir respectively.

Differential revision: https://reviews.llvm.org/D86817
This commit is contained in:
Jonas Devlieghere 2020-08-28 15:43:35 -07:00
parent 55e7d91072
commit 141c8475b6
5 changed files with 24 additions and 50 deletions

View File

@ -510,10 +510,9 @@ def skipIfNoSBHeaders(func):
if lldb.remote_platform: if lldb.remote_platform:
return "skip because SBHeaders tests make no sense remotely" return "skip because SBHeaders tests make no sense remotely"
if lldbplatformutil.getHostPlatform() == 'darwin': if lldbplatformutil.getHostPlatform() == 'darwin' and configuration.lldb_framework_path:
header = os.path.join( header = os.path.join(
os.environ["LLDB_LIB_DIR"], configuration.lldb_framework_path,
'LLDB.framework',
'Versions', 'Versions',
'Current', 'Current',
'Headers', 'Headers',

View File

@ -519,13 +519,6 @@ def setupSysPath():
print("The 'lldb' executable cannot be located. Some of the tests may not be run as a result.") print("The 'lldb' executable cannot be located. Some of the tests may not be run as a result.")
sys.exit(-1) sys.exit(-1)
# confusingly, this is the "bin" directory
lldbLibDir = os.path.dirname(lldbtest_config.lldbExec)
os.environ["LLDB_LIB_DIR"] = lldbLibDir
lldbImpLibDir = configuration.lldb_libs_dir
os.environ["LLDB_IMPLIB_DIR"] = lldbImpLibDir
print("LLDB library dir:", os.environ["LLDB_LIB_DIR"])
print("LLDB import library dir:", os.environ["LLDB_IMPLIB_DIR"])
os.system('%s -v' % lldbtest_config.lldbExec) os.system('%s -v' % lldbtest_config.lldbExec)
lldbDir = os.path.dirname(lldbtest_config.lldbExec) lldbDir = os.path.dirname(lldbtest_config.lldbExec)
@ -540,8 +533,6 @@ def setupSysPath():
configuration.skip_categories.append("lldb-vscode") configuration.skip_categories.append("lldb-vscode")
lldbPythonDir = None # The directory that contains 'lldb/__init__.py' lldbPythonDir = None # The directory that contains 'lldb/__init__.py'
if not configuration.lldb_framework_path and os.path.exists(os.path.join(lldbLibDir, "LLDB.framework")):
configuration.lldb_framework_path = os.path.join(lldbLibDir, "LLDB.framework")
if configuration.lldb_framework_path: if configuration.lldb_framework_path:
lldbtest_config.lldb_framework_path = configuration.lldb_framework_path lldbtest_config.lldb_framework_path = configuration.lldb_framework_path
candidatePath = os.path.join( candidatePath = os.path.join(

View File

@ -916,28 +916,18 @@ class Base(unittest2.TestCase):
self.setPlatformWorkingDir() self.setPlatformWorkingDir()
self.enableLogChannelsForCurrentTest() self.enableLogChannelsForCurrentTest()
lib_dir = os.environ["LLDB_LIB_DIR"] self.lib_lldb = None
self.dsym = None
self.framework_dir = None self.framework_dir = None
self.darwinWithFramework = self.platformIsDarwin() self.darwinWithFramework = False
if sys.platform.startswith("darwin"):
# Handle the framework environment variable if it is set if sys.platform.startswith("darwin") and configuration.lldb_framework_path:
if hasattr(lldbtest_config, 'lldb_framework_path'): framework = configuration.lldb_framework_path
framework_path = lldbtest_config.lldb_framework_path lib = os.path.join(framework, 'LLDB')
# Framework dir should be the directory containing the framework if os.path.exists(lib):
self.framework_dir = framework_path[:framework_path.rfind('LLDB.framework')] self.framework_dir = os.path.dirname(framework)
# If a framework dir was not specified assume the Xcode build self.lib_lldb = lib
# directory layout where the framework is in LLDB_LIB_DIR. self.darwinWithFramework = self.platformIsDarwin()
else:
self.framework_dir = lib_dir
self.dsym = os.path.join(self.framework_dir, 'LLDB.framework', 'LLDB')
# If the framework binary doesn't exist, assume we didn't actually
# build a framework, and fallback to standard *nix behavior by
# setting framework_dir and dsym to None.
if not os.path.exists(self.dsym):
self.framework_dir = None
self.dsym = None
self.darwinWithFramework = False
self.makeBuildDir() self.makeBuildDir()
def setAsync(self, value): def setAsync(self, value):
@ -1499,7 +1489,7 @@ class Base(unittest2.TestCase):
'EXE': exe_name, 'EXE': exe_name,
'CFLAGS_EXTRAS': "%s %s" % (stdflag, stdlibflag), 'CFLAGS_EXTRAS': "%s %s" % (stdflag, stdlibflag),
'FRAMEWORK_INCLUDES': "-F%s" % self.framework_dir, 'FRAMEWORK_INCLUDES': "-F%s" % self.framework_dir,
'LD_EXTRAS': "%s -Wl,-rpath,%s" % (self.dsym, self.framework_dir), 'LD_EXTRAS': "%s -Wl,-rpath,%s" % (self.lib_lldb, self.framework_dir),
} }
elif sys.platform.startswith('win'): elif sys.platform.startswith('win'):
d = { d = {
@ -1510,7 +1500,7 @@ class Base(unittest2.TestCase):
os.path.join( os.path.join(
os.environ["LLDB_SRC"], os.environ["LLDB_SRC"],
"include")), "include")),
'LD_EXTRAS': "-L%s -lliblldb" % os.environ["LLDB_IMPLIB_DIR"]} 'LD_EXTRAS': "-L%s -lliblldb" % lib_dir}
else: else:
d = { d = {
'CXX_SOURCES': sources, 'CXX_SOURCES': sources,
@ -1539,7 +1529,7 @@ class Base(unittest2.TestCase):
'DYLIB_NAME': lib_name, 'DYLIB_NAME': lib_name,
'CFLAGS_EXTRAS': "%s -stdlib=libc++" % stdflag, 'CFLAGS_EXTRAS': "%s -stdlib=libc++" % stdflag,
'FRAMEWORK_INCLUDES': "-F%s" % self.framework_dir, 'FRAMEWORK_INCLUDES': "-F%s" % self.framework_dir,
'LD_EXTRAS': "%s -Wl,-rpath,%s -dynamiclib" % (self.dsym, self.framework_dir), 'LD_EXTRAS': "%s -Wl,-rpath,%s -dynamiclib" % (self.lib_lldb, self.framework_dir),
} }
elif self.getPlatform() == 'windows': elif self.getPlatform() == 'windows':
d = { d = {
@ -1549,7 +1539,7 @@ class Base(unittest2.TestCase):
os.path.join( os.path.join(
os.environ["LLDB_SRC"], os.environ["LLDB_SRC"],
"include")), "include")),
'LD_EXTRAS': "-shared -l%s\liblldb.lib" % self.os.environ["LLDB_IMPLIB_DIR"]} 'LD_EXTRAS': "-shared -l%s\liblldb.lib" % lib_dir}
else: else:
d = { d = {
'DYLIB_CXX_SOURCES': sources, 'DYLIB_CXX_SOURCES': sources,
@ -1759,13 +1749,11 @@ class Base(unittest2.TestCase):
""" """
existing_library_path = os.environ[ existing_library_path = os.environ[
self.dylibPath] if self.dylibPath in os.environ else None self.dylibPath] if self.dylibPath in os.environ else None
lib_dir = os.environ["LLDB_LIB_DIR"]
if existing_library_path: if existing_library_path:
return "%s:%s" % (existing_library_path, lib_dir) return "%s:%s" % (existing_library_path, configuration.lldb_libs_dir)
elif sys.platform.startswith("darwin"): if sys.platform.startswith("darwin") and configuration.lldb_framework_path:
return os.path.join(lib_dir, 'LLDB.framework') return configuration.lldb_framework_path
else: return configuration.lldb_libs_dir
return lib_dir
def getLibcPlusPlusLibs(self): def getLibcPlusPlusLibs(self):
if self.getPlatform() in ('freebsd', 'linux', 'netbsd', 'openbsd'): if self.getPlatform() in ('freebsd', 'linux', 'netbsd', 'openbsd'):

View File

@ -21,7 +21,7 @@ class TestIntelPTSimpleBinary(TestBase):
if 'intel-pt' not in configuration.enabled_plugins: if 'intel-pt' not in configuration.enabled_plugins:
self.skipTest("The intel-pt test plugin is not enabled") self.skipTest("The intel-pt test plugin is not enabled")
plugin_path = os.path.join(os.environ["LLDB_IMPLIB_DIR"], "liblldbIntelFeatures.so") plugin_path = os.path.join(configuration.lldb_libs_dir, "liblldbIntelFeatures.so")
self.runCmd("plugin load " + plugin_path) self.runCmd("plugin load " + plugin_path)
@skipIf(oslist=no_match(['linux'])) @skipIf(oslist=no_match(['linux']))

View File

@ -30,9 +30,7 @@ class TestMPXTable(TestBase):
"""Test 'mpx-table show' command""" """Test 'mpx-table show' command"""
self.build() self.build()
lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"] plugin_file = os.path.join(configuration.lldb_libs_dir, "liblldbIntelFeatures.so")
lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
if not os.path.isfile(plugin_file): if not os.path.isfile(plugin_file):
self.skipTest("features plugin missing.") self.skipTest("features plugin missing.")
plugin_command = " " plugin_command = " "
@ -122,9 +120,7 @@ class TestMPXTable(TestBase):
"""Test 'mpx-table set' command""" """Test 'mpx-table set' command"""
self.build() self.build()
lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"] plugin_file = os.path.join(configuration.lldb_libs_dir, "liblldbIntelFeatures.so")
lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
if not os.path.isfile(plugin_file): if not os.path.isfile(plugin_file):
self.skipTest("features plugin missing.") self.skipTest("features plugin missing.")
plugin_command = " " plugin_command = " "