Skip to content

Commit

Permalink
[lldb] Get rid of LLDB_LIB_DIR and LLDB_IMPLIB_DIR in dotest
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JDevlieghere committed Aug 28, 2020
1 parent 55e7d91 commit 141c847
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 50 deletions.
5 changes: 2 additions & 3 deletions lldb/packages/Python/lldbsuite/test/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,9 @@ def are_sb_headers_missing():
if lldb.remote_platform:
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(
os.environ["LLDB_LIB_DIR"],
'LLDB.framework',
configuration.lldb_framework_path,
'Versions',
'Current',
'Headers',
Expand Down
9 changes: 0 additions & 9 deletions lldb/packages/Python/lldbsuite/test/dotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,6 @@ def setupSysPath():
print("The 'lldb' executable cannot be located. Some of the tests may not be run as a result.")
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)

lldbDir = os.path.dirname(lldbtest_config.lldbExec)
Expand All @@ -540,8 +533,6 @@ def setupSysPath():
configuration.skip_categories.append("lldb-vscode")

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:
lldbtest_config.lldb_framework_path = configuration.lldb_framework_path
candidatePath = os.path.join(
Expand Down
50 changes: 19 additions & 31 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,28 +916,18 @@ def setUp(self):
self.setPlatformWorkingDir()
self.enableLogChannelsForCurrentTest()

lib_dir = os.environ["LLDB_LIB_DIR"]
self.dsym = None
self.lib_lldb = None
self.framework_dir = None
self.darwinWithFramework = self.platformIsDarwin()
if sys.platform.startswith("darwin"):
# Handle the framework environment variable if it is set
if hasattr(lldbtest_config, 'lldb_framework_path'):
framework_path = lldbtest_config.lldb_framework_path
# Framework dir should be the directory containing the framework
self.framework_dir = framework_path[:framework_path.rfind('LLDB.framework')]
# If a framework dir was not specified assume the Xcode build
# directory layout where the framework is in LLDB_LIB_DIR.
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.darwinWithFramework = False

if sys.platform.startswith("darwin") and configuration.lldb_framework_path:
framework = configuration.lldb_framework_path
lib = os.path.join(framework, 'LLDB')
if os.path.exists(lib):
self.framework_dir = os.path.dirname(framework)
self.lib_lldb = lib
self.darwinWithFramework = self.platformIsDarwin()

self.makeBuildDir()

def setAsync(self, value):
Expand Down Expand Up @@ -1499,7 +1489,7 @@ def buildDriver(self, sources, exe_name):
'EXE': exe_name,
'CFLAGS_EXTRAS': "%s %s" % (stdflag, stdlibflag),
'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'):
d = {
Expand All @@ -1510,7 +1500,7 @@ def buildDriver(self, sources, exe_name):
os.path.join(
os.environ["LLDB_SRC"],
"include")),
'LD_EXTRAS': "-L%s -lliblldb" % os.environ["LLDB_IMPLIB_DIR"]}
'LD_EXTRAS': "-L%s -lliblldb" % lib_dir}
else:
d = {
'CXX_SOURCES': sources,
Expand Down Expand Up @@ -1539,7 +1529,7 @@ def buildLibrary(self, sources, lib_name):
'DYLIB_NAME': lib_name,
'CFLAGS_EXTRAS': "%s -stdlib=libc++" % stdflag,
'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':
d = {
Expand All @@ -1549,7 +1539,7 @@ def buildLibrary(self, sources, lib_name):
os.path.join(
os.environ["LLDB_SRC"],
"include")),
'LD_EXTRAS': "-shared -l%s\liblldb.lib" % self.os.environ["LLDB_IMPLIB_DIR"]}
'LD_EXTRAS': "-shared -l%s\liblldb.lib" % lib_dir}
else:
d = {
'DYLIB_CXX_SOURCES': sources,
Expand Down Expand Up @@ -1759,13 +1749,11 @@ def getLLDBLibraryEnvVal(self):
"""
existing_library_path = os.environ[
self.dylibPath] if self.dylibPath in os.environ else None
lib_dir = os.environ["LLDB_LIB_DIR"]
if existing_library_path:
return "%s:%s" % (existing_library_path, lib_dir)
elif sys.platform.startswith("darwin"):
return os.path.join(lib_dir, 'LLDB.framework')
else:
return lib_dir
return "%s:%s" % (existing_library_path, configuration.lldb_libs_dir)
if sys.platform.startswith("darwin") and configuration.lldb_framework_path:
return configuration.lldb_framework_path
return configuration.lldb_libs_dir

def getLibcPlusPlusLibs(self):
if self.getPlatform() in ('freebsd', 'linux', 'netbsd', 'openbsd'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setUp(self):
if 'intel-pt' not in configuration.enabled_plugins:
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)

@skipIf(oslist=no_match(['linux']))
Expand Down
8 changes: 2 additions & 6 deletions lldb/tools/intel-features/intel-mpx/test/TestMPXTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ def test_show_command(self):
"""Test 'mpx-table show' command"""
self.build()

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

lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
plugin_file = os.path.join(configuration.lldb_libs_dir, "liblldbIntelFeatures.so")
if not os.path.isfile(plugin_file):
self.skipTest("features plugin missing.")
plugin_command = " "
Expand Down

0 comments on commit 141c847

Please sign in to comment.