Skip to content

Commit d5c03d9

Browse files
authored
Merge pull request #927 from tweag/th-with-cbits
TemplateHaskell with cbits dependencies
2 parents 5b3a13e + a9dd9b4 commit d5c03d9

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

haskell/private/actions/compile.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths")
1010
load(
1111
":private/path_utils.bzl",
1212
"declare_compiled",
13+
"link_libraries",
1314
"module_name",
1415
"target_unique_name",
1516
)
@@ -320,6 +321,7 @@ def _compilation_defaults(hs, cc, java, dep_info, plugin_dep_info, cc_info, srcs
320321

321322
# Transitive library dependencies for runtime.
322323
(ghci_extra_libs, ghc_env) = get_ghci_extra_libs(hs, cc_info)
324+
link_libraries(ghci_extra_libs, args)
323325

324326
return struct(
325327
args = args,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
load(
2+
"@rules_haskell//haskell:defs.bzl",
3+
"haskell_test",
4+
)
5+
6+
package(default_testonly = 1)
7+
8+
haskell_test(
9+
name = "template-haskell-with-cbits",
10+
srcs = [
11+
"Main.hs",
12+
"TH.hs",
13+
],
14+
deps = [
15+
"//tests/data:ourclibrary",
16+
"//tests/hackage:base",
17+
"//tests/hackage:template-haskell",
18+
],
19+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{-# LANGUAGE TemplateHaskell #-}
2+
3+
module Main where
4+
5+
import Control.Monad (unless)
6+
import System.Exit (exitFailure)
7+
import System.IO (hPutStrLn, stderr)
8+
import TH (value)
9+
10+
main :: IO ()
11+
main =
12+
unless ($(value) == 42) $ do
13+
hPutStrLn stderr "Expected 42"
14+
exitFailure
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{-# LANGUAGE TemplateHaskell #-}
2+
3+
module TH where
4+
5+
import Language.Haskell.TH
6+
7+
foreign import ccall "c_add_one" c_add_one' :: Int -> Int
8+
9+
value :: Q Exp
10+
value = [| c_add_one' 41 |]

0 commit comments

Comments
 (0)