aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/python/libghdl/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhdl/python/libghdl/__init__.py')
-rw-r--r--src/vhdl/python/libghdl/__init__.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/vhdl/python/libghdl/__init__.py b/src/vhdl/python/libghdl/__init__.py
index d36f58d9f..d09b70cbd 100644
--- a/src/vhdl/python/libghdl/__init__.py
+++ b/src/vhdl/python/libghdl/__init__.py
@@ -1,11 +1,23 @@
import ctypes
import sys
+import os.path
-dll_ext = {'linux': '.so',
- 'linux2': '.so',
- 'darwin': '.dylib',
- 'win32': '.dll',
- 'cygwin': '.dll'}
+_ext = {'linux': '.so',
+ 'linux2': '.so',
+ 'darwin': '.dylib',
+ 'win32': '.dll',
+ 'cygwin': '.dll'}
-libghdl = ctypes.CDLL("libghdl" + dll_ext.get(sys.platform, '.so'))
+# Load the DLL.
+_basedir = os.path.join(os.path.dirname(__file__), '..')
+libghdl = ctypes.CDLL(os.path.join(
+ _basedir, 'libghdl' + _ext.get(sys.platform, '.so')))
+
+# Low-level initialization (elaboration).
libghdl.libghdl_init()
+
+# Set the default prefix.
+_prefix = os.path.join(_basedir, "ghdl")
+_prefix_opt = "--PREFIX=" + _prefix
+libghdl.libghdl__set_option(
+ ctypes.c_char_p(_prefix_opt), len(_prefix_opt))