-
Notifications
You must be signed in to change notification settings - Fork 0
/
ld_lib_path.py
49 lines (35 loc) · 1.38 KB
/
ld_lib_path.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import sublime, sublime_plugin
import platform
from os import environ, pathsep
# this script relies on the ld_lib_path_original and ld_lib_path_settings globals defined below
def is_mac():
# not very found of this one, but, whatever
if platform.system() == "Darwin":
return True
else:
return False
def ld_path_env_name():
# on OS X, the linker searches for DYLD_LIBRARY_PATH
return ("DY" if is_mac() else "") + "LD_LIBRARY_PATH"
def ld_lib_path():
global ld_lib_path_original
global ld_lib_path_settings
# concatenations with platform specific path separator (eg ':' colon on UNIX, ';' semicolon on windows)
environ[ld_path_env_name()] = pathsep.join(ld_lib_path_settings.get("ld_library_path_items", []))
def plugin_loaded():
global ld_lib_path_original
global ld_lib_path_settings
ld_lib_path_original = None
ld_lib_path_settings = None
ld_lib_path_settings = sublime.load_settings("Preferences.sublime-settings")
ld_lib_path_settings.clear_on_change('ldlibpath-reload')
ld_lib_path_settings.add_on_change('ldlibpath-reload', ld_lib_path)
if ld_path_env_name() in environ:
ld_lib_path_original = environ[ld_path_env_name()]
ld_lib_path()
def plugin_unloaded():
global ld_lib_path_original
global ld_lib_path_settings
environ[ld_path_env_name()] = ld_lib_path_original
ld_lib_path_settings.clear_on_change('ldlibpath-reload')
plugin_loaded()