Skip to content

Commit

Permalink
Switch --incompatible_require_ctx_in_configure_features
Browse files Browse the repository at this point in the history
See: bazelbuild/bazel#7793

buildifier needed an update of buildtools and rules_go, and starting from
rules_go 0.17.0, it must be loaded using go:deps.bzl.
  • Loading branch information
guibou committed Jun 27, 2019
1 parent 3e5acf1 commit 8d92356
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 13 deletions.
6 changes: 0 additions & 6 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ build --incompatible_use_python_toolchains=false
# see: https://github.com/tweag/rules_haskell/issues/647#issuecomment-459001362
test:windows --experimental_enable_runfiles

# WIP: bazel 0.27 fixs
build\
--incompatible_require_ctx_in_configure_features=false
test\
--incompatible_require_ctx_in_configure_features=false

# test environment does not propagate locales by default
# some tests reads files written in UTF8, we need to propagate the correct
# environment variables, such as LOCALE_ARCHIVE
Expand Down
14 changes: 7 additions & 7 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,16 @@ skydoc_repositories()

http_archive(
name = "io_bazel_rules_go",
sha256 = "8be57ff66da79d9e4bd434c860dce589195b9101b2c187d144014bbca23b5166",
strip_prefix = "rules_go-0.16.3",
urls = ["https://github.com/bazelbuild/rules_go/archive/0.16.3.tar.gz"],
sha256 = "9084496dde809363c491137e077ace81780463ead0060a0a6c3c4c0f613e9fcb",
strip_prefix = "rules_go-0.18.6",
urls = ["https://github.com/bazelbuild/rules_go/archive/0.18.6.tar.gz"],
)

http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "0a0920151acf18c51866331944d12db9023707a6861e78225366f5711efc845b",
strip_prefix = "buildtools-0.25.1",
urls = ["https://github.com/bazelbuild/buildtools/archive/0.25.1.tar.gz"],
sha256 = "86592d703ecbe0c5cbb5139333a63268cf58d7efd2c459c8be8e69e77d135e29",
strip_prefix = "buildtools-0.26.0",
urls = ["https://github.com/bazelbuild/buildtools/archive/0.26.0.tar.gz"],
)

# A repository that generates the Go SDK imports, see ./tools/go_sdk/README
Expand All @@ -404,7 +404,7 @@ local_repository(
)

load(
"@io_bazel_rules_go//go:def.bzl",
"@io_bazel_rules_go//go:deps.bzl",
"go_register_toolchains",
"go_rules_dependencies",
)
Expand Down
1 change: 1 addition & 0 deletions haskell/c2hs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ c2hs_library = rule(
"@io_tweag_rules_haskell//haskell:toolchain",
"@io_tweag_rules_haskell//haskell/c2hs:toolchain",
],
fragments = ["cpp"],
)

def _c2hs_toolchain_impl(ctx):
Expand Down
3 changes: 3 additions & 0 deletions haskell/cabal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def _haskell_cabal_library_impl(ctx):
lib_info = HaskellLibraryInfo(package_id = name, version = None)
cc_toolchain = find_cpp_toolchain(ctx)
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
Expand Down Expand Up @@ -277,6 +278,7 @@ haskell_cabal_library = rule(
),
},
toolchains = ["@io_tweag_rules_haskell//haskell:toolchain"],
fragments = ["cpp"],
)
"""Use Cabal to build a library.
Expand Down Expand Up @@ -401,6 +403,7 @@ haskell_cabal_binary = rule(
),
},
toolchains = ["@io_tweag_rules_haskell//haskell:toolchain"],
fragments = ["cpp"],
)
"""Use Cabal to build a binary.
Expand Down
3 changes: 3 additions & 0 deletions haskell/cc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def cc_interop_info(ctx):
# Should be find_cpp_toolchain() instead.
cc_toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]
feature_configuration = cc_common.configure_features(
# XXX: protobuf is passing a "patched ctx"
# which includes the real ctx as "real_ctx"
ctx = getattr(ctx, "real_ctx", ctx),
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
Expand Down
4 changes: 4 additions & 0 deletions haskell/haskell.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def _mk_binary_rule(**kwargs):
toolchains = [
"@io_tweag_rules_haskell//haskell:toolchain",
],
fragments = ["cpp"],
**kwargs
)

Expand Down Expand Up @@ -257,6 +258,7 @@ haskell_library = rule(
toolchains = [
"@io_tweag_rules_haskell//haskell:toolchain",
],
fragments = ["cpp"],
)
"""Build a library from Haskell source.
Expand Down Expand Up @@ -315,6 +317,7 @@ haskell_toolchain_libraries = rule(
toolchains = [
"@io_tweag_rules_haskell//haskell:toolchain",
],
fragments = ["cpp"],
)

haskell_toolchain_library = rule(
Expand All @@ -327,6 +330,7 @@ haskell_toolchain_library = rule(
default = Label("@io_tweag_rules_haskell//haskell:toolchain-libraries"),
),
),
fragments = ["cpp"],
)
"""Import packages that are prebuilt outside of Bazel.
Expand Down
4 changes: 4 additions & 0 deletions haskell/private/haskell_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,9 @@ def haskell_library_impl(ctx):
# Should be find_cpp_toolchain() instead.
cc_toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]
feature_configuration = cc_common.configure_features(
# XXX: protobuf is passing a "patched ctx"
# which includes the real ctx as "real_ctx"
ctx = getattr(ctx, "real_ctx", ctx),
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
Expand Down Expand Up @@ -643,6 +646,7 @@ def haskell_toolchain_libraries_impl(ctx):
# Should be find_cpp_toolchain() instead.
cc_toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
Expand Down
2 changes: 2 additions & 0 deletions haskell/protobuf.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def _haskell_proto_aspect_impl(target, ctx):
label = ctx.label,
toolchains = ctx.toolchains,
var = ctx.var,
real_ctx = ctx,
)

# TODO this pattern match is very brittle. Let's not do this. The
Expand Down Expand Up @@ -242,6 +243,7 @@ _haskell_proto_aspect = aspect(
"@io_tweag_rules_haskell//haskell:toolchain",
"@io_tweag_rules_haskell//protobuf:toolchain",
],
fragments = ["cpp"],
)

def _haskell_proto_library_impl(ctx):
Expand Down

0 comments on commit 8d92356

Please sign in to comment.