Skip to content

Commit 3537682

Browse files
committed
fix: Fix support for Haskell IDEs, including vscode.
Also auto-generate haskell targets for the HIE BIOS.
1 parent 10eb91b commit 3537682

37 files changed

+187
-101
lines changed

.bazelrc

+6-6
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,12 @@ build:gnulike --per_file_copt='external/com_google_absl[:/]@-UNO_FRAME_POINTER,-
322322
build:linux-arm64-musl --per_file_copt='external/com_google_absl/absl/base/internal/low_level_alloc.cc@-Doff64_t=long'
323323

324324
# Compile toxcore as C++.
325-
build:clang --per_file_copt='//c-toxcore/@-xc++,-std=c++17'
326-
build:clang --per_file_copt='//c-toxcore/@-Wno-alloca'
327-
build:clang --per_file_copt='//c-toxcore/@-Wno-c99-extensions'
328-
build:clang --per_file_copt='//c-toxcore/@-Wno-old-style-cast'
329-
build:clang --per_file_copt='//c-toxcore/@-Wno-unreachable-code-return'
330-
build:clang --per_file_copt='//c-toxcore/@-Wno-unused-macros'
325+
build:c-as-cpp --per_file_copt='//c-toxcore/@-xc++,-std=c++17'
326+
build:c-as-cpp --per_file_copt='//c-toxcore/@-Wno-alloca'
327+
build:c-as-cpp --per_file_copt='//c-toxcore/@-Wno-c99-extensions'
328+
build:c-as-cpp --per_file_copt='//c-toxcore/@-Wno-old-style-cast'
329+
build:c-as-cpp --per_file_copt='//c-toxcore/@-Wno-unreachable-code-return'
330+
build:c-as-cpp --per_file_copt='//c-toxcore/@-Wno-unused-macros'
331331

332332
# Cython code isn't very clean.
333333
build:clang --per_file_copt='//py_toxcore_c[:/]@-Wno-cast-function-type-strict'

.bazelversion

-1
This file was deleted.

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
[submodule "hs-msgpack-binary"]
3535
path = hs-msgpack-binary
3636
url = https://github.com/TokTok/hs-msgpack-binary
37-
[submodule "hs-msgpack-persist"]
38-
path = hs-msgpack-persist
39-
url = https://github.com/TokTok/hs-msgpack-persist
4037
[submodule "hs-msgpack-rpc-conduit"]
4138
path = hs-msgpack-rpc-conduit
4239
url = https://github.com/TokTok/hs-msgpack-rpc-conduit

.hie-bios

+18-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@
22
import os
33
import subprocess
44

5-
subprocess.run(
6-
["bazel", "build", "//tools:hie-bios", "--output_groups=hie_bios"],
7-
check=True)
5+
subprocess.run(["tools/haskell/gen_haskell_targets"], check=True)
6+
result = subprocess.run(
7+
["bazel", "run", "//tools:hie-bios@bios", "--output_groups=hie_bios"],
8+
check=True,
9+
capture_output=True,
10+
)
811
with open(os.environ["HIE_BIOS_OUTPUT"], "w") as fh:
9-
fh.write("-hide-all-packages\n")
10-
with open("bazel-bin/tools/hie-bios@hie-bios", "r") as bios:
11-
for line in bios.readlines():
12+
prev = None
13+
for line in result.stdout.decode("utf-8").splitlines(keepends=True):
14+
line = line.replace(
15+
"/home/builder/.cache/bazel/_bazel_builder/a08c2e4811c846650b733c6fc815a920/execroot/toktok/bazel-out/k8-fastbuild/bin/",
16+
"/src/workspace/bazel-bin/",
17+
)
18+
line = line.replace(
19+
"/home/builder/.cache/bazel/_bazel_builder/a08c2e4811c846650b733c6fc815a920/execroot/toktok/",
20+
"/src/workspace/",
21+
)
22+
if line != prev and not line.startswith("-l"):
1223
fh.write(line)
24+
prev = line
1325
# Make warnings non-fatal
1426
fh.write("-Wwarn\n")

WORKSPACE

+21-20
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ install_deps()
5353
github_archive(
5454
name = "io_bazel_rules_go",
5555
repo = "bazelbuild/rules_go",
56-
sha256 = "2c6388e97cb4fb30546d65e983c45bb422bfe32c6e946af329cd1c52f1eaf836",
57-
version = "v0.39.1",
56+
sha256 = "82f7ae1c9ffcfde827f4164123a6775c5c28d9993d291e4fd40bf40698926569",
57+
version = "v0.41.0",
5858
)
5959

6060
github_archive(
6161
name = "bazel_gazelle",
6262
repo = "bazelbuild/bazel-gazelle",
63-
sha256 = "1e246edb247c76ddf698ddc58fec7d3a9f908131b356133e6dccf91194d47aee",
64-
version = "v0.33.0",
63+
sha256 = "4aa8e6c9cb98a9814c82289e4a87c661aa16c8b31bffa448163da8fd20a5bb93",
64+
version = "v0.35.0",
6565
)
6666

6767
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")
@@ -74,8 +74,9 @@ go_rules_dependencies()
7474
github_archive(
7575
name = "rules_haskell",
7676
repo = "tweag/rules_haskell",
77-
sha256 = "c9c2dc3d1a97e8b16d85c73d45d7f8c3a8d3bb7b35783c4305e61e0aed8a3ea5",
78-
version = "2d0942ec1d9ad239c44c6cfc635fa7e51cd0f0f3",
77+
sha256 = "713d03014f08f20ad9d68fe458703f3f7bdbc8c94c21be22748af5728f5c7c4b",
78+
# TODO(https://github.com/tweag/rules_haskell/issues/2097): Upgrade once this bug is fixed.
79+
version = "d14584e7f227fee55d857694d6ba7dc7e74d8f3c",
7980
)
8081

8182
load(
@@ -103,8 +104,8 @@ load(
103104

104105
nixpkgs_git_repository(
105106
name = "nixpkgs",
106-
revision = "23.05",
107-
sha256 = "f2b96094f6dfbb53b082fe8709da94137475fcfead16c960f2395c98fc014b68",
107+
revision = "23.11",
108+
sha256 = "bc9a0a74e8d7fb0e11434dd3abaa0cb0572ccd3a65b5a192eea41832b286e8a0",
108109
)
109110

110111
FULLY_STATIC = False
@@ -114,8 +115,8 @@ NIXPKGS = {
114115
"prefix": "pkgsStatic.",
115116
"suffix": ".pkgsStatic",
116117
} if FULLY_STATIC else {
117-
#"cc": "llvmPackages_16.libcxxClang",
118-
"cc": "llvmPackages_16.clang",
118+
#"cc": "libcxxClang",
119+
"cc": "clang",
119120
"prefix": "",
120121
"suffix": "",
121122
}
@@ -143,7 +144,7 @@ nixpkgs_package(
143144

144145
nixpkgs_package(
145146
name = "libllvm",
146-
attribute_path = "llvmPackages_16.libllvm",
147+
attribute_path = "libllvm",
147148
build_file = "//third_party:BUILD.libllvm",
148149
repository = "@nixpkgs",
149150
)
@@ -220,16 +221,16 @@ http_archive(
220221
patch_cmds = [
221222
"chmod 755 java_tools/ijar/ijar",
222223
"{patchelf} --set-interpreter {ld_linux} --add-rpath {gcc_lib} java_tools/ijar/ijar".format(
223-
gcc_lib = "/nix/store/yazs3bdl481s2kyffgsa825ihy1adn8f-gcc-12.2.0-lib/lib",
224-
ld_linux = "/nix/store/yaz7pyf0ah88g2v505l38n0f3wg2vzdj-glibc-2.37-8/lib64/ld-linux-x86-64.so.2",
225-
patchelf = "/nix/store/ywwjpdyhar4f3vcqf4qk77vrbr3vj5wl-patchelf-0.15.0/bin/patchelf",
224+
gcc_lib = "/nix/store/myw67gkgayf3s2mniij7zwd79lxy8v0k-gcc-12.3.0-lib/lib",
225+
ld_linux = "/nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/lib64/ld-linux-x86-64.so.2",
226+
patchelf = "/nix/store/85jldj870vzcl72yz03labc93bwvqayx-patchelf-0.15.0/bin/patchelf",
226227
),
227228
"chmod 555 java_tools/ijar/ijar",
228229
"chmod 755 java_tools/src/tools/singlejar/singlejar_local",
229230
"{patchelf} --set-interpreter {ld_linux} --add-rpath {gcc_lib} java_tools/src/tools/singlejar/singlejar_local".format(
230-
gcc_lib = "/nix/store/yazs3bdl481s2kyffgsa825ihy1adn8f-gcc-12.2.0-lib/lib",
231-
ld_linux = "/nix/store/yaz7pyf0ah88g2v505l38n0f3wg2vzdj-glibc-2.37-8/lib64/ld-linux-x86-64.so.2",
232-
patchelf = "/nix/store/ywwjpdyhar4f3vcqf4qk77vrbr3vj5wl-patchelf-0.15.0/bin/patchelf",
231+
gcc_lib = "/nix/store/myw67gkgayf3s2mniij7zwd79lxy8v0k-gcc-12.3.0-lib/lib",
232+
ld_linux = "/nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/lib64/ld-linux-x86-64.so.2",
233+
patchelf = "/nix/store/85jldj870vzcl72yz03labc93bwvqayx-patchelf-0.15.0/bin/patchelf",
233234
),
234235
"chmod 555 java_tools/src/tools/singlejar/singlejar_local",
235236
],
@@ -282,7 +283,8 @@ load(
282283
# https://api.haskell.build/haskell/nixpkgs.html#haskell_register_ghc_nixpkgs
283284
haskell_register_ghc_nixpkgs(
284285
attribute_path = "ghc",
285-
compiler_flags = [
286+
#fully_static_link = True,
287+
ghcopts = [
286288
"-Wall",
287289
"-Werror",
288290
"-XHaskell2010",
@@ -292,11 +294,10 @@ haskell_register_ghc_nixpkgs(
292294
"-optc=-Wno-unused-command-line-argument",
293295
"-optl=-Wl,--no-fatal-warnings",
294296
],
295-
#fully_static_link = True,
296297
nix_file = "//:ghc.nix",
297298
repositories = {"nixpkgs": "@nixpkgs"},
298299
#static_runtime = True,
299-
version = "9.2.7",
300+
version = "9.4.8",
300301
)
301302

302303
[nixpkgs_package(

c-toxcore-hs

ghc.nix

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ with (import <nixpkgs> { });
5757
mtl
5858
network
5959
parallel
60-
persist
6160
pretty
6261
process
6362
QuickCheck

hie.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cradle:
22
bios:
33
program: ".hie-bios"
4-
with-ghc: "bazel-workspace/external/rules_haskell_ghc_linux_amd64/bin/ghc"
4+
with-ghc: "bazel-workspace/external/rules_haskell_ghc_nixpkgs/bin/ghc"

hs-apigen

hs-msgpack-persist

-1
This file was deleted.

hs-msgpack-testsuite

hs-toxcore-c

stack.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ packages:
55
- hs-github-tools/
66
- hs-msgpack-arbitrary/
77
- hs-msgpack-binary/
8-
- hs-msgpack-persist/
98
- hs-msgpack-rpc-conduit/
109
- hs-msgpack-testsuite/
1110
- hs-msgpack-types/
@@ -16,7 +15,6 @@ packages:
1615
resolver: lts-21.9
1716
extra-deps:
1817
- monad-validate-1.3.0.0
19-
- persist-0.1.1.5
2018
- suspend-0.2.0.0
2119
- timers-0.2.0.4
2220
allow-newer: true

third_party/haskell/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ licenses(["notice"])
6262
"mtl",
6363
"network",
6464
"parallel",
65-
"persist",
6665
"pretty",
6766
"process",
6867
"QuickCheck",

third_party/haskell/hspec-discover/build_defs.bzl

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def hspec_library(name, src_strip_prefix, **kwargs):
3838
**kwargs
3939
)
4040

41-
def hspec_test(name, **kwargs):
41+
def hspec_test(name, visibility=["//tools/haskell:__pkg__"], **kwargs):
4242
"""HSpec test."""
4343
srcs = native.glob(["test/*/**/*.*hs"])
4444

@@ -58,5 +58,6 @@ def hspec_test(name, **kwargs):
5858
srcs = srcs + [name + "_hspec_driver"],
5959
main_file = "test/Spec.hs",
6060
src_strip_prefix = "test",
61+
visibility = visibility,
6162
**kwargs
6263
)

third_party/libzmq/linux/platform.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#define ZMQ_HAVE_PTHREAD_SET_AFFINITY
5757
#define HAVE_ACCEPT4
5858
#define HAVE_STRNLEN
59-
/* #undef ZMQ_HAVE_STRLCPY */
59+
#define ZMQ_HAVE_STRLCPY
6060
/* #undef ZMQ_HAVE_LIBBSD */
6161

6262
#define ZMQ_HAVE_IPC

third_party/qt/build_defs.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def qt_test(name, src, deps, copts = [], mocopts = [], size = None):
285285
srcs = [src],
286286
copts = copts + ["-I$(GENDIR)/%s/%s" % (native.package_name(), src[:src.rindex("/")])],
287287
# TODO(iphydf): Infer this, rather than hard-coding the Qt version number.
288-
env = {"QT_PLUGIN_PATH": "external/qt5.qtbase.bin/lib/qt-5.15.9/plugins"},
288+
env = {"QT_PLUGIN_PATH": "external/qt5.qtbase.bin/lib/qt-5.15.11/plugins"},
289289
data = ["@qt//:qt_platform"],
290290
deps = deps + [
291291
":%s_moc" % name,

tools/BUILD.bazel

-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
load("@rules_haskell//haskell:defs.bzl", "haskell_repl")
21
load("//tools/project:build_defs.bzl", "workspace")
32

43
workspace(projects = [
@@ -14,7 +13,6 @@ workspace(projects = [
1413
"hs-github-tools",
1514
"hs-msgpack-arbitrary",
1615
"hs-msgpack-binary",
17-
"hs-msgpack-persist",
1816
"hs-msgpack-rpc-conduit",
1917
"hs-msgpack-testsuite",
2018
"hs-msgpack-types",
@@ -33,25 +31,6 @@ workspace(projects = [
3331
"website",
3432
])
3533

36-
haskell_repl(
37-
name = "hie-bios",
38-
collect_data = False,
39-
deps = [
40-
"//hs-cimple",
41-
"//hs-github-tools",
42-
"//hs-msgpack-arbitrary",
43-
"//hs-msgpack-binary",
44-
"//hs-msgpack-persist",
45-
"//hs-msgpack-rpc-conduit",
46-
"//hs-msgpack-testsuite",
47-
"//hs-msgpack-types",
48-
"//hs-schema",
49-
"//hs-tokstyle",
50-
"//hs-toxcore",
51-
"//hs-toxcore-c",
52-
],
53-
)
54-
5534
exports_files(srcs = [
5635
"LICENSE.gpl3",
5736
"LICENSE.hs-msgpack",

tools/built/src/Dockerfile.dev

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ FROM toxchat/toktok-stack:latest-fastbuild
1313
ENV USER=builder
1414

1515
RUN sudo nix-daemon --daemon & sleep 1 \
16-
&& nix-channel --add https://github.com/NixOS/nixpkgs/archive/refs/tags/23.05.tar.gz nixpkgs \
17-
&& nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager \
16+
&& nix-channel --add https://github.com/NixOS/nixpkgs/archive/refs/tags/23.11.tar.gz nixpkgs \
17+
&& nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.11.tar.gz home-manager \
1818
&& nix-channel --update \
1919
&& nix-shell '<home-manager>' -A install
2020

tools/built/src/Dockerfile.haskell

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ COPY --chown=builder:users hs-cimple/ /work/hs-cimple/
1313
COPY --chown=builder:users hs-github-tools/ /work/hs-github-tools/
1414
COPY --chown=builder:users hs-msgpack-arbitrary/ /work/hs-msgpack-arbitrary/
1515
COPY --chown=builder:users hs-msgpack-binary/ /work/hs-msgpack-binary/
16-
COPY --chown=builder:users hs-msgpack-persist/ /work/hs-msgpack-persist/
1716
COPY --chown=builder:users hs-msgpack-rpc-conduit/ /work/hs-msgpack-rpc-conduit/
1817
COPY --chown=builder:users hs-msgpack-testsuite/ /work/hs-msgpack-testsuite/
1918
COPY --chown=builder:users hs-msgpack-types/ /work/hs-msgpack-types/

tools/built/src/Dockerfile.third_party

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ RUN ["mkdir", "/tmp/cirrus-ci-build"]
88
# minimum number of files to avoid rebuilding this when making changes to the
99
# toktok-stack tools.
1010
COPY --chown=builder:users tools/bazelrc.boot /src/workspace/.bazelrc
11-
COPY --chown=builder:users BUILD.bazel WORKSPACE .bazelignore .bazelversion ghc.nix /src/workspace/
11+
COPY --chown=builder:users BUILD.bazel WORKSPACE .bazelignore ghc.nix /src/workspace/
1212
COPY --chown=builder:users third_party /src/workspace/third_party
1313
COPY --chown=builder:users tools/config /src/workspace/tools/config
1414
COPY --chown=builder:users tools/workspace /src/workspace/tools/workspace
1515
WORKDIR /src/workspace
1616
RUN sudo nix-daemon --daemon & bazel aquery --output=proto --show_timestamps //... > /dev/null
1717

18+
# TODO(https://github.com/tweag/rules_nixpkgs/issues/439): Remove.
19+
RUN sudo sed -Eie "s!\b(mktemp|rm)\b!$(echo -n /nix/store/*-coreutils-9.3/bin/)\1!" /nix/store/*-clang-wrapper-*/bin/cc
20+
1821
# vim:ft=dockerfile

0 commit comments

Comments
 (0)