-
Notifications
You must be signed in to change notification settings - Fork 15
/
BUILD.bazel
73 lines (71 loc) · 2.05 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
load(
"@rules_haskell//haskell:defs.bzl",
"haskell_library",
)
# Note cat-tokens
#
# This is a script to concatenate tokens after CPP preprocessing.
#
# On OSX we used to rely on cpphs to concatenate tokens in
# definitions like
#
# define GET_FIELD(name, hs_rettype, c_rettype) \
# get/**/name/**/Field :: Coercible o (J a) => o -> JFieldID -> IO hs_rettype;
#
# The C preprocessor in OSX would otherwise replace the
# comments with whitespaces.
#
# Using cpphs, however, required a couple of hacks to workaround
# https://github.com/haskell/cabal/issues/4278
# https://gitlab.haskell.org/ghc/ghc/-/issues/17185
#
# And moreover, when using rules_haskell, ghc passes response files to cpphs,
# which are unsupported.
# https://github.com/tweag/rules_haskell/pull/836
#
# Therefore, we currently resolve concatenation with a custom
# preprocessor to avoid the pile of hacks. The concatenator operator is ####.
#
# define GET_FIELD(name, hs_rettype, c_rettype) \
# get####name####Field :: Coercible o (J a) => o -> JFieldID -> IO hs_rettype;
#
genrule(
name = "cat-tokens-sh",
srcs = [],
executable = 1,
outs = ["cat-tokens.sh"],
tools = ["@sed//:bin"],
cmd = """
cat > $@ <<END
#!/bin/sh
( echo "{-# LINE 1 \\"\\$$1\\" #-}" ; $(location @sed//:bin) 's/####//g' \\$$2) > \\$$3
exit \\$$?
END
""",
)
haskell_library(
name = "jni",
srcs = glob([
'src/common/**/*.hs', 'src/common/**/*.hsc',
'src/linear-types/**/*.hs',
]),
extra_srcs = ["//jni:cat-tokens-sh"],
compiler_flags = ["-F", "-pgmF$(location cat-tokens-sh)"],
deps = [
"@openjdk//:lib",
"@stackage//:async",
"@stackage//:base",
"@stackage//:bytestring",
"@stackage//:choice",
"@stackage//:containers",
"@stackage//:constraints",
"@stackage//:deepseq",
"@stackage//:inline-c",
"@stackage//:linear-base",
"@stackage//:singletons-base",
"@stackage//:stm",
"@stackage//:text",
],
tools = ["@sed//:bin"],
visibility = ["//visibility:public"],
)