about summary refs log tree commit diff
path: root/third_party/bazel/rules_haskell/tests/cc_haskell_import
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-08-15T15·11+0100
committerVincent Ambo <tazjin@google.com>2019-08-15T15·11+0100
commit128875b501bc2989617ae553317b80faa556d752 (patch)
tree9b32d12123801179ebe900980556486ad4803482 /third_party/bazel/rules_haskell/tests/cc_haskell_import
parenta20daf87265a62b494d67f86d4a5199f14394973 (diff)
chore: Remove remaining Bazel-related files r/31
Diffstat (limited to 'third_party/bazel/rules_haskell/tests/cc_haskell_import')
-rw-r--r--third_party/bazel/rules_haskell/tests/cc_haskell_import/BUILD.bazel70
-rw-r--r--third_party/bazel/rules_haskell/tests/cc_haskell_import/LibA.hs8
-rw-r--r--third_party/bazel/rules_haskell/tests/cc_haskell_import/LibB.hs9
-rw-r--r--third_party/bazel/rules_haskell/tests/cc_haskell_import/cbits.c5
-rw-r--r--third_party/bazel/rules_haskell/tests/cc_haskell_import/main.c11
-rw-r--r--third_party/bazel/rules_haskell/tests/cc_haskell_import/python_add_one.py18
6 files changed, 0 insertions, 121 deletions
diff --git a/third_party/bazel/rules_haskell/tests/cc_haskell_import/BUILD.bazel b/third_party/bazel/rules_haskell/tests/cc_haskell_import/BUILD.bazel
deleted file mode 100644
index c896314500..0000000000
--- a/third_party/bazel/rules_haskell/tests/cc_haskell_import/BUILD.bazel
+++ /dev/null
@@ -1,70 +0,0 @@
-load(
-    "@io_tweag_rules_haskell//haskell:haskell.bzl",
-    "haskell_library",
-)
-
-package(default_testonly = 1)
-
-haskell_library(
-    name = "hs-lib-a",
-    srcs = ["LibA.hs"],
-    deps = [
-        "//tests/data:ourclibrary",
-        "//tests/hackage:base",
-    ],
-)
-
-haskell_library(
-    name = "hs-lib-b",
-    srcs = ["LibB.hs"],
-    deps = [
-        ":hs-lib-a",
-        "//tests/hackage:base",
-    ],
-)
-
-cc_binary(
-    name = "cc-bin",
-    srcs = [
-        "main.c",
-    ],
-    # TODO support linking with static haskell libraries.
-    linkstatic = False,
-    tags = ["requires_threaded_rts"],
-    visibility = ["//tests:__subpackages__"],
-    deps = [
-        ":hs-lib-b",
-        "@ghc//:threaded-rts",
-    ],
-)
-
-# We go one step further and use the Haskell library from above
-# to build a static .so which is then loaded with a Python script
-# and calls the Haskell function constructed from GHC C FFI.
-
-# shared library which python will dlopen
-cc_binary(
-    name = "hs-lib-b-wrapped.so",
-    linkshared = 1,
-    linkstatic = 0,
-    tags = ["requires_threaded_rts"],
-    visibility = ["//tests:__subpackages__"],
-    deps = [
-        ":hs-lib-b",
-        "@ghc//:threaded-rts",
-    ],
-)
-
-# just dlopens hb-lib-b-wrapped.so and prints it
-py_binary(
-    name = "python_add_one",
-    srcs = ["python_add_one.py"],
-    data = [
-        ":hs-lib-b-wrapped.so",
-    ],
-    default_python_version = "PY3",
-    srcs_version = "PY3ONLY",
-    tags = ["requires_threaded_rts"],
-    visibility = ["//tests:__subpackages__"],
-    deps = ["@bazel_tools//tools/python/runfiles"],
-)
diff --git a/third_party/bazel/rules_haskell/tests/cc_haskell_import/LibA.hs b/third_party/bazel/rules_haskell/tests/cc_haskell_import/LibA.hs
deleted file mode 100644
index db8e442e5a..0000000000
--- a/third_party/bazel/rules_haskell/tests/cc_haskell_import/LibA.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module LibA (add_one) where
-
-import Data.Int (Int32)
-
-foreign import ccall "c_add_one" c_add_one' :: Int32 -> Int32
-
-add_one :: Int32 -> Int32
-add_one x = c_add_one' x
diff --git a/third_party/bazel/rules_haskell/tests/cc_haskell_import/LibB.hs b/third_party/bazel/rules_haskell/tests/cc_haskell_import/LibB.hs
deleted file mode 100644
index 5904463b51..0000000000
--- a/third_party/bazel/rules_haskell/tests/cc_haskell_import/LibB.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-module LibB (add_one_hs) where
-
-import LibA (add_one)
-import Data.Int (Int32)
-
-foreign export ccall add_one_hs :: Int32 -> IO Int32
-
-add_one_hs :: Int32 -> IO Int32
-add_one_hs x = pure $! add_one x + 0
diff --git a/third_party/bazel/rules_haskell/tests/cc_haskell_import/cbits.c b/third_party/bazel/rules_haskell/tests/cc_haskell_import/cbits.c
deleted file mode 100644
index 587d26ba28..0000000000
--- a/third_party/bazel/rules_haskell/tests/cc_haskell_import/cbits.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <stdint.h>
-
-int32_t c_add_one(int32_t x) {
-  return 1 + x;
-}
diff --git a/third_party/bazel/rules_haskell/tests/cc_haskell_import/main.c b/third_party/bazel/rules_haskell/tests/cc_haskell_import/main.c
deleted file mode 100644
index 661174e5df..0000000000
--- a/third_party/bazel/rules_haskell/tests/cc_haskell_import/main.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <stdio.h>
-#include "HsFFI.h"
-
-extern HsInt32 add_one_hs(HsInt32 a0);
-
-int main(int argc, char *argv[]) {
-  hs_init(&argc, &argv);
-  printf("Adding one to 5 through Haskell is %d\n", add_one_hs(5));
-  hs_exit();
-  return 0;
-}
diff --git a/third_party/bazel/rules_haskell/tests/cc_haskell_import/python_add_one.py b/third_party/bazel/rules_haskell/tests/cc_haskell_import/python_add_one.py
deleted file mode 100644
index b400102d1c..0000000000
--- a/third_party/bazel/rules_haskell/tests/cc_haskell_import/python_add_one.py
+++ /dev/null
@@ -1,18 +0,0 @@
-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")