diff options
author | Vincent Ambo <tazjin@google.com> | 2019-07-04T10·18+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2019-07-04T10·18+0100 |
commit | f723b8b878a3c4a4687b9e337a875500bebb39b1 (patch) | |
tree | e85204cf042c355e90cff61c111e7d8cd15df311 /third_party/bazel/rules_haskell/tests/indirect-link | |
parent | 2eb1dc26e42ffbdc168f05ef744bd4b4f3e4c36f (diff) |
feat(third_party/bazel): Check in rules_haskell from Tweag r/17
Diffstat (limited to 'third_party/bazel/rules_haskell/tests/indirect-link')
5 files changed, 91 insertions, 0 deletions
diff --git a/third_party/bazel/rules_haskell/tests/indirect-link/BUILD.bazel b/third_party/bazel/rules_haskell/tests/indirect-link/BUILD.bazel new file mode 100644 index 000000000000..60403a4ef277 --- /dev/null +++ b/third_party/bazel/rules_haskell/tests/indirect-link/BUILD.bazel @@ -0,0 +1,52 @@ +load("@io_tweag_rules_haskell//haskell:haskell.bzl", "haskell_library", "haskell_test", "haskell_toolchain_library") + +cc_library( + name = "cbits-indirect", + srcs = ["cbits/impl.c"], +) + +cc_library( + name = "cbits", + srcs = ["cbits/intf.c"], + deps = ["cbits-indirect"], +) + +haskell_library( + name = "mypkg", + srcs = ["src/MyModule.hs"], + src_strip_prefix = "src", + deps = [ + ":cbits", + "//tests/hackage:base", + ], +) + +haskell_test( + name = "indirect-link-static", + srcs = ["test/Main.hs"], + linkstatic = True, + src_strip_prefix = "test", + deps = [ + ":mypkg", + "//tests/hackage:base", + ], +) + +haskell_test( + name = "indirect-link-dynamic", + srcs = ["test/Main.hs"], + linkstatic = False, + src_strip_prefix = "test", + deps = [ + ":mypkg", + "//tests/hackage:base", + ], +) + +test_suite( + name = "indirect-link", + tests = [ + ":indirect-link-dynamic", + ":indirect-link-static", + ], +) diff --git a/third_party/bazel/rules_haskell/tests/indirect-link/cbits/impl.c b/third_party/bazel/rules_haskell/tests/indirect-link/cbits/impl.c new file mode 100644 index 000000000000..666ce43962a3 --- /dev/null +++ b/third_party/bazel/rules_haskell/tests/indirect-link/cbits/impl.c @@ -0,0 +1,9 @@ +static int thing; + +int real_get_thing(void) { + return thing; +} + +void real_set_thing(int value) { + thing = value; +} diff --git a/third_party/bazel/rules_haskell/tests/indirect-link/cbits/intf.c b/third_party/bazel/rules_haskell/tests/indirect-link/cbits/intf.c new file mode 100644 index 000000000000..f7a8f5e9f2e8 --- /dev/null +++ b/third_party/bazel/rules_haskell/tests/indirect-link/cbits/intf.c @@ -0,0 +1,10 @@ +extern int real_get_thing(void); +extern void real_set_thing(int value); + +int get_thing(void) { + return real_get_thing(); +} + +void set_thing(int value) { + real_set_thing(value); +} diff --git a/third_party/bazel/rules_haskell/tests/indirect-link/src/MyModule.hs b/third_party/bazel/rules_haskell/tests/indirect-link/src/MyModule.hs new file mode 100644 index 000000000000..4b75cee13989 --- /dev/null +++ b/third_party/bazel/rules_haskell/tests/indirect-link/src/MyModule.hs @@ -0,0 +1,11 @@ +module MyModule where + +foreign import ccall get_thing :: IO Int + +getThing :: IO Int +getThing = get_thing + +foreign import ccall set_thing :: Int -> IO () + +setThing :: Int -> IO () +setThing = set_thing diff --git a/third_party/bazel/rules_haskell/tests/indirect-link/test/Main.hs b/third_party/bazel/rules_haskell/tests/indirect-link/test/Main.hs new file mode 100644 index 000000000000..0b3d188d736a --- /dev/null +++ b/third_party/bazel/rules_haskell/tests/indirect-link/test/Main.hs @@ -0,0 +1,9 @@ +module Main (main) where + +import qualified MyModule + +main :: IO () +main = do + print =<< MyModule.getThing + MyModule.setThing 123 + print =<< MyModule.getThing |