From fddb2995a90dada83c7c6633e25fc9e4458273a8 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 14 Nov 2023 17:31:30 +0100 Subject: [PATCH 1/3] Use `json.encode` instead of deprecated `struct.to_json` --- haskell/cabal.bzl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/haskell/cabal.bzl b/haskell/cabal.bzl index d67ddb508..39bc3c39f 100644 --- a/haskell/cabal.bzl +++ b/haskell/cabal.bzl @@ -559,7 +559,7 @@ def _haskell_cabal_library_impl(ctx): (_, runghc_manifest) = ctx.resolve_tools(tools = [ctx.attr._runghc]) json_args = ctx.actions.declare_file("{}_cabal_wrapper_args.json".format(ctx.label.name)) - ctx.actions.write(json_args, c.args.to_json()) + ctx.actions.write(json_args, json.encode(c.args)) ctx.actions.run( executable = c.cabal_wrapper, arguments = [json_args.path], @@ -861,7 +861,7 @@ def _haskell_cabal_binary_impl(ctx): ) (_, runghc_manifest) = ctx.resolve_tools(tools = [ctx.attr._runghc]) json_args = ctx.actions.declare_file("{}_cabal_wrapper_args.json".format(ctx.label.name)) - ctx.actions.write(json_args, c.args.to_json()) + ctx.actions.write(json_args, json.encode(c.args)) ctx.actions.run( executable = c.cabal_wrapper, arguments = [json_args.path], @@ -1291,7 +1291,7 @@ library ) # Create a stack.yaml capturing user overrides to the snapshot. - stack_yaml_content = struct(**{ + stack_yaml_content = json.encode(struct(**{ "resolver": str(snapshot), "packages": [resolve_package] + core_packages + [ # Determines path to vendored package's root directory relative to @@ -1311,7 +1311,7 @@ library ]) for (pkg, flags) in repository_ctx.attr.flags.items() }, - }).to_json() + })) repository_ctx.file("stack.yaml", content = stack_yaml_content, executable = False) # We declared core packages as local packages in stack.yaml for two reasons. @@ -1679,7 +1679,7 @@ def _write_snapshot_json(repository_ctx, all_cabal_hashes, resolved): "__GENERATED_FILE_DO_NOT_MODIFY_MANUALLY": checksum, "all-cabal-hashes": repr(all_cabal_hashes), "resolved": _pretty_print_kvs(1, { - name: struct(**spec).to_json() + name: json.encode(struct(**spec)) for (name, spec) in resolved.items() }), }), From aed0c41f6270e8570be49d87234b1a65889db939 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 14 Nov 2023 17:36:41 +0100 Subject: [PATCH 2/3] Use `proto.encode_text` instead of `struct.to_proto` --- haskell/private/actions/info.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haskell/private/actions/info.bzl b/haskell/private/actions/info.bzl index 2f63ec023..c0499c7c9 100644 --- a/haskell/private/actions/info.bzl +++ b/haskell/private/actions/info.bzl @@ -31,7 +31,7 @@ def write_proto_file(hs, output_name, proto_type, content): """ proto_txt = hs.actions.declare_file(output_name + ".txt") proto_pb = hs.actions.declare_file(output_name + ".pb") - hs.actions.write(output = proto_txt, content = content.to_proto()) + hs.actions.write(output = proto_txt, content = proto.encode_text(content)) protoc = hs.toolchain.protoc rule_info_protos = hs.toolchain.rule_info_proto[ProtoInfo].direct_sources From 3e643b86ea3a12a1e26ec8a550511fdd3186f1ea Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 14 Nov 2023 17:36:58 +0100 Subject: [PATCH 3/3] Enable `--incompatible_struct_has_no_methods` --- .bazelrc.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelrc.common b/.bazelrc.common index 5b70fa619..522d5d5f4 100644 --- a/.bazelrc.common +++ b/.bazelrc.common @@ -15,7 +15,7 @@ common --config common startup --host_jvm_args=-Djdk.tls.client.protocols=TLSv1.2 common --incompatible_require_linker_input_cc_api - +common --incompatible_struct_has_no_methods common --incompatible_disallow_empty_glob=true # test environment does not propagate locales by default some tests reads files