Skip to content

Commit e358783

Browse files
authored
Merge pull request #2394 from iteratee/kb/bazel86
Fixes for Bazel 8.6
2 parents 6f8bd97 + c3dd18d commit e358783

File tree

17 files changed

+113
-16
lines changed

17 files changed

+113
-16
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ bazel_dep(
1313
)
1414
bazel_dep(
1515
name = "rules_license",
16-
version = "0.0.7",
16+
version = "1.0.0",
1717
)
1818
bazel_dep(
1919
name = "protobuf",

extensions/stack_snapshot.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ def _add_packages(conf, module, root_or_rules_haskell):
194194
# Some packages have default components set
195195
conf.components[package_name] = package_tag.components
196196
if package_tag.components_args:
197-
conf.components[package_name] = package_tag.components_args
197+
for (local_name, target) in package_tag.components_args.items():
198+
conf.components_args[package_name + ":" + local_name] = target
198199
if package_tag.components_dependencies:
199200
conf.components_dependencies[package_name] = json.encode(package_tag.components_dependencies)
200201
if package_tag.extra_deps:
@@ -298,7 +299,7 @@ def _stack_snapshot_impl(mctx):
298299
if module.tags.haddock:
299300
_assert_unique_tag(module.tags.haddock, "haddock", module)
300301
haddock_tag = module.tags.haddock[0]
301-
kwargs["haddock"] = haddock_tag.label
302+
kwargs["haddock"] = haddock_tag.value
302303
else:
303304
_assert_no_root_tags(module)
304305

haskell/cabal.bzl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ def _prepare_cabal_inputs(
197197
generate_paths_module,
198198
is_library = False, # @unused
199199
dynamic_file = None,
200-
static_binary = True):
200+
static_binary = True,
201+
label = None):
201202
"""Compute Cabal wrapper, arguments, inputs."""
202203
with_profiling = is_profiling_enabled(hs)
203204

@@ -349,6 +350,10 @@ def _prepare_cabal_inputs(
349350
# Redundant with _binary_paths() above, but better be explicit when we can.
350351
path_args.extend([_cabal_tool_flag(tool_flag) for tool_flag in tool_inputs.to_list() if _cabal_tool_flag(tool_flag)])
351352

353+
repo_name = "_main"
354+
if generate_paths_module and label and label.repo_name:
355+
repo_name = label.repo_name
356+
352357
args = struct(
353358
component = component,
354359
pkg_name = package_id,
@@ -364,6 +369,7 @@ def _prepare_cabal_inputs(
364369
ghc_version = ghc_version,
365370
cabal_basename = cabal.basename,
366371
cabal_dirname = cabal.dirname,
372+
repo_name = repo_name,
367373
extra_ldflags_file = extra_ldflags_file.path if extra_ldflags_file else None,
368374
package_databases = [p.path for p in package_databases.to_list()],
369375
)
@@ -479,7 +485,7 @@ def _haskell_cabal_library_impl(ctx):
479485

480486
is_empty = False
481487
ignore_setup = False
482-
with_haddock = hs.tools_config.supports_haddock
488+
with_haddock = hs.tools_config.supports_haddock and ctx.attr.haddock
483489
if ctx.attr.cabal_args:
484490
cabal_args = ctx.attr.cabal_args[HaskellCabalArgsInfo]
485491

@@ -598,6 +604,7 @@ def _haskell_cabal_library_impl(ctx):
598604
generate_paths_module = ctx.attr.generate_paths_module,
599605
dynamic_file = dynamic_library,
600606
transitive_haddocks = _gather_transitive_haddocks(ctx.attr.deps) if with_haddock else depset([]),
607+
label = ctx.label,
601608
)
602609
outputs = [
603610
package_database,
@@ -933,6 +940,7 @@ def _haskell_cabal_binary_impl(ctx):
933940
dynamic_file = binary,
934941
transitive_haddocks = _gather_transitive_haddocks(ctx.attr.deps) if hs.tools_config.supports_haddock else depset([]),
935942
static_binary = static_binary,
943+
label = ctx.label,
936944
)
937945
(_, runghc_manifest) = ctx.resolve_tools(tools = [ctx.attr._runghc])
938946
json_args = ctx.actions.declare_file("{}_cabal_wrapper_args.json".format(ctx.label.name))

haskell/private/cabal_wrapper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ def distdir_prefix():
263263
is_windows = is_windows,
264264
cabal_basename = json_args["cabal_basename"],
265265
cabal_dirname = json_args["cabal_dirname"],
266+
repo_name = json_args["repo_name"],
266267
ghc = ghc,
267268
libdir = os.path.basename(libdir),
268269
dynlibdir = os.path.basename(dynlibdir),

haskell/private/generate_cabal_paths_module.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def normalise_arch(arch):
4242
return arch
4343

4444
def generate_cabal_paths_module(component_name, ghc_version, is_windows, cabal_basename, cabal_dirname,
45-
ghc, libdir, dynlibdir, bindir, datadir, pkgroot, workspace):
45+
repo_name, ghc, libdir, dynlibdir, bindir, datadir, pkgroot, workspace):
4646

4747
# cabal calls ghc --info to recover the target arch and os, and uses these in path names.
4848
# https://github.com/haskell/cabal/blob/496d6fcc26779e754523a6cc7576aea49ef8056e/Cabal/src/Distribution/Simple/GHC/Internal.hs#L87
@@ -125,6 +125,13 @@ def generate_cabal_paths_module(component_name, ghc_version, is_windows, cabal_b
125125
126126
"""
127127

128+
if repo_name == "_main":
129+
base_data_path = workspace + path_separator + cabal_dirname
130+
else:
131+
base_data_path = repo_name
132+
if cabal_dirname.startswith("external" + path_separator + repo_name):
133+
base_data_path = cabal_dirname.removeprefix("external" + path_separator)
134+
128135
rebindable_syntax_pragma = ("{-# LANGUAGE NoRebindableSyntax #-}"
129136
if supports_rebindable_syntax else "")
130137
if supports_cpp:
@@ -177,7 +184,7 @@ def generate_cabal_paths_module(component_name, ghc_version, is_windows, cabal_b
177184
{version_definition}
178185
179186
s = [pathSeparator]
180-
dataDirWorkspacePath = "{workspace}"++s++"{cabal_dirname}"++s++"_install"++s++"{datadir}"
187+
dataDirWorkspacePath = "{base_data_path}"++s++"_install"++s++"{datadir}"
181188
packageName = "{component_name}"
182189
183190
libdir = "{libdir}"
@@ -257,6 +264,7 @@ def generate_cabal_paths_module(component_name, ghc_version, is_windows, cabal_b
257264
bindir = bindir,
258265
datadir = datadir,
259266
cabal_dirname = cabal_dirname,
267+
base_data_path = base_data_path,
260268
workspace = workspace,
261269
other_functions = other_functions,
262270
)

rules_haskell_nix/MODULE.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ bazel_dep(
2828
name = "platforms",
2929
version = "1.0.0",
3030
)
31+
bazel_dep(
32+
name = "rules_license",
33+
version = "1.0.0",
34+
)
3135
bazel_dep(name = "bazel_skylib", version = "1.5.0")
3236
bazel_dep(name = "rules_shell", version = "0.2.0")
3337

rules_haskell_nix/nixpkgs.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Workspace rules (Nixpkgs)"""
22

3-
load("@bazel_tools//tools/cpp:lib_cc_configure.bzl", "get_cpu_value")
3+
load("@rules_haskell//haskell:private/get_cpu_value.bzl", "get_cpu_value")
44
load(
55
"@rules_haskell//haskell:private/pkgdb_to_bzl.bzl",
66
"pkgdb_to_bzl",

rules_haskell_nix/private/declare_toolchains.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ They are however visible from the `nix_haskell_toolchains_configurations` reposi
1010
- `toolchains` contains the configuration of these toolchains.
1111
"""
1212

13-
load("@bazel_tools//tools/cpp:lib_cc_configure.bzl", "get_cpu_value")
13+
load("@rules_haskell//haskell:private/get_cpu_value.bzl", "get_cpu_value")
1414
load(
1515
"@nix_haskell_toolchains_configurations//:nix_haskell_toolchains_configurations.bzl",
1616
"ghc_labels",

rules_haskell_tests/MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ use_repo(
118118
"library_repo",
119119
"os_info",
120120
"zlib.hs",
121+
"runfiles_repo",
121122
)
122123

123124
non_modules_deps_1 = use_extension("//:non_module_deps_1.bzl", "non_module_deps_1")

rules_haskell_tests/non_module_deps.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ cc_library(
8888
urls = ["https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz"],
8989
)
9090

91+
http_archive(
92+
name = "runfiles_repo",
93+
build_file = "//tests:haskell_cabal_datafiles/BUILD.external-repo",
94+
url = "file:./tests/haskell_cabal_datafiles/external-repo.tar",
95+
integrity = "sha256-pQVTQmtR1JaDPeLQvAOhUrHZIHKhlpxUP00XowH5PoQ=",
96+
)
97+
9198
def _non_module_deps_impl(_ctx):
9299
repositories(bzlmod = True)
93100

0 commit comments

Comments
 (0)