about summary refs log tree commit diff
path: root/third_party/bazel/rules_haskell/tests/cc_haskell_import/python_add_one.py
blob: b400102d1cc66b97e15b6831315a630b9a27b405 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
import ctypes
from bazel_tools.tools.python.runfiles import runfiles
import subprocess

r = runfiles.Create()

path = r.Rlocation('io_tweag_rules_haskell/tests/cc_haskell_import/hs-lib-b-wrapped.so')

foreignlib = ctypes.cdll.LoadLibrary(path)

# ATTN: If you remove this print *statement* hs_init will segfault!
# If you use the python3 print *function*, it will segfault as well!
# TODO: wtf?
print foreignlib

foreignlib.hs_init()
assert(str(foreignlib.add_one_hs(1)) == "2")