This repository has been archived by the owner on Nov 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
/
WORKSPACE
220 lines (186 loc) · 4.98 KB
/
WORKSPACE
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
workspace(name = "bazel_asterius")
# This commit must be the same as the one from bazel/stack.yaml
HASKELL_BINARYEN_COMMIT = "7d0ea214e47946fc830d332a6e3e1b73f60f61fd"
######################
# BAZEL DEPENDENCIES #
######################
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load(
"@bazel_tools//tools/build_defs/repo:git.bzl",
"git_repository",
"new_git_repository",
)
git_repository(
name = "rules_haskell",
commit = "26a966abf7328b08c449c682f07d0e00e6f14466",
remote = "https://github.com/tweag/rules_haskell.git",
shallow_since = "1641820378 +0000",
)
load("@rules_haskell//haskell:repositories.bzl", "rules_haskell_dependencies")
rules_haskell_dependencies()
load(
"@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl",
"nixpkgs_cc_configure",
"nixpkgs_local_repository",
"nixpkgs_package",
"nixpkgs_python_configure",
"nixpkgs_sh_posix_configure",
)
# Setup the posix toolchain
http_archive(
name = "rules_sh",
sha256 = "83a065ba6469135a35786eb741e17d50f360ca92ab2897857475ab17c0d29931",
strip_prefix = "rules_sh-0.2.0",
urls = ["https://github.com/tweag/rules_sh/archive/v0.2.0.tar.gz"],
)
load("@rules_sh//sh:repositories.bzl", "rules_sh_dependencies")
rules_sh_dependencies()
#####################
# Setup toolchains #
#####################
nixpkgs_local_repository(
name = "nixpkgs",
nix_file = "//bazel/nix:bazel_deps.nix",
nix_file_deps = [
"//nix:sources.nix",
"//nix:binaryen.nix",
"//nix:binaryen.patch",
"//nix:wasi-sdk.nix",
"//nix:sources.json",
"//ghc-toolkit:cbits/ghc_constants.c",
"//nix:ghcconstants.nix",
],
)
nixpkgs_sh_posix_configure(repository = "@nixpkgs")
nixpkgs_cc_configure(repository = "@nixpkgs")
nixpkgs_python_configure(repository = "@nixpkgs")
load("@rules_haskell//haskell:nixpkgs.bzl", "haskell_register_ghc_nixpkgs")
haskell_register_ghc_nixpkgs(
attribute_path = "ghc",
repository = "@nixpkgs",
version = "8.10.7",
)
##############################################
# External dependencies specific to asterius #
##############################################
# We recover the binaryen C library through nix
nixpkgs_package(
name = "binaryen_dev",
attribute_path = "binaryen",
build_file_content = """
load("@rules_cc//cc:defs.bzl", "cc_library")
filegroup(
name = "include",
srcs = glob(["include/*.h"]),
visibility = ["//visibility:public"],
)
filegroup(
name = "binaryen",
srcs = glob(["lib/*.so", "lib/*.a"]),
visibility = ["//visibility:public"],
)
cc_library(
name = "binaryen_cc",
srcs = [":binaryen"],
deps = [":binaryen_import"],
hdrs = [":include"],
includes = ["include"],
visibility = ["//visibility:public"],
)
cc_import(
name = "binaryen_import",
hdrs = [":include"],
shared_library = "lib/libbinaryen.so",
visibility = ["//visibility:public"],
)
""",
repository = "@nixpkgs",
)
load(
"@rules_haskell//haskell:cabal.bzl",
"stack_snapshot",
)
stack_snapshot(
name = "stackage",
components = {
"ahc-pkg": ["exe"],
},
local_snapshot = "//:bazel/stack.yaml",
packages = [
"inline-js-core",
"base",
"binary",
"bytestring",
"containers",
"directory",
"filepath",
"Cabal",
"ghc-prim",
"process",
"stm",
"template-haskell",
"text",
"haskeline",
"exceptions",
# dependencies from ghc-asterius
# "ahc-bin",
"ahc-pkg",
"ghc-asterius",
"ghc-boot-asterius",
"ghc-boot-th-asterius",
"ghc-heap-asterius",
"ghci-asterius",
"template-haskell-asterius",
],
# To update the stackage dependencies, run `bazel run @stackage-unpinned//:pin` and
stack_snapshot_json = "//:bazel/stackage_snapshot.json",
)
# We not use the custom stack snapshot for this in order to work around the following bug.
# https://github.com/tweag/rules_haskell/issues/1676
new_git_repository(
name = "haskell_binaryen",
build_file_content = """
load(
"@rules_haskell//haskell:cabal.bzl",
"haskell_cabal_library",
)
load(
"@rules_haskell//haskell:defs.bzl",
"haskell_library",
"haskell_toolchain_library",
)
haskell_toolchain_library(name = "base")
cc_library(
name = "libbinaryen",
srcs = ["cbits/wrappers.c"],
deps = [
"@binaryen_dev//:binaryen_cc",
],
visibility = ["//visibility:public"]
)
haskell_library(
name = "binaryen",
srcs = glob(["src/**"]),
deps = [
"libbinaryen",
"base",
],
visibility = ["//visibility:public"],
)
""",
commit = HASKELL_BINARYEN_COMMIT,
remote = "https://github.com/tweag/haskell-binaryen",
shallow_since = "1610373671 +0100",
)
######################
# Tools from nixpkgs #
######################
[
nixpkgs_package(
name = pack,
repository = "@nixpkgs",
)
for pack in [
"hpack",
]
]