Skip to content

Commit acb6442

Browse files
authored
Merge branch 'master' into circleci-run-linters-first
2 parents ca5c2f7 + 849c0ae commit acb6442

26 files changed

+243
-125
lines changed

.circleci/config.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,13 @@ jobs:
4646
name: Bazel linter
4747
shell: /bin/bash -eilo pipefail
4848
command: |
49-
nix-shell --run 'CC=$(which clang) bazel run //:buildifier'
50-
- run:
51-
name: Build
52-
shell: /bin/bash -eilo pipefail
53-
command: |
54-
nix-shell --run 'CC=$(which clang) bazel build --jobs=2 //...'
55-
- run:
49+
nix-shell --run 'bazel run //:buildifier'
5650
name: Run tests
5751
shell: /bin/bash -eilo pipefail
5852
# bazel does not support recursive bazel call, so we
5953
# cannot use bazel run here because the test runner uses
6054
# bazel
61-
command: nix-shell --run 'CC=$(which clang) bazel build //tests:run-tests && ./bazel-bin/tests/run-tests'
55+
command: nix-shell --arg docTools false --pure --run 'bazel build //tests:run-tests && ./bazel-bin/tests/run-tests'
6256

6357
workflows:
6458
version: 2

.netlify/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ awk '
1919
# Note: awk -i inplace not available
2020
mv WORKSPACE.tmp WORKSPACE
2121

22+
# We don't want to be depending on Nixpkgs for documentation
23+
# generation either.
24+
sed -i 's/vendored_node = "@nixpkgs_nodejs"/vendored_node = None/' WORKSPACE
25+
2226
bazel build //docs:api_html
2327
unzip -d public bazel-bin/docs/api_html-skydoc.zip
2428
cp start public

.netlify/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -eux
44

5-
V=0.16.0
5+
V=0.20.0
66

77
curl -LO https://github.com/bazelbuild/bazel/releases/download/$V/bazel-$V-installer-linux-x86_64.sh
88
chmod +x bazel-$V-installer-linux-x86_64.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The full reference documentation for rules is at https://haskell.build.
4141

4242
## Setup
4343

44-
You'll need [Bazel >= 0.14.0][bazel-getting-started] installed.
44+
You'll need [Bazel >= 0.20.0][bazel-getting-started] installed.
4545

4646
### The easy way
4747

WORKSPACE

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ haskell_nixpkgs_package(
3737

3838
http_archive(
3939
name = "com_google_protobuf",
40-
sha256 = "d625beb4a43304409429a0466bb4fb44c89f7e7d90aeced972b8a61dbe92c80b",
41-
strip_prefix = "protobuf-7b28271a61a3da0a37f6fda399b0c4c86464e5b3",
42-
urls = ["https://github.com/google/protobuf/archive/7b28271a61a3da0a37f6fda399b0c4c86464e5b3.zip"], # 2018-11-16
40+
sha256 = "73fdad358857e120fd0fa19e071a96e15c0f23bb25f85d3f7009abfd4f264a2a",
41+
strip_prefix = "protobuf-3.6.1.3",
42+
urls = ["https://github.com/google/protobuf/archive/v3.6.1.3.tar.gz"],
4343
)
4444

4545
nixpkgs_local_repository(
@@ -130,9 +130,9 @@ import_packages(name = "hackage")
130130

131131
# zlib as a Haskell library
132132

133-
new_http_archive(
133+
http_archive(
134134
name = "haskell_zlib",
135-
build_file = "tests/BUILD.zlib",
135+
build_file = "//tests:BUILD.zlib",
136136
strip_prefix = "zlib-0.6.2",
137137
urls = ["https://hackage.haskell.org/package/zlib-0.6.2/zlib-0.6.2.tar.gz"],
138138
)
@@ -150,46 +150,77 @@ local_repository(
150150

151151
# For Skydoc
152152

153+
nixpkgs_package(
154+
name = "nixpkgs_nodejs",
155+
# XXX Indirection derivation to make all of NodeJS rooted in
156+
# a single directory. We shouldn't need this, but it's
157+
# a workaround for
158+
# https://github.com/bazelbuild/bazel/issues/2927.
159+
nix_file_content = """
160+
with import <nixpkgs> {};
161+
runCommand "nodejs-rules_haskell" { buildInputs = [ nodejs ]; } ''
162+
mkdir -p $out/nixpkgs_nodejs
163+
cd $out/nixpkgs_nodejs
164+
for i in ${nodejs}/*; do ln -s $i; done
165+
''
166+
""",
167+
repository = "@nixpkgs",
168+
)
169+
170+
http_archive(
171+
name = "build_bazel_rules_nodejs",
172+
sha256 = "f79f605a920145216e64991d6eff4e23babc48810a9efd63a31744bb6637b01e",
173+
strip_prefix = "rules_nodejs-b4dad57d2ecc63d74db1f5523593639a635e447d",
174+
# Tip of https://github.com/bazelbuild/rules_nodejs/pull/471.
175+
urls = ["https://github.com/mboes/rules_nodejs/archive/b4dad57d2ecc63d74db1f5523593639a635e447d.tar.gz"],
176+
)
177+
153178
http_archive(
154179
name = "io_bazel_rules_sass",
155-
sha256 = "14536292b14b5d36d1d72ae68ee7384a51e304fa35a3c4e4db0f4590394f36ad",
156-
strip_prefix = "rules_sass-0.0.3",
157-
urls = ["https://github.com/bazelbuild/rules_sass/archive/0.0.3.tar.gz"],
180+
sha256 = "1e135452dc627f52eab39a50f4d5b8d13e8ed66cba2e6da56ac4cbdbd776536c",
181+
strip_prefix = "rules_sass-1.15.2",
182+
urls = ["https://github.com/bazelbuild/rules_sass/archive/1.15.2.tar.gz"],
158183
)
159184

160-
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_repositories")
185+
load("@io_bazel_rules_sass//:package.bzl", "rules_sass_dependencies")
186+
187+
rules_sass_dependencies()
188+
189+
load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories")
161190

162191
sass_repositories()
163192

193+
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")
194+
195+
node_repositories(
196+
vendored_node = "@nixpkgs_nodejs",
197+
)
198+
164199
http_archive(
165200
name = "io_bazel_skydoc",
166-
sha256 = "12a82b494a40c4ef96230bc66aeff654420dd39a537eb3064ff18ce1838f1fb7",
167-
strip_prefix = "skydoc-9bbdf62c03b5c3fed231604f78d3976f47753d79",
168-
urls = ["https://github.com/mrkkrp/skydoc/archive/9bbdf62c03b5c3fed231604f78d3976f47753d79.tar.gz"],
201+
sha256 = "19eb6c162075707df5703c274d3348127625873dbfa5ff83b1ef4b8f5dbaa449",
202+
strip_prefix = "skydoc-0.2.0",
203+
urls = ["https://github.com/bazelbuild/skydoc/archive/0.2.0.tar.gz"],
169204
)
170205

171-
load("@io_bazel_skydoc//skylark:skylark.bzl", "skydoc_repositories")
206+
load("@io_bazel_skydoc//:setup.bzl", "skydoc_repositories")
172207

173208
skydoc_repositories()
174209

175210
# For buildifier
176211

177-
# XXX Need a patched version of rules_go to workaround warnings fixed
178-
# by https://github.com/NixOS/nixpkgs/pull/28029 on NixOS. Revert to
179-
# official release once fix hits Nixpkgs master.
180212
http_archive(
181213
name = "io_bazel_rules_go",
182-
strip_prefix = "rules_go-6a2b1f780b475a75a7baae5b441635c566f0ed8a",
183-
urls = ["https://github.com/mboes/rules_go/archive/6a2b1f780b475a75a7baae5b441635c566f0ed8a.tar.gz"],
214+
sha256 = "8be57ff66da79d9e4bd434c860dce589195b9101b2c187d144014bbca23b5166",
215+
strip_prefix = "rules_go-0.16.3",
216+
urls = ["https://github.com/bazelbuild/rules_go/archive/0.16.3.tar.gz"],
184217
)
185218

186-
bazelbuild_buildtools_rev = "4a7914a1466ff7388c934bfcd43a3852928536f6"
187-
188219
http_archive(
189220
name = "com_github_bazelbuild_buildtools",
190-
sha256 = "45775c7bb7ee7656e9df4ca4278f977c8e4e260aff755734734c19321e14bc84",
191-
strip_prefix = "buildtools-%s" % bazelbuild_buildtools_rev,
192-
url = "https://github.com/bazelbuild/buildtools/archive/%s.zip" % bazelbuild_buildtools_rev,
221+
sha256 = "d42e4c9727958bc5814d3bc44f19db5a24f419436cbba09f1e8913eb4a09da31",
222+
strip_prefix = "buildtools-0.19.2.1",
223+
urls = ["https://github.com/bazelbuild/buildtools/archive/0.19.2.1.tar.gz"],
193224
)
194225

195226
load(

haskell/c2hs.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ c2hs_library = rule(
8888
allow_single_file = True,
8989
default = Label("@io_tweag_rules_haskell//haskell:private/c2hs_wrapper.sh"),
9090
),
91+
"_cc_toolchain": attr.label(
92+
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
93+
),
9194
},
9295
toolchains = [
9396
"@io_tweag_rules_haskell//haskell:toolchain",
94-
"@bazel_tools//tools/cpp:toolchain_type",
9597
],
9698
)

haskell/cc.bzl

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
These rules are temporary and will be deprecated in the future.
44
"""
55

6+
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
7+
load(
8+
"@bazel_tools//tools/build_defs/cc:action_names.bzl",
9+
"CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME",
10+
"C_COMPILE_ACTION_NAME",
11+
)
612
load(":private/path_utils.bzl", "ln")
713
load("@bazel_skylib//lib:paths.bzl", "paths")
814
load(":private/set.bzl", "set")
@@ -83,19 +89,47 @@ def cc_interop_info(ctx):
8389

8490
include_args = ["-I" + include for include in include_directories]
8591

86-
# TODO Replace with https://github.com/bazelbuild/bazel/issues/4571
87-
# when ready.
88-
cc_toolchain = ctx.toolchains["@bazel_tools//tools/cpp:toolchain_type"]
92+
# XXX Workaround https://github.com/bazelbuild/bazel/issues/6874.
93+
# Should be find_cpp_toolchain() instead.
94+
cc_toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]
95+
feature_configuration = cc_common.configure_features(
96+
cc_toolchain = cc_toolchain,
97+
requested_features = ctx.features,
98+
unsupported_features = ctx.disabled_features,
99+
)
100+
compile_variables = cc_common.create_compile_variables(
101+
feature_configuration = feature_configuration,
102+
cc_toolchain = cc_toolchain,
103+
)
104+
compiler_flags = cc_common.get_memory_inefficient_command_line(
105+
feature_configuration = feature_configuration,
106+
action_name = C_COMPILE_ACTION_NAME,
107+
variables = compile_variables,
108+
)
109+
link_variables = cc_common.create_link_variables(
110+
feature_configuration = feature_configuration,
111+
cc_toolchain = cc_toolchain,
112+
is_linking_dynamic_library = False,
113+
is_static_linking_mode = True,
114+
)
115+
linker_flags = cc_common.get_memory_inefficient_command_line(
116+
feature_configuration = feature_configuration,
117+
action_name = CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME,
118+
variables = link_variables,
119+
)
120+
121+
# XXX Workaround https://github.com/bazelbuild/bazel/issues/6876.
122+
linker_flags = [flag for flag in linker_flags if flag not in ["-shared"]]
89123

90124
return CcInteropInfo(
91125
hdrs = hdrs.to_list(),
92126
cpp_flags = cpp_flags,
93127
include_args = include_args,
94-
compiler_flags = cc_toolchain.compiler_options(),
128+
compiler_flags = compiler_flags,
95129
# XXX this might not be the right set of flags for all situations,
96130
# but this will anyways all be replaced (once implemented) by
97131
# https://github.com/bazelbuild/bazel/issues/4571.
98-
linker_flags = cc_toolchain.mostly_static_link_options(True),
132+
linker_flags = linker_flags,
99133
)
100134

101135
def _cc_import_impl(ctx):

haskell/doctest.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ load("@bazel_skylib//lib:paths.bzl", "paths")
55
load(":private/context.bzl", "haskell_context")
66
load(
77
":private/path_utils.bzl",
8-
"get_external_libs_path",
98
"get_lib_name",
9+
"make_external_libs_path",
1010
)
1111
load(":private/set.bzl", "set")
1212
load(
@@ -108,9 +108,9 @@ def _haskell_doctest_single(target, ctx):
108108
args.add(ctx.attr.doctest_flags)
109109

110110
# External libraries.
111-
external_libs = set.from_list(build_info.external_libraries.values())
111+
external_libraries = build_info.external_libraries
112112
seen_libs = set.empty()
113-
for lib in set.to_list(external_libs):
113+
for lib in [e.mangled_lib for e in set.to_list(build_info.external_libraries)]:
114114
lib_name = get_lib_name(lib)
115115
if not set.is_member(seen_libs, lib_name):
116116
set.mutable_insert(seen_libs, lib_name)
@@ -147,7 +147,7 @@ def _haskell_doctest_single(target, ctx):
147147
set.to_depset(build_info.interface_dirs),
148148
set.to_depset(build_info.dynamic_libraries),
149149
set.to_depset(header_files),
150-
set.to_depset(external_libs),
150+
depset([e.mangled_lib for e in set.to_list(external_libraries)]),
151151
depset([exposed_modules_file]),
152152
depset(
153153
toolchain.doctest +
@@ -167,7 +167,7 @@ def _haskell_doctest_single(target, ctx):
167167
# in this case.
168168
env = dicts.add(
169169
{
170-
"LD_LIBRARY_PATH": get_external_libs_path(external_libs),
170+
"LD_LIBRARY_PATH": make_external_libs_path(external_libraries),
171171
},
172172
hs.env,
173173
),

haskell/haddock.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _haskell_doc_aspect_impl(target, ctx):
9494
set.to_depset(target[HaskellBuildInfo].package_caches),
9595
set.to_depset(target[HaskellBuildInfo].interface_dirs),
9696
set.to_depset(target[HaskellBuildInfo].dynamic_libraries),
97-
depset(target[HaskellBuildInfo].external_libraries.values()),
97+
depset([e.mangled_lib for e in set.to_list(target[HaskellBuildInfo].external_libraries)]),
9898
depset(transitive_haddocks.values()),
9999
depset(transitive_html.values()),
100100
# Need to give source files this way because the source_files field of

haskell/haskell.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ _haskell_common_attrs = {
9090
cfg = "host",
9191
default = Label("@io_tweag_rules_haskell//haskell:ls_modules"),
9292
),
93+
"_cc_toolchain": attr.label(
94+
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
95+
),
9396
}
9497

9598
def _mk_binary_rule(**kwargs):
@@ -135,7 +138,6 @@ def _mk_binary_rule(**kwargs):
135138
},
136139
toolchains = [
137140
"@io_tweag_rules_haskell//haskell:toolchain",
138-
"@bazel_tools//tools/cpp:toolchain_type",
139141
],
140142
**kwargs
141143
)
@@ -200,7 +202,6 @@ haskell_library = rule(
200202
},
201203
toolchains = [
202204
"@io_tweag_rules_haskell//haskell:toolchain",
203-
"@bazel_tools//tools/cpp:toolchain_type",
204205
],
205206
)
206207
"""Build a library from Haskell source.

0 commit comments

Comments
 (0)