diff options
author | Pavel Labath <labath@google.com> | 2017-06-15 11:23:22 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2017-06-15 11:23:22 +0000 |
commit | c91ba1ccccda3b9329ac6f8cb6caeb34b1db8111 (patch) | |
tree | 0a4374e7b94ae8eb79733d5b751f86dac010e7de | |
parent | 518c16c32b266663614c227575537c3e75f88784 (diff) | |
download | lldb-c91ba1ccccda3b9329ac6f8cb6caeb34b1db8111.tar.gz |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@305461 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | scripts/lldb.swig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/scripts/lldb.swig b/scripts/lldb.swig index 8f1b59c32..8345a4b95 100644 --- a/scripts/lldb.swig +++ b/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 |