[lldb] Support Python imports relative the to the current file being sourced
authorJonas Devlieghere <jonas@devlieghere.com>
Tue, 27 Oct 2020 16:14:40 +0000 (09:14 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Tue, 27 Oct 2020 16:20:45 +0000 (09:20 -0700)
commit00bb397b0dc79fcad27bfe63456a2100039706f2
treec1b5cddc681cb2104a68409abcafe6fce70d1c6e
parentd028d2b376a1a01404e9766f9303a24771baab1f
[lldb] Support Python imports relative the to the current file being sourced

Make it possible to use a relative path in command script import to the
location of the file being sourced. This allows the user to put Python
scripts next to LLDB command files and importing them without having to
specify an absolute path.

To enable this behavior pass `-c` to `command script import`. The
argument can only be used when sourcing the command from a file.

rdar://68310384

Differential revision: https://reviews.llvm.org/D89334
13 files changed:
lldb/include/lldb/Interpreter/CommandInterpreter.h
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/source/Commands/CommandObjectCommands.cpp
lldb/source/Commands/Options.td
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Interpreter/ScriptInterpreter.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
lldb/test/Shell/ScriptInterpreter/Python/Inputs/hello.split [new file with mode: 0644]
lldb/test/Shell/ScriptInterpreter/Python/Inputs/relative.split [new file with mode: 0644]
lldb/test/Shell/ScriptInterpreter/Python/command_relative_import.test [new file with mode: 0644]