summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2017-06-15 11:23:22 +0000
committerPavel Labath <labath@google.com>2017-06-15 11:23:22 +0000
commit054243f75a189b32f58a73bd3d2fd925417e3faa (patch)
tree096eef17985c6d3bd592de1df01b5f6d546d512b
parenta91cbdc60f0f3ba924c4bbbddd580358c8ad822e (diff)
downloadbcm5719-llvm-054243f75a189b32f58a73bd3d2fd925417e3faa.tar.gz
bcm5719-llvm-054243f75a189b32f58a73bd3d2fd925417e3faa.zip
[swig] Improve the native module import logic
The simple module import logic was not sufficient for our distribution model of lldb, which is without the _lldb.pyd file (normally that would be a symlink to the shared library, but symlinks are not really a thing on windows). With the older swigs it worked (loading of the python scripting machinery from within lldb) because the normal swig import logic contained a last-ditch import of a global module _lldb (which is defined when you run python from lldb). Add back the last-ditch import to our custom import logic as well. llvm-svn: 305461
-rw-r--r--lldb/scripts/lldb.swig8
1 files changed, 7 insertions, 1 deletions
diff --git a/lldb/scripts/lldb.swig b/lldb/scripts/lldb.swig
index 8f1b59c32d4..8345a4b9503 100644
--- a/lldb/scripts/lldb.swig
+++ b/lldb/scripts/lldb.swig
@@ -40,7 +40,13 @@ us to override the module import logic to suit our needs. This does that.
Older swig versions will simply ignore this setting.
*/
%define MODULEIMPORT
-"from . import $module"
+"try:
+ # Try a relative import first
+ from . import $module
+except ImportError:
+ # Maybe absolute import will work (if we're being loaded from lldb, it
+ # should).
+ import $module"
%enddef
// These versions will not generate working python modules, so error out early.
#if SWIG_VERSION >= 0x030009 && SWIG_VERSION < 0x030011
OpenPOWER on IntegriCloud