From 63b8a35108d25d4c65edda79743d2a13dfdccb04 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 23 Jan 2026 17:57:12 +0100 Subject: [PATCH 001/287] feat: Enable bzlmod and disable workspace --- sdk/.bazelrc | 3 ++- sdk/.gitignore | 5 +++++ sdk/MODULE.bazel | 0 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 sdk/MODULE.bazel diff --git a/sdk/.bazelrc b/sdk/.bazelrc index 5d922f7caddb..8cf545ce9ac6 100644 --- a/sdk/.bazelrc +++ b/sdk/.bazelrc @@ -1,4 +1,5 @@ -common --noenable_bzlmod +common --enable_bzlmod +common --noenable_workspace # Bazel distributed cache, can be temporarily disabled by passing the following # flag: --noremote_accept_cached diff --git a/sdk/.gitignore b/sdk/.gitignore index 94191ae32ca7..d4a7676af845 100644 --- a/sdk/.gitignore +++ b/sdk/.gitignore @@ -1,3 +1,8 @@ +# This should be later on unignored, for now it will just make a mess +# in commit history +# Refer to: https://bazel.build/external/lockfile#best-practices +MODULE.bazel.lock + # private configuration .envrc.private diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel new file mode 100644 index 000000000000..e69de29bb2d1 From 16ebc08688a3ae35539935e237d7c6e1d2ed32a5 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 23 Jan 2026 18:11:54 +0100 Subject: [PATCH 002/287] feat: Add `rules_haskell` in version `1.0` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index e69de29bb2d1..dd2ede4da94c 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -0,0 +1 @@ +bazel_dep(name = "rules_haskell", version = "1.0") \ No newline at end of file From d3be44322aef3d341e3de17c47a7dc353740b83f Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 23 Jan 2026 18:19:43 +0100 Subject: [PATCH 003/287] feat: Attach old scripts for `build_environment`, `os_info`, `scala_version` --- sdk/MODULE.bazel | 5 ++++- .../MODULE_MIGRATION/module_temporary_extension.bzl | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/module_temporary_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index dd2ede4da94c..354d32c9189b 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -1 +1,4 @@ -bazel_dep(name = "rules_haskell", version = "1.0") \ No newline at end of file +bazel_dep(name = "rules_haskell", version = "1.0") + +module_temporary_extension = use_extension("//bazel_tools:module_temporary_extension.bzl", "temporary_extension") +use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") diff --git a/sdk/bazel_tools/MODULE_MIGRATION/module_temporary_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/module_temporary_extension.bzl new file mode 100644 index 000000000000..a2fda48311b8 --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/module_temporary_extension.bzl @@ -0,0 +1,12 @@ +load("//bazel_tools:scala_version.bzl", "scala_version_configure") +load("//bazel_tools:os_info.bzl", "os_info") +load("//bazel_tools:build_environment.bzl", "build_environment") + +def _temporary_extension_impl(module_ctx): + scala_version_configure(name = "scala_version") + os_info(name = "os_info") + build_environment(name = "build_environment") + +temporary_extension = module_extension( + implementation = _temporary_extension_impl, +) \ No newline at end of file From 93d45a3b30a5091636dc6cf75128422a4f7d54e0 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 14:07:25 +0100 Subject: [PATCH 004/287] feat: Add `bazel_skylib` in version `1.9.0` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 354d32c9189b..c0431b74d611 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -1,4 +1,5 @@ bazel_dep(name = "rules_haskell", version = "1.0") +bazel_dep(name = "bazel_skylib", version = "1.9.0") module_temporary_extension = use_extension("//bazel_tools:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") From 326a4828bf8465bdd6d30c62f8a7d13ca7f06f15 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 14:10:09 +0100 Subject: [PATCH 005/287] feat: Add `rules_scala` in version `7.1.6` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index c0431b74d611..5e26b5fb31ea 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -1,5 +1,6 @@ bazel_dep(name = "rules_haskell", version = "1.0") bazel_dep(name = "bazel_skylib", version = "1.9.0") +bazel_dep(name = "rules_scala", version = "7.1.6") module_temporary_extension = use_extension("//bazel_tools:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") From 324373b653b2ba412c8bda8884ae86db519f894e Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 14:18:35 +0100 Subject: [PATCH 006/287] fix: Rename `io_bazel_rules_scala` to new name - `rules_scala` note: - it still might be left somewhere, not gonna bother with it for now --- sdk/bazel_tools/scala.bzl | 6 +++--- sdk/bazel_tools/scala/BUILD.bazel | 4 ++-- sdk/canton/BUILD.bazel | 2 +- sdk/canton/community/daml-lf/interpreter/BUILD.bazel | 0 sdk/replacements/BUILD.bazel | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 sdk/canton/community/daml-lf/interpreter/BUILD.bazel diff --git a/sdk/bazel_tools/scala.bzl b/sdk/bazel_tools/scala.bzl index dec5f9c6464d..70105e4f6d68 100644 --- a/sdk/bazel_tools/scala.bzl +++ b/sdk/bazel_tools/scala.bzl @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 load( - "@io_bazel_rules_scala//scala:scala.bzl", + "@rules_scala//scala:scala.bzl", "scala_binary", "scala_library", "scala_library_suite", @@ -12,9 +12,9 @@ load( "scala_test_suite", ) load("@rules_java//java:defs.bzl", "JavaInfo") -load("@io_bazel_rules_scala//scala/private:common.bzl", "sanitize_string_for_usage") +load("@rules_scala//scala/private:common.bzl", "sanitize_string_for_usage") load( - "@io_bazel_rules_scala//jmh:jmh.bzl", + "@rules_scala//jmh:jmh.bzl", "scala_benchmark_jmh", ) load("//bazel_tools:pom_file.bzl", "pom_file") diff --git a/sdk/bazel_tools/scala/BUILD.bazel b/sdk/bazel_tools/scala/BUILD.bazel index 4ca015aaa739..a7d539e60686 100644 --- a/sdk/bazel_tools/scala/BUILD.bazel +++ b/sdk/bazel_tools/scala/BUILD.bazel @@ -1,7 +1,7 @@ # Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -load("@io_bazel_rules_scala//scala:scala_toolchain.bzl", "scala_toolchain") +load("@rules_scala//scala:scala_toolchain.bzl", "scala_toolchain") scala_toolchain( name = "toolchain_impl", @@ -12,6 +12,6 @@ scala_toolchain( toolchain( name = "toolchain", toolchain = "toolchain_impl", - toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", + toolchain_type = "@rules_scala//scala:toolchain_type", visibility = ["//visibility:public"], ) diff --git a/sdk/canton/BUILD.bazel b/sdk/canton/BUILD.bazel index 10042fea77ab..b5c13aacd732 100644 --- a/sdk/canton/BUILD.bazel +++ b/sdk/canton/BUILD.bazel @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 load("@bazel_skylib//rules:copy_file.bzl", "copy_file") -load("@io_bazel_rules_scala//scala:scala.bzl", "scala_binary") +load("@rules_scala//scala:scala.bzl", "scala_binary") load("//bazel_tools:proto.bzl", "proto_gen", "proto_jars") load("//bazel_tools/packaging:packaging.bzl", "package_oci_component") load("//canton:canton_jar.bzl", "canton_jar") diff --git a/sdk/canton/community/daml-lf/interpreter/BUILD.bazel b/sdk/canton/community/daml-lf/interpreter/BUILD.bazel new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/sdk/replacements/BUILD.bazel b/sdk/replacements/BUILD.bazel index 335a79b705b0..53c18c138125 100644 --- a/sdk/replacements/BUILD.bazel +++ b/sdk/replacements/BUILD.bazel @@ -4,4 +4,4 @@ # This file defines custom targets that are referenced in replacements in # dependencies.yaml. -load("@io_bazel_rules_scala//scala:scala_import.bzl", "scala_import") +load("@rules_scala//scala:scala_import.bzl", "scala_import") From 76d77c4d9ed5805eb6dcfa90361052523ccce5ca Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 14:28:08 +0100 Subject: [PATCH 007/287] fix: Correctly point to temporary file load for `build_environment`, `os_info`, `scala_version` --- sdk/MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 5e26b5fb31ea..cf1e8f89c21e 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -2,5 +2,5 @@ bazel_dep(name = "rules_haskell", version = "1.0") bazel_dep(name = "bazel_skylib", version = "1.9.0") bazel_dep(name = "rules_scala", version = "7.1.6") -module_temporary_extension = use_extension("//bazel_tools:module_temporary_extension.bzl", "temporary_extension") +module_temporary_extension = use_extension("//bazel_tools:MODULE_MIGRATION/module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") From 9bbbf8a13e22afc2bad0997059b3ded68c71cf21 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 14:29:33 +0100 Subject: [PATCH 008/287] feat: Add `gazelle` in version `0.47.0` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index cf1e8f89c21e..fcd15a9dde29 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -1,6 +1,7 @@ bazel_dep(name = "rules_haskell", version = "1.0") bazel_dep(name = "bazel_skylib", version = "1.9.0") bazel_dep(name = "rules_scala", version = "7.1.6") +bazel_dep(name = "gazelle", version = "0.47.0") module_temporary_extension = use_extension("//bazel_tools:MODULE_MIGRATION/module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") From c3e61f94d410c1410cdcbd59395b6339fbf4f4cf Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 14:47:29 +0100 Subject: [PATCH 009/287] feat: Add `protobuf` in version `33.4` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index fcd15a9dde29..11bcfc4eb2b8 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -2,6 +2,7 @@ bazel_dep(name = "rules_haskell", version = "1.0") bazel_dep(name = "bazel_skylib", version = "1.9.0") bazel_dep(name = "rules_scala", version = "7.1.6") bazel_dep(name = "gazelle", version = "0.47.0") +bazel_dep(name = "protobuf", version = "33.4") module_temporary_extension = use_extension("//bazel_tools:MODULE_MIGRATION/module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") From abadc62d09c756524e5f47a308441e1f47b5ece9 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 14:50:15 +0100 Subject: [PATCH 010/287] feat: Add `rules_go` in version `0.59.0` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 11bcfc4eb2b8..2806310f68cf 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -3,6 +3,7 @@ bazel_dep(name = "bazel_skylib", version = "1.9.0") bazel_dep(name = "rules_scala", version = "7.1.6") bazel_dep(name = "gazelle", version = "0.47.0") bazel_dep(name = "protobuf", version = "33.4") +bazel_dep(name = "rules_go", version = "0.59.0") module_temporary_extension = use_extension("//bazel_tools:MODULE_MIGRATION/module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") From 8f44d60846bd71de6101b06a5055e912b3e79089 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 14:53:54 +0100 Subject: [PATCH 011/287] fix: Rename `io_bazel_rules_go` to new name - `rules_go` --- sdk/scala-protoc-plugins/scalapb/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/scala-protoc-plugins/scalapb/BUILD.bazel b/sdk/scala-protoc-plugins/scalapb/BUILD.bazel index 6cf99289976c..9c611ca0b7b7 100644 --- a/sdk/scala-protoc-plugins/scalapb/BUILD.bazel +++ b/sdk/scala-protoc-plugins/scalapb/BUILD.bazel @@ -39,7 +39,7 @@ da_scala_binary( # protoc_gen_scala_deploy.jar'. Either figure out how to do this in java # directly or write the wrapper in C++ ot remove the go dependency here. # -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@rules_go//go:def.bzl", "go_binary", "go_library") go_library( name = "go_default_library", From ad771fc039c754d8bfbe3759437af551fed02d32 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 14:55:31 +0100 Subject: [PATCH 012/287] fix: Rename `bazel_gazelle` to new name - `gazelle` --- sdk/BUILD | 2 +- sdk/go_deps.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/BUILD b/sdk/BUILD index cb2a615f5785..badc072248ff 100644 --- a/sdk/BUILD +++ b/sdk/BUILD @@ -212,7 +212,7 @@ da_haskell_repl( ], ) -load("@bazel_gazelle//:def.bzl", "gazelle") +load("@gazelle//:def.bzl", "gazelle") gazelle( name = "gazelle-update-repos", diff --git a/sdk/go_deps.bzl b/sdk/go_deps.bzl index 042498ff5476..5b05532ddd73 100644 --- a/sdk/go_deps.bzl +++ b/sdk/go_deps.bzl @@ -1,7 +1,7 @@ # Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -load("@bazel_gazelle//:deps.bzl", "go_repository") +load("@gazelle//:deps.bzl", "go_repository") def go_deps(): go_repository( From 38559f957e1884e678fa9b1dbc095cebf14c7a3d Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 14:56:45 +0100 Subject: [PATCH 013/287] feat: Add `rules_sh` in version `0.5.0` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 2806310f68cf..3c56226008c9 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -4,6 +4,7 @@ bazel_dep(name = "rules_scala", version = "7.1.6") bazel_dep(name = "gazelle", version = "0.47.0") bazel_dep(name = "protobuf", version = "33.4") bazel_dep(name = "rules_go", version = "0.59.0") +bazel_dep(name = "rules_sh", version = "0.5.0") module_temporary_extension = use_extension("//bazel_tools:MODULE_MIGRATION/module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") From 14b58cee424852d66d4e311d2cfdc73921b80e7d Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 17:02:56 +0100 Subject: [PATCH 014/287] fix: Use new `rules_proto` (`protobuf`) library --- sdk/bazel_tools/scalapb/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/bazel_tools/scalapb/BUILD.bazel b/sdk/bazel_tools/scalapb/BUILD.bazel index 20dbc2165a72..35b2807bd9ff 100644 --- a/sdk/bazel_tools/scalapb/BUILD.bazel +++ b/sdk/bazel_tools/scalapb/BUILD.bazel @@ -5,7 +5,7 @@ # They play havoc both with `unapply` calls, as you always need an extra `_` to ignore them, # and also with automatically-derived Circe JSON encoders and decoders. -load("@rules_proto//proto:defs.bzl", "proto_library") +load("@protobuf//bazel:proto_library.bzl", "proto_library") load("@scala_version//:index.bzl", "scala_major_version_suffix") proto_library( From 72a63b20216738b3806dbeeaac57d95abcb70a6d Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 17:31:44 +0100 Subject: [PATCH 015/287] feat: Add `buildifier_prebuilt` in version `8.2.1.1` and replace old implementation - There is missing pre-commit hook failure - tbd --- sdk/BUILD | 14 ++++---------- sdk/MODULE.bazel | 1 + 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/sdk/BUILD b/sdk/BUILD index badc072248ff..bf7147e9aa5f 100644 --- a/sdk/BUILD +++ b/sdk/BUILD @@ -166,9 +166,6 @@ exports_files([ ]) # Buildifier. - -load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") - buildifier_excluded_patterns = [ "./3rdparty/haskell/c2hs-package.bzl", "./3rdparty/haskell/network-package.bzl", @@ -176,18 +173,15 @@ buildifier_excluded_patterns = [ ] # Run this to check if BUILD files are well-formatted. -buildifier( +alias( name = "buildifier", - exclude_patterns = buildifier_excluded_patterns, - mode = "check", + actual = "@buildifier_prebuilt//:buildifier", ) # Run this to fix the errors in BUILD files. -buildifier( +alias( name = "buildifier-fix", - exclude_patterns = buildifier_excluded_patterns, - mode = "fix", - verbose = True, + actual = "@buildifier_prebuilt//:buildifier.fix", ) # Default target for da-ghci, da-ghcid. diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 3c56226008c9..dbceea54a433 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -5,6 +5,7 @@ bazel_dep(name = "gazelle", version = "0.47.0") bazel_dep(name = "protobuf", version = "33.4") bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_sh", version = "0.5.0") +bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1") module_temporary_extension = use_extension("//bazel_tools:MODULE_MIGRATION/module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") From e044836bd0ca7c85760b8f9c8942d4f0f7f553c2 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 26 Jan 2026 18:22:38 +0100 Subject: [PATCH 016/287] query: Disable nodejs targets until full refactor to `rules_js` --- sdk/docs/BUILD.bazel | 2 +- .../js/daml-types/BUILD.bazel | 142 +++++++++--------- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/sdk/docs/BUILD.bazel b/sdk/docs/BUILD.bazel index 0f642861c7c6..faf9ed29e046 100644 --- a/sdk/docs/BUILD.bazel +++ b/sdk/docs/BUILD.bazel @@ -1,7 +1,7 @@ # Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") +# load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") load("@os_info//:os_info.bzl", "is_windows") load("//rules_daml:daml.bzl", "daml_build_test", "daml_compile", "daml_multi_package_test", "daml_test") load("@rules_pkg//:pkg.bzl", "pkg_tar") diff --git a/sdk/language-support/js/daml-types/BUILD.bazel b/sdk/language-support/js/daml-types/BUILD.bazel index accdbd99bb69..3886a6cbdf9f 100644 --- a/sdk/language-support/js/daml-types/BUILD.bazel +++ b/sdk/language-support/js/daml-types/BUILD.bazel @@ -1,71 +1,71 @@ -# Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -load("@rules_pkg//:pkg.bzl", "pkg_tar") -load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm") -load("@language_support_js_deps//eslint:index.bzl", "eslint_test") -load("@os_info//:os_info.bzl", "is_windows") -load("//language-support/js:defs.bzl", "da_ts_library") -load("//language-support/js:eslint.bzl", "eslint_test") -load("//language-support/js:jest.bzl", "jest_test") -load("//language-support/js:typedoc.bzl", "ts_docs") -load("@build_environment//:configuration.bzl", "sdk_version") - -sources = [ - "index.ts", - "index.test.ts", -] - -da_ts_library( - name = "daml-types", - srcs = sources, - module_name = "@daml/types", - tsconfig = ":tsconfig.json", - visibility = ["//visibility:public"], - deps = [ - "@language_support_js_deps//@mojotech/json-type-validation", - "@language_support_js_deps//@types/jest", - "@language_support_js_deps//@types/lodash", - ], -) if not is_windows else None - -genrule( - name = "license", - srcs = ["//:LICENSE"], - outs = ["LICENSE"], - cmd = """ - cp $(location //:LICENSE) $@ - """, -) - -eslint_test( - name = "lint", - srcs = sources, - data = ["tsconfig.json"], - tsconfig = "tsconfig.eslint.json", -) - -pkg_npm( - name = "npm_package", - package_name = "@daml/types", - srcs = [ - ":README.md", - ":package.json", - ":tsconfig.json", - ], - substitutions = {"0.0.0-SDKVERSION": sdk_version}, - visibility = ["//visibility:public"], - deps = [ - ":daml-types", - ":license", - ], -) if not is_windows else None - -jest_test( - name = "test", - srcs = sources, - deps = [ - "@language_support_js_deps//@mojotech/json-type-validation", - "@language_support_js_deps//@types/lodash", - ], -) +# # Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# # SPDX-License-Identifier: Apache-2.0 +# +# load("@rules_pkg//:pkg.bzl", "pkg_tar") +# load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm") +# load("@language_support_js_deps//eslint:index.bzl", "eslint_test") +# load("@os_info//:os_info.bzl", "is_windows") +# load("//language-support/js:defs.bzl", "da_ts_library") +# load("//language-support/js:eslint.bzl", "eslint_test") +# load("//language-support/js:jest.bzl", "jest_test") +# load("//language-support/js:typedoc.bzl", "ts_docs") +# load("@build_environment//:configuration.bzl", "sdk_version") +# +# sources = [ +# "index.ts", +# "index.test.ts", +# ] +# +# da_ts_library( +# name = "daml-types", +# srcs = sources, +# module_name = "@daml/types", +# tsconfig = ":tsconfig.json", +# visibility = ["//visibility:public"], +# deps = [ +# "@language_support_js_deps//@mojotech/json-type-validation", +# "@language_support_js_deps//@types/jest", +# "@language_support_js_deps//@types/lodash", +# ], +# ) if not is_windows else None +# +# genrule( +# name = "license", +# srcs = ["//:LICENSE"], +# outs = ["LICENSE"], +# cmd = """ +# cp $(location //:LICENSE) $@ +# """, +# ) +# +# eslint_test( +# name = "lint", +# srcs = sources, +# data = ["tsconfig.json"], +# tsconfig = "tsconfig.eslint.json", +# ) +# +# pkg_npm( +# name = "npm_package", +# package_name = "@daml/types", +# srcs = [ +# ":README.md", +# ":package.json", +# ":tsconfig.json", +# ], +# substitutions = {"0.0.0-SDKVERSION": sdk_version}, +# visibility = ["//visibility:public"], +# deps = [ +# ":daml-types", +# ":license", +# ], +# ) if not is_windows else None +# +# jest_test( +# name = "test", +# srcs = sources, +# deps = [ +# "@language_support_js_deps//@mojotech/json-type-validation", +# "@language_support_js_deps//@types/lodash", +# ], +# ) From a49efddbb319f91017341fba07bd9aae36da1037 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 27 Jan 2026 16:51:39 +0100 Subject: [PATCH 017/287] tmp: Add temporary stackage workaround Note: It still fails, but there is much more easier issues to solve in the background --- sdk/MODULE.bazel | 11 +++ .../haskell_deps_extension.bzl | 82 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/haskell_deps_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index dbceea54a433..554d7a015d75 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -7,5 +7,16 @@ bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_sh", version = "0.5.0") bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1") +haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") +haskell.toolchain(version = "9.12.3") +use_repo(haskell, "ghc_toolchains") + +stack = use_extension("//bazel_tools:MODULE_MIGRATION/haskell_deps_extension.bzl", "haskell_deps") +stack.snapshot( + name = "stackage", + local_snapshot = "//:stack-snapshot.yaml", +) +use_repo(stack, "stackage") + module_temporary_extension = use_extension("//bazel_tools:MODULE_MIGRATION/module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell_deps_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell_deps_extension.bzl new file mode 100644 index 000000000000..d9c7f2d285fb --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell_deps_extension.bzl @@ -0,0 +1,82 @@ +load("@bazel_skylib//lib:dicts.bzl", "dicts") +load("@rules_haskell//haskell:cabal.bzl", "stack_snapshot") + +def _haskell_deps_impl(ctx): + """Module extension for Haskell dependencies.""" + + for mod in ctx.modules: + for snapshot in mod.tags.snapshot: + stack_snapshot( + name = snapshot.name, + extra_deps = { + "zlib": ["@zlib//:zlib"], + }, + stack_snapshot_json = snapshot.snapshot_json or "//:stackage_snapshot.json", + haddock = False, + local_snapshot = snapshot.local_snapshot, + packages = [ + "aeson", + "aeson-extra", + "async", + "base", + "bytestring", + "conduit", + "conduit-extra", + "containers", + "cryptonite", + "directory", + "extra", + "filepath", + "http-client", + "http-conduit", + "jwt", + "lens", + "lens-aeson", + "memory", + "monad-loops", + "mtl", + "network", + "optparse-applicative", + "process", + "safe", + "safe-exceptions", + "semver", + "split", + "stm", + "tagged", + "tar-conduit", + "tasty", + "tasty-hunit", + "text", + "time", + "typed-process", + "unix-compat", + "unordered-containers", + "utf8-string", + "uuid", + ], + components = { + "attoparsec": [ + "lib:attoparsec", + "lib:attoparsec-internal", + ], + }, + components_dependencies = { + "attoparsec": """{"lib:attoparsec": ["lib:attoparsec-internal"]}""", + }, + ) + +_snapshot = tag_class( + attrs = { + "name": attr.string(mandatory = True), + "local_snapshot": attr.label(mandatory = True), + "snapshot_json": attr.label(), + }, +) + +haskell_deps = module_extension( + implementation = _haskell_deps_impl, + tag_classes = { + "snapshot": _snapshot, + }, +) From 0a6bc886308dfd25b30c3dfb54bfaae70b8ce147 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 27 Jan 2026 17:03:12 +0100 Subject: [PATCH 018/287] feat: Add `zlib` in version `1.3.1.bcr.8` note: Bazel need to be upped to 7.2.1 for this lib specifically --- sdk/.bazeliskrc | 1 - sdk/.bazelversion | 1 + sdk/MODULE.bazel | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) delete mode 100644 sdk/.bazeliskrc create mode 100644 sdk/.bazelversion diff --git a/sdk/.bazeliskrc b/sdk/.bazeliskrc deleted file mode 100644 index 16c346d541a5..000000000000 --- a/sdk/.bazeliskrc +++ /dev/null @@ -1 +0,0 @@ -USE_BAZEL_VERSION=7.1.0 diff --git a/sdk/.bazelversion b/sdk/.bazelversion new file mode 100644 index 000000000000..468c41f93ccc --- /dev/null +++ b/sdk/.bazelversion @@ -0,0 +1 @@ +7.2.1 \ No newline at end of file diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 554d7a015d75..d8f26a966d12 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -6,6 +6,7 @@ bazel_dep(name = "protobuf", version = "33.4") bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_sh", version = "0.5.0") bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1") +bazel_dep(name = "zlib", version = "1.3.1.bcr.8") haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.12.3") From 4b87c019078c1b37bcb48ef81668080c802756ca Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 27 Jan 2026 17:04:39 +0100 Subject: [PATCH 019/287] feat: Add `rules_pkg` in version `1.2.0` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index d8f26a966d12..07826c524bd5 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -7,6 +7,7 @@ bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_sh", version = "0.5.0") bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1") bazel_dep(name = "zlib", version = "1.3.1.bcr.8") +bazel_dep(name = "rules_pkg", version = "1.2.0") haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.12.3") From 6a10616dd1b35deeb4c273f6ba9acbb20fa9f114 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 27 Jan 2026 17:36:26 +0100 Subject: [PATCH 020/287] feat: Add `google_bazel_common` in version `0.0.1` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 07826c524bd5..bd0b0678f90e 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -8,6 +8,7 @@ bazel_dep(name = "rules_sh", version = "0.5.0") bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1") bazel_dep(name = "zlib", version = "1.3.1.bcr.8") bazel_dep(name = "rules_pkg", version = "1.2.0") +bazel_dep(name = "google_bazel_common", version = "0.0.1") haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.12.3") From a60f5278660da5c8bb80720b41be7369ed24bc85 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 27 Jan 2026 17:36:44 +0100 Subject: [PATCH 021/287] fix: Rename `com_github_google_bazel_common` to new name - `google_bazel_common` --- sdk/bazel_tools/java.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/bazel_tools/java.bzl b/sdk/bazel_tools/java.bzl index f49b6d0a2b12..b1b33d8403dc 100644 --- a/sdk/bazel_tools/java.bzl +++ b/sdk/bazel_tools/java.bzl @@ -3,7 +3,7 @@ load("//bazel_tools:pom_file.bzl", "pom_file") load("@os_info//:os_info.bzl", "is_windows") -load("@com_github_google_bazel_common//tools/javadoc:javadoc.bzl", "javadoc_library") +load("@google_bazel_common//tools/javadoc:javadoc.bzl", "javadoc_library") load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_package") load("//bazel_tools:pkg.bzl", "pkg_empty_zip") load("//bazel_tools/dev_env_tool:dev_env_tool.bzl", "dadew_tool_home", "dadew_where") From 47a0bdeccce659c43d5c94c3da1303ac32c2a593 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 27 Jan 2026 17:39:53 +0100 Subject: [PATCH 022/287] feat: Add `bazel_jar_jar` in version `0.1.14` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index bd0b0678f90e..3a0acbdaa1a3 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -9,6 +9,7 @@ bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1") bazel_dep(name = "zlib", version = "1.3.1.bcr.8") bazel_dep(name = "rules_pkg", version = "1.2.0") bazel_dep(name = "google_bazel_common", version = "0.0.1") +bazel_dep(name = "bazel_jar_jar", version = "0.1.14") haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.12.3") From 4621c7d200c4af49bcb89f4f83099f070d969011 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 27 Jan 2026 17:42:06 +0100 Subject: [PATCH 023/287] feat: Add `rules_cc` in version `0.2.16` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 3a0acbdaa1a3..d8a0f524141d 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -10,6 +10,7 @@ bazel_dep(name = "zlib", version = "1.3.1.bcr.8") bazel_dep(name = "rules_pkg", version = "1.2.0") bazel_dep(name = "google_bazel_common", version = "0.0.1") bazel_dep(name = "bazel_jar_jar", version = "0.1.14") +bazel_dep(name = "rules_cc", version = "0.2.16") haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.12.3") From 396d8c5b7956abc411e9f47315c0b361765be1c6 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 27 Jan 2026 17:43:47 +0100 Subject: [PATCH 024/287] fix: Remove unused `load(...)` --- sdk/bazel_tools/java.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/bazel_tools/java.bzl b/sdk/bazel_tools/java.bzl index b1b33d8403dc..38669dc1d659 100644 --- a/sdk/bazel_tools/java.bzl +++ b/sdk/bazel_tools/java.bzl @@ -4,7 +4,6 @@ load("//bazel_tools:pom_file.bzl", "pom_file") load("@os_info//:os_info.bzl", "is_windows") load("@google_bazel_common//tools/javadoc:javadoc.bzl", "javadoc_library") -load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_package") load("//bazel_tools:pkg.bzl", "pkg_empty_zip") load("//bazel_tools/dev_env_tool:dev_env_tool.bzl", "dadew_tool_home", "dadew_where") From 99fac4bb8888f32d47352c7cb14360c5b0ffce92 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 27 Jan 2026 17:45:14 +0100 Subject: [PATCH 025/287] fix: Rename `io_bazel_rules_scala` to new name - `rules_scala` --- sdk/bazel_tools/proto.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/bazel_tools/proto.bzl b/sdk/bazel_tools/proto.bzl index 42365f43ad72..54f79bee93f6 100644 --- a/sdk/bazel_tools/proto.bzl +++ b/sdk/bazel_tools/proto.bzl @@ -6,7 +6,7 @@ load("//bazel_tools:javadoc_library.bzl", "javadoc_library") load("//bazel_tools:pkg.bzl", "pkg_empty_zip") load("//bazel_tools:pom_file.bzl", "pom_file") load("//bazel_tools:scala.bzl", "scala_source_jar", "scaladoc_jar") -load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library") +load("@rules_scala//scala:scala.bzl", "scala_library") load("@os_info//:os_info.bzl", "is_windows") load("@rules_pkg//:pkg.bzl", "pkg_tar") load("@rules_proto//proto:defs.bzl", "proto_library") From ca93038c4427038d2137b710fb751b81dc377cd0 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 27 Jan 2026 17:46:54 +0100 Subject: [PATCH 026/287] fix: Use `@protobuf` instead of `@rules_proto` --- sdk/bazel_tools/proto.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/bazel_tools/proto.bzl b/sdk/bazel_tools/proto.bzl index 54f79bee93f6..9ab7cf031c0a 100644 --- a/sdk/bazel_tools/proto.bzl +++ b/sdk/bazel_tools/proto.bzl @@ -9,7 +9,7 @@ load("//bazel_tools:scala.bzl", "scala_source_jar", "scaladoc_jar") load("@rules_scala//scala:scala.bzl", "scala_library") load("@os_info//:os_info.bzl", "is_windows") load("@rules_pkg//:pkg.bzl", "pkg_tar") -load("@rules_proto//proto:defs.bzl", "proto_library") +load("@protobuf//bazel:proto_library.bzl", "proto_library") load("@scala_version//:index.bzl", "scala_major_version_suffix") # taken from rules_proto: From 0f8c7c84056618732d872505c623859d400d1eb9 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 28 Jan 2026 15:27:33 +0100 Subject: [PATCH 027/287] tmp: Disable haskell temporarily --- sdk/MODULE.bazel | 6 -- .../haskell_deps_extension.bzl | 82 ------------------- 2 files changed, 88 deletions(-) delete mode 100644 sdk/bazel_tools/MODULE_MIGRATION/haskell_deps_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index d8a0f524141d..3bdb9345ff2f 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -16,12 +16,6 @@ haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.12.3") use_repo(haskell, "ghc_toolchains") -stack = use_extension("//bazel_tools:MODULE_MIGRATION/haskell_deps_extension.bzl", "haskell_deps") -stack.snapshot( - name = "stackage", - local_snapshot = "//:stack-snapshot.yaml", -) -use_repo(stack, "stackage") module_temporary_extension = use_extension("//bazel_tools:MODULE_MIGRATION/module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell_deps_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell_deps_extension.bzl deleted file mode 100644 index d9c7f2d285fb..000000000000 --- a/sdk/bazel_tools/MODULE_MIGRATION/haskell_deps_extension.bzl +++ /dev/null @@ -1,82 +0,0 @@ -load("@bazel_skylib//lib:dicts.bzl", "dicts") -load("@rules_haskell//haskell:cabal.bzl", "stack_snapshot") - -def _haskell_deps_impl(ctx): - """Module extension for Haskell dependencies.""" - - for mod in ctx.modules: - for snapshot in mod.tags.snapshot: - stack_snapshot( - name = snapshot.name, - extra_deps = { - "zlib": ["@zlib//:zlib"], - }, - stack_snapshot_json = snapshot.snapshot_json or "//:stackage_snapshot.json", - haddock = False, - local_snapshot = snapshot.local_snapshot, - packages = [ - "aeson", - "aeson-extra", - "async", - "base", - "bytestring", - "conduit", - "conduit-extra", - "containers", - "cryptonite", - "directory", - "extra", - "filepath", - "http-client", - "http-conduit", - "jwt", - "lens", - "lens-aeson", - "memory", - "monad-loops", - "mtl", - "network", - "optparse-applicative", - "process", - "safe", - "safe-exceptions", - "semver", - "split", - "stm", - "tagged", - "tar-conduit", - "tasty", - "tasty-hunit", - "text", - "time", - "typed-process", - "unix-compat", - "unordered-containers", - "utf8-string", - "uuid", - ], - components = { - "attoparsec": [ - "lib:attoparsec", - "lib:attoparsec-internal", - ], - }, - components_dependencies = { - "attoparsec": """{"lib:attoparsec": ["lib:attoparsec-internal"]}""", - }, - ) - -_snapshot = tag_class( - attrs = { - "name": attr.string(mandatory = True), - "local_snapshot": attr.label(mandatory = True), - "snapshot_json": attr.label(), - }, -) - -haskell_deps = module_extension( - implementation = _haskell_deps_impl, - tag_classes = { - "snapshot": _snapshot, - }, -) From edb13f2071dc244ea52819dcb7935733335ffd86 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 29 Jan 2026 17:20:06 +0100 Subject: [PATCH 028/287] tmp: Add empty implementation for new Haskell extension --- sdk/MODULE.bazel | 4 ++++ sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 3bdb9345ff2f..c1c4122b986a 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -16,6 +16,10 @@ haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.12.3") use_repo(haskell, "ghc_toolchains") +local_haskell_extension = use_extension( + "//bazel_tools:MODULE_MIGRATION/haskell_deps_extension.bzl", + "haskell_extension" + ) module_temporary_extension = use_extension("//bazel_tools:MODULE_MIGRATION/module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl new file mode 100644 index 000000000000..cc4516bb1fd9 --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl @@ -0,0 +1,4 @@ +def _impl(module_ctx): + pass + +haskell_extension = module_extension(implementation = _impl) From efe7f99eba26fed10f9e7bc8d164fa08932775a1 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 29 Jan 2026 17:42:16 +0100 Subject: [PATCH 029/287] fix: Change name of `stack_snapshot.yaml` to `stackage_snapshot.yaml` to fit rules standard --- sdk/{stack-snapshot.yaml => stackage_snapshot.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sdk/{stack-snapshot.yaml => stackage_snapshot.yaml} (100%) diff --git a/sdk/stack-snapshot.yaml b/sdk/stackage_snapshot.yaml similarity index 100% rename from sdk/stack-snapshot.yaml rename to sdk/stackage_snapshot.yaml From f4f8ea434f641ddd694d485b7f7e2a6782f8bf56 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 30 Jan 2026 16:52:50 +0100 Subject: [PATCH 030/287] feat: Add working? Cabal instance --- sdk/MODULE.bazel | 8 +- sdk/bazel-haskell-deps.bzl | 2 +- sdk/bazel_tools/MODULE_MIGRATION/BUILD | 0 .../haskell/haskell_cabal.BUILD.bzl | 9 + .../haskell_non_module_deps_extension.bzl | 15 ++ .../ghc-lib/ghc-lib-parser/BUILD.bazel | 166 +++++++++--------- sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel | 166 +++++++++--------- 7 files changed, 194 insertions(+), 172 deletions(-) create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/BUILD create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_cabal.BUILD.bzl create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index c1c4122b986a..a846563956ff 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -16,10 +16,8 @@ haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.12.3") use_repo(haskell, "ghc_toolchains") -local_haskell_extension = use_extension( - "//bazel_tools:MODULE_MIGRATION/haskell_deps_extension.bzl", - "haskell_extension" - ) +haskell_non_module_deps = use_extension("//bazel_tools/MODULE_MIGRATION:haskell_non_module_deps_extension.bzl", "haskell_non_module_deps_extension") +use_repo(haskell_non_module_deps, "Cabal") -module_temporary_extension = use_extension("//bazel_tools:MODULE_MIGRATION/module_temporary_extension.bzl", "temporary_extension") +module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") diff --git a/sdk/bazel-haskell-deps.bzl b/sdk/bazel-haskell-deps.bzl index b13d97b051eb..62f2d6a14d6f 100644 --- a/sdk/bazel-haskell-deps.bzl +++ b/sdk/bazel-haskell-deps.bzl @@ -462,7 +462,7 @@ exports_files(["stack.exe"], visibility = ["//visibility:public"]) }, ), haddock = False, - local_snapshot = "//:stack-snapshot.yaml", + local_snapshot = "//:stackage_snapshot.yaml", stack_snapshot_json = "//:stackage_snapshot_windows.json" if is_windows else "//:stackage_snapshot.json", packages = [ diff --git a/sdk/bazel_tools/MODULE_MIGRATION/BUILD b/sdk/bazel_tools/MODULE_MIGRATION/BUILD new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_cabal.BUILD.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_cabal.BUILD.bzl new file mode 100644 index 000000000000..9c0a4368463c --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_cabal.BUILD.bzl @@ -0,0 +1,9 @@ +load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") + +haskell_cabal_library( + name = "Cabal", + srcs = glob(["Cabal/**"]), + verbose = False, + version = "3.8.1.0", + visibility = ["//visibility:public"], +) \ No newline at end of file diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl new file mode 100644 index 000000000000..c14b601f2af1 --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl @@ -0,0 +1,15 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _get_cabal(module_ctx): + http_archive( + name = "Cabal", + build_file = ":haskell/haskell_cabal.BUILD.bzl", + sha256 = "b697b558558f351d2704e520e7dcb1f300cd77fea5677d4b2ee71d0b965a4fe9", + strip_prefix = "cabal-ghc-9.4-paths-module-relocatable", + urls = ["https://github.com/tweag/cabal/archive/refs/heads/ghc-9.4-paths-module-relocatable.zip"], + ) + +def _impl(module_ctx): + _get_cabal(module_ctx) + +haskell_non_module_deps_extension = module_extension(implementation = _impl) diff --git a/sdk/bazel_tools/ghc-lib/ghc-lib-parser/BUILD.bazel b/sdk/bazel_tools/ghc-lib/ghc-lib-parser/BUILD.bazel index 1a18b4f299ff..66d22615e721 100644 --- a/sdk/bazel_tools/ghc-lib/ghc-lib-parser/BUILD.bazel +++ b/sdk/bazel_tools/ghc-lib/ghc-lib-parser/BUILD.bazel @@ -1,83 +1,83 @@ -# Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -load("@bazel_skylib//rules:copy_file.bzl", "copy_file") -load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") -load("@stackage//:packages.bzl", "packages") -load("//bazel_tools/ghc-lib:version.bzl", "GHC_LIB_VERSION") -load("//bazel_tools:pkg.bzl", "unpack_tar") -load( - "//bazel_tools/sh:sh.bzl", - "sh_inline_binary", - "sh_inline_test", -) - -unpack_tar( - name = "unpack", - src = "@da-ghc//:ghc-lib-parser-{}.tar.gz".format(GHC_LIB_VERSION), - outs = [ - "srcs/LICENSE", - "srcs/compiler/", - "srcs/ghc-lib/", - "srcs/includes/", - "srcs/libraries/", - ], - prefix = "srcs", - strip = 1, -) - -copy_file( - name = "cabal-file", - src = "@da-ghc//:ghc-lib-parser.cabal", - out = "srcs/ghc-lib-parser.cabal", -) - -sh_inline_binary( - name = "cabal-update", - cmd = """\ -SOURCE=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib-parser.cabal)) -OUTPUT_DIR=$$BUILD_WORKSPACE_DIRECTORY/bazel_tools/ghc-lib/ghc-lib-parser - -cp --no-preserve=mode -t "$$OUTPUT_DIR" "$$SOURCE" -""", - data = [ - "@da-ghc//:ghc-lib-parser.cabal", - ], - toolchains = ["@rules_sh//sh/posix:make_variables"], -) - -sh_inline_test( - name = "cabal-file-diff", - cmd = """\ -EXPECTED=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib-parser.cabal)) -ACTUAL=$$(canonicalize_rlocation $(rootpath ghc-lib-parser.cabal)) -$(POSIX_DIFF) -Naur --strip-trailing-cr $$EXPECTED $$ACTUAL || { - echo "The checked in ghc-lib-parser.cabal file is out of sync" >&2 - exit 1 -} -""", - data = [ - "ghc-lib-parser.cabal", - "@da-ghc//:ghc-lib-parser.cabal", - ], - toolchains = ["@rules_sh//sh/posix:make_variables"], -) - -filegroup( - name = "srcs", - srcs = [ - ":cabal-file", - ":unpack", - ], -) - -haskell_cabal_library( - name = "ghc-lib-parser", - srcs = [":srcs"], - flags = packages["ghc-lib-parser"].flags, - haddock = False, - tools = packages["ghc-lib-parser"].tools, - version = packages["ghc-lib-parser"].version, - visibility = ["//visibility:public"], - deps = packages["ghc-lib-parser"].deps, -) +# # Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# # SPDX-License-Identifier: Apache-2.0 +# +# load("@bazel_skylib//rules:copy_file.bzl", "copy_file") +# load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") +# load("@stackage//:packages.bzl", "packages") +# load("//bazel_tools/ghc-lib:version.bzl", "GHC_LIB_VERSION") +# load("//bazel_tools:pkg.bzl", "unpack_tar") +# load( +# "//bazel_tools/sh:sh.bzl", +# "sh_inline_binary", +# "sh_inline_test", +# ) +# +# unpack_tar( +# name = "unpack", +# src = "@da-ghc//:ghc-lib-parser-{}.tar.gz".format(GHC_LIB_VERSION), +# outs = [ +# "srcs/LICENSE", +# "srcs/compiler/", +# "srcs/ghc-lib/", +# "srcs/includes/", +# "srcs/libraries/", +# ], +# prefix = "srcs", +# strip = 1, +# ) +# +# copy_file( +# name = "cabal-file", +# src = "@da-ghc//:ghc-lib-parser.cabal", +# out = "srcs/ghc-lib-parser.cabal", +# ) +# +# sh_inline_binary( +# name = "cabal-update", +# cmd = """\ +# SOURCE=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib-parser.cabal)) +# OUTPUT_DIR=$$BUILD_WORKSPACE_DIRECTORY/bazel_tools/ghc-lib/ghc-lib-parser +# +# cp --no-preserve=mode -t "$$OUTPUT_DIR" "$$SOURCE" +# """, +# data = [ +# "@da-ghc//:ghc-lib-parser.cabal", +# ], +# toolchains = ["@rules_sh//sh/posix:make_variables"], +# ) +# +# sh_inline_test( +# name = "cabal-file-diff", +# cmd = """\ +# EXPECTED=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib-parser.cabal)) +# ACTUAL=$$(canonicalize_rlocation $(rootpath ghc-lib-parser.cabal)) +# $(POSIX_DIFF) -Naur --strip-trailing-cr $$EXPECTED $$ACTUAL || { +# echo "The checked in ghc-lib-parser.cabal file is out of sync" >&2 +# exit 1 +# } +# """, +# data = [ +# "ghc-lib-parser.cabal", +# "@da-ghc//:ghc-lib-parser.cabal", +# ], +# toolchains = ["@rules_sh//sh/posix:make_variables"], +# ) +# +# filegroup( +# name = "srcs", +# srcs = [ +# ":cabal-file", +# ":unpack", +# ], +# ) +# +# haskell_cabal_library( +# name = "ghc-lib-parser", +# srcs = [":srcs"], +# flags = packages["ghc-lib-parser"].flags, +# haddock = False, +# tools = packages["ghc-lib-parser"].tools, +# version = packages["ghc-lib-parser"].version, +# visibility = ["//visibility:public"], +# deps = packages["ghc-lib-parser"].deps, +# ) diff --git a/sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel b/sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel index 6a6357b74e7d..b4898db0cab7 100644 --- a/sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel +++ b/sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel @@ -1,83 +1,83 @@ -# Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -load("@bazel_skylib//rules:copy_file.bzl", "copy_file") -load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") -load("@stackage//:packages.bzl", "packages") -load("//bazel_tools/ghc-lib:version.bzl", "GHC_LIB_VERSION") -load("//bazel_tools:pkg.bzl", "unpack_tar") -load( - "//bazel_tools/sh:sh.bzl", - "sh_inline_binary", - "sh_inline_test", -) - -unpack_tar( - name = "unpack", - src = "@da-ghc//:ghc-lib-{}.tar.gz".format(GHC_LIB_VERSION), - outs = [ - "srcs/LICENSE", - "srcs/compiler/", - "srcs/ghc-lib/", - "srcs/includes/", - "srcs/libraries/", - ], - prefix = "srcs", - strip = 1, -) - -copy_file( - name = "cabal-file", - src = "@da-ghc//:ghc-lib.cabal", - out = "srcs/ghc-lib.cabal", -) - -sh_inline_binary( - name = "cabal-update", - cmd = """\ -SOURCE=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib.cabal)) -OUTPUT_DIR=$$BUILD_WORKSPACE_DIRECTORY/bazel_tools/ghc-lib/ghc-lib - -cp --no-preserve=mode -t "$$OUTPUT_DIR" "$$SOURCE" -""", - data = [ - "@da-ghc//:ghc-lib.cabal", - ], - toolchains = ["@rules_sh//sh/posix:make_variables"], -) - -sh_inline_test( - name = "cabal-file-diff", - cmd = """\ -EXPECTED=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib.cabal)) -ACTUAL=$$(canonicalize_rlocation $(rootpath ghc-lib.cabal)) -$(POSIX_DIFF) -Naur --strip-trailing-cr $$EXPECTED $$ACTUAL || { - echo "The checked in ghc-lib.cabal file is out of sync" >&2 - exit 1 -} -""", - data = [ - "ghc-lib.cabal", - "@da-ghc//:ghc-lib.cabal", - ], - toolchains = ["@rules_sh//sh/posix:make_variables"], -) - -filegroup( - name = "srcs", - srcs = [ - ":cabal-file", - ":unpack", - ], -) - -haskell_cabal_library( - name = "ghc-lib", - srcs = [":srcs"], - flags = packages["ghc-lib"].flags, - haddock = False, - tools = packages["ghc-lib"].tools, - version = packages["ghc-lib"].version, - visibility = ["//visibility:public"], - deps = packages["ghc-lib"].deps, -) +# # Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# # SPDX-License-Identifier: Apache-2.0 +# +# load("@bazel_skylib//rules:copy_file.bzl", "copy_file") +# load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") +# load("@stackage//:packages.bzl", "packages") +# load("//bazel_tools/ghc-lib:version.bzl", "GHC_LIB_VERSION") +# load("//bazel_tools:pkg.bzl", "unpack_tar") +# load( +# "//bazel_tools/sh:sh.bzl", +# "sh_inline_binary", +# "sh_inline_test", +# ) +# +# unpack_tar( +# name = "unpack", +# src = "@da-ghc//:ghc-lib-{}.tar.gz".format(GHC_LIB_VERSION), +# outs = [ +# "srcs/LICENSE", +# "srcs/compiler/", +# "srcs/ghc-lib/", +# "srcs/includes/", +# "srcs/libraries/", +# ], +# prefix = "srcs", +# strip = 1, +# ) +# +# copy_file( +# name = "cabal-file", +# src = "@da-ghc//:ghc-lib.cabal", +# out = "srcs/ghc-lib.cabal", +# ) +# +# sh_inline_binary( +# name = "cabal-update", +# cmd = """\ +# SOURCE=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib.cabal)) +# OUTPUT_DIR=$$BUILD_WORKSPACE_DIRECTORY/bazel_tools/ghc-lib/ghc-lib +# +# cp --no-preserve=mode -t "$$OUTPUT_DIR" "$$SOURCE" +# """, +# data = [ +# "@da-ghc//:ghc-lib.cabal", +# ], +# toolchains = ["@rules_sh//sh/posix:make_variables"], +# ) +# +# sh_inline_test( +# name = "cabal-file-diff", +# cmd = """\ +# EXPECTED=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib.cabal)) +# ACTUAL=$$(canonicalize_rlocation $(rootpath ghc-lib.cabal)) +# $(POSIX_DIFF) -Naur --strip-trailing-cr $$EXPECTED $$ACTUAL || { +# echo "The checked in ghc-lib.cabal file is out of sync" >&2 +# exit 1 +# } +# """, +# data = [ +# "ghc-lib.cabal", +# "@da-ghc//:ghc-lib.cabal", +# ], +# toolchains = ["@rules_sh//sh/posix:make_variables"], +# ) +# +# filegroup( +# name = "srcs", +# srcs = [ +# ":cabal-file", +# ":unpack", +# ], +# ) +# +# haskell_cabal_library( +# name = "ghc-lib", +# srcs = [":srcs"], +# flags = packages["ghc-lib"].flags, +# haddock = False, +# tools = packages["ghc-lib"].tools, +# version = packages["ghc-lib"].version, +# visibility = ["//visibility:public"], +# deps = packages["ghc-lib"].deps, +# ) From 594a99e2bf79804b35c657ace8efc3ef4a3bd6d9 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 30 Jan 2026 16:56:29 +0100 Subject: [PATCH 031/287] feat: Add working? stackage repo --- sdk/MODULE.bazel | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index a846563956ff..5e1a9cc9e0d7 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -19,5 +19,13 @@ use_repo(haskell, "ghc_toolchains") haskell_non_module_deps = use_extension("//bazel_tools/MODULE_MIGRATION:haskell_non_module_deps_extension.bzl", "haskell_non_module_deps_extension") use_repo(haskell_non_module_deps, "Cabal") +stack_snapshot = use_extension( + "@rules_haskell//extensions:stack_snapshot.bzl", + "stack_snapshot", +) +use_repo(stack_snapshot, "stackage") + +stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") + module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") From 4573e6258523d7e35d7fc9d96df473bf88bdb1a1 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 18 Feb 2026 11:20:38 +0100 Subject: [PATCH 032/287] feat: Enable `lsp-types` in stackage (with custom patch) --- sdk/MODULE.bazel | 7 +++++- .../haskell/haskell_lsp_types.BUILD.bzl | 11 +++++++++ .../MODULE_MIGRATION/haskell_extension.bzl | 23 ++++++++++++++++++- .../haskell_non_module_deps_extension.bzl | 22 ++++++++++++++++-- 4 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_lsp_types.BUILD.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 5e1a9cc9e0d7..4dc264de3d20 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -17,7 +17,11 @@ haskell.toolchain(version = "9.12.3") use_repo(haskell, "ghc_toolchains") haskell_non_module_deps = use_extension("//bazel_tools/MODULE_MIGRATION:haskell_non_module_deps_extension.bzl", "haskell_non_module_deps_extension") -use_repo(haskell_non_module_deps, "Cabal") +use_repo( + haskell_non_module_deps, + "Cabal", + "lsp-types", +) stack_snapshot = use_extension( "@rules_haskell//extensions:stack_snapshot.bzl", @@ -26,6 +30,7 @@ stack_snapshot = use_extension( use_repo(stack_snapshot, "stackage") stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") +stack_snapshot.package(name = "lsp-types") module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_lsp_types.BUILD.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_lsp_types.BUILD.bzl new file mode 100644 index 000000000000..d7d8d89b0f04 --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_lsp_types.BUILD.bzl @@ -0,0 +1,11 @@ +load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") +load("@stackage//:packages.bzl", "packages") + +haskell_cabal_library( + name = "lsp-types", + version = packages["lsp-types"].version, + srcs = glob(["**"]), + deps = packages["lsp-types"].deps, + haddock = False, + visibility = ["//visibility:public"], +) diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl index cc4516bb1fd9..083e0538904c 100644 --- a/sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl @@ -1,4 +1,25 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _get_lsp_types(module_ctx): + LSP_TYPES_VERSION = "1.4.0.0" + LSP_TYPES_SHA256 = "7ae8a3bad0e91d4a2af9b93e3ad207e3f4c3dace40d420e0592f6323ac93fb67" + + print(packages) + + http_archive( + name = "lsp-types", + build_file = ":haskell/haskell_lsp_types.BUILD.bzl", + patch_args = ["-p1"], + patches = [ + "//bazel_tools:lsp-types-normalisation.patch", + "//bazel_tools:lsp-types-expose-other-modules.patch", + ], + sha256 = LSP_TYPES_SHA256, + strip_prefix = "lsp-types-{}".format(LSP_TYPES_VERSION), + urls = ["http://hackage.haskell.org/package/lsp-types-{version}/lsp-types-{version}.tar.gz".format(version = LSP_TYPES_VERSION)], + ) + def _impl(module_ctx): - pass + _get_lsp_types(module_ctx) haskell_extension = module_extension(implementation = _impl) diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl index c14b601f2af1..8572921b475b 100644 --- a/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl @@ -1,6 +1,6 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -def _get_cabal(module_ctx): +def _get_cabal(): http_archive( name = "Cabal", build_file = ":haskell/haskell_cabal.BUILD.bzl", @@ -9,7 +9,25 @@ def _get_cabal(module_ctx): urls = ["https://github.com/tweag/cabal/archive/refs/heads/ghc-9.4-paths-module-relocatable.zip"], ) +def _get_lsp_types(): + LSP_TYPES_VERSION = "1.4.0.0" + LSP_TYPES_SHA256 = "7ae8a3bad0e91d4a2af9b93e3ad207e3f4c3dace40d420e0592f6323ac93fb67" + + http_archive( + name = "lsp-types", + build_file = ":haskell/haskell_lsp_types.BUILD.bzl", + patch_args = ["-p1"], + patches = [ + "//bazel_tools:lsp-types-normalisation.patch", + "//bazel_tools:lsp-types-expose-other-modules.patch", + ], + sha256 = LSP_TYPES_SHA256, + strip_prefix = "lsp-types-{}".format(LSP_TYPES_VERSION), + urls = ["http://hackage.haskell.org/package/lsp-types-{version}/lsp-types-{version}.tar.gz".format(version = LSP_TYPES_VERSION)], + ) + def _impl(module_ctx): - _get_cabal(module_ctx) + _get_cabal() + _get_lsp_types() haskell_non_module_deps_extension = module_extension(implementation = _impl) From 3848e4c1a257734e9fc2c364946f352137e80a7e Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 18 Feb 2026 15:26:05 +0100 Subject: [PATCH 033/287] feat: Add support for new `daml_versions_repo` --- sdk/MODULE.bazel | 2 +- .../MODULE_MIGRATION/module_temporary_extension.bzl | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 4dc264de3d20..82eaa1524694 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -33,4 +33,4 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") stack_snapshot.package(name = "lsp-types") module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") -use_repo(module_temporary_extension, "build_environment", "os_info", "scala_version") +use_repo(module_temporary_extension, "build_environment", "daml_versions_repo", "os_info", "scala_version") diff --git a/sdk/bazel_tools/MODULE_MIGRATION/module_temporary_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/module_temporary_extension.bzl index a2fda48311b8..00a340fbd0e6 100644 --- a/sdk/bazel_tools/MODULE_MIGRATION/module_temporary_extension.bzl +++ b/sdk/bazel_tools/MODULE_MIGRATION/module_temporary_extension.bzl @@ -1,12 +1,17 @@ -load("//bazel_tools:scala_version.bzl", "scala_version_configure") -load("//bazel_tools:os_info.bzl", "os_info") load("//bazel_tools:build_environment.bzl", "build_environment") +load("//bazel_tools:os_info.bzl", "os_info") +load("//bazel_tools:scala_version.bzl", "scala_version_configure") +load("//daml-lf:json_repo.bzl", "daml_versions_repo") def _temporary_extension_impl(module_ctx): scala_version_configure(name = "scala_version") os_info(name = "os_info") build_environment(name = "build_environment") + daml_versions_repo( + name = "daml_versions_data", + json_file = "//daml-lf:daml-lf-versions.json", + ) temporary_extension = module_extension( implementation = _temporary_extension_impl, -) \ No newline at end of file +) From aee0c9415ee5a194e3356ffcf52614ee4078d624 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 18 Feb 2026 15:27:52 +0100 Subject: [PATCH 034/287] feat: Add `rules_java` in version `9.5.0` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 82eaa1524694..51be40538d40 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -11,6 +11,7 @@ bazel_dep(name = "rules_pkg", version = "1.2.0") bazel_dep(name = "google_bazel_common", version = "0.0.1") bazel_dep(name = "bazel_jar_jar", version = "0.1.14") bazel_dep(name = "rules_cc", version = "0.2.16") +bazel_dep(name = "rules_java", version = "9.5.0") haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.12.3") From 187c29938df277f2986a36224172f39a565c6ddd Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 18 Feb 2026 15:29:45 +0100 Subject: [PATCH 035/287] fix: Apply correct name for `daml_version_data` from `daml_version_repo` --- sdk/MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 51be40538d40..982af4978223 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -34,4 +34,4 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") stack_snapshot.package(name = "lsp-types") module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") -use_repo(module_temporary_extension, "build_environment", "daml_versions_repo", "os_info", "scala_version") +use_repo(module_temporary_extension, "build_environment", "daml_versions_data", "os_info", "scala_version") From 4486488d1708a468894061e36e05d90d373318ed Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 18 Feb 2026 16:01:55 +0100 Subject: [PATCH 036/287] chore: Minor code cleanup --- sdk/MODULE.bazel | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 982af4978223..0cccb00d60cf 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -1,28 +1,24 @@ -bazel_dep(name = "rules_haskell", version = "1.0") +bazel_dep(name = "bazel_jar_jar", version = "0.1.14") bazel_dep(name = "bazel_skylib", version = "1.9.0") -bazel_dep(name = "rules_scala", version = "7.1.6") +bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1") bazel_dep(name = "gazelle", version = "0.47.0") +bazel_dep(name = "google_bazel_common", version = "0.0.1") bazel_dep(name = "protobuf", version = "33.4") +bazel_dep(name = "rules_cc", version = "0.2.16") bazel_dep(name = "rules_go", version = "0.59.0") +bazel_dep(name = "rules_haskell", version = "1.0") +bazel_dep(name = "rules_java", version = "9.5.0") +bazel_dep(name = "rules_pkg", version = "1.2.0") +bazel_dep(name = "rules_scala", version = "7.1.6") bazel_dep(name = "rules_sh", version = "0.5.0") -bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1") bazel_dep(name = "zlib", version = "1.3.1.bcr.8") -bazel_dep(name = "rules_pkg", version = "1.2.0") -bazel_dep(name = "google_bazel_common", version = "0.0.1") -bazel_dep(name = "bazel_jar_jar", version = "0.1.14") -bazel_dep(name = "rules_cc", version = "0.2.16") -bazel_dep(name = "rules_java", version = "9.5.0") haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.12.3") use_repo(haskell, "ghc_toolchains") haskell_non_module_deps = use_extension("//bazel_tools/MODULE_MIGRATION:haskell_non_module_deps_extension.bzl", "haskell_non_module_deps_extension") -use_repo( - haskell_non_module_deps, - "Cabal", - "lsp-types", -) +use_repo(haskell_non_module_deps, "Cabal", "lsp-types") stack_snapshot = use_extension( "@rules_haskell//extensions:stack_snapshot.bzl", From f9eb86e1bf4085d3b872e079c948ed05dd2484af Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 18 Feb 2026 16:35:50 +0100 Subject: [PATCH 037/287] feat: Add gzip and tar from `dev_env` --- sdk/MODULE.bazel | 3 ++ .../MODULE_MIGRATION/packaging_extension.bzl | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/packaging_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 0cccb00d60cf..1d57b6273acb 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -31,3 +31,6 @@ stack_snapshot.package(name = "lsp-types") module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "daml_versions_data", "os_info", "scala_version") + +packaging_extension = use_extension("//bazel_tools/MODULE_MIGRATION:packaging_extension.bzl", "packaging_extension") +use_repo(packaging_extension, "tar_dev_env", "gzip_dev_env") diff --git a/sdk/bazel_tools/MODULE_MIGRATION/packaging_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/packaging_extension.bzl new file mode 100644 index 000000000000..da983c00fbc4 --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/packaging_extension.bzl @@ -0,0 +1,30 @@ +load("//bazel_tools/dev_env_tool:dev_env_tool.bzl", "dev_env_tool") + +def _impl(module_ctx): + """ + Note: + This should be later migrated to use bazel defined toolset, not + one from dev_env + """ + dev_env_tool( + name = "tar_dev_env", + nix_include = ["bin/tar"], + nix_label = "@tar_nix", + nix_paths = ["bin/tar"], + tools = ["tar"], + win_include = ["usr/bin/tar.exe"], + win_paths = ["usr/bin/tar.exe"], + win_tool = "msys2", + ) + dev_env_tool( + name = "gzip_dev_env", + nix_include = ["bin/gzip"], + nix_label = "@gzip_nix", + nix_paths = ["bin/gzip"], + tools = ["gzip"], + win_include = ["usr/bin/gzip.exe"], + win_paths = ["usr/bin/gzip.exe"], + win_tool = "msys2", + ) + +packaging_extension = module_extension(implementation = _impl) \ No newline at end of file From 36422d0a8e4fd64e86ad1dae1bf8494e0de000d0 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 18 Feb 2026 18:11:53 +0100 Subject: [PATCH 038/287] feat: Add `patchelf` in version `0.18.0.bcr.1` --- sdk/MODULE.bazel | 2 ++ sdk/bazel_tools/packaging/BUILD.bazel | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 1d57b6273acb..b1a471e646f3 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -13,6 +13,8 @@ bazel_dep(name = "rules_scala", version = "7.1.6") bazel_dep(name = "rules_sh", version = "0.5.0") bazel_dep(name = "zlib", version = "1.3.1.bcr.8") +bazel_dep(name = "patchelf", version = "0.18.0.bcr.1") + haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.12.3") use_repo(haskell, "ghc_toolchains") diff --git a/sdk/bazel_tools/packaging/BUILD.bazel b/sdk/bazel_tools/packaging/BUILD.bazel index cdc9a1d4d3d4..b1a2b762a80d 100644 --- a/sdk/bazel_tools/packaging/BUILD.bazel +++ b/sdk/bazel_tools/packaging/BUILD.bazel @@ -10,7 +10,7 @@ sh_binary( "//bazel_tools/sh:mktgz", "@gzip_dev_env//:gzip", "@tar_dev_env//:tar", - ] + (["@patchelf_nix//:bin/patchelf"] if not is_windows else []), + ] + (["@patchelf//:patchelf"] if not is_windows else []), visibility = ["//visibility:public"], deps = ["@bazel_tools//tools/bash/runfiles"], ) From 496ad69044f3e5f623d994b1f609f96772898422 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 20 Feb 2026 17:09:53 +0100 Subject: [PATCH 039/287] feat: Add `tar.bzl` in version `0.8.1` and `pigz` in version `2.8.bcr.1` Note - It's not yet fixed in script, as there is nothing to package yet! --- sdk/MODULE.bazel | 6 ++++-- sdk/bazel_tools/packaging/BUILD.bazel | 14 ++++++++++---- sdk/bazel_tools/packaging/package-app.sh | 6 ++++-- sdk/bazel_tools/sh/BUILD.bazel | 14 +++++++++++--- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index b1a471e646f3..706ee50303a0 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -14,6 +14,8 @@ bazel_dep(name = "rules_sh", version = "0.5.0") bazel_dep(name = "zlib", version = "1.3.1.bcr.8") bazel_dep(name = "patchelf", version = "0.18.0.bcr.1") +bazel_dep(name = "tar.bzl", version = "0.8.1") +bazel_dep(name = "pigz", version = "2.8.bcr.1") haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.12.3") @@ -34,5 +36,5 @@ stack_snapshot.package(name = "lsp-types") module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "daml_versions_data", "os_info", "scala_version") -packaging_extension = use_extension("//bazel_tools/MODULE_MIGRATION:packaging_extension.bzl", "packaging_extension") -use_repo(packaging_extension, "tar_dev_env", "gzip_dev_env") +# packaging_extension = use_extension("//bazel_tools/MODULE_MIGRATION:packaging_extension.bzl", "packaging_extension") +# use_repo(packaging_extension, "tar_dev_env", "gzip_dev_env") diff --git a/sdk/bazel_tools/packaging/BUILD.bazel b/sdk/bazel_tools/packaging/BUILD.bazel index b1a2b762a80d..d1209a45df26 100644 --- a/sdk/bazel_tools/packaging/BUILD.bazel +++ b/sdk/bazel_tools/packaging/BUILD.bazel @@ -3,25 +3,31 @@ load("@os_info//:os_info.bzl", "is_windows") +# # +# TODO: +# IMPLEMENT `@tar.bzl//tar:tar` INSTEAD OF `tar_dev_env/tar` INSIDE OF `mktgz.sh`! sh_binary( name = "package-app", srcs = ["package-app.sh"], data = [ "//bazel_tools/sh:mktgz", - "@gzip_dev_env//:gzip", - "@tar_dev_env//:tar", + # "@gzip_dev_env//:gzip", + "@tar.bzl//tar:tar", ] + (["@patchelf//:patchelf"] if not is_windows else []), visibility = ["//visibility:public"], deps = ["@bazel_tools//tools/bash/runfiles"], ) +# # +# TODO: +# IMPLEMENT `@tar.bzl//tar:tar` INSTEAD OF `tar_dev_env/tar` INSIDE OF `mktgz.sh`! sh_binary( name = "package-oci-component", srcs = ["package-oci-component.sh"], data = [ "//bazel_tools/sh:mktgz", - "@gzip_dev_env//:gzip", - "@tar_dev_env//:tar", + # "@gzip_dev_env//:gzip", + "@tar.bzl//tar:tar", ], visibility = ["//visibility:public"], deps = ["@bazel_tools//tools/bash/runfiles"], diff --git a/sdk/bazel_tools/packaging/package-app.sh b/sdk/bazel_tools/packaging/package-app.sh index 60bf1f2c19b7..764e51c0a42a 100755 --- a/sdk/bazel_tools/packaging/package-app.sh +++ b/sdk/bazel_tools/packaging/package-app.sh @@ -49,13 +49,15 @@ fi case "$(uname -s)" in Darwin|Linux) tar=$(abspath $(rlocation tar_dev_env/tar)) - gzip=$(abspath $(rlocation gzip_dev_env/gzip)) +# Unused +# gzip=$(abspath $(rlocation gzip_dev_env/gzip)) mktgz=$(abspath $(rlocation com_github_digital_asset_daml/bazel_tools/sh/mktgz)) patchelf=$(abspath $(rlocation patchelf_nix/bin/patchelf)) ;; CYGWIN*|MINGW*|MSYS*) tar=$(abspath $(rlocation tar_dev_env/usr/bin/tar.exe)) - gzip=$(abspath $(rlocation gzip_dev_env/usr/bin/gzip.exe)) +# Unused +# gzip=$(abspath $(rlocation gzip_dev_env/usr/bin/gzip.exe)) mktgz=$(abspath $(rlocation com_github_digital_asset_daml/bazel_tools/sh/mktgz.exe)) ;; esac diff --git a/sdk/bazel_tools/sh/BUILD.bazel b/sdk/bazel_tools/sh/BUILD.bazel index 1a1b16f72781..82d6dcab8f7c 100644 --- a/sdk/bazel_tools/sh/BUILD.bazel +++ b/sdk/bazel_tools/sh/BUILD.bazel @@ -6,20 +6,28 @@ exports_files([ "test.sh.tpl", ]) +# # +# TODO: +# IMPLEMENT `@tar.bzl//tar:tar` INSTEAD OF `tar_dev_env/tar` INSIDE OF `mktgz.sh`! sh_binary( name = "mktar", srcs = ["mktar.sh"], - data = ["@tar_dev_env//:tar"], + data = ["@tar.bzl//tar:tar"], visibility = ["//visibility:public"], deps = ["@bazel_tools//tools/bash/runfiles"], ) +# # +# TODO: +# IMPLEMENT `@tar.bzl//tar:tar` INSTEAD OF `tar_dev_env/tar` INSIDE OF `mktgz.sh`! +# TODO: +# IMPLEMENT PIGZ INSTEAD OF GZIP INSIDE OF `mktgz.sh`! sh_binary( name = "mktgz", srcs = ["mktgz.sh"], data = [ - "@gzip_dev_env//:gzip", - "@tar_dev_env//:tar", + "@pigz//:pigz", + "@tar.bzl//tar:tar", ], visibility = ["//visibility:public"], deps = ["@bazel_tools//tools/bash/runfiles"], From 4afc077bd3d6755da918e5534febe4e82a6573fb Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 20 Feb 2026 18:13:12 +0100 Subject: [PATCH 040/287] feat: Add first haskell packages --- sdk/MODULE.bazel | 51 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 706ee50303a0..73965f54c8c6 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -31,7 +31,56 @@ stack_snapshot = use_extension( use_repo(stack_snapshot, "stackage") stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") -stack_snapshot.package(name = "lsp-types") +# stack_snapshot.package(name = "lsp-types") +[ + stack_snapshot.package( + name = pkg, + setup_deps = ["@Cabal//:Cabal"], + ) + for pkg in [ + "aeson", + "aeson-pretty", + "ansi-terminal", + "async", + "base", + "binary", + "blaze-html", + "bytestring", + "conduit", + "containers", + "deepseq", + "directory", + "extra", + "filepath", + "hashable", + "http-client", + "http-conduit", + "http-types", + "lens", + "lsp-test", + "lsp-types", + "monad-loops", + "network", + "optparse-applicative", + "parser-combinators", + "pretty", + "process", + "safe", + "safe-exceptions", + "split", + "tar-conduit", + "tasty", + "tasty-hunit", + "tasty-quickcheck", + "text", + "time", + "typed-process", + "unix-compat", + "unordered-containers", + "vector", + "unix", + ] +] module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "daml_versions_data", "os_info", "scala_version") From 864d649c364b91609cd09fe765f5a0edd089c077 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 25 Feb 2026 16:34:10 +0100 Subject: [PATCH 041/287] feat: Add ghc `9.2.8` as main compiler for haskell --- sdk/MODULE.bazel | 11 ++++++----- .../MODULE_MIGRATION/haskell/haskell_cabal.BUILD.bzl | 2 +- .../haskell_non_module_deps_extension.bzl | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 73965f54c8c6..4cfee345719f 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -6,7 +6,7 @@ bazel_dep(name = "google_bazel_common", version = "0.0.1") bazel_dep(name = "protobuf", version = "33.4") bazel_dep(name = "rules_cc", version = "0.2.16") bazel_dep(name = "rules_go", version = "0.59.0") -bazel_dep(name = "rules_haskell", version = "1.0") +bazel_dep(name = "rules_haskell", version = "0.18") bazel_dep(name = "rules_java", version = "9.5.0") bazel_dep(name = "rules_pkg", version = "1.2.0") bazel_dep(name = "rules_scala", version = "7.1.6") @@ -18,11 +18,13 @@ bazel_dep(name = "tar.bzl", version = "0.8.1") bazel_dep(name = "pigz", version = "2.8.bcr.1") haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") -haskell.toolchain(version = "9.12.3") +haskell.toolchain(version = "9.0.2") use_repo(haskell, "ghc_toolchains") haskell_non_module_deps = use_extension("//bazel_tools/MODULE_MIGRATION:haskell_non_module_deps_extension.bzl", "haskell_non_module_deps_extension") -use_repo(haskell_non_module_deps, "Cabal", "lsp-types") +use_repo(haskell_non_module_deps, +# "Cabal", + "lsp-types") stack_snapshot = use_extension( "@rules_haskell//extensions:stack_snapshot.bzl", @@ -35,7 +37,7 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") [ stack_snapshot.package( name = pkg, - setup_deps = ["@Cabal//:Cabal"], +# setup_deps = ["@Cabal//:Cabal"], ) for pkg in [ "aeson", @@ -58,7 +60,6 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") "http-types", "lens", "lsp-test", - "lsp-types", "monad-loops", "network", "optparse-applicative", diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_cabal.BUILD.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_cabal.BUILD.bzl index 9c0a4368463c..3aedb3236235 100644 --- a/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_cabal.BUILD.bzl +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_cabal.BUILD.bzl @@ -4,6 +4,6 @@ haskell_cabal_library( name = "Cabal", srcs = glob(["Cabal/**"]), verbose = False, - version = "3.8.1.0", + version = "3.0.0.0", visibility = ["//visibility:public"], ) \ No newline at end of file diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl index 8572921b475b..d8f1d6c4c6fc 100644 --- a/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl @@ -27,7 +27,7 @@ def _get_lsp_types(): ) def _impl(module_ctx): - _get_cabal() +# _get_cabal() _get_lsp_types() haskell_non_module_deps_extension = module_extension(implementation = _impl) From 650d97ba6e1ae983985a8859e6358d84169fa62c Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 25 Feb 2026 16:50:04 +0100 Subject: [PATCH 042/287] feat: Enable `dpm_binary` for project --- sdk/MODULE.bazel | 3 +++ .../MODULE_MIGRATION/dpm_extension.bzl | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/dpm_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 4cfee345719f..f15a800adccd 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -86,5 +86,8 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "daml_versions_data", "os_info", "scala_version") +dpm_extension = use_extension("//bazel_tools/MODULE_MIGRATION:dpm_extension.bzl", "dpm_extension") +use_repo(dpm_extension, "dpm_binary") + # packaging_extension = use_extension("//bazel_tools/MODULE_MIGRATION:packaging_extension.bzl", "packaging_extension") # use_repo(packaging_extension, "tar_dev_env", "gzip_dev_env") diff --git a/sdk/bazel_tools/MODULE_MIGRATION/dpm_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/dpm_extension.bzl new file mode 100644 index 000000000000..1f44c8e9b18c --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/dpm_extension.bzl @@ -0,0 +1,21 @@ +load("//bazel_tools:dpm.bzl", "dpm_binary") + +def _get_dpm(module_ctx): + dpm_binary( + name = "dpm_binary", + # Hashes taken from the files themselves, not the OCI artifacts + # See `layers[0].digest` in the manifest for each platform + sha256 = { + "linux_arm64": "0a108513d99d3f996282ed85c51dc6c10b5790737a299182671c450f87cdf851", + "darwin_amd64": "edfeeec2ea7ac5eb03b56cc2a912ebc59d4ff9db9831cfa0b6033def218aa637", + "darwin_arm64": "ed9c7c6724efc36ca39cf5193a87a73e146685ae2dd042580ee20ca685aa0e1e", + "linux_amd64": "49dcc18c5dbea13bda52f6668b5831b53b46d209e1e539a1ef2a5553c3df6c09", + "windows_amd64": "594ac706c4eff9f0779d0cf04c18cda5ea8f6e4cf82fbead3f03f6aa7de423f9", + }, + version = "1.0.8", + ) + +def _impl(module_ctx): + _get_dpm(module_ctx) + +dpm_extension = module_extension(implementation = _impl) From b9bc8fb5e06f65760103b8e63286f763998faca9 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 25 Feb 2026 16:53:52 +0100 Subject: [PATCH 043/287] feat: Add `remotejdk_17` as main jdk for project - Enable build of `//canton:community_app-lib` --- sdk/.bazelrc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sdk/.bazelrc b/sdk/.bazelrc index 8cf545ce9ac6..3e4d6eac3fda 100644 --- a/sdk/.bazelrc +++ b/sdk/.bazelrc @@ -69,15 +69,21 @@ test --strategy=Scalac=worker # https://github.com/grpc/grpc/pull/13929/files build --copt -DGRPC_BAZEL_BUILD +# build --java_language_version=17 +# build:linux --java_runtime_version=nixpkgs_java_17 +# build:linux --tool_java_runtime_version=nixpkgs_java_17 +# build:darwin --java_runtime_version=nixpkgs_java_17 +# build:darwin --tool_java_runtime_version=nixpkgs_java_17 +# build:windows --java_runtime_version=17 +# build:windows --tool_java_runtime_version=17 +# build --tool_java_language_version=17 + build --java_language_version=17 -build:linux --java_runtime_version=nixpkgs_java_17 -build:linux --tool_java_runtime_version=nixpkgs_java_17 -build:darwin --java_runtime_version=nixpkgs_java_17 -build:darwin --tool_java_runtime_version=nixpkgs_java_17 -build:windows --java_runtime_version=17 -build:windows --tool_java_runtime_version=17 build --tool_java_language_version=17 +build --java_runtime_version=remotejdk_17 +build --tool_java_runtime_version=remotejdk_17 + # Propagate locales and the java home to the test environment. build --test_env=LANG=en_US.utf8 --test_env=LOCALE_ARCHIVE --test_env=JAVA_HOME From d49fe30ae78077905da6aba50f9b7941a071ae0f Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 25 Feb 2026 17:42:22 +0100 Subject: [PATCH 044/287] feat: Add scala in version `2.12.21` to bazel - Packaging is breaking (good, the gzip was not replaced yet) --- sdk/MODULE.bazel | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index f15a800adccd..068207423638 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -9,7 +9,7 @@ bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_haskell", version = "0.18") bazel_dep(name = "rules_java", version = "9.5.0") bazel_dep(name = "rules_pkg", version = "1.2.0") -bazel_dep(name = "rules_scala", version = "7.1.6") +bazel_dep(name = "rules_scala", version = "7.2.2") bazel_dep(name = "rules_sh", version = "0.5.0") bazel_dep(name = "zlib", version = "1.3.1.bcr.8") @@ -89,5 +89,15 @@ use_repo(module_temporary_extension, "build_environment", "daml_versions_data", dpm_extension = use_extension("//bazel_tools/MODULE_MIGRATION:dpm_extension.bzl", "dpm_extension") use_repo(dpm_extension, "dpm_binary") -# packaging_extension = use_extension("//bazel_tools/MODULE_MIGRATION:packaging_extension.bzl", "packaging_extension") -# use_repo(packaging_extension, "tar_dev_env", "gzip_dev_env") +scala_config = use_extension( + "@rules_scala//scala/extensions:config.bzl", + "scala_config" +) +scala_config.settings(scala_version = "2.12.21") +use_repo(scala_config, "rules_scala_config") + +scala_deps = use_extension( + "@rules_scala//scala/extensions:deps.bzl", + "scala_deps", +) +scala_deps.scala() \ No newline at end of file From 79e37fef1efcaa5cfde96d5eb863a2238a139ff0 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 27 Feb 2026 17:21:34 +0100 Subject: [PATCH 045/287] feat: Enable packaging for canton --- sdk/MODULE.bazel | 5 ++++ sdk/bazel_tools/packaging/BUILD.bazel | 9 +------ .../packaging/package-oci-component.sh | 16 ++++--------- sdk/bazel_tools/sh/BUILD.bazel | 10 +------- sdk/bazel_tools/sh/mktgz.sh | 24 +++++++------------ 5 files changed, 19 insertions(+), 45 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 068207423638..75a21ad6542c 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -17,6 +17,11 @@ bazel_dep(name = "patchelf", version = "0.18.0.bcr.1") bazel_dep(name = "tar.bzl", version = "0.8.1") bazel_dep(name = "pigz", version = "2.8.bcr.1") +bazel_lib_toolchains = use_extension("@tar.bzl//tar:extensions.bzl", "toolchains") +use_repo(bazel_lib_toolchains, "bsd_tar_toolchains") + +register_toolchains("@bsd_tar_toolchains//:all") + haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") haskell.toolchain(version = "9.0.2") use_repo(haskell, "ghc_toolchains") diff --git a/sdk/bazel_tools/packaging/BUILD.bazel b/sdk/bazel_tools/packaging/BUILD.bazel index d1209a45df26..21ef534206fb 100644 --- a/sdk/bazel_tools/packaging/BUILD.bazel +++ b/sdk/bazel_tools/packaging/BUILD.bazel @@ -3,9 +3,6 @@ load("@os_info//:os_info.bzl", "is_windows") -# # -# TODO: -# IMPLEMENT `@tar.bzl//tar:tar` INSTEAD OF `tar_dev_env/tar` INSIDE OF `mktgz.sh`! sh_binary( name = "package-app", srcs = ["package-app.sh"], @@ -18,16 +15,12 @@ sh_binary( deps = ["@bazel_tools//tools/bash/runfiles"], ) -# # -# TODO: -# IMPLEMENT `@tar.bzl//tar:tar` INSTEAD OF `tar_dev_env/tar` INSIDE OF `mktgz.sh`! sh_binary( name = "package-oci-component", srcs = ["package-oci-component.sh"], data = [ "//bazel_tools/sh:mktgz", - # "@gzip_dev_env//:gzip", - "@tar.bzl//tar:tar", + "@bsd_tar_toolchains//:resolved_target_toolchain" ], visibility = ["//visibility:public"], deps = ["@bazel_tools//tools/bash/runfiles"], diff --git a/sdk/bazel_tools/packaging/package-oci-component.sh b/sdk/bazel_tools/packaging/package-oci-component.sh index e9d393251222..91da1b16118a 100755 --- a/sdk/bazel_tools/packaging/package-oci-component.sh +++ b/sdk/bazel_tools/packaging/package-oci-component.sh @@ -31,16 +31,8 @@ if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then export RUNFILES_DIR=$(abspath $RUNFILES_MANIFEST_FILE) fi -case "$(uname -s)" in - Darwin|Linux) - tar=$(abspath $(rlocation tar_dev_env/tar)) - mktgz=$(abspath $(rlocation com_github_digital_asset_daml/bazel_tools/sh/mktgz)) - ;; - CYGWIN*|MINGW*|MSYS*) - tar=$(abspath $(rlocation tar_dev_env/usr/bin/tar.exe)) - mktgz=$(abspath $(rlocation com_github_digital_asset_daml/bazel_tools/sh/mktgz.exe)) - ;; -esac +MKTGZ=$(abspath $(rlocation _main/bazel_tools/sh/mktgz)) +TAR=$(find "${RUNFILES_DIR}" -maxdepth 2 -name "tar") set -eou pipefail @@ -75,7 +67,7 @@ for res in "$@"; do RAWNAME=${BASENAME%%.*} # unzip to a directory, as these often have internal relative symlinks to top level, which oras (used by DPM to download artifacts) can't handle right now mkdir -p "$WORKDIR/$RAWNAME" - $tar xf "$res" --strip-components=1 -C "$WORKDIR/$RAWNAME" + $TAR xf "$res" --strip-components=1 -C "$WORKDIR/$RAWNAME" ;; *) cp $res $WORKDIR @@ -88,4 +80,4 @@ for dir in $(find $WORKDIR -type d -name '*.exe'); do mv $dir ${dir%.*} done -cd $WORKDIR && $mktgz $OUT * +cd $WORKDIR && $MKTGZ $OUT * diff --git a/sdk/bazel_tools/sh/BUILD.bazel b/sdk/bazel_tools/sh/BUILD.bazel index 82d6dcab8f7c..4c0366b7d7ef 100644 --- a/sdk/bazel_tools/sh/BUILD.bazel +++ b/sdk/bazel_tools/sh/BUILD.bazel @@ -6,9 +6,6 @@ exports_files([ "test.sh.tpl", ]) -# # -# TODO: -# IMPLEMENT `@tar.bzl//tar:tar` INSTEAD OF `tar_dev_env/tar` INSIDE OF `mktgz.sh`! sh_binary( name = "mktar", srcs = ["mktar.sh"], @@ -17,17 +14,12 @@ sh_binary( deps = ["@bazel_tools//tools/bash/runfiles"], ) -# # -# TODO: -# IMPLEMENT `@tar.bzl//tar:tar` INSTEAD OF `tar_dev_env/tar` INSIDE OF `mktgz.sh`! -# TODO: -# IMPLEMENT PIGZ INSTEAD OF GZIP INSIDE OF `mktgz.sh`! sh_binary( name = "mktgz", srcs = ["mktgz.sh"], data = [ "@pigz//:pigz", - "@tar.bzl//tar:tar", + "@bsd_tar_toolchains//:resolved_target_toolchain" ], visibility = ["//visibility:public"], deps = ["@bazel_tools//tools/bash/runfiles"], diff --git a/sdk/bazel_tools/sh/mktgz.sh b/sdk/bazel_tools/sh/mktgz.sh index 8de50f9bdb74..2dcd831ca604 100755 --- a/sdk/bazel_tools/sh/mktgz.sh +++ b/sdk/bazel_tools/sh/mktgz.sh @@ -24,24 +24,16 @@ EOF } trap usage ERR -case "$(uname -s)" in - Darwin|Linux) - tar=$(rlocation tar_dev_env/tar) - gzip=$(rlocation gzip_dev_env/gzip) - ;; - CYGWIN*|MINGW*|MSYS*) - tar=$(rlocation tar_dev_env/usr/bin/tar.exe) - gzip=$(rlocation gzip_dev_env/usr/bin/gzip.exe) - ;; -esac +PIGZ="$(rlocation "pigz~/pigz")" +TAR=$(find "${RUNFILES_DIR}" -maxdepth 2 -name "tar") -$tar c "${@:2}" \ - --owner="0" \ - --group="0" \ +$TAR \ + --owner=0 \ + --group=0 \ --numeric-owner \ --mtime="2000-01-01 00:00Z" \ --no-acls \ --no-xattrs \ - --no-selinux \ - --sort="name" \ - | $gzip -n > "$1" + --use-compress-program "$PIGZ -n" \ + -cf ${1} \ + "${@:2}" From 7d5967c1ecb3d8d6237cd82d234d05577c9112b7 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 2 Mar 2026 19:06:05 +0100 Subject: [PATCH 046/287] feat: Enable `//ledger-service/utils:utils` - Add maven handling - Up c++ compile flags to c++17 (new abseil requirement) --- sdk/.bazelrc | 6 +++--- sdk/MODULE.bazel | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/sdk/.bazelrc b/sdk/.bazelrc index 3e4d6eac3fda..99ea8ea4920a 100644 --- a/sdk/.bazelrc +++ b/sdk/.bazelrc @@ -24,9 +24,9 @@ sync:darwin --repository_cache=.bazel-cache/repo test:oracle --repo_env DAML_ORACLE_TESTING=true --test_env ORACLE_USERNAME --test_env ORACLE_PORT --test_env ORACLE_PWD -# set c++ compilation version to 14 (requiered for abseil) -build --cxxopt=-std=c++14 -build --host_cxxopt=-std=c++14 +# set c++ compilation version to 14 (requiered for abseil) -> 17 for new version +build --cxxopt=-std=c++17 +build --host_cxxopt=-std=c++17 # Improve remote cache hit rate by exluding environment variables from the # sandbox that are not whitelisted using --action_env. diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 75a21ad6542c..73ff8b192ae2 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -9,9 +9,11 @@ bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_haskell", version = "0.18") bazel_dep(name = "rules_java", version = "9.5.0") bazel_dep(name = "rules_pkg", version = "1.2.0") -bazel_dep(name = "rules_scala", version = "7.2.2") +bazel_dep(name = "rules_scala", version = "7.1.2") # 7.1.2 is last version supporting scala 2.13.16. + # TODO: Verify if there is no need to up it bazel_dep(name = "rules_sh", version = "0.5.0") bazel_dep(name = "zlib", version = "1.3.1.bcr.8") +bazel_dep(name = "rules_jvm_external", version = "6.10") bazel_dep(name = "patchelf", version = "0.18.0.bcr.1") bazel_dep(name = "tar.bzl", version = "0.8.1") @@ -98,11 +100,38 @@ scala_config = use_extension( "@rules_scala//scala/extensions:config.bzl", "scala_config" ) -scala_config.settings(scala_version = "2.12.21") +scala_config.settings(scala_version = "2.13.16") use_repo(scala_config, "rules_scala_config") scala_deps = use_extension( "@rules_scala//scala/extensions:deps.bzl", "scala_deps", ) -scala_deps.scala() \ No newline at end of file +scala_deps.scala() + + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven.install( + known_contributing_modules = ["bazel_jar_jar", "bazel_worker_java", "protobuf"], + artifacts = [ + "com.daml:contextualized-logging_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-api-type-signature_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-archive_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-data_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-language_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:ledger-api-value_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:logging-entries_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:scala-utils_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.google.protobuf:protobuf-java:3.25.5", + "com.thesamet.scalapb:lenses_2.13:0.11.14", + "com.thesamet.scalapb:scalapb-runtime_2.13:0.11.14", + "io.grpc:grpc-protobuf:1.77.0", + "org.scalaz:scalaz-core_2.13:7.2.33", + "org.wartremover:wartremover_2.13.16:3.2.5", + ], + repositories = [ + "https://repo1.maven.org/maven2", + "https://europe-maven.pkg.dev/da-images/public-maven-unstable", + ], +) +use_repo(maven, "maven") \ No newline at end of file From 61b8c02d77c7a65b1fc2a852c9b841214038a85a Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 2 Mar 2026 19:11:16 +0100 Subject: [PATCH 047/287] feat: Add `org.jline:jline:3.27.1` to maven - Enable `//ledger-service/utils:utils_repl` --- sdk/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 73ff8b192ae2..babbe230f14d 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -128,6 +128,7 @@ maven.install( "io.grpc:grpc-protobuf:1.77.0", "org.scalaz:scalaz-core_2.13:7.2.33", "org.wartremover:wartremover_2.13.16:3.2.5", + "org.jline:jline:3.27.1" ], repositories = [ "https://repo1.maven.org/maven2", From 237ae830552c79bc25c03536c420e7b3ae6b01be Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 3 Mar 2026 16:14:17 +0100 Subject: [PATCH 048/287] feat: Enable `//ledger-service/lf-value-json:lf-value-json` --- sdk/MODULE.bazel | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index babbe230f14d..85107496ee8e 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -9,12 +9,16 @@ bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_haskell", version = "0.18") bazel_dep(name = "rules_java", version = "9.5.0") bazel_dep(name = "rules_pkg", version = "1.2.0") -bazel_dep(name = "rules_scala", version = "7.1.2") # 7.1.2 is last version supporting scala 2.13.16. - # TODO: Verify if there is no need to up it + +# # # +bazel_dep(name = "rules_scala", version = "7.1.2") +# 7.1.2 is last version supporting scala 2.13.16. +# TODO: Verify if there is no need to up it +# # # + bazel_dep(name = "rules_sh", version = "0.5.0") bazel_dep(name = "zlib", version = "1.3.1.bcr.8") bazel_dep(name = "rules_jvm_external", version = "6.10") - bazel_dep(name = "patchelf", version = "0.18.0.bcr.1") bazel_dep(name = "tar.bzl", version = "0.8.1") bazel_dep(name = "pigz", version = "2.8.bcr.1") @@ -29,9 +33,11 @@ haskell.toolchain(version = "9.0.2") use_repo(haskell, "ghc_toolchains") haskell_non_module_deps = use_extension("//bazel_tools/MODULE_MIGRATION:haskell_non_module_deps_extension.bzl", "haskell_non_module_deps_extension") -use_repo(haskell_non_module_deps, -# "Cabal", - "lsp-types") +use_repo( + haskell_non_module_deps, + # "Cabal", + "lsp-types", +) stack_snapshot = use_extension( "@rules_haskell//extensions:stack_snapshot.bzl", @@ -40,11 +46,12 @@ stack_snapshot = use_extension( use_repo(stack_snapshot, "stackage") stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") + # stack_snapshot.package(name = "lsp-types") [ stack_snapshot.package( name = pkg, -# setup_deps = ["@Cabal//:Cabal"], + # setup_deps = ["@Cabal//:Cabal"], ) for pkg in [ "aeson", @@ -98,7 +105,7 @@ use_repo(dpm_extension, "dpm_binary") scala_config = use_extension( "@rules_scala//scala/extensions:config.bzl", - "scala_config" + "scala_config", ) scala_config.settings(scala_version = "2.13.16") use_repo(scala_config, "rules_scala_config") @@ -108,11 +115,10 @@ scala_deps = use_extension( "scala_deps", ) scala_deps.scala() - +scala_deps.scalatest() maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") maven.install( - known_contributing_modules = ["bazel_jar_jar", "bazel_worker_java", "protobuf"], artifacts = [ "com.daml:contextualized-logging_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.daml:daml-lf-api-type-signature_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", @@ -122,17 +128,24 @@ maven.install( "com.daml:ledger-api-value_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.daml:logging-entries_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.daml:scala-utils_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-transaction_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.google.protobuf:protobuf-java:3.25.5", "com.thesamet.scalapb:lenses_2.13:0.11.14", "com.thesamet.scalapb:scalapb-runtime_2.13:0.11.14", "io.grpc:grpc-protobuf:1.77.0", "org.scalaz:scalaz-core_2.13:7.2.33", "org.wartremover:wartremover_2.13.16:3.2.5", - "org.jline:jline:3.27.1" + "org.jline:jline:3.27.1", + "io.spray:spray-json_2.13:1.3.6", + ], + known_contributing_modules = [ + "bazel_jar_jar", + "bazel_worker_java", + "protobuf", ], repositories = [ "https://repo1.maven.org/maven2", "https://europe-maven.pkg.dev/da-images/public-maven-unstable", ], ) -use_repo(maven, "maven") \ No newline at end of file +use_repo(maven, "maven") From 1564df93ff9a36163f2c04317c647a5ac6caafb5 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 6 Mar 2026 10:59:47 +0100 Subject: [PATCH 049/287] feat: Enable GHC in version `9.0.2` --- sdk/MODULE.bazel | 16 +++++++++++++--- .../rules_haskell_ghc_version.patch | 11 +++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/rules_haskell_ghc_version.patch diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 85107496ee8e..f8a3bd6c0afc 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -7,6 +7,13 @@ bazel_dep(name = "protobuf", version = "33.4") bazel_dep(name = "rules_cc", version = "0.2.16") bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_haskell", version = "0.18") +archive_override( + module_name = "rules_haskell", + urls = ["https://github.com/tweag/rules_haskell/releases/download/v0.18/rules_haskell-0.18.tar.gz"], + strip_prefix = "rules_haskell-0.18", + patches = ["//bazel_tools/MODULE_MIGRATION:rules_haskell_ghc_version.patch"], +) + bazel_dep(name = "rules_java", version = "9.5.0") bazel_dep(name = "rules_pkg", version = "1.2.0") @@ -28,9 +35,11 @@ use_repo(bazel_lib_toolchains, "bsd_tar_toolchains") register_toolchains("@bsd_tar_toolchains//:all") -haskell = use_extension("@rules_haskell//extensions:haskell.bzl", "haskell") -haskell.toolchain(version = "9.0.2") -use_repo(haskell, "ghc_toolchains") +# haskell_toolchains = use_extension( +# "@rules_haskell//extensions:default.bzl", +# "haskell_toolchains", +# ) +# haskell_toolchains.bindist(version = "9.0.1") haskell_non_module_deps = use_extension("//bazel_tools/MODULE_MIGRATION:haskell_non_module_deps_extension.bzl", "haskell_non_module_deps_extension") use_repo( @@ -39,6 +48,7 @@ use_repo( "lsp-types", ) + stack_snapshot = use_extension( "@rules_haskell//extensions:stack_snapshot.bzl", "stack_snapshot", diff --git a/sdk/bazel_tools/MODULE_MIGRATION/rules_haskell_ghc_version.patch b/sdk/bazel_tools/MODULE_MIGRATION/rules_haskell_ghc_version.patch new file mode 100644 index 000000000000..b8f407912f17 --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/rules_haskell_ghc_version.patch @@ -0,0 +1,11 @@ +--- MODULE.bazel ++++ MODULE.bazel +@@ -79,7 +79,7 @@ haskell_toolchains = use_extension( + "@rules_haskell//extensions:haskell_toolchains.bzl", + "haskell_toolchains", + ) +-haskell_toolchains.bindists() ++haskell_toolchains.bindists(version = "9.0.2") + use_repo( + haskell_toolchains, + "all_bindist_toolchains", From ca50a73a3c9d11177dfb739eb1830cb2819d9cea Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 6 Mar 2026 11:00:10 +0100 Subject: [PATCH 050/287] feat: Enable `//libs-haskell/da-hs-base:da-hs-base` --- sdk/MODULE.bazel | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index f8a3bd6c0afc..5c9b21dac341 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -106,6 +106,11 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") "unix", ] ] +stack_snapshot.package( + name = "attoparsec", + components = ["lib:attoparsec", "lib:attoparsec-internal"], + components_dependencies = {"lib:attoparsec": ["lib:attoparsec-internal"]}, +) module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "daml_versions_data", "os_info", "scala_version") From b0682fc20d59a01ccc3772dba61a73e4ed56b015 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 6 Mar 2026 11:12:25 +0100 Subject: [PATCH 051/287] feat: Enable `//libs-haskell/da-version-types:da-version-types` --- sdk/MODULE.bazel | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 5c9b21dac341..4315e101cc0a 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -92,6 +92,7 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") "process", "safe", "safe-exceptions", + "semver", "split", "tar-conduit", "tasty", @@ -104,6 +105,7 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") "unordered-containers", "vector", "unix", + "yaml", ] ] stack_snapshot.package( From bb156d20085e513b23fd8d2d4f8b11dd206699fa Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 6 Mar 2026 11:17:54 +0100 Subject: [PATCH 052/287] feat: Enable `//daml-assistant:daml-project-config` --- sdk/MODULE.bazel | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 4315e101cc0a..bd73b101b162 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -9,9 +9,9 @@ bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_haskell", version = "0.18") archive_override( module_name = "rules_haskell", - urls = ["https://github.com/tweag/rules_haskell/releases/download/v0.18/rules_haskell-0.18.tar.gz"], - strip_prefix = "rules_haskell-0.18", patches = ["//bazel_tools/MODULE_MIGRATION:rules_haskell_ghc_version.patch"], + strip_prefix = "rules_haskell-0.18", + urls = ["https://github.com/tweag/rules_haskell/releases/download/v0.18/rules_haskell-0.18.tar.gz"], ) bazel_dep(name = "rules_java", version = "9.5.0") @@ -48,7 +48,6 @@ use_repo( "lsp-types", ) - stack_snapshot = use_extension( "@rules_haskell//extensions:stack_snapshot.bzl", "stack_snapshot", @@ -106,11 +105,19 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") "vector", "unix", "yaml", + "regex-tdfa", + "uniplate", + "array", + "transformers", ] ] + stack_snapshot.package( name = "attoparsec", - components = ["lib:attoparsec", "lib:attoparsec-internal"], + components = [ + "lib:attoparsec", + "lib:attoparsec-internal", + ], components_dependencies = {"lib:attoparsec": ["lib:attoparsec-internal"]}, ) From 91c7e16bf51b5eb93839414fbde6f3c0fcb83359 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 6 Mar 2026 19:25:32 +0100 Subject: [PATCH 053/287] feat: Enable `lsp-types` with custom patches --- sdk/MODULE.bazel | 12 ++++++++++++ sdk/stackage_snapshot.yaml | 1 + 2 files changed, 13 insertions(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index bd73b101b162..31c54c7f6ded 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -109,6 +109,18 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") "uniplate", "array", "transformers", + "Diff", + "data-default", + "dlist", + "hslogger", + "mod", + "mtl", + "network-uri", + "rope-utf16-splay", + "scientific", + "some", + "template-haskell", + "temporary", ] ] diff --git a/sdk/stackage_snapshot.yaml b/sdk/stackage_snapshot.yaml index c24a643df3a6..f3fe020f816a 100644 --- a/sdk/stackage_snapshot.yaml +++ b/sdk/stackage_snapshot.yaml @@ -3,6 +3,7 @@ resolver: lts-19.33 packages: + - lsp-types-1.4.0.0 - ghc-lib-parser-ex-8.8.5.8 - github: digital-asset/hlint commit: "99999eee1c220396e1545788ef22ca3c204908a9" From e37c18eadcca56db8b6f83bb0e831e111b81f332 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 11 Mar 2026 11:04:27 +0100 Subject: [PATCH 054/287] feat: Enable `@da-ghc//:hadrian` --- sdk/MODULE.bazel | 44 ++++++++++++++- .../haskell/haskell_da_ghc.BUILD.bzl | 47 ++++++++++++++++ .../haskell/haskell_ghc_lib_gen.BUILD.bzl | 39 +++++++++++++ .../haskell/haskell_ghcide_ghc_lib.BUILD.bzl | 46 ++++++++++++++++ .../MODULE_MIGRATION/haskell_extension.bzl | 25 --------- .../haskell_non_module_deps_extension.bzl | 55 ++++++++++++++++++- 6 files changed, 229 insertions(+), 27 deletions(-) create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_da_ghc.BUILD.bzl create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_ghc_lib_gen.BUILD.bzl create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_ghcide_ghc_lib.BUILD.bzl delete mode 100644 sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 31c54c7f6ded..f8872d3a6fbc 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -45,6 +45,9 @@ haskell_non_module_deps = use_extension("//bazel_tools/MODULE_MIGRATION:haskell_ use_repo( haskell_non_module_deps, # "Cabal", + "da-ghc", + "ghc-lib-gen", + "ghcide_ghc_lib", "lsp-types", ) @@ -52,7 +55,7 @@ stack_snapshot = use_extension( "@rules_haskell//extensions:stack_snapshot.bzl", "stack_snapshot", ) -use_repo(stack_snapshot, "stackage") +use_repo(stack_snapshot, "stackage", "stackage-exe") stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") @@ -121,6 +124,18 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") "some", "template-haskell", "temporary", + # + "Decimal", + "megaparsec", + "zip-archive", + # + "hlint", + "ghc-lib-parser-ex", + # + "shake", + "QuickCheck", + "Cabal", + "parsec", ] ] @@ -132,6 +147,33 @@ stack_snapshot.package( ], components_dependencies = {"lib:attoparsec": ["lib:attoparsec-internal"]}, ) +stack_snapshot.package( + name = "ghc-lib", + vendored = "//bazel_tools/ghc-lib/ghc-lib", +) +stack_snapshot.package( + name = "ghc-lib-parser", + vendored = "//bazel_tools/ghc-lib/ghc-lib-parser", +) +stack_snapshot.package( + name = "ghcide", + flags = ["ghc-lib"], + vendored = "@ghcide_ghc_lib//:ghcide", +) +stack_snapshot.package( + name = "happy", + components = [ +# "lib", + "exe", + ], +) +stack_snapshot.package( + name = "alex", + components = [ +# "lib", + "exe", + ], +) module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "daml_versions_data", "os_info", "scala_version") diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_da_ghc.BUILD.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_da_ghc.BUILD.bzl new file mode 100644 index 000000000000..7f2726fe5938 --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_da_ghc.BUILD.bzl @@ -0,0 +1,47 @@ +load("@os_info//:os_info.bzl", "is_darwin") +load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_binary") +load( + "@//bazel_tools/ghc-lib:version.bzl", + "GHC_CPP_OPTIONS", + "GHC_FLAVOR", + "GHC_LIB_VERSION", +) + +filegroup( + name = "hadrian-srcs", + srcs = glob(["hadrian/**"]), + visibility = ["//visibility:public"], +) + +haskell_cabal_binary( + name = "hadrian", + flags = ["with_bazel"], + srcs = [":hadrian-srcs"], + deps = [ + "@stackage//:base", + "@stackage//:Cabal", + "@stackage//:containers", + "@stackage//:directory", + "@stackage//:extra", + "@stackage//:mtl", + "@stackage//:parsec", + "@stackage//:QuickCheck", + "@stackage//:shake", + "@stackage//:transformers", + "@stackage//:unordered-containers", + ], + tools = [ + "@stackage-exe//alex", + "@stackage-exe//happy", + ], + cabalopts = [ + "--ghc-option=-Wno-dodgy-imports", + "--ghc-option=-Wno-unused-imports", + ], +) + +filegroup( + name = "srcs", + srcs = glob(["**"]), + visibility = ["//visibility:public"], +) diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_ghc_lib_gen.BUILD.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_ghc_lib_gen.BUILD.bzl new file mode 100644 index 000000000000..f832e43c6282 --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_ghc_lib_gen.BUILD.bzl @@ -0,0 +1,39 @@ +load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_binary", "haskell_cabal_library") + +haskell_cabal_library( + name = "ghc-lib-gen-lib", + package_name = "ghc-lib-gen", + version = "0.1.0.0", + haddock = False, + srcs = glob(["**"]), + deps = [ + "@stackage//:base", + "@stackage//:process", + "@stackage//:filepath", + "@stackage//:containers", + "@stackage//:directory", + "@stackage//:optparse-applicative", + "@stackage//:bytestring", + "@stackage//:yaml", + "@stackage//:aeson", + "@stackage//:text", + "@stackage//:unordered-containers", + "@stackage//:extra", + ], +) + +haskell_cabal_binary( + name = "ghc-lib-gen", + srcs = glob(["**"]), + deps = [ + ":ghc-lib-gen-lib", + "@stackage//:base", + "@stackage//:containers", + "@stackage//:directory", + "@stackage//:extra", + "@stackage//:filepath", + "@stackage//:optparse-applicative", + "@stackage//:process", + ], + visibility = ["//visibility:public"], +) \ No newline at end of file diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_ghcide_ghc_lib.BUILD.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_ghcide_ghc_lib.BUILD.bzl new file mode 100644 index 000000000000..293c9df098f1 --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_ghcide_ghc_lib.BUILD.bzl @@ -0,0 +1,46 @@ +load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") +load("@rules_haskell//haskell:defs.bzl", "haskell_library") +load("@stackage//:packages.bzl", "packages") + +haskell_cabal_library( + name = "ghcide", + version = packages["ghcide"].version, + srcs = glob(["**"]), + haddock = False, + flags = packages["ghcide"].flags, + deps = packages["ghcide"].deps, + visibility = ["//visibility:public"], +) +haskell_library( + name = "testing", + srcs = glob(["test/src/**/*.hs"]), + src_strip_prefix = "test/src", + deps = [ + "@stackage//:aeson", + "@stackage//:base", + "@stackage//:extra", + "@stackage//:containers", + "@stackage//:lsp-types", + "@stackage//:lens", + "@stackage//:lsp-test", + "@stackage//:parser-combinators", + "@stackage//:tasty-hunit", + "@stackage//:text", + ], + ghcopts = [ + "-XBangPatterns", + "-XDeriveFunctor", + "-XDeriveGeneric", + "-XGeneralizedNewtypeDeriving", + "-XLambdaCase", + "-XNamedFieldPuns", + "-XOverloadedStrings", + "-XRecordWildCards", + "-XScopedTypeVariables", + "-XStandaloneDeriving", + "-XTupleSections", + "-XTypeApplications", + "-XViewPatterns", + ], + visibility = ["//visibility:public"], +) diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl deleted file mode 100644 index 083e0538904c..000000000000 --- a/sdk/bazel_tools/MODULE_MIGRATION/haskell_extension.bzl +++ /dev/null @@ -1,25 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -def _get_lsp_types(module_ctx): - LSP_TYPES_VERSION = "1.4.0.0" - LSP_TYPES_SHA256 = "7ae8a3bad0e91d4a2af9b93e3ad207e3f4c3dace40d420e0592f6323ac93fb67" - - print(packages) - - http_archive( - name = "lsp-types", - build_file = ":haskell/haskell_lsp_types.BUILD.bzl", - patch_args = ["-p1"], - patches = [ - "//bazel_tools:lsp-types-normalisation.patch", - "//bazel_tools:lsp-types-expose-other-modules.patch", - ], - sha256 = LSP_TYPES_SHA256, - strip_prefix = "lsp-types-{}".format(LSP_TYPES_VERSION), - urls = ["http://hackage.haskell.org/package/lsp-types-{version}/lsp-types-{version}.tar.gz".format(version = LSP_TYPES_VERSION)], - ) - -def _impl(module_ctx): - _get_lsp_types(module_ctx) - -haskell_extension = module_extension(implementation = _impl) diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl index d8f1d6c4c6fc..c396423b2546 100644 --- a/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl +++ b/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl @@ -1,4 +1,15 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel_tools/ghc-lib:version.bzl", + "GHC_LIB_PATCHES", + "GHC_LIB_REPO_URL", + "GHC_LIB_REV", + "GHC_LIB_SHA256", + "GHC_PATCHES", + "GHC_REPO_URL", + "GHC_REV", +) def _get_cabal(): http_archive( @@ -26,8 +37,50 @@ def _get_lsp_types(): urls = ["http://hackage.haskell.org/package/lsp-types-{version}/lsp-types-{version}.tar.gz".format(version = LSP_TYPES_VERSION)], ) +def _get_ghcide(): + GHCIDE_REV = "2914f9328dc549bd4918c3cf0fc008690a102d70" + GHCIDE_SHA256 = "bc2bd2fbfbfb501e303b35fb4b2f503b122e4eb0aff34472f0e882d2289afc57" + GHCIDE_LOCAL_PATH = None + + http_archive( + name = "ghcide_ghc_lib", + build_file = ":haskell/haskell_ghcide_ghc_lib.BUILD.bzl", + patch_args = ["-p1"], + patches = [ + "//bazel_tools:haskell-ghcide-binary-q.patch", + ], + sha256 = None if GHCIDE_LOCAL_PATH != None else GHCIDE_SHA256, + strip_prefix = None if GHCIDE_LOCAL_PATH != None else "daml-ghcide-%s" % GHCIDE_REV, + url = "file://" + GHCIDE_LOCAL_PATH if GHCIDE_LOCAL_PATH != None else "https://github.com/digital-asset/daml-ghcide/archive/%s.tar.gz" % GHCIDE_REV, + ) + +def _get_ghc_lib_gen(): + http_archive( + name = "ghc-lib-gen", + url = "{}/archive/{}.tar.gz".format(GHC_LIB_REPO_URL, GHC_LIB_REV), + sha256 = GHC_LIB_SHA256, + strip_prefix = "ghc-lib-{}".format(GHC_LIB_REV), + build_file = ":haskell/haskell_ghc_lib_gen.BUILD.bzl", + patches = GHC_LIB_PATCHES, + patch_args = ["-p1"], + ) + +def _get_da_ghc(): + git_repository( + name = "da-ghc", + remote = GHC_REPO_URL, + commit = GHC_REV, + recursive_init_submodules = True, + build_file = ":haskell/haskell_da_ghc.BUILD.bzl", + shallow_since = "1639050525 +0100", + patches = GHC_PATCHES, + patch_args = ["-p1"], + ) + def _impl(module_ctx): -# _get_cabal() _get_lsp_types() + _get_ghcide() + _get_ghc_lib_gen() + _get_da_ghc() haskell_non_module_deps_extension = module_extension(implementation = _impl) From 333a7c67507cd09f13741727d55e393a05f97446 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 12 Mar 2026 16:52:48 +0100 Subject: [PATCH 055/287] feat: Add `static_asset_d3plus` repo --- sdk/MODULE.bazel | 13 +++++-------- .../MODULE_MIGRATION/d3plus_extension.bzl | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 sdk/bazel_tools/MODULE_MIGRATION/d3plus_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index f8872d3a6fbc..a23677abcb96 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -162,17 +162,11 @@ stack_snapshot.package( ) stack_snapshot.package( name = "happy", - components = [ -# "lib", - "exe", - ], + components = ["exe"], ) stack_snapshot.package( name = "alex", - components = [ -# "lib", - "exe", - ], + components = ["exe"], ) module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") @@ -181,6 +175,9 @@ use_repo(module_temporary_extension, "build_environment", "daml_versions_data", dpm_extension = use_extension("//bazel_tools/MODULE_MIGRATION:dpm_extension.bzl", "dpm_extension") use_repo(dpm_extension, "dpm_binary") +d3plus_extension = use_extension("//bazel_tools/MODULE_MIGRATION:d3plus_extension.bzl", "d3plus_extension") +use_repo(d3plus_extension, "static_asset_d3plus") + scala_config = use_extension( "@rules_scala//scala/extensions:config.bzl", "scala_config", diff --git a/sdk/bazel_tools/MODULE_MIGRATION/d3plus_extension.bzl b/sdk/bazel_tools/MODULE_MIGRATION/d3plus_extension.bzl new file mode 100644 index 000000000000..fe9cab4754fb --- /dev/null +++ b/sdk/bazel_tools/MODULE_MIGRATION/d3plus_extension.bzl @@ -0,0 +1,16 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _get_d3plus(): + http_archive( + name = "static_asset_d3plus", + build_file_content = 'exports_files(["js/d3.min.js", "js/d3plus.min.js"])', + sha256 = "7d31a500a4850364a966ac938eea7f2fa5ce1334966b52729079490636e7049a", + strip_prefix = "d3plus.v1.9.8", + type = "zip", + urls = ["https://github.com/alexandersimoes/d3plus/releases/download/v1.9.8/d3plus.zip"], + ) + +def _impl(module_ctx): + _get_d3plus() + +d3plus_extension = module_extension(implementation = _impl) From 67fe6b11c2c0ac86d320f8ad511457cf98d9e69c Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 12 Mar 2026 17:32:09 +0100 Subject: [PATCH 056/287] chore: Refactor file placement to be more clear and easy to find in the structure --- sdk/MODULE.bazel | 10 +++++----- .../MODULE_MIGRATION => bazel/extensions}/BUILD | 0 .../extensions}/d3plus_extension.bzl | 0 .../extensions}/dpm_extension.bzl | 0 .../extensions/files}/haskell/haskell_cabal.BUILD.bzl | 0 .../extensions/files}/haskell/haskell_da_ghc.BUILD.bzl | 0 .../files}/haskell/haskell_ghc_lib_gen.BUILD.bzl | 0 .../files}/haskell/haskell_ghcide_ghc_lib.BUILD.bzl | 0 .../files}/haskell/haskell_lsp_types.BUILD.bzl | 0 .../extensions}/haskell_non_module_deps_extension.bzl | 8 ++++---- .../extensions}/module_temporary_extension.bzl | 0 .../extensions}/packaging_extension.bzl | 0 sdk/bazel/rules/patches/BUILD | 0 .../rules/patches}/rules_haskell_ghc_version.patch | 0 14 files changed, 9 insertions(+), 9 deletions(-) rename sdk/{bazel_tools/MODULE_MIGRATION => bazel/extensions}/BUILD (100%) rename sdk/{bazel_tools/MODULE_MIGRATION => bazel/extensions}/d3plus_extension.bzl (100%) rename sdk/{bazel_tools/MODULE_MIGRATION => bazel/extensions}/dpm_extension.bzl (100%) rename sdk/{bazel_tools/MODULE_MIGRATION => bazel/extensions/files}/haskell/haskell_cabal.BUILD.bzl (100%) rename sdk/{bazel_tools/MODULE_MIGRATION => bazel/extensions/files}/haskell/haskell_da_ghc.BUILD.bzl (100%) rename sdk/{bazel_tools/MODULE_MIGRATION => bazel/extensions/files}/haskell/haskell_ghc_lib_gen.BUILD.bzl (100%) rename sdk/{bazel_tools/MODULE_MIGRATION => bazel/extensions/files}/haskell/haskell_ghcide_ghc_lib.BUILD.bzl (100%) rename sdk/{bazel_tools/MODULE_MIGRATION => bazel/extensions/files}/haskell/haskell_lsp_types.BUILD.bzl (100%) rename sdk/{bazel_tools/MODULE_MIGRATION => bazel/extensions}/haskell_non_module_deps_extension.bzl (91%) rename sdk/{bazel_tools/MODULE_MIGRATION => bazel/extensions}/module_temporary_extension.bzl (100%) rename sdk/{bazel_tools/MODULE_MIGRATION => bazel/extensions}/packaging_extension.bzl (100%) create mode 100644 sdk/bazel/rules/patches/BUILD rename sdk/{bazel_tools/MODULE_MIGRATION => bazel/rules/patches}/rules_haskell_ghc_version.patch (100%) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index a23677abcb96..82e88ed649f5 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -9,7 +9,7 @@ bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_haskell", version = "0.18") archive_override( module_name = "rules_haskell", - patches = ["//bazel_tools/MODULE_MIGRATION:rules_haskell_ghc_version.patch"], + patches = ["//bazel/rules/patches:rules_haskell_ghc_version.patch"], strip_prefix = "rules_haskell-0.18", urls = ["https://github.com/tweag/rules_haskell/releases/download/v0.18/rules_haskell-0.18.tar.gz"], ) @@ -41,7 +41,7 @@ register_toolchains("@bsd_tar_toolchains//:all") # ) # haskell_toolchains.bindist(version = "9.0.1") -haskell_non_module_deps = use_extension("//bazel_tools/MODULE_MIGRATION:haskell_non_module_deps_extension.bzl", "haskell_non_module_deps_extension") +haskell_non_module_deps = use_extension("//bazel/extensions:haskell_non_module_deps_extension.bzl", "haskell_non_module_deps_extension") use_repo( haskell_non_module_deps, # "Cabal", @@ -169,13 +169,13 @@ stack_snapshot.package( components = ["exe"], ) -module_temporary_extension = use_extension("//bazel_tools/MODULE_MIGRATION:module_temporary_extension.bzl", "temporary_extension") +module_temporary_extension = use_extension("//bazel/extensions:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "daml_versions_data", "os_info", "scala_version") -dpm_extension = use_extension("//bazel_tools/MODULE_MIGRATION:dpm_extension.bzl", "dpm_extension") +dpm_extension = use_extension("//bazel/extensions:dpm_extension.bzl", "dpm_extension") use_repo(dpm_extension, "dpm_binary") -d3plus_extension = use_extension("//bazel_tools/MODULE_MIGRATION:d3plus_extension.bzl", "d3plus_extension") +d3plus_extension = use_extension("//bazel/extensions:d3plus_extension.bzl", "d3plus_extension") use_repo(d3plus_extension, "static_asset_d3plus") scala_config = use_extension( diff --git a/sdk/bazel_tools/MODULE_MIGRATION/BUILD b/sdk/bazel/extensions/BUILD similarity index 100% rename from sdk/bazel_tools/MODULE_MIGRATION/BUILD rename to sdk/bazel/extensions/BUILD diff --git a/sdk/bazel_tools/MODULE_MIGRATION/d3plus_extension.bzl b/sdk/bazel/extensions/d3plus_extension.bzl similarity index 100% rename from sdk/bazel_tools/MODULE_MIGRATION/d3plus_extension.bzl rename to sdk/bazel/extensions/d3plus_extension.bzl diff --git a/sdk/bazel_tools/MODULE_MIGRATION/dpm_extension.bzl b/sdk/bazel/extensions/dpm_extension.bzl similarity index 100% rename from sdk/bazel_tools/MODULE_MIGRATION/dpm_extension.bzl rename to sdk/bazel/extensions/dpm_extension.bzl diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_cabal.BUILD.bzl b/sdk/bazel/extensions/files/haskell/haskell_cabal.BUILD.bzl similarity index 100% rename from sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_cabal.BUILD.bzl rename to sdk/bazel/extensions/files/haskell/haskell_cabal.BUILD.bzl diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_da_ghc.BUILD.bzl b/sdk/bazel/extensions/files/haskell/haskell_da_ghc.BUILD.bzl similarity index 100% rename from sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_da_ghc.BUILD.bzl rename to sdk/bazel/extensions/files/haskell/haskell_da_ghc.BUILD.bzl diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_ghc_lib_gen.BUILD.bzl b/sdk/bazel/extensions/files/haskell/haskell_ghc_lib_gen.BUILD.bzl similarity index 100% rename from sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_ghc_lib_gen.BUILD.bzl rename to sdk/bazel/extensions/files/haskell/haskell_ghc_lib_gen.BUILD.bzl diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_ghcide_ghc_lib.BUILD.bzl b/sdk/bazel/extensions/files/haskell/haskell_ghcide_ghc_lib.BUILD.bzl similarity index 100% rename from sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_ghcide_ghc_lib.BUILD.bzl rename to sdk/bazel/extensions/files/haskell/haskell_ghcide_ghc_lib.BUILD.bzl diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_lsp_types.BUILD.bzl b/sdk/bazel/extensions/files/haskell/haskell_lsp_types.BUILD.bzl similarity index 100% rename from sdk/bazel_tools/MODULE_MIGRATION/haskell/haskell_lsp_types.BUILD.bzl rename to sdk/bazel/extensions/files/haskell/haskell_lsp_types.BUILD.bzl diff --git a/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl b/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl similarity index 91% rename from sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl rename to sdk/bazel/extensions/haskell_non_module_deps_extension.bzl index c396423b2546..6d5dc430f441 100644 --- a/sdk/bazel_tools/MODULE_MIGRATION/haskell_non_module_deps_extension.bzl +++ b/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl @@ -14,7 +14,7 @@ load( def _get_cabal(): http_archive( name = "Cabal", - build_file = ":haskell/haskell_cabal.BUILD.bzl", + build_file = ":files/haskell/haskell_cabal.BUILD.bzl", sha256 = "b697b558558f351d2704e520e7dcb1f300cd77fea5677d4b2ee71d0b965a4fe9", strip_prefix = "cabal-ghc-9.4-paths-module-relocatable", urls = ["https://github.com/tweag/cabal/archive/refs/heads/ghc-9.4-paths-module-relocatable.zip"], @@ -44,7 +44,7 @@ def _get_ghcide(): http_archive( name = "ghcide_ghc_lib", - build_file = ":haskell/haskell_ghcide_ghc_lib.BUILD.bzl", + build_file = ":files/haskell/haskell_ghcide_ghc_lib.BUILD.bzl", patch_args = ["-p1"], patches = [ "//bazel_tools:haskell-ghcide-binary-q.patch", @@ -60,7 +60,7 @@ def _get_ghc_lib_gen(): url = "{}/archive/{}.tar.gz".format(GHC_LIB_REPO_URL, GHC_LIB_REV), sha256 = GHC_LIB_SHA256, strip_prefix = "ghc-lib-{}".format(GHC_LIB_REV), - build_file = ":haskell/haskell_ghc_lib_gen.BUILD.bzl", + build_file = ":files/haskell/haskell_ghc_lib_gen.BUILD.bzl", patches = GHC_LIB_PATCHES, patch_args = ["-p1"], ) @@ -71,7 +71,7 @@ def _get_da_ghc(): remote = GHC_REPO_URL, commit = GHC_REV, recursive_init_submodules = True, - build_file = ":haskell/haskell_da_ghc.BUILD.bzl", + build_file = ":files/haskell/haskell_da_ghc.BUILD.bzl", shallow_since = "1639050525 +0100", patches = GHC_PATCHES, patch_args = ["-p1"], diff --git a/sdk/bazel_tools/MODULE_MIGRATION/module_temporary_extension.bzl b/sdk/bazel/extensions/module_temporary_extension.bzl similarity index 100% rename from sdk/bazel_tools/MODULE_MIGRATION/module_temporary_extension.bzl rename to sdk/bazel/extensions/module_temporary_extension.bzl diff --git a/sdk/bazel_tools/MODULE_MIGRATION/packaging_extension.bzl b/sdk/bazel/extensions/packaging_extension.bzl similarity index 100% rename from sdk/bazel_tools/MODULE_MIGRATION/packaging_extension.bzl rename to sdk/bazel/extensions/packaging_extension.bzl diff --git a/sdk/bazel/rules/patches/BUILD b/sdk/bazel/rules/patches/BUILD new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/sdk/bazel_tools/MODULE_MIGRATION/rules_haskell_ghc_version.patch b/sdk/bazel/rules/patches/rules_haskell_ghc_version.patch similarity index 100% rename from sdk/bazel_tools/MODULE_MIGRATION/rules_haskell_ghc_version.patch rename to sdk/bazel/rules/patches/rules_haskell_ghc_version.patch From 3f039b4abbe629ade1794dca2d2795150e7372ee Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 16 Mar 2026 18:20:52 +0100 Subject: [PATCH 057/287] feat: Add `@proto3-suite` - BROKEN --- sdk/MODULE.bazel | 8 +++ .../extensions/files/proto3_suite.BUILD.bzl | 27 +++++++ .../extensions/proto3_suite_extension.bzl | 20 ++++++ .../proto3_suite/deriving_defaults.patch} | 0 .../support_reserved_enums.patch} | 0 sdk/libs-haskell/google-proto-hs/BUILD.bazel | 70 ++++++++++++++++++- 6 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 sdk/bazel/extensions/files/proto3_suite.BUILD.bzl create mode 100644 sdk/bazel/extensions/proto3_suite_extension.bzl rename sdk/{bazel_tools/haskell_proto3_suite_deriving_defaults.patch => bazel/patches/proto3_suite/deriving_defaults.patch} (100%) rename sdk/{bazel_tools/haskell_proto3_support_reserved_enums.patch => bazel/patches/proto3_suite/support_reserved_enums.patch} (100%) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 82e88ed649f5..86c67cb92d18 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -168,6 +168,11 @@ stack_snapshot.package( name = "alex", components = ["exe"], ) +stack_snapshot.package( + name = "proto3-suite", + flags = ["-swagger"], + vendored = "@proto3-suite//:proto3-suite", +) module_temporary_extension = use_extension("//bazel/extensions:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "daml_versions_data", "os_info", "scala_version") @@ -178,6 +183,9 @@ use_repo(dpm_extension, "dpm_binary") d3plus_extension = use_extension("//bazel/extensions:d3plus_extension.bzl", "d3plus_extension") use_repo(d3plus_extension, "static_asset_d3plus") +proto3_suite = use_extension("//bazel/extensions:proto3_suite_extension.bzl", "proto3_suite_extension") +use_repo(proto3_suite, "proto3-suite") + scala_config = use_extension( "@rules_scala//scala/extensions:config.bzl", "scala_config", diff --git a/sdk/bazel/extensions/files/proto3_suite.BUILD.bzl b/sdk/bazel/extensions/files/proto3_suite.BUILD.bzl new file mode 100644 index 000000000000..691da985a222 --- /dev/null +++ b/sdk/bazel/extensions/files/proto3_suite.BUILD.bzl @@ -0,0 +1,27 @@ +load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") + +# XXX: haskell_cabal_binary inexplicably fails with +# realgcc.exe: error: CreateProcess: No such file or directory +# So we use haskell_binary instead. +load("@rules_haskell//haskell:defs.bzl", "haskell_binary") +load("@stackage//:packages.bzl", "packages") + +deps = [p for p in packages["proto3-suite"].deps if p != "swagger2"] +haskell_cabal_library( + name = "proto3-suite", + version = packages["proto3-suite"].version, + srcs = glob(["src/**", "test-files/*.bin", "tests/*", "proto3-suite.cabal"]), + haddock = False, + deps = deps, + verbose = False, + visibility = ["//visibility:public"], + flags = ["-swagger"], +) + +haskell_binary( + name = "compile-proto-file", + srcs = ["tools/compile-proto-file/Main.hs"], + ghcopts = ["-w", "-optF=-w"], + deps = [":proto3-suite"] + deps, + visibility = ["//visibility:public"], +) diff --git a/sdk/bazel/extensions/proto3_suite_extension.bzl b/sdk/bazel/extensions/proto3_suite_extension.bzl new file mode 100644 index 000000000000..9eb9022715df --- /dev/null +++ b/sdk/bazel/extensions/proto3_suite_extension.bzl @@ -0,0 +1,20 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _impl(module_ctx): + PROTO3SUITE_REV = "0.5.1" + PROTO3SUITE_SHA256 = "6e6d514867e8efe90fe6a7e5167b86260da00fdb7ef335af694295a1adde57f4" + + http_archive( + name = "proto3-suite", + build_file = ":files/proto3_suite.BUILD.bzl", + sha256 = PROTO3SUITE_SHA256, + strip_prefix = "proto3-suite-{}".format(PROTO3SUITE_REV), + urls = ["https://github.com/awakesecurity/proto3-suite/archive/refs/tags/v{}.tar.gz".format(PROTO3SUITE_REV)], + patches = [ + "//bazel/patches:proto3_suite/deriving_defaults.patch", + "//bazel/patches:proto3_suite/support_reserved_enums.patch", + ], + patch_args = ["-p1"], + ) + +proto3_suite_extension = module_extension(implementation = _impl) diff --git a/sdk/bazel_tools/haskell_proto3_suite_deriving_defaults.patch b/sdk/bazel/patches/proto3_suite/deriving_defaults.patch similarity index 100% rename from sdk/bazel_tools/haskell_proto3_suite_deriving_defaults.patch rename to sdk/bazel/patches/proto3_suite/deriving_defaults.patch diff --git a/sdk/bazel_tools/haskell_proto3_support_reserved_enums.patch b/sdk/bazel/patches/proto3_suite/support_reserved_enums.patch similarity index 100% rename from sdk/bazel_tools/haskell_proto3_support_reserved_enums.patch rename to sdk/bazel/patches/proto3_suite/support_reserved_enums.patch diff --git a/sdk/libs-haskell/google-proto-hs/BUILD.bazel b/sdk/libs-haskell/google-proto-hs/BUILD.bazel index 397af3b34336..68fe0b178b08 100644 --- a/sdk/libs-haskell/google-proto-hs/BUILD.bazel +++ b/sdk/libs-haskell/google-proto-hs/BUILD.bazel @@ -5,7 +5,7 @@ google_protobuf_src = "external/com_google_protobuf/src" genrule( name = "google-protobuf-pb-sources", - srcs = ["@com_google_protobuf//:well_known_type_protos"], + srcs = ["@protobuf//:well_known_type_protos"], outs = ["Google/Protobuf/" + b for b in [ "Any.hs", "Duration.hs", @@ -49,7 +49,7 @@ genrule( name = "google-rpc-pb-sources", srcs = [ ":google-rpc-source-protos", - "@com_google_protobuf//:well_known_type_protos", + "@protobuf//:well_known_type_protos", ], outs = [ "Google/Rpc/Status.hs", @@ -69,3 +69,69 @@ genrule( ], visibility = ["//visibility:public"], ) + +filegroup( + name = "ledger-api-protos-fg", + srcs = glob(["src/protobuf/**/*.proto"]), +) + +genrule( + name = "ledger-api-pb-sources", + srcs = [ + "@protobuf//:well_known_type_protos", + "@go_googleapis//google/rpc:status.proto", + "ledger-api-protos-fg", + ], + outs = [ + "Com/Daml/Ledger/Api/V2/PackageService.hs", + "Com/Daml/Ledger/Api/V2/PackageReference.hs", + "Com/Daml/Ledger/Api/V2/Admin/PackageManagementService.hs", + "Com/Daml/Ledger/Api/V2/Admin/PartyManagementService.hs", + "Com/Daml/Ledger/Api/V2/Admin/ObjectMeta.hs", + "Com/Daml/Ledger/Api/V2/Admin/UserManagementService.hs", + ], + cmd = """ + for src in $(locations :ledger-api-protos-fg); do + $(location @proto3-suite//:compile-proto-file) \ + --includeDir """ + google_protobuf_src + """ \ + --includeDir """ + google_rpc_src + """ \ + --includeDir libs-haskell/ledger-api-pb/src/protobuf \ + --proto $${src#libs-haskell/ledger-api-pb/src/protobuf/} \ + --out $(@D) + done + """, + tools = [ + "@proto3-suite//:compile-proto-file", + ], +) + +filegroup( + name = "all-ledger-api-pb-sources", + srcs = [ + ":google-protobuf-pb-sources", + ":google-rpc-pb-sources", + ":ledger-api-pb-sources", + ], + visibility = ["//visibility:public"], +) + +da_haskell_library( + name = "ledger-api-pb", + srcs = [":all-ledger-api-pb-sources"], + compiler_flags = [ + "-O0", + ], + hackage_deps = [ + "base", + "bytestring", + "containers", + "deepseq", + "grpc-haskell", + "grpc-haskell-core", + "proto3-suite", + "proto3-wire", + "text", + "vector", + ], + visibility = ["//visibility:public"], +) From 31c2458e77eeb7abf2c764b72e6f41b0b414de15 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 19 Mar 2026 17:14:01 +0100 Subject: [PATCH 058/287] fix: Apply missing patch BUILD file --- sdk/bazel/patches/BUILD | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sdk/bazel/patches/BUILD diff --git a/sdk/bazel/patches/BUILD b/sdk/bazel/patches/BUILD new file mode 100644 index 000000000000..e69de29bb2d1 From d3525db6140ee27b57938a6a70e0dd2589bcf4fb Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 19 Mar 2026 18:23:57 +0100 Subject: [PATCH 059/287] feat: Enable `@stackage-exe//hpp` --- sdk/MODULE.bazel | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 86c67cb92d18..5755eda766ce 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -168,6 +168,10 @@ stack_snapshot.package( name = "alex", components = ["exe"], ) +stack_snapshot.package( + name = "hpp", + components = ["lib", "exe"], +) stack_snapshot.package( name = "proto3-suite", flags = ["-swagger"], From 71934d7033e4b9013c303b25a8c19bbd63b97649 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 20 Mar 2026 12:27:21 +0100 Subject: [PATCH 060/287] feat: Add `@go_googleapis` --- sdk/MODULE.bazel | 8 ++++++- .../extensions/go_googleapis_extension.bzl | 24 +++++++++++++++++++ .../patches/go_googleapis/status-proto.patch | 12 ++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 sdk/bazel/extensions/go_googleapis_extension.bzl create mode 100644 sdk/bazel/patches/go_googleapis/status-proto.patch diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 5755eda766ce..e8b4e1d05bcb 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -170,7 +170,10 @@ stack_snapshot.package( ) stack_snapshot.package( name = "hpp", - components = ["lib", "exe"], + components = [ + "lib", + "exe", + ], ) stack_snapshot.package( name = "proto3-suite", @@ -187,6 +190,9 @@ use_repo(dpm_extension, "dpm_binary") d3plus_extension = use_extension("//bazel/extensions:d3plus_extension.bzl", "d3plus_extension") use_repo(d3plus_extension, "static_asset_d3plus") +googleapis_extenstion = use_extension("//bazel/extensions:go_googleapis_extension.bzl", "googleapis_extension") +use_repo(googleapis_extenstion, "go_googleapis") + proto3_suite = use_extension("//bazel/extensions:proto3_suite_extension.bzl", "proto3_suite_extension") use_repo(proto3_suite, "proto3-suite") diff --git a/sdk/bazel/extensions/go_googleapis_extension.bzl b/sdk/bazel/extensions/go_googleapis_extension.bzl new file mode 100644 index 000000000000..5bfdca3a0f1f --- /dev/null +++ b/sdk/bazel/extensions/go_googleapis_extension.bzl @@ -0,0 +1,24 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _impl(module_ctx): + GOOGLEAPIS_VERSION = "83c3605afb5a39952bf0a0809875d41cf2a558ca" + GOOGLEAPIS_SHA256 = "ba694861340e792fd31cb77274eacaf6e4ca8bda97707898f41d8bebfd8a4984" + + http_archive( + name = "go_googleapis", + # We must use the same version as rules_go + # master, as of 2022-12-05 + urls = [ + "https://mirror.bazel.build/github.com/googleapis/googleapis/archive/{}.zip".format(GOOGLEAPIS_VERSION), + "https://github.com/googleapis/googleapis/archive/{}.zip".format(GOOGLEAPIS_VERSION), + ], + sha256 = GOOGLEAPIS_SHA256, + strip_prefix = "googleapis-{}".format(GOOGLEAPIS_VERSION), + patches = [ + # The Haskell gRPC bindings require access to the status.proto source file. + "//bazel/patches:go_googleapis/status-proto.patch", + ], + patch_args = ["-E", "-p1"], + ) + +googleapis_extension = module_extension(implementation = _impl) diff --git a/sdk/bazel/patches/go_googleapis/status-proto.patch b/sdk/bazel/patches/go_googleapis/status-proto.patch new file mode 100644 index 000000000000..1ca75cb04013 --- /dev/null +++ b/sdk/bazel/patches/go_googleapis/status-proto.patch @@ -0,0 +1,12 @@ +diff --git a/google/rpc/BUILD.bazel b/google/rpc/BUILD.bazel +index 8ffa5a49c..eb0a8127b 100644 +--- a/google/rpc/BUILD.bazel ++++ b/google/rpc/BUILD.bazel +@@ -1,5 +1,7 @@ + load("@rules_proto//proto:defs.bzl", "proto_library") + ++exports_files(["status.proto", "error_details.proto"]) ++ + # This is an API workspace, having public visibility by default makes perfect sense. + package(default_visibility = ["//visibility:public"]) + From 927ec9613443752052383c4e6c025639769f1d3f Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 20 Mar 2026 15:47:52 +0100 Subject: [PATCH 061/287] feat: Add `com_google_googleapis_imports` --- sdk/MODULE.bazel | 3 +++ .../extensions/go_googleapis_import_extension.bzl | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 sdk/bazel/extensions/go_googleapis_import_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index e8b4e1d05bcb..d18959368b59 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -193,6 +193,9 @@ use_repo(d3plus_extension, "static_asset_d3plus") googleapis_extenstion = use_extension("//bazel/extensions:go_googleapis_extension.bzl", "googleapis_extension") use_repo(googleapis_extenstion, "go_googleapis") +import_googleapis_extenstion = use_extension("//bazel/extensions:go_googleapis_import_extension.bzl", "import_googleapis_extension") +use_repo(import_googleapis_extenstion, "com_google_googleapis_imports") + proto3_suite = use_extension("//bazel/extensions:proto3_suite_extension.bzl", "proto3_suite_extension") use_repo(proto3_suite, "proto3-suite") diff --git a/sdk/bazel/extensions/go_googleapis_import_extension.bzl b/sdk/bazel/extensions/go_googleapis_import_extension.bzl new file mode 100644 index 000000000000..e6a22ab7f722 --- /dev/null +++ b/sdk/bazel/extensions/go_googleapis_import_extension.bzl @@ -0,0 +1,10 @@ +load("@go_googleapis//:repository_rules.bzl", "switched_rules_by_language") + +def _impl(module_ctx): + switched_rules_by_language( + name = "com_google_googleapis_imports", + grpc = True, + java = True, + ) + +import_googleapis_extension = module_extension(implementation = _impl) From 1394cfbde4952d7398990815276cc24f2daca311 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 20 Mar 2026 15:54:01 +0100 Subject: [PATCH 062/287] feat: Add `@rules_proto` --- sdk/MODULE.bazel | 6 ++++++ .../extensions/deprecated/rules_proto_extension.bzl | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 sdk/bazel/extensions/deprecated/rules_proto_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index d18959368b59..08b8c6684864 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -245,3 +245,9 @@ maven.install( ], ) use_repo(maven, "maven") + +# # # +# DEPRECATED +rules_proto_extenstion = use_extension("//bazel/extensions:deprecated/rules_proto_extension.bzl", "rules_proto_extension") +use_repo(rules_proto_extenstion, "rules_proto") +# # # \ No newline at end of file diff --git a/sdk/bazel/extensions/deprecated/rules_proto_extension.bzl b/sdk/bazel/extensions/deprecated/rules_proto_extension.bzl new file mode 100644 index 000000000000..1b6ece693712 --- /dev/null +++ b/sdk/bazel/extensions/deprecated/rules_proto_extension.bzl @@ -0,0 +1,13 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +# TODO: This is deprecated rules, check https://github.com/protocolbuffers/protobuf for newer version +# Check https://github.com/bazelbuild/rules_proto for current version and annotation +def _impl(module_ctx): + http_archive( + name = "rules_proto", + sha256 = "303e86e722a520f6f326a50b41cfc16b98fe6d1955ce46642a5b7a67c11c0f5d", + strip_prefix = "rules_proto-6.0.0", + url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0/rules_proto-6.0.0.tar.gz", + ) + +rules_proto_extension = module_extension(implementation = _impl) From 2d06677ec3c1e29064a33425a9fee4ae65cb0ad0 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 20 Mar 2026 16:00:41 +0100 Subject: [PATCH 063/287] feat: Add `@rules_proto` --- sdk/MODULE.bazel | 3 +++ .../deprecated/io_grpc_grpc_java_extension.bzl | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 sdk/bazel/extensions/deprecated/io_grpc_grpc_java_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 08b8c6684864..312e15bc3d77 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -250,4 +250,7 @@ use_repo(maven, "maven") # DEPRECATED rules_proto_extenstion = use_extension("//bazel/extensions:deprecated/rules_proto_extension.bzl", "rules_proto_extension") use_repo(rules_proto_extenstion, "rules_proto") + +io_grpc_grpc_java_extension = use_extension("//bazel/extensions:deprecated/io_grpc_grpc_java_extension.bzl", "io_grpc_grpc_java_extension") +use_repo(io_grpc_grpc_java_extension, "io_grpc_grpc_java") # # # \ No newline at end of file diff --git a/sdk/bazel/extensions/deprecated/io_grpc_grpc_java_extension.bzl b/sdk/bazel/extensions/deprecated/io_grpc_grpc_java_extension.bzl new file mode 100644 index 000000000000..d8ffc05c780d --- /dev/null +++ b/sdk/bazel/extensions/deprecated/io_grpc_grpc_java_extension.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _impl(module_ctx): + http_archive( + name = "io_grpc_grpc_java", + strip_prefix = "grpc-java-1.60.2", + urls = ["https://github.com/grpc/grpc-java/archive/v1.60.2.tar.gz"], + sha256 = "4baf80f35488739d99515d71b8e72bd17a476c214a84106edc66b259fe8ac22c", + ) + +io_grpc_grpc_java_extension = module_extension(implementation = _impl) From 401d479c91d76011bfa39deb5d537be08fe6ce9c Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 20 Mar 2026 17:07:33 +0100 Subject: [PATCH 064/287] feat: Enable `@zip//:zip` --- sdk/MODULE.bazel | 11 ++++ .../files/haskell/haskell_zip.BUILD.bzl | 13 +++++ .../haskell_non_module_deps_extension.bzl | 16 ++++++ sdk/bazel/patches/haskell/zip.patch | 57 +++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 sdk/bazel/extensions/files/haskell/haskell_zip.BUILD.bzl create mode 100644 sdk/bazel/patches/haskell/zip.patch diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 312e15bc3d77..d238175b83f2 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -49,6 +49,7 @@ use_repo( "ghc-lib-gen", "ghcide_ghc_lib", "lsp-types", + "zip", ) stack_snapshot = use_extension( @@ -160,6 +161,16 @@ stack_snapshot.package( flags = ["ghc-lib"], vendored = "@ghcide_ghc_lib//:ghcide", ) +stack_snapshot.package( + name = "proto3-suite", + flags = ["-swagger"], + vendored = "@proto3-suite//:proto3-suite", +) +stack_snapshot.package( + name = "zip", + vendored = "@zip//:zip", +) + stack_snapshot.package( name = "happy", components = ["exe"], diff --git a/sdk/bazel/extensions/files/haskell/haskell_zip.BUILD.bzl b/sdk/bazel/extensions/files/haskell/haskell_zip.BUILD.bzl new file mode 100644 index 000000000000..32161d1c0f6d --- /dev/null +++ b/sdk/bazel/extensions/files/haskell/haskell_zip.BUILD.bzl @@ -0,0 +1,13 @@ +load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") +load("@stackage//:packages.bzl", "packages") + +haskell_cabal_library( + name = "zip", + version = packages["zip"].version, + srcs = glob(["**"]), + haddock = False, + deps = packages["zip"].deps, + verbose = False, + visibility = ["//visibility:public"], + flags = packages["zip"].flags, +) diff --git a/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl b/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl index 6d5dc430f441..8004ebbb7b19 100644 --- a/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl +++ b/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl @@ -77,10 +77,26 @@ def _get_da_ghc(): patch_args = ["-p1"], ) +def _get_zip(): + ZIP_VERSION = "1.7.1" + + http_archive( + name = "zip", + build_file = ":files/haskell/haskell_zip.BUILD.bzl", + patch_args = ["-p1"], + patches = [ + "//bazel/patches:haskell/zip.patch", + ], + sha256 = "0d7f02bbdf6c49e9a33d2eca4b3d7644216a213590866dafdd2b47ddd38eb746", + strip_prefix = "zip-{}".format(ZIP_VERSION), + urls = ["http://hackage.haskell.org/package/zip-{version}/zip-{version}.tar.gz".format(version = ZIP_VERSION)], + ) + def _impl(module_ctx): _get_lsp_types() _get_ghcide() _get_ghc_lib_gen() _get_da_ghc() + _get_zip() haskell_non_module_deps_extension = module_extension(implementation = _impl) diff --git a/sdk/bazel/patches/haskell/zip.patch b/sdk/bazel/patches/haskell/zip.patch new file mode 100644 index 000000000000..46440bbc72ef --- /dev/null +++ b/sdk/bazel/patches/haskell/zip.patch @@ -0,0 +1,57 @@ +The use of temp files in `zip` sadly runs into an issue +with GHC’s `openBinaryTempFile` function which seems +to have a race condition where multiple processes can get +the same temp file name. Then one process will move away the temp +file of the other process resulting in the following error: + +damlc.exe: C:\users\\…\\ghc77D0.zip" Just "\\\\?\\C:\\users\\…\\daml-script-1.dev.dar": does not exist (The system cannot find the file specified.) + +We don’t need the atomic write of the zip (DAR) file here so +we simply patch `zip` to write to the file directly. +It doesn’t really make sense to upstream this. The code in the +zip library is correct, it’s `openBinaryTempFile` that is broken. + +diff --git a/Codec/Archive/Zip/Internal.hs b/Codec/Archive/Zip/Internal.hs +index b3fa27f..31e34b0 100644 +--- a/Codec/Archive/Zip/Internal.hs ++++ b/Codec/Archive/Zip/Internal.hs +@@ -27,7 +27,6 @@ import Codec.Archive.Zip.CP437 (decodeCP437) + import Codec.Archive.Zip.Type + import Conduit (PrimMonad) + import Control.Applicative (many, (<|>)) +-import Control.Exception (bracketOnError, catchJust) + import Control.Monad + import Control.Monad.Catch (MonadThrow (..)) + import Control.Monad.Trans.Maybe +@@ -60,10 +59,7 @@ import Data.Version + import Data.Void + import Data.Word (Word16, Word32) + import Numeric.Natural (Natural) +-import System.Directory +-import System.FilePath + import System.IO +-import System.IO.Error (isDoesNotExistError) + + #ifndef mingw32_HOST_OS + import qualified Codec.Archive.Zip.Unix as Unix +@@ -302,19 +298,7 @@ withNewFile :: + (Handle -> IO ()) -> + IO () + withNewFile fpath action = +- bracketOnError allocate release $ \(path, h) -> do +- action h +- hClose h +- renameFile path fpath +- where +- allocate = openBinaryTempFile (takeDirectory fpath) ".zip" +- release (path, h) = do +- hClose h +- -- Despite using `bracketOnError` the file is not guaranteed to exist +- -- here since we could be interrupted with an async exception after +- -- the file has been renamed. Therefore, we silentely ignore +- -- `DoesNotExistError`. +- catchJust (guard . isDoesNotExistError) (removeFile path) (const $ pure ()) ++ withBinaryFile fpath ReadWriteMode action + + -- | Determine what comment in new archive will look like given its original + -- value and a collection of pending actions. From cc7028c19ae76bd7aad27e776744735c939ba43b Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 20 Mar 2026 17:17:59 +0100 Subject: [PATCH 065/287] chore: Remove `packaging_extension.bzl` --- sdk/bazel/extensions/packaging_extension.bzl | 30 -------------------- 1 file changed, 30 deletions(-) delete mode 100644 sdk/bazel/extensions/packaging_extension.bzl diff --git a/sdk/bazel/extensions/packaging_extension.bzl b/sdk/bazel/extensions/packaging_extension.bzl deleted file mode 100644 index da983c00fbc4..000000000000 --- a/sdk/bazel/extensions/packaging_extension.bzl +++ /dev/null @@ -1,30 +0,0 @@ -load("//bazel_tools/dev_env_tool:dev_env_tool.bzl", "dev_env_tool") - -def _impl(module_ctx): - """ - Note: - This should be later migrated to use bazel defined toolset, not - one from dev_env - """ - dev_env_tool( - name = "tar_dev_env", - nix_include = ["bin/tar"], - nix_label = "@tar_nix", - nix_paths = ["bin/tar"], - tools = ["tar"], - win_include = ["usr/bin/tar.exe"], - win_paths = ["usr/bin/tar.exe"], - win_tool = "msys2", - ) - dev_env_tool( - name = "gzip_dev_env", - nix_include = ["bin/gzip"], - nix_label = "@gzip_nix", - nix_paths = ["bin/gzip"], - tools = ["gzip"], - win_include = ["usr/bin/gzip.exe"], - win_paths = ["usr/bin/gzip.exe"], - win_tool = "msys2", - ) - -packaging_extension = module_extension(implementation = _impl) \ No newline at end of file From 36cde8375bbb915ce120a8e1fed122f7a45110c6 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Fri, 20 Mar 2026 17:45:45 +0100 Subject: [PATCH 066/287] chore: Cleanup the structure and file names --- sdk/MODULE.bazel | 5 --- .../haskell_non_module_deps_extension.bzl | 12 +++-- .../patches/haskell/ghc_lib_no_stack.patch | 35 +++++++++++++++ .../patches/haskell/ghcide_binary_q.patch | 20 +++++++++ .../lsp_types_expose_other_modules.patch | 20 +++++++++ .../haskell/lsp_types_normalisation.patch | 44 +++++++++++++++++++ 6 files changed, 124 insertions(+), 12 deletions(-) create mode 100644 sdk/bazel/patches/haskell/ghc_lib_no_stack.patch create mode 100644 sdk/bazel/patches/haskell/ghcide_binary_q.patch create mode 100644 sdk/bazel/patches/haskell/lsp_types_expose_other_modules.patch create mode 100644 sdk/bazel/patches/haskell/lsp_types_normalisation.patch diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index d238175b83f2..6b68f2508f84 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -186,11 +186,6 @@ stack_snapshot.package( "exe", ], ) -stack_snapshot.package( - name = "proto3-suite", - flags = ["-swagger"], - vendored = "@proto3-suite//:proto3-suite", -) module_temporary_extension = use_extension("//bazel/extensions:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_extension, "build_environment", "daml_versions_data", "os_info", "scala_version") diff --git a/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl b/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl index 8004ebbb7b19..f059bc2b370f 100644 --- a/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl +++ b/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl @@ -29,8 +29,8 @@ def _get_lsp_types(): build_file = ":haskell/haskell_lsp_types.BUILD.bzl", patch_args = ["-p1"], patches = [ - "//bazel_tools:lsp-types-normalisation.patch", - "//bazel_tools:lsp-types-expose-other-modules.patch", + "//bazel/patches:haskell/lsp_types_normalisation.patch", + "//bazel/patches:haskell/lsp_types_expose_other_modules.patch", ], sha256 = LSP_TYPES_SHA256, strip_prefix = "lsp-types-{}".format(LSP_TYPES_VERSION), @@ -47,7 +47,7 @@ def _get_ghcide(): build_file = ":files/haskell/haskell_ghcide_ghc_lib.BUILD.bzl", patch_args = ["-p1"], patches = [ - "//bazel_tools:haskell-ghcide-binary-q.patch", + "//bazel/patches:haskell/ghcide_binary_q.patch", ], sha256 = None if GHCIDE_LOCAL_PATH != None else GHCIDE_SHA256, strip_prefix = None if GHCIDE_LOCAL_PATH != None else "daml-ghcide-%s" % GHCIDE_REV, @@ -61,7 +61,7 @@ def _get_ghc_lib_gen(): sha256 = GHC_LIB_SHA256, strip_prefix = "ghc-lib-{}".format(GHC_LIB_REV), build_file = ":files/haskell/haskell_ghc_lib_gen.BUILD.bzl", - patches = GHC_LIB_PATCHES, + patches = ["//bazel/patches:haskell/ghc_lib_no_stack.patch"], patch_args = ["-p1"], ) @@ -84,9 +84,7 @@ def _get_zip(): name = "zip", build_file = ":files/haskell/haskell_zip.BUILD.bzl", patch_args = ["-p1"], - patches = [ - "//bazel/patches:haskell/zip.patch", - ], + patches = ["//bazel/patches:haskell/zip.patch"], sha256 = "0d7f02bbdf6c49e9a33d2eca4b3d7644216a213590866dafdd2b47ddd38eb746", strip_prefix = "zip-{}".format(ZIP_VERSION), urls = ["http://hackage.haskell.org/package/zip-{version}/zip-{version}.tar.gz".format(version = ZIP_VERSION)], diff --git a/sdk/bazel/patches/haskell/ghc_lib_no_stack.patch b/sdk/bazel/patches/haskell/ghc_lib_no_stack.patch new file mode 100644 index 000000000000..e7119de52c57 --- /dev/null +++ b/sdk/bazel/patches/haskell/ghc_lib_no_stack.patch @@ -0,0 +1,35 @@ +diff --git a/ghc-lib-gen/src/Ghclibgen.hs b/ghc-lib-gen/src/Ghclibgen.hs +index 3574255..4fee612 100644 +--- a/ghc-lib-gen/src/Ghclibgen.hs ++++ b/ghc-lib-gen/src/Ghclibgen.hs +@@ -336,10 +336,7 @@ calcParserModules ghcFlavor = do + hsSrcIncludes = map ("-i" ++ ) (placeholderModulesDir : hsSrcDirs) + -- See [Note: GHC now depends on exceptions package]. + cmd = unwords $ +- [ "stack exec" ] ++ +- [ "--package exceptions" | ghcFlavor >= Ghc901 ] ++ +- [ "--stack-yaml hadrian/stack.yaml" ] ++ +- [ "-- ghc" ++ [ "ghc" + , "-dep-suffix ''" + , "-dep-makefile .parser-depends" + , "-M" +@@ -1258,15 +1255,13 @@ generatePrerequisites ghcFlavor = do + -- If building happy in the next step, the configure it does + -- requires some versions of alex and happy pre-exist. We make sure + -- of this in CI.hs. +- system_ "stack --stack-yaml hadrian/stack.yaml build --only-dependencies" +- system_ "stack --stack-yaml hadrian/stack.yaml exec -- bash -c ./boot" +- system_ "stack --stack-yaml hadrian/stack.yaml exec -- bash -c \"./configure --enable-tarballs-autodownload\"" ++ system_ "bash -c \"./boot --hadrian\"" ++ system_ "bash -c \"./configure --enable-tarballs-autodownload\"" + withCurrentDirectory "hadrian" $ do + -- No need to specify a stack.yaml here, we are in the hadrian + -- directory itself. +- system_ "stack build --no-library-profiling" + system_ $ unwords $ +- [ "stack exec hadrian --" ++ [ "hadrian" + , "--directory=.." + , "--build-root=ghc-lib" + ] ++ diff --git a/sdk/bazel/patches/haskell/ghcide_binary_q.patch b/sdk/bazel/patches/haskell/ghcide_binary_q.patch new file mode 100644 index 000000000000..05d61b2d0abd --- /dev/null +++ b/sdk/bazel/patches/haskell/ghcide_binary_q.patch @@ -0,0 +1,20 @@ +diff --git a/src/Development/IDE/Core/Shake.hs b/src/Development/IDE/Core/Shake.hs +index a471070..a2b3183 100644 +--- a/src/Development/IDE/Core/Shake.hs ++++ b/src/Development/IDE/Core/Shake.hs +@@ -503,7 +503,14 @@ isBadDependency x + newtype Q k = Q (k, NormalizedFilePath) + deriving (Eq,Hashable,NFData, Generic) + +-instance Binary k => Binary (Q k) ++instance Binary k => Binary (Q k) where ++ put (Q (k, fp)) = put (k, fp) ++ get = do ++ (k, fp) <- get ++ -- The `get` implementation of NormalizedFilePath ++ -- does not handle empty file paths so we ++ -- need to handle this ourselves here. ++ pure (Q (k, toNormalizedFilePath' fp)) + + instance Show k => Show (Q k) where + show (Q (k, file)) = show k ++ "; " ++ fromNormalizedFilePath file diff --git a/sdk/bazel/patches/haskell/lsp_types_expose_other_modules.patch b/sdk/bazel/patches/haskell/lsp_types_expose_other_modules.patch new file mode 100644 index 000000000000..eafabbfcc91f --- /dev/null +++ b/sdk/bazel/patches/haskell/lsp_types_expose_other_modules.patch @@ -0,0 +1,20 @@ +diff --git a/lsp-types.cabal b/lsp-types.cabal +index 1af6907..1443cc0 100644 +--- a/lsp-types.cabal ++++ b/lsp-types.cabal +@@ -21,6 +21,7 @@ library + , Language.LSP.Types.Capabilities + , Language.LSP.Types.Lens + , Language.LSP.Types.SMethodMap ++ , Language.LSP.Types.Utils + , Language.LSP.VFS + , Data.IxMap + other-modules: Language.LSP.Types.CallHierarchy +@@ -63,7 +64,6 @@ library + , Language.LSP.Types.TextDocument + , Language.LSP.Types.TypeDefinition + , Language.LSP.Types.Uri +- , Language.LSP.Types.Utils + , Language.LSP.Types.Window + , Language.LSP.Types.WatchedFiles + , Language.LSP.Types.WorkspaceEdit diff --git a/sdk/bazel/patches/haskell/lsp_types_normalisation.patch b/sdk/bazel/patches/haskell/lsp_types_normalisation.patch new file mode 100644 index 000000000000..df2212488ee2 --- /dev/null +++ b/sdk/bazel/patches/haskell/lsp_types_normalisation.patch @@ -0,0 +1,44 @@ +diff --git a/src/Language/LSP/Types/Uri.hs b/src/Language/LSP/Types/Uri.hs +index 8d2d43f..8477dde 100644 +--- a/src/Language/LSP/Types/Uri.hs ++++ b/src/Language/LSP/Types/Uri.hs +@@ -112,12 +112,12 @@ platformAdjustFromUriPath systemOS authority srcPath = + else let + firstSegment:rest = (FPP.splitDirectories . tail) srcPath -- Drop leading '/' for absolute Windows paths + drive = if FPW.isDrive firstSegment +- then FPW.addTrailingPathSeparator firstSegment ++ then FPP.addTrailingPathSeparator firstSegment + else firstSegment +- in FPW.joinDrive drive $ FPW.joinPath rest ++ in FPP.joinDrive drive $ FPP.joinPath rest + + filePathToUri :: FilePath -> Uri +-filePathToUri = (platformAwareFilePathToUri System.Info.os) . FP.normalise ++filePathToUri = (platformAwareFilePathToUri System.Info.os) . normalise' + + {-# WARNING platformAwareFilePathToUri "This function is considered private. Use normalizedUriToFilePath instead." #-} + platformAwareFilePathToUri :: SystemOS -> FilePath -> Uri +@@ -193,10 +193,22 @@ instance Hashable NormalizedFilePath where + instance IsString NormalizedFilePath where + fromString = toNormalizedFilePath + ++-- | Normalise a file path, but always convert to POSIX style file paths. ++normalise' :: FilePath -> FilePath ++normalise' fp = nfp ++ where ++ (drv, nfp0) = FP.splitDrive fp ++ nfp = convertDrive drv `FPP.joinDrive` (FPP.joinPath $ FP.splitDirectories nfp0) ++ ++ convertDrive drv ++ | System.Info.os == windowsOS && FPW.hasTrailingPathSeparator drv = ++ FPP.addTrailingPathSeparator (init drv) ++ | otherwise = drv ++ + toNormalizedFilePath :: FilePath -> NormalizedFilePath + toNormalizedFilePath fp = normalizedFilePath nuri nfp + where +- nfp = FP.normalise fp ++ nfp = normalise' fp + nuri = internalNormalizedFilePathToUri nfp + + fromNormalizedFilePath :: NormalizedFilePath -> FilePath From 86aa5f0488ff3b4b39fdaae0e4e977b6926da624 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 25 Mar 2026 12:59:03 +0100 Subject: [PATCH 067/287] feat: Add `@ncurses//:libs` lib to replace `@nix_ghc_lib_deps//:libs` --- sdk/MODULE.bazel | 6 ++ .../extensions/files/libs/ncurses.BUILD.bzl | 58 +++++++++++++++++++ .../extensions/lib_ncurses_extension.bzl | 12 ++++ 3 files changed, 76 insertions(+) create mode 100644 sdk/bazel/extensions/files/libs/ncurses.BUILD.bzl create mode 100644 sdk/bazel/extensions/lib_ncurses_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 6b68f2508f84..e82f06decc98 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -259,4 +259,10 @@ use_repo(rules_proto_extenstion, "rules_proto") io_grpc_grpc_java_extension = use_extension("//bazel/extensions:deprecated/io_grpc_grpc_java_extension.bzl", "io_grpc_grpc_java_extension") use_repo(io_grpc_grpc_java_extension, "io_grpc_grpc_java") +# # # + +# # # +# Libs +ncurses = use_extension("//bazel/extensions:lib_ncurses_extension.bzl", "ncurses") +use_repo(ncurses, "ncurses") # # # \ No newline at end of file diff --git a/sdk/bazel/extensions/files/libs/ncurses.BUILD.bzl b/sdk/bazel/extensions/files/libs/ncurses.BUILD.bzl new file mode 100644 index 000000000000..d472577d6904 --- /dev/null +++ b/sdk/bazel/extensions/files/libs/ncurses.BUILD.bzl @@ -0,0 +1,58 @@ +genrule( + name = "ncurses_build", + srcs = glob(["**"]), + outs = [ + "lib/libtinfow.so", + "lib/libncursesw.so", + "lib/libformw.so", + "lib/libmenuw.so", + "lib/libpanelw.so", + "lib/libtinfo.so", + "lib/libncurses.so", + "lib/libform.so", + "lib/libmenu.so", + "lib/libpanel.so", + ], + cmd = """ + SRC=$$(dirname $(location configure)) + PREFIX=$$(realpath $(@D)) + cd $$SRC && CC="$(CC)" AR="$(AR)" \ + ./configure \ + --prefix=$$PREFIX \ + --with-shared \ + --with-termlib \ + --enable-widec \ + --without-debug \ + --without-ada \ + --without-manpages \ + --without-tests \ + && make -j$$(nproc) CC="$(CC)" AR="$(AR)" \ + && make install \ + && cd $$PREFIX/lib \ + && for f in *.so; do \ + if [ -L "$$f" ]; then \ + target=$$(readlink -f "$$f"); \ + rm "$$f"; \ + cp "$$target" "$$f"; \ + fi; \ + done \ + && for f in *.so.*; do \ + if [ -L "$$f" ]; then \ + target=$$(readlink -f "$$f"); \ + rm "$$f"; \ + cp "$$target" "$$f"; \ + fi; \ + done \ + && for lib in ncurses form menu panel; do \ + cp lib$${lib}w.so lib$${lib}.so; \ + done \ + && cp libtinfow.so libtinfo.so + """, + toolchains = ["@rules_cc//cc:current_cc_toolchain"], +) + +filegroup( + name = "libs", + srcs = [":ncurses_build"], + visibility = ["//visibility:public"], +) \ No newline at end of file diff --git a/sdk/bazel/extensions/lib_ncurses_extension.bzl b/sdk/bazel/extensions/lib_ncurses_extension.bzl new file mode 100644 index 000000000000..316e38602834 --- /dev/null +++ b/sdk/bazel/extensions/lib_ncurses_extension.bzl @@ -0,0 +1,12 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _impl(module_ctx): + http_archive( + name = "ncurses", + url = "https://ftp.gnu.org/gnu/ncurses/ncurses-6.4.tar.gz", + sha256 = "6931283d9ac87c5073f30b6290c4c75f21632bb4fc3603ac8100812bed248159", + strip_prefix = "ncurses-6.4", + build_file = Label(":files/libs/ncurses.BUILD.bzl"), + ) + +ncurses = module_extension(implementation = _impl) From 99c5335f852043d134b8f55deacca10ee9dc677d Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 1 Apr 2026 16:22:07 +0200 Subject: [PATCH 068/287] feat: Add `@m4//:m4` to project --- sdk/MODULE.bazel | 4 +++- sdk/bazel/extensions/dependencies/bin/BUILD | 0 .../dependencies/bin/files/m4.BUILD.bzl | 20 +++++++++++++++++++ .../dependencies/bin/m4_extension.bzl | 12 +++++++++++ sdk/bazel/extensions/dependencies/lib/BUILD | 16 +++++++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 sdk/bazel/extensions/dependencies/bin/BUILD create mode 100644 sdk/bazel/extensions/dependencies/bin/files/m4.BUILD.bzl create mode 100644 sdk/bazel/extensions/dependencies/bin/m4_extension.bzl create mode 100644 sdk/bazel/extensions/dependencies/lib/BUILD diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index e82f06decc98..8789efdd81ac 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -265,4 +265,6 @@ use_repo(io_grpc_grpc_java_extension, "io_grpc_grpc_java") # Libs ncurses = use_extension("//bazel/extensions:lib_ncurses_extension.bzl", "ncurses") use_repo(ncurses, "ncurses") -# # # \ No newline at end of file + +m4 = use_extension("//bazel/extensions/dependencies/bin:m4_extension.bzl", "m4") +use_repo(m4, "m4") diff --git a/sdk/bazel/extensions/dependencies/bin/BUILD b/sdk/bazel/extensions/dependencies/bin/BUILD new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/sdk/bazel/extensions/dependencies/bin/files/m4.BUILD.bzl b/sdk/bazel/extensions/dependencies/bin/files/m4.BUILD.bzl new file mode 100644 index 000000000000..cec64b1f3daf --- /dev/null +++ b/sdk/bazel/extensions/dependencies/bin/files/m4.BUILD.bzl @@ -0,0 +1,20 @@ +genrule( + name = "m4", + srcs = glob(["**"]), + outs = ["m4"], + toolchains = ["@rules_cc//cc:current_cc_toolchain"], + cmd = """ + set -euo pipefail + + OUT=$$PWD/$@ + SRC=$$(dirname $(location configure)) + + cd $$SRC + + CC=$(CC) ./configure + make -j + + cp src/m4 $$OUT + """, + visibility = ["//visibility:public"], +) \ No newline at end of file diff --git a/sdk/bazel/extensions/dependencies/bin/m4_extension.bzl b/sdk/bazel/extensions/dependencies/bin/m4_extension.bzl new file mode 100644 index 000000000000..e75a3ae74b80 --- /dev/null +++ b/sdk/bazel/extensions/dependencies/bin/m4_extension.bzl @@ -0,0 +1,12 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _impl(module_ctx): + http_archive( + name = "m4", + urls = ["https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.gz"], + strip_prefix = "m4-1.4.19", + sha256 = "3be4a26d825ffdfda52a56fc43246456989a3630093cced3fbddf4771ee58a70", + build_file = ":files/m4.BUILD.bzl", + ) + +m4 = module_extension(implementation = _impl) diff --git a/sdk/bazel/extensions/dependencies/lib/BUILD b/sdk/bazel/extensions/dependencies/lib/BUILD new file mode 100644 index 000000000000..297733ac3c20 --- /dev/null +++ b/sdk/bazel/extensions/dependencies/lib/BUILD @@ -0,0 +1,16 @@ +genrule( + name = "install", + srcs = glob(["**"]), + outs = ["m4_install"], + cmd = """ + set -euo pipefail + SRC=$$PWD/$$(dirname $(location configure)) + OUT=$$PWD/$@ + mkdir -p $$OUT + cd $$SRC + ./configure --prefix=$$OUT + make -j + make install + """, + visibility = ["//visibility:public"], +) \ No newline at end of file From 11106ef28fe6462234a9a38f77477958c6d2f6de Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 7 Apr 2026 14:27:09 +0200 Subject: [PATCH 069/287] feat: Change name of genrule from `@m4//:m4` to `@m4//:m4_binary`, the `@m4//:m4` is still correct --- sdk/bazel/extensions/dependencies/bin/files/m4.BUILD.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/bazel/extensions/dependencies/bin/files/m4.BUILD.bzl b/sdk/bazel/extensions/dependencies/bin/files/m4.BUILD.bzl index cec64b1f3daf..7444ecbc163c 100644 --- a/sdk/bazel/extensions/dependencies/bin/files/m4.BUILD.bzl +++ b/sdk/bazel/extensions/dependencies/bin/files/m4.BUILD.bzl @@ -1,5 +1,5 @@ genrule( - name = "m4", + name = "m4_binary", srcs = glob(["**"]), outs = ["m4"], toolchains = ["@rules_cc//cc:current_cc_toolchain"], From d355d6d218a2763b4c767bd706e5bc3609894417 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 7 Apr 2026 14:28:10 +0200 Subject: [PATCH 070/287] feat: Up the bazel version to latest `7.x` --- sdk/.bazelversion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/.bazelversion b/sdk/.bazelversion index 468c41f93ccc..e28dc5baea54 100644 --- a/sdk/.bazelversion +++ b/sdk/.bazelversion @@ -1 +1 @@ -7.2.1 \ No newline at end of file +7.x \ No newline at end of file From 9f045b7e342d734dffd4de492c9fb427848c7f04 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 7 Apr 2026 14:35:18 +0200 Subject: [PATCH 071/287] feat: Move ncurses setup to more fitting place --- .../{files/libs => dependencies/lib/files}/ncurses.BUILD.bzl | 0 .../lib/ncurses_extension.bzl} | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename sdk/bazel/extensions/{files/libs => dependencies/lib/files}/ncurses.BUILD.bzl (100%) rename sdk/bazel/extensions/{lib_ncurses_extension.bzl => dependencies/lib/ncurses_extension.bzl} (86%) diff --git a/sdk/bazel/extensions/files/libs/ncurses.BUILD.bzl b/sdk/bazel/extensions/dependencies/lib/files/ncurses.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/files/libs/ncurses.BUILD.bzl rename to sdk/bazel/extensions/dependencies/lib/files/ncurses.BUILD.bzl diff --git a/sdk/bazel/extensions/lib_ncurses_extension.bzl b/sdk/bazel/extensions/dependencies/lib/ncurses_extension.bzl similarity index 86% rename from sdk/bazel/extensions/lib_ncurses_extension.bzl rename to sdk/bazel/extensions/dependencies/lib/ncurses_extension.bzl index 316e38602834..e1bdb392cbb4 100644 --- a/sdk/bazel/extensions/lib_ncurses_extension.bzl +++ b/sdk/bazel/extensions/dependencies/lib/ncurses_extension.bzl @@ -6,7 +6,7 @@ def _impl(module_ctx): url = "https://ftp.gnu.org/gnu/ncurses/ncurses-6.4.tar.gz", sha256 = "6931283d9ac87c5073f30b6290c4c75f21632bb4fc3603ac8100812bed248159", strip_prefix = "ncurses-6.4", - build_file = Label(":files/libs/ncurses.BUILD.bzl"), + build_file = Label(":files/ncurses.BUILD.bzl"), ) ncurses = module_extension(implementation = _impl) From 3c2c3b934e356828f9bfe70f320209c62b63bedc Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 7 Apr 2026 14:36:03 +0200 Subject: [PATCH 072/287] feat: Add automake and autoconf --- sdk/MODULE.bazel | 11 +++++++++-- .../dependencies/scripts/autoconf_extension.bzl | 12 ++++++++++++ .../dependencies/scripts/automake_extension.bzl | 12 ++++++++++++ .../dependencies/scripts/files/autoconf.BUILD.bzl | 7 +++++++ .../dependencies/scripts/files/automake.BUILD.bzl | 7 +++++++ 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl create mode 100644 sdk/bazel/extensions/dependencies/scripts/automake_extension.bzl create mode 100644 sdk/bazel/extensions/dependencies/scripts/files/autoconf.BUILD.bzl create mode 100644 sdk/bazel/extensions/dependencies/scripts/files/automake.BUILD.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 8789efdd81ac..60dcb45a3953 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -170,7 +170,6 @@ stack_snapshot.package( name = "zip", vendored = "@zip//:zip", ) - stack_snapshot.package( name = "happy", components = ["exe"], @@ -263,8 +262,16 @@ use_repo(io_grpc_grpc_java_extension, "io_grpc_grpc_java") # # # # Libs -ncurses = use_extension("//bazel/extensions:lib_ncurses_extension.bzl", "ncurses") +ncurses = use_extension("//bazel/extensions/dependencies/lib:ncurses_extension.bzl", "ncurses") use_repo(ncurses, "ncurses") m4 = use_extension("//bazel/extensions/dependencies/bin:m4_extension.bzl", "m4") use_repo(m4, "m4") + +autoconf = use_extension("//bazel/extensions/dependencies/scripts:autoconf_extension.bzl", "autoconf") +use_repo(autoconf, "autoconf") +automake = use_extension("//bazel/extensions/dependencies/scripts:automake_extension.bzl", "automake") +use_repo(automake, "automake") +# # # + +bazel_dep(name = "rules_perl", version = "1.1.0") \ No newline at end of file diff --git a/sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl b/sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl new file mode 100644 index 000000000000..178f15f6e550 --- /dev/null +++ b/sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl @@ -0,0 +1,12 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _impl(module_ctx): + http_archive( + name = "autoconf", + urls = ["https://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.gz"], + strip_prefix = "autoconf-2.71", + sha256 = "431075ad0bf529ef13cb41e9042c542381103e80015686222b8a9d4abef42a1c", # fill after first download + build_file = ":files/autoconf.BUILD.bzl", + ) + +autoconf = module_extension(implementation = _impl) diff --git a/sdk/bazel/extensions/dependencies/scripts/automake_extension.bzl b/sdk/bazel/extensions/dependencies/scripts/automake_extension.bzl new file mode 100644 index 000000000000..b3517a076793 --- /dev/null +++ b/sdk/bazel/extensions/dependencies/scripts/automake_extension.bzl @@ -0,0 +1,12 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _impl(module_ctx): + http_archive( + name = "automake", + urls = ["https://ftp.gnu.org/gnu/automake/automake-1.16.5.tar.gz"], + strip_prefix = "automake-1.16.5", + sha256 = "07bd24ad08a64bc17250ce09ec56e921d6343903943e99ccf63bbf0705e34605", + build_file = ":files/automake.BUILD.bzl", + ) + +automake = module_extension(implementation = _impl) diff --git a/sdk/bazel/extensions/dependencies/scripts/files/autoconf.BUILD.bzl b/sdk/bazel/extensions/dependencies/scripts/files/autoconf.BUILD.bzl new file mode 100644 index 000000000000..a591b7974470 --- /dev/null +++ b/sdk/bazel/extensions/dependencies/scripts/files/autoconf.BUILD.bzl @@ -0,0 +1,7 @@ +exports_files(["README"]) + +filegroup( + name = "srcs", + srcs = glob(["**"]), + visibility = ["//visibility:public"], +) diff --git a/sdk/bazel/extensions/dependencies/scripts/files/automake.BUILD.bzl b/sdk/bazel/extensions/dependencies/scripts/files/automake.BUILD.bzl new file mode 100644 index 000000000000..a591b7974470 --- /dev/null +++ b/sdk/bazel/extensions/dependencies/scripts/files/automake.BUILD.bzl @@ -0,0 +1,7 @@ +exports_files(["README"]) + +filegroup( + name = "srcs", + srcs = glob(["**"]), + visibility = ["//visibility:public"], +) From 0784855d8ec8bf63809f29b4e2bbec4b2cebcd09 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 7 Apr 2026 17:41:51 +0200 Subject: [PATCH 073/287] feat: Reimplement `@autoconf//:autoconf` and `@automake//:automake` to be correct rule with dir output. --- .../extensions/dependencies/scripts/BUILD | 0 .../scripts/autoconf_extension.bzl | 6 +- .../scripts/files/automake.BUILD.bzl | 15 ++ sdk/bazel/rules/BUILD | 0 sdk/bazel/rules/install_gnu_tool.bzl | 135 ++++++++++++++++++ 5 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 sdk/bazel/extensions/dependencies/scripts/BUILD create mode 100644 sdk/bazel/rules/BUILD create mode 100644 sdk/bazel/rules/install_gnu_tool.bzl diff --git a/sdk/bazel/extensions/dependencies/scripts/BUILD b/sdk/bazel/extensions/dependencies/scripts/BUILD new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl b/sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl index 178f15f6e550..c4241d6c39d7 100644 --- a/sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl +++ b/sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl @@ -3,9 +3,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def _impl(module_ctx): http_archive( name = "autoconf", - urls = ["https://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.gz"], - strip_prefix = "autoconf-2.71", - sha256 = "431075ad0bf529ef13cb41e9042c542381103e80015686222b8a9d4abef42a1c", # fill after first download + urls = ["https://ftp.gnu.org/gnu/autoconf/autoconf-2.72.tar.gz"], + strip_prefix = "autoconf-2.72", + sha256 = "afb181a76e1ee72832f6581c0eddf8df032b83e2e0239ef79ebedc4467d92d6e", build_file = ":files/autoconf.BUILD.bzl", ) diff --git a/sdk/bazel/extensions/dependencies/scripts/files/automake.BUILD.bzl b/sdk/bazel/extensions/dependencies/scripts/files/automake.BUILD.bzl index a591b7974470..3e5ce2a47308 100644 --- a/sdk/bazel/extensions/dependencies/scripts/files/automake.BUILD.bzl +++ b/sdk/bazel/extensions/dependencies/scripts/files/automake.BUILD.bzl @@ -1,3 +1,8 @@ +load( + "@//bazel/rules:install_gnu_tool.bzl", + "install_gnu_tool", +) + exports_files(["README"]) filegroup( @@ -5,3 +10,13 @@ filegroup( srcs = glob(["**"]), visibility = ["//visibility:public"], ) + +install_gnu_tool( + name = "automake", + srcs = ":srcs", + configure = "configure", + perl = "@rules_perl//:current_toolchain", + extra_tools = ["@m4//:m4"], + pre_build_srcs = ["@autoconf//:srcs"], + visibility = ["//visibility:public"], +) diff --git a/sdk/bazel/rules/BUILD b/sdk/bazel/rules/BUILD new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/sdk/bazel/rules/install_gnu_tool.bzl b/sdk/bazel/rules/install_gnu_tool.bzl new file mode 100644 index 000000000000..eb74475c126c --- /dev/null +++ b/sdk/bazel/rules/install_gnu_tool.bzl @@ -0,0 +1,135 @@ +InstalledGnuToolInfo = provider( + doc = "Paths within a GNU tool install prefix.", + fields = { + "prefix": "The directory tree artifact containing the installed tool.", + "bindir": "Relative path to bin/ within prefix.", + "datadir": "Relative path to share/ within prefix.", + }, +) + +def _install_gnu_tool_impl(ctx): + prefix_dir = ctx.actions.declare_directory(ctx.attr.name + "_prefix") + + configure_src = ctx.file.configure + perl_files = ctx.files.perl + perl_bin = [f for f in perl_files if f.basename == "perl"][0] + + extra_path_entries = [ + "$EXECROOT/" + f.dirname + for f in ctx.files.extra_tools + ] + + m4_env_line = "" + for f in ctx.files.extra_tools: + if f.basename == "m4": + m4_env_line = 'export M4="$EXECROOT/{}"'.format(f.path) + + # Build additional source packages before the main one. Each entry + # is built via ./configure && make install into the shared prefix + # so that all tools share consistent internal paths. + pre_build_steps = [] + for dep_src in ctx.attr.pre_build_srcs: + dep_files = dep_src.files.to_list() + dep_configure = None + for f in dep_files: + if f.basename == "configure" and f.dirname.count("/") == dep_files[0].dirname.count("/"): + dep_configure = f + break + if dep_configure: + pre_build_steps.append("""\ +echo "=== Pre-building from {src_dir} ===" +cd "$EXECROOT/$(dirname {configure})" +PERL="$PERL" ./configure --prefix="$PREFIX" +make -j$(nproc) install +cd "$EXECROOT" +""".format(configure = dep_configure.path, src_dir = dep_configure.dirname)) + + path_str = ":".join(extra_path_entries) + + all_srcs = ctx.files.srcs + ctx.files.extra_tools + perl_files + for dep_src in ctx.attr.pre_build_srcs: + all_srcs = all_srcs + dep_src.files.to_list() + + inputs = depset(direct = all_srcs) + + ctx.actions.run_shell( + outputs = [prefix_dir], + inputs = inputs, + command = """\ +set -euo pipefail +EXECROOT="$PWD" +PERL="$EXECROOT/{perl}" +PREFIX="$EXECROOT/{output}" +SRC="$EXECROOT/$(dirname {configure})" +EXTRA_PATH="{extra_path}" + +export PATH="$PREFIX/bin:$(dirname $PERL):$EXTRA_PATH:$PATH" +{m4_env} + +{pre_build_steps} + +echo "=== Building main package ===" +cd "$SRC" +PERL="$PERL" ./configure --prefix="$PREFIX" +make -j$(nproc) install + +# Fix shebangs to be relocatable (use env perl instead of hardcoded path). +for f in "$PREFIX/bin/"*; do + [ -f "$f" ] || continue + if head -1 "$f" | grep -q perl; then + sed -i '1s|#!.*perl.*|#!/usr/bin/env perl|' "$f" + fi +done + +# Replace all hardcoded sandbox-absolute paths with a relocatable placeholder. +# Autotools bakes the absolute install prefix, perl path, and m4 path into +# scripts and config files. Replacing the common execroot prefix lets the +# consumer do a single: sed 's|__EXECROOT__|'"$PWD"'|g' to fix everything, +# since execroot-relative artifact paths are stable across sandboxes. +find "$PREFIX" -type f | while IFS= read -r pf; do + if file --mime-type "$pf" | grep -q text; then + sed -i "s|$EXECROOT|__EXECROOT__|g" "$pf" + fi +done +""".format( + configure = configure_src.path, + perl = perl_bin.path, + output = prefix_dir.path, + extra_path = path_str, + m4_env = m4_env_line, + pre_build_steps = "\n".join(pre_build_steps), + ), + mnemonic = "InstallGnuTool", + progress_message = "Building %s from source" % ctx.label, + use_default_shell_env = False, + ) + + return [ + DefaultInfo(files = depset([prefix_dir])), + InstalledGnuToolInfo( + prefix = prefix_dir, + bindir = "bin", + datadir = "share", + ), + ] + +install_gnu_tool = rule( + implementation = _install_gnu_tool_impl, + attrs = { + "srcs": attr.label(mandatory = True, doc = "Source tree filegroup."), + "configure": attr.label( + mandatory = True, + allow_single_file = True, + doc = "The configure script for the main package.", + ), + "perl": attr.label(mandatory = True, doc = "Perl toolchain files."), + "extra_tools": attr.label_list( + allow_files = True, + doc = "Additional tool binaries needed on PATH during build (individual files).", + ), + "pre_build_srcs": attr.label_list( + doc = "Source trees to build and install before the main package. " + + "Each must contain a configure script at its root.", + ), + }, +) From 63cf34bd4340dd75561cfcd6a4abc5c05eb9de89 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 7 Apr 2026 18:24:37 +0200 Subject: [PATCH 074/287] fix: Enable standard ghc version setting --- sdk/MODULE.bazel | 17 +++++------------ .../patches/rules_haskell_ghc_version.patch | 11 ----------- 2 files changed, 5 insertions(+), 23 deletions(-) delete mode 100644 sdk/bazel/rules/patches/rules_haskell_ghc_version.patch diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 60dcb45a3953..e7a43c73a62c 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -7,13 +7,6 @@ bazel_dep(name = "protobuf", version = "33.4") bazel_dep(name = "rules_cc", version = "0.2.16") bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_haskell", version = "0.18") -archive_override( - module_name = "rules_haskell", - patches = ["//bazel/rules/patches:rules_haskell_ghc_version.patch"], - strip_prefix = "rules_haskell-0.18", - urls = ["https://github.com/tweag/rules_haskell/releases/download/v0.18/rules_haskell-0.18.tar.gz"], -) - bazel_dep(name = "rules_java", version = "9.5.0") bazel_dep(name = "rules_pkg", version = "1.2.0") @@ -35,11 +28,11 @@ use_repo(bazel_lib_toolchains, "bsd_tar_toolchains") register_toolchains("@bsd_tar_toolchains//:all") -# haskell_toolchains = use_extension( -# "@rules_haskell//extensions:default.bzl", -# "haskell_toolchains", -# ) -# haskell_toolchains.bindist(version = "9.0.1") +haskell_toolchains = use_extension( + "@rules_haskell//extensions:haskell_toolchains.bzl", + "haskell_toolchains", +) +haskell_toolchains.bindists(version = "9.0.2") haskell_non_module_deps = use_extension("//bazel/extensions:haskell_non_module_deps_extension.bzl", "haskell_non_module_deps_extension") use_repo( diff --git a/sdk/bazel/rules/patches/rules_haskell_ghc_version.patch b/sdk/bazel/rules/patches/rules_haskell_ghc_version.patch deleted file mode 100644 index b8f407912f17..000000000000 --- a/sdk/bazel/rules/patches/rules_haskell_ghc_version.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- MODULE.bazel -+++ MODULE.bazel -@@ -79,7 +79,7 @@ haskell_toolchains = use_extension( - "@rules_haskell//extensions:haskell_toolchains.bzl", - "haskell_toolchains", - ) --haskell_toolchains.bindists() -+haskell_toolchains.bindists(version = "9.0.2") - use_repo( - haskell_toolchains, - "all_bindist_toolchains", From 7fc2eb8fa53c6e3afd13604037f61abddef1bd5a Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 7 Apr 2026 19:18:31 +0200 Subject: [PATCH 075/287] feat: Move old haskell deps to more fitting structure --- sdk/MODULE.bazel | 22 +-- .../extensions/dependencies/haskell/BUILD | 0 .../dependencies/haskell/da_ghc_extension.bzl | 40 ++++++ .../haskell/files/haskell_da_ghc.BUILD.bzl | 134 ++++++++++++++++++ .../files}/haskell_ghc_lib_gen.BUILD.bzl | 2 +- .../files}/haskell_ghcide_ghc_lib.BUILD.bzl | 0 .../files}/haskell_lsp_types.BUILD.bzl | 0 .../haskell/files}/haskell_zip.BUILD.bzl | 0 .../dependencies/haskell/ghcide_extension.bzl | 19 +++ .../haskell/lsp_types_extension.bzl | 20 +++ .../dependencies/haskell/zip_extension.bzl | 16 +++ .../files/haskell/haskell_cabal.BUILD.bzl | 9 -- .../files/haskell/haskell_da_ghc.BUILD.bzl | 47 ------ .../haskell_non_module_deps_extension.bzl | 100 ------------- 14 files changed, 241 insertions(+), 168 deletions(-) create mode 100644 sdk/bazel/extensions/dependencies/haskell/BUILD create mode 100644 sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl create mode 100644 sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl rename sdk/bazel/extensions/{files/haskell => dependencies/haskell/files}/haskell_ghc_lib_gen.BUILD.bzl (99%) rename sdk/bazel/extensions/{files/haskell => dependencies/haskell/files}/haskell_ghcide_ghc_lib.BUILD.bzl (100%) rename sdk/bazel/extensions/{files/haskell => dependencies/haskell/files}/haskell_lsp_types.BUILD.bzl (100%) rename sdk/bazel/extensions/{files/haskell => dependencies/haskell/files}/haskell_zip.BUILD.bzl (100%) create mode 100644 sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl create mode 100644 sdk/bazel/extensions/dependencies/haskell/lsp_types_extension.bzl create mode 100644 sdk/bazel/extensions/dependencies/haskell/zip_extension.bzl delete mode 100644 sdk/bazel/extensions/files/haskell/haskell_cabal.BUILD.bzl delete mode 100644 sdk/bazel/extensions/files/haskell/haskell_da_ghc.BUILD.bzl delete mode 100644 sdk/bazel/extensions/haskell_non_module_deps_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index e7a43c73a62c..53d5dfa05ac6 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -34,16 +34,17 @@ haskell_toolchains = use_extension( ) haskell_toolchains.bindists(version = "9.0.2") -haskell_non_module_deps = use_extension("//bazel/extensions:haskell_non_module_deps_extension.bzl", "haskell_non_module_deps_extension") -use_repo( - haskell_non_module_deps, - # "Cabal", - "da-ghc", - "ghc-lib-gen", - "ghcide_ghc_lib", - "lsp-types", - "zip", -) +da_ghc_ext = use_extension("//bazel/extensions/dependencies/haskell:da_ghc_extension.bzl", "da_ghc") +use_repo(da_ghc_ext, "da-ghc", "ghc-lib-gen") + +ghcide_ext = use_extension("//bazel/extensions/dependencies/haskell:ghcide_extension.bzl", "ghcide") +use_repo(ghcide_ext, "ghcide_ghc_lib") + +lsp_types_ext = use_extension("//bazel/extensions/dependencies/haskell:lsp_types_extension.bzl", "lsp_types") +use_repo(lsp_types_ext, "lsp-types") + +zip_ext = use_extension("//bazel/extensions/dependencies/haskell:zip_extension.bzl", "zip") +use_repo(zip_ext, "zip") stack_snapshot = use_extension( "@rules_haskell//extensions:stack_snapshot.bzl", @@ -57,7 +58,6 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") [ stack_snapshot.package( name = pkg, - # setup_deps = ["@Cabal//:Cabal"], ) for pkg in [ "aeson", diff --git a/sdk/bazel/extensions/dependencies/haskell/BUILD b/sdk/bazel/extensions/dependencies/haskell/BUILD new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl new file mode 100644 index 000000000000..998c2bd6f1ca --- /dev/null +++ b/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl @@ -0,0 +1,40 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel_tools/ghc-lib:version.bzl", + "GHC_LIB_PATCHES", + "GHC_LIB_REPO_URL", + "GHC_LIB_REV", + "GHC_LIB_SHA256", + "GHC_PATCHES", + "GHC_REPO_URL", + "GHC_REV", +) + +def _get_ghc_lib_gen(): + http_archive( + name = "ghc-lib-gen", + url = "{}/archive/{}.tar.gz".format(GHC_LIB_REPO_URL, GHC_LIB_REV), + sha256 = GHC_LIB_SHA256, + strip_prefix = "ghc-lib-{}".format(GHC_LIB_REV), + build_file = ":files/haskell_ghc_lib_gen.BUILD.bzl", + patches = ["//bazel/patches:haskell/ghc_lib_no_stack.patch"], + patch_args = ["-p1"], + ) + +def _get_da_ghc(): + git_repository( + name = "da-ghc", + remote = GHC_REPO_URL, + commit = GHC_REV, + recursive_init_submodules = True, + build_file = ":files/haskell_da_ghc.BUILD.bzl", + shallow_since = "1771323697 +0100", + patch_args = ["-p1"], + ) + +def _impl(module_ctx): + _get_ghc_lib_gen() + _get_da_ghc() + +da_ghc = module_extension(implementation = _impl) diff --git a/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl b/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl new file mode 100644 index 000000000000..4303195d39ec --- /dev/null +++ b/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl @@ -0,0 +1,134 @@ +load( + "@//bazel_tools/ghc-lib:version.bzl", + "GHC_CPP_OPTIONS", + "GHC_FLAVOR", + "GHC_LIB_VERSION", +) +load("@os_info//:os_info.bzl", "is_darwin") +load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_binary") + +filegroup( + name = "hadrian-srcs", + srcs = glob(["hadrian/**"]), + visibility = ["//visibility:public"], +) + +haskell_cabal_binary( + name = "hadrian", + flags = ["with_bazel"], + srcs = [":hadrian-srcs"], + deps = [ + "@stackage//:base", + "@stackage//:Cabal", + "@stackage//:containers", + "@stackage//:directory", + "@stackage//:extra", + "@stackage//:mtl", + "@stackage//:parsec", + "@stackage//:QuickCheck", + "@stackage//:shake", + "@stackage//:transformers", + "@stackage//:unordered-containers", + ], + tools = [ + "@stackage-exe//alex", + "@stackage-exe//happy", + ], + cabalopts = [ + "--ghc-option=-Wno-dodgy-imports", + "--ghc-option=-Wno-unused-imports", + ], +) + +filegroup( + name = "srcs", + srcs = glob(["**"]), + visibility = ["//visibility:public"], +) + +_LANG = "en_US.UTF-8" if is_darwin else "C.UTF-8" +_CPP_OPTIONS = " ".join(["--cpp={}".format(cpp) for cpp in GHC_CPP_OPTIONS]) + +genrule( + name = "ghc-lib", + srcs = [ + ":srcs", + ":README.md", + "@autoconf//:srcs", + "@autoconf//:README", + "@automake//:srcs", + "@automake//:README", + ], + tools = [ + ":hadrian", + "@ghc-lib-gen//:ghc-lib-gen", + "@m4//:m4", + "@rules_perl//:current_toolchain", + "@rules_haskell//haskell:current_haskell_toolchain", + ], + toolchains = [ + "@rules_cc//cc:current_cc_toolchain", + ], + outs = [ + "ghc-lib.cabal", + "ghc-lib-{version}.tar.gz".format(version = GHC_LIB_VERSION), + ], + cmd = """\ +set -euo pipefail +ORIGIN=$$PWD + +echo "HASKELL: $(locations @rules_haskell//haskell:current_haskell_toolchain)" | tr ' ' '\n' | grep bin/ghc | head -3 +exit + +# Tool paths +M4_DIR="$$(dirname $$(realpath $(execpath @m4//:m4)))" +PERL_DIR="$$(realpath $$(dirname $$(echo "$(locations @rules_perl//:current_toolchain)" | cut -d' ' -f1)))/bin" +AUTOCONF_SRC="$$ORIGIN/$$(dirname $(location @autoconf//:README))" + +export PATH="$$PERL_DIR:$$M4_DIR:$$PATH" + +# Build autoconf inline +AUTOCONF_PREFIX=$$(mktemp -d) +cd $$AUTOCONF_SRC +./configure --prefix=$$AUTOCONF_PREFIX +make install +cd $$ORIGIN +export PATH="$$AUTOCONF_PREFIX/bin:$$PATH" + +# Build automake inline (shares prefix with autoconf) +AUTOMAKE_SRC="$$ORIGIN/$$(dirname $(location @automake//:README))" +cd $$AUTOMAKE_SRC +./configure --prefix=$$AUTOCONF_PREFIX +make install +cd $$ORIGIN + +export LANG={lang} +export CC="$(CC)" +export LD="$(LD)" +export PATH="$$ORIGIN/$$(dirname $(execpath :hadrian)):$$PATH" + +GHC_DIR="$$ORIGIN/$$(dirname $(execpath :README.md))" +TMP=$$(mktemp -d) +trap "rm -rf $$TMP $$AUTOCONF_PREFIX" EXIT +cp -rLt $$TMP $$GHC_DIR/. +export HOME="$$TMP" + +$(execpath @ghc-lib-gen//:ghc-lib-gen) $$TMP \ + --ghc-lib \ + --ghc-flavor={ghc_flavor} \ + {cpp_options} + +sed -i.bak -e "s#$$ORIGIN/##" $$TMP/ghc-lib/stage0/lib/settings +sed -i.bak -e 's#version: 0.1.0#version: {ghc_lib_version}#' $$TMP/ghc-lib.cabal + +cp $$TMP/ghc-lib.cabal $(execpath ghc-lib.cabal) +# cabal sdist must run from the source tree; OLDPWD retains the exec root after cd. +cd $$TMP && cabal sdist -o $$OLDPWD/$(RULEDIR) +""".format( + cpp_options = _CPP_OPTIONS, + ghc_flavor = GHC_FLAVOR, + ghc_lib_version = GHC_LIB_VERSION, + lang = _LANG, + ), + visibility = ["//visibility:public"], +) diff --git a/sdk/bazel/extensions/files/haskell/haskell_ghc_lib_gen.BUILD.bzl b/sdk/bazel/extensions/dependencies/haskell/files/haskell_ghc_lib_gen.BUILD.bzl similarity index 99% rename from sdk/bazel/extensions/files/haskell/haskell_ghc_lib_gen.BUILD.bzl rename to sdk/bazel/extensions/dependencies/haskell/files/haskell_ghc_lib_gen.BUILD.bzl index f832e43c6282..cefe5957c464 100644 --- a/sdk/bazel/extensions/files/haskell/haskell_ghc_lib_gen.BUILD.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/files/haskell_ghc_lib_gen.BUILD.bzl @@ -36,4 +36,4 @@ haskell_cabal_binary( "@stackage//:process", ], visibility = ["//visibility:public"], -) \ No newline at end of file +) diff --git a/sdk/bazel/extensions/files/haskell/haskell_ghcide_ghc_lib.BUILD.bzl b/sdk/bazel/extensions/dependencies/haskell/files/haskell_ghcide_ghc_lib.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/files/haskell/haskell_ghcide_ghc_lib.BUILD.bzl rename to sdk/bazel/extensions/dependencies/haskell/files/haskell_ghcide_ghc_lib.BUILD.bzl diff --git a/sdk/bazel/extensions/files/haskell/haskell_lsp_types.BUILD.bzl b/sdk/bazel/extensions/dependencies/haskell/files/haskell_lsp_types.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/files/haskell/haskell_lsp_types.BUILD.bzl rename to sdk/bazel/extensions/dependencies/haskell/files/haskell_lsp_types.BUILD.bzl diff --git a/sdk/bazel/extensions/files/haskell/haskell_zip.BUILD.bzl b/sdk/bazel/extensions/dependencies/haskell/files/haskell_zip.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/files/haskell/haskell_zip.BUILD.bzl rename to sdk/bazel/extensions/dependencies/haskell/files/haskell_zip.BUILD.bzl diff --git a/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl new file mode 100644 index 000000000000..659134e97540 --- /dev/null +++ b/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl @@ -0,0 +1,19 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _impl(module_ctx): + GHCIDE_REV = "2914f9328dc549bd4918c3cf0fc008690a102d70" + GHCIDE_SHA256 = "bc2bd2fbfbfb501e303b35fb4b2f503b122e4eb0aff34472f0e882d2289afc57" + + http_archive( + name = "ghcide_ghc_lib", + build_file = ":files/haskell_ghcide_ghc_lib.BUILD.bzl", + patch_args = ["-p1"], + patches = [ + "//bazel/patches:haskell/ghcide_binary_q.patch", + ], + sha256 = GHCIDE_SHA256, + strip_prefix = "daml-ghcide-%s" % GHCIDE_REV, + url = "https://github.com/digital-asset/daml-ghcide/archive/%s.tar.gz" % GHCIDE_REV, + ) + +ghcide = module_extension(implementation = _impl) diff --git a/sdk/bazel/extensions/dependencies/haskell/lsp_types_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/lsp_types_extension.bzl new file mode 100644 index 000000000000..7246a73a981b --- /dev/null +++ b/sdk/bazel/extensions/dependencies/haskell/lsp_types_extension.bzl @@ -0,0 +1,20 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _impl(module_ctx): + LSP_TYPES_VERSION = "1.4.0.0" + LSP_TYPES_SHA256 = "7ae8a3bad0e91d4a2af9b93e3ad207e3f4c3dace40d420e0592f6323ac93fb67" + + http_archive( + name = "lsp-types", + build_file = ":files/haskell_lsp_types.BUILD.bzl", + patch_args = ["-p1"], + patches = [ + "//bazel/patches:haskell/lsp_types_normalisation.patch", + "//bazel/patches:haskell/lsp_types_expose_other_modules.patch", + ], + sha256 = LSP_TYPES_SHA256, + strip_prefix = "lsp-types-{}".format(LSP_TYPES_VERSION), + urls = ["http://hackage.haskell.org/package/lsp-types-{version}/lsp-types-{version}.tar.gz".format(version = LSP_TYPES_VERSION)], + ) + +lsp_types = module_extension(implementation = _impl) diff --git a/sdk/bazel/extensions/dependencies/haskell/zip_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/zip_extension.bzl new file mode 100644 index 000000000000..56e2e2fcfe4d --- /dev/null +++ b/sdk/bazel/extensions/dependencies/haskell/zip_extension.bzl @@ -0,0 +1,16 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _impl(module_ctx): + ZIP_VERSION = "1.7.1" + + http_archive( + name = "zip", + build_file = ":files/haskell_zip.BUILD.bzl", + patch_args = ["-p1"], + patches = ["//bazel/patches:haskell/zip.patch"], + sha256 = "0d7f02bbdf6c49e9a33d2eca4b3d7644216a213590866dafdd2b47ddd38eb746", + strip_prefix = "zip-{}".format(ZIP_VERSION), + urls = ["http://hackage.haskell.org/package/zip-{version}/zip-{version}.tar.gz".format(version = ZIP_VERSION)], + ) + +zip = module_extension(implementation = _impl) diff --git a/sdk/bazel/extensions/files/haskell/haskell_cabal.BUILD.bzl b/sdk/bazel/extensions/files/haskell/haskell_cabal.BUILD.bzl deleted file mode 100644 index 3aedb3236235..000000000000 --- a/sdk/bazel/extensions/files/haskell/haskell_cabal.BUILD.bzl +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") - -haskell_cabal_library( - name = "Cabal", - srcs = glob(["Cabal/**"]), - verbose = False, - version = "3.0.0.0", - visibility = ["//visibility:public"], -) \ No newline at end of file diff --git a/sdk/bazel/extensions/files/haskell/haskell_da_ghc.BUILD.bzl b/sdk/bazel/extensions/files/haskell/haskell_da_ghc.BUILD.bzl deleted file mode 100644 index 7f2726fe5938..000000000000 --- a/sdk/bazel/extensions/files/haskell/haskell_da_ghc.BUILD.bzl +++ /dev/null @@ -1,47 +0,0 @@ -load("@os_info//:os_info.bzl", "is_darwin") -load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_binary") -load( - "@//bazel_tools/ghc-lib:version.bzl", - "GHC_CPP_OPTIONS", - "GHC_FLAVOR", - "GHC_LIB_VERSION", -) - -filegroup( - name = "hadrian-srcs", - srcs = glob(["hadrian/**"]), - visibility = ["//visibility:public"], -) - -haskell_cabal_binary( - name = "hadrian", - flags = ["with_bazel"], - srcs = [":hadrian-srcs"], - deps = [ - "@stackage//:base", - "@stackage//:Cabal", - "@stackage//:containers", - "@stackage//:directory", - "@stackage//:extra", - "@stackage//:mtl", - "@stackage//:parsec", - "@stackage//:QuickCheck", - "@stackage//:shake", - "@stackage//:transformers", - "@stackage//:unordered-containers", - ], - tools = [ - "@stackage-exe//alex", - "@stackage-exe//happy", - ], - cabalopts = [ - "--ghc-option=-Wno-dodgy-imports", - "--ghc-option=-Wno-unused-imports", - ], -) - -filegroup( - name = "srcs", - srcs = glob(["**"]), - visibility = ["//visibility:public"], -) diff --git a/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl b/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl deleted file mode 100644 index f059bc2b370f..000000000000 --- a/sdk/bazel/extensions/haskell_non_module_deps_extension.bzl +++ /dev/null @@ -1,100 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load( - "//bazel_tools/ghc-lib:version.bzl", - "GHC_LIB_PATCHES", - "GHC_LIB_REPO_URL", - "GHC_LIB_REV", - "GHC_LIB_SHA256", - "GHC_PATCHES", - "GHC_REPO_URL", - "GHC_REV", -) - -def _get_cabal(): - http_archive( - name = "Cabal", - build_file = ":files/haskell/haskell_cabal.BUILD.bzl", - sha256 = "b697b558558f351d2704e520e7dcb1f300cd77fea5677d4b2ee71d0b965a4fe9", - strip_prefix = "cabal-ghc-9.4-paths-module-relocatable", - urls = ["https://github.com/tweag/cabal/archive/refs/heads/ghc-9.4-paths-module-relocatable.zip"], - ) - -def _get_lsp_types(): - LSP_TYPES_VERSION = "1.4.0.0" - LSP_TYPES_SHA256 = "7ae8a3bad0e91d4a2af9b93e3ad207e3f4c3dace40d420e0592f6323ac93fb67" - - http_archive( - name = "lsp-types", - build_file = ":haskell/haskell_lsp_types.BUILD.bzl", - patch_args = ["-p1"], - patches = [ - "//bazel/patches:haskell/lsp_types_normalisation.patch", - "//bazel/patches:haskell/lsp_types_expose_other_modules.patch", - ], - sha256 = LSP_TYPES_SHA256, - strip_prefix = "lsp-types-{}".format(LSP_TYPES_VERSION), - urls = ["http://hackage.haskell.org/package/lsp-types-{version}/lsp-types-{version}.tar.gz".format(version = LSP_TYPES_VERSION)], - ) - -def _get_ghcide(): - GHCIDE_REV = "2914f9328dc549bd4918c3cf0fc008690a102d70" - GHCIDE_SHA256 = "bc2bd2fbfbfb501e303b35fb4b2f503b122e4eb0aff34472f0e882d2289afc57" - GHCIDE_LOCAL_PATH = None - - http_archive( - name = "ghcide_ghc_lib", - build_file = ":files/haskell/haskell_ghcide_ghc_lib.BUILD.bzl", - patch_args = ["-p1"], - patches = [ - "//bazel/patches:haskell/ghcide_binary_q.patch", - ], - sha256 = None if GHCIDE_LOCAL_PATH != None else GHCIDE_SHA256, - strip_prefix = None if GHCIDE_LOCAL_PATH != None else "daml-ghcide-%s" % GHCIDE_REV, - url = "file://" + GHCIDE_LOCAL_PATH if GHCIDE_LOCAL_PATH != None else "https://github.com/digital-asset/daml-ghcide/archive/%s.tar.gz" % GHCIDE_REV, - ) - -def _get_ghc_lib_gen(): - http_archive( - name = "ghc-lib-gen", - url = "{}/archive/{}.tar.gz".format(GHC_LIB_REPO_URL, GHC_LIB_REV), - sha256 = GHC_LIB_SHA256, - strip_prefix = "ghc-lib-{}".format(GHC_LIB_REV), - build_file = ":files/haskell/haskell_ghc_lib_gen.BUILD.bzl", - patches = ["//bazel/patches:haskell/ghc_lib_no_stack.patch"], - patch_args = ["-p1"], - ) - -def _get_da_ghc(): - git_repository( - name = "da-ghc", - remote = GHC_REPO_URL, - commit = GHC_REV, - recursive_init_submodules = True, - build_file = ":files/haskell/haskell_da_ghc.BUILD.bzl", - shallow_since = "1639050525 +0100", - patches = GHC_PATCHES, - patch_args = ["-p1"], - ) - -def _get_zip(): - ZIP_VERSION = "1.7.1" - - http_archive( - name = "zip", - build_file = ":files/haskell/haskell_zip.BUILD.bzl", - patch_args = ["-p1"], - patches = ["//bazel/patches:haskell/zip.patch"], - sha256 = "0d7f02bbdf6c49e9a33d2eca4b3d7644216a213590866dafdd2b47ddd38eb746", - strip_prefix = "zip-{}".format(ZIP_VERSION), - urls = ["http://hackage.haskell.org/package/zip-{version}/zip-{version}.tar.gz".format(version = ZIP_VERSION)], - ) - -def _impl(module_ctx): - _get_lsp_types() - _get_ghcide() - _get_ghc_lib_gen() - _get_da_ghc() - _get_zip() - -haskell_non_module_deps_extension = module_extension(implementation = _impl) From f241bd0700c884efc76554bef90ac79900d437dc Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 7 Apr 2026 19:24:27 +0200 Subject: [PATCH 076/287] fix: Move to shorter extension naming format --- sdk/MODULE.bazel | 102 +++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 53d5dfa05ac6..b1e980c5c48c 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -23,16 +23,16 @@ bazel_dep(name = "patchelf", version = "0.18.0.bcr.1") bazel_dep(name = "tar.bzl", version = "0.8.1") bazel_dep(name = "pigz", version = "2.8.bcr.1") -bazel_lib_toolchains = use_extension("@tar.bzl//tar:extensions.bzl", "toolchains") -use_repo(bazel_lib_toolchains, "bsd_tar_toolchains") +bazel_lib_toolchains_ext = use_extension("@tar.bzl//tar:extensions.bzl", "toolchains") +use_repo(bazel_lib_toolchains_ext, "bsd_tar_toolchains") register_toolchains("@bsd_tar_toolchains//:all") -haskell_toolchains = use_extension( +haskell_toolchains_ext = use_extension( "@rules_haskell//extensions:haskell_toolchains.bzl", "haskell_toolchains", ) -haskell_toolchains.bindists(version = "9.0.2") +haskell_toolchains_ext.bindists(version = "9.0.2") da_ghc_ext = use_extension("//bazel/extensions/dependencies/haskell:da_ghc_extension.bzl", "da_ghc") use_repo(da_ghc_ext, "da-ghc", "ghc-lib-gen") @@ -46,17 +46,17 @@ use_repo(lsp_types_ext, "lsp-types") zip_ext = use_extension("//bazel/extensions/dependencies/haskell:zip_extension.bzl", "zip") use_repo(zip_ext, "zip") -stack_snapshot = use_extension( +stack_snapshot_ext = use_extension( "@rules_haskell//extensions:stack_snapshot.bzl", "stack_snapshot", ) -use_repo(stack_snapshot, "stackage", "stackage-exe") +use_repo(stack_snapshot_ext, "stackage", "stackage-exe") -stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") +stack_snapshot_ext.snapshot(local_snapshot = "//:stackage_snapshot.yaml") -# stack_snapshot.package(name = "lsp-types") +# stack_snapshot_ext.package(name = "lsp-types") [ - stack_snapshot.package( + stack_snapshot_ext.package( name = pkg, ) for pkg in [ @@ -133,7 +133,7 @@ stack_snapshot.snapshot(local_snapshot = "//:stackage_snapshot.yaml") ] ] -stack_snapshot.package( +stack_snapshot_ext.package( name = "attoparsec", components = [ "lib:attoparsec", @@ -141,37 +141,37 @@ stack_snapshot.package( ], components_dependencies = {"lib:attoparsec": ["lib:attoparsec-internal"]}, ) -stack_snapshot.package( +stack_snapshot_ext.package( name = "ghc-lib", vendored = "//bazel_tools/ghc-lib/ghc-lib", ) -stack_snapshot.package( +stack_snapshot_ext.package( name = "ghc-lib-parser", vendored = "//bazel_tools/ghc-lib/ghc-lib-parser", ) -stack_snapshot.package( +stack_snapshot_ext.package( name = "ghcide", flags = ["ghc-lib"], vendored = "@ghcide_ghc_lib//:ghcide", ) -stack_snapshot.package( +stack_snapshot_ext.package( name = "proto3-suite", flags = ["-swagger"], vendored = "@proto3-suite//:proto3-suite", ) -stack_snapshot.package( +stack_snapshot_ext.package( name = "zip", vendored = "@zip//:zip", ) -stack_snapshot.package( +stack_snapshot_ext.package( name = "happy", components = ["exe"], ) -stack_snapshot.package( +stack_snapshot_ext.package( name = "alex", components = ["exe"], ) -stack_snapshot.package( +stack_snapshot_ext.package( name = "hpp", components = [ "lib", @@ -179,40 +179,40 @@ stack_snapshot.package( ], ) -module_temporary_extension = use_extension("//bazel/extensions:module_temporary_extension.bzl", "temporary_extension") -use_repo(module_temporary_extension, "build_environment", "daml_versions_data", "os_info", "scala_version") +module_temporary_ext = use_extension("//bazel/extensions:module_temporary_extension.bzl", "temporary_extension") +use_repo(module_temporary_ext, "build_environment", "daml_versions_data", "os_info", "scala_version") -dpm_extension = use_extension("//bazel/extensions:dpm_extension.bzl", "dpm_extension") -use_repo(dpm_extension, "dpm_binary") +dpm_ext = use_extension("//bazel/extensions:dpm_extension.bzl", "dpm_extension") +use_repo(dpm_ext, "dpm_binary") -d3plus_extension = use_extension("//bazel/extensions:d3plus_extension.bzl", "d3plus_extension") -use_repo(d3plus_extension, "static_asset_d3plus") +d3plus_ext = use_extension("//bazel/extensions:d3plus_extension.bzl", "d3plus_extension") +use_repo(d3plus_ext, "static_asset_d3plus") -googleapis_extenstion = use_extension("//bazel/extensions:go_googleapis_extension.bzl", "googleapis_extension") -use_repo(googleapis_extenstion, "go_googleapis") +googleapis_ext = use_extension("//bazel/extensions:go_googleapis_extension.bzl", "googleapis_extension") +use_repo(googleapis_ext, "go_googleapis") -import_googleapis_extenstion = use_extension("//bazel/extensions:go_googleapis_import_extension.bzl", "import_googleapis_extension") -use_repo(import_googleapis_extenstion, "com_google_googleapis_imports") +import_googleapis_ext = use_extension("//bazel/extensions:go_googleapis_import_extension.bzl", "import_googleapis_extension") +use_repo(import_googleapis_ext, "com_google_googleapis_imports") -proto3_suite = use_extension("//bazel/extensions:proto3_suite_extension.bzl", "proto3_suite_extension") -use_repo(proto3_suite, "proto3-suite") +proto3_suite_ext = use_extension("//bazel/extensions:proto3_suite_extension.bzl", "proto3_suite_extension") +use_repo(proto3_suite_ext, "proto3-suite") -scala_config = use_extension( +scala_config_ext = use_extension( "@rules_scala//scala/extensions:config.bzl", "scala_config", ) -scala_config.settings(scala_version = "2.13.16") -use_repo(scala_config, "rules_scala_config") +scala_config_ext.settings(scala_version = "2.13.16") +use_repo(scala_config_ext, "rules_scala_config") -scala_deps = use_extension( +scala_deps_ext = use_extension( "@rules_scala//scala/extensions:deps.bzl", "scala_deps", ) -scala_deps.scala() -scala_deps.scalatest() +scala_deps_ext.scala() +scala_deps_ext.scalatest() -maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") -maven.install( +maven_ext = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven_ext.install( artifacts = [ "com.daml:contextualized-logging_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.daml:daml-lf-api-type-signature_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", @@ -242,29 +242,29 @@ maven.install( "https://europe-maven.pkg.dev/da-images/public-maven-unstable", ], ) -use_repo(maven, "maven") +use_repo(maven_ext, "maven") # # # # DEPRECATED -rules_proto_extenstion = use_extension("//bazel/extensions:deprecated/rules_proto_extension.bzl", "rules_proto_extension") -use_repo(rules_proto_extenstion, "rules_proto") +rules_proto_ext = use_extension("//bazel/extensions:deprecated/rules_proto_extension.bzl", "rules_proto_extension") +use_repo(rules_proto_ext, "rules_proto") -io_grpc_grpc_java_extension = use_extension("//bazel/extensions:deprecated/io_grpc_grpc_java_extension.bzl", "io_grpc_grpc_java_extension") -use_repo(io_grpc_grpc_java_extension, "io_grpc_grpc_java") +io_grpc_grpc_java_ext = use_extension("//bazel/extensions:deprecated/io_grpc_grpc_java_extension.bzl", "io_grpc_grpc_java_extension") +use_repo(io_grpc_grpc_java_ext, "io_grpc_grpc_java") # # # # # # # Libs -ncurses = use_extension("//bazel/extensions/dependencies/lib:ncurses_extension.bzl", "ncurses") -use_repo(ncurses, "ncurses") +ncurses_ext = use_extension("//bazel/extensions/dependencies/lib:ncurses_extension.bzl", "ncurses") +use_repo(ncurses_ext, "ncurses") -m4 = use_extension("//bazel/extensions/dependencies/bin:m4_extension.bzl", "m4") -use_repo(m4, "m4") +m4_ext = use_extension("//bazel/extensions/dependencies/bin:m4_extension.bzl", "m4") +use_repo(m4_ext, "m4") -autoconf = use_extension("//bazel/extensions/dependencies/scripts:autoconf_extension.bzl", "autoconf") -use_repo(autoconf, "autoconf") -automake = use_extension("//bazel/extensions/dependencies/scripts:automake_extension.bzl", "automake") -use_repo(automake, "automake") +autoconf_ext = use_extension("//bazel/extensions/dependencies/scripts:autoconf_extension.bzl", "autoconf") +use_repo(autoconf_ext, "autoconf") +automake_ext = use_extension("//bazel/extensions/dependencies/scripts:automake_extension.bzl", "automake") +use_repo(automake_ext, "automake") # # # bazel_dep(name = "rules_perl", version = "1.1.0") \ No newline at end of file From 92bfbb591c1d5cc16ecd277baeb2b741f0b9fa6f Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 7 Apr 2026 21:07:38 +0200 Subject: [PATCH 077/287] feat: Add Cabal to project --- sdk/MODULE.bazel | 3 + .../dependencies/haskell/cabal_extension.bzl | 67 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index b1e980c5c48c..70816e65b37c 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -37,6 +37,9 @@ haskell_toolchains_ext.bindists(version = "9.0.2") da_ghc_ext = use_extension("//bazel/extensions/dependencies/haskell:da_ghc_extension.bzl", "da_ghc") use_repo(da_ghc_ext, "da-ghc", "ghc-lib-gen") +cabal_ext = use_extension("//bazel/extensions/dependencies/haskell:cabal_extension.bzl", "cabal") +use_repo(cabal_ext, "cabal") + ghcide_ext = use_extension("//bazel/extensions/dependencies/haskell:ghcide_extension.bzl", "ghcide") use_repo(ghcide_ext, "ghcide_ghc_lib") diff --git a/sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl new file mode 100644 index 000000000000..892d3e9b0817 --- /dev/null +++ b/sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl @@ -0,0 +1,67 @@ +# Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +CABAL_INSTALL_VERSION = "3.10.3.0" + +_BASE_URL = "https://downloads.haskell.org/~cabal/cabal-install-{v}/cabal-install-{v}".format( + v = CABAL_INSTALL_VERSION, +) + +_PLATFORMS = { + "linux-x86_64": { + "url": _BASE_URL + "-x86_64-linux-deb10.tar.xz", + "sha256": "1d7a7131402295b01f25be5373fde095a404c45f9b5a5508fb7474bb0d3d057a", + }, + "linux-aarch64": { + "url": _BASE_URL + "-aarch64-linux-deb10.tar.xz", + "sha256": "92d341620c60294535f03098bff796ef6de2701de0c4fcba249cde18a2923013", + }, + "darwin-x86_64": { + "url": _BASE_URL + "-x86_64-darwin.tar.xz", + "sha256": "3aed78619b2164dd61eb61afb024073ae2c50f6655fa60fcc1080980693e3220", + }, + "darwin-aarch64": { + "url": _BASE_URL + "-aarch64-darwin.tar.xz", + "sha256": "f4f606b1488a4b24c238f7e09619959eed89c550ed8f8478b350643f652dc08c", + }, + "windows-x86_64": { + "url": _BASE_URL + "-x86_64-windows.zip", + "sha256": "b651ca732998eba5c0e54f4329c147664a7fb3fe3e74eac890c31647ce1e179a", + }, +} + +def _cabal_install_impl(repository_ctx): + os_name = repository_ctx.os.name + os_arch = repository_ctx.os.arch + + if "linux" in os_name: + arch = "aarch64" if os_arch == "aarch64" else "x86_64" + platform_key = "linux-" + arch + elif "mac" in os_name: + arch = "aarch64" if os_arch == "aarch64" else "x86_64" + platform_key = "darwin-" + arch + elif "windows" in os_name: + platform_key = "windows-x86_64" + else: + fail("Unsupported OS for cabal-install: " + os_name) + + platform = _PLATFORMS[platform_key] + repository_ctx.download_and_extract( + url = platform["url"], + sha256 = platform["sha256"], + ) + + cabal_bin = "cabal.exe" if "windows" in os_name else "cabal" + repository_ctx.file( + "BUILD.bazel", + 'exports_files(["{}"], visibility = ["//visibility:public"])\n'.format(cabal_bin), + ) + +_cabal_install = repository_rule( + implementation = _cabal_install_impl, +) + +def _impl(module_ctx): + _cabal_install(name = "cabal") + +cabal = module_extension(implementation = _impl) From 39fe2ce4f59935e3843278d369facbe2d0d02cea Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 7 Apr 2026 22:42:17 +0200 Subject: [PATCH 078/287] feat: Enable sdist for ghc-lib and ghc-lib-parser --- .../haskell/files/haskell_da_ghc.BUILD.bzl | 119 ++++------- sdk/bazel/rules/ghc_lib_sdist.bzl | 192 ++++++++++++++++++ 2 files changed, 229 insertions(+), 82 deletions(-) create mode 100644 sdk/bazel/rules/ghc_lib_sdist.bzl diff --git a/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl b/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl index 4303195d39ec..d8410cd9d8d7 100644 --- a/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl @@ -4,8 +4,8 @@ load( "GHC_FLAVOR", "GHC_LIB_VERSION", ) -load("@os_info//:os_info.bzl", "is_darwin") load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_binary") +load("@//bazel/rules:ghc_lib_sdist.bzl", "ghc_lib_sdist") filegroup( name = "hadrian-srcs", @@ -46,89 +46,44 @@ filegroup( visibility = ["//visibility:public"], ) -_LANG = "en_US.UTF-8" if is_darwin else "C.UTF-8" -_CPP_OPTIONS = " ".join(["--cpp={}".format(cpp) for cpp in GHC_CPP_OPTIONS]) - -genrule( +ghc_lib_sdist( name = "ghc-lib", - srcs = [ - ":srcs", - ":README.md", - "@autoconf//:srcs", - "@autoconf//:README", - "@automake//:srcs", - "@automake//:README", - ], - tools = [ - ":hadrian", - "@ghc-lib-gen//:ghc-lib-gen", - "@m4//:m4", - "@rules_perl//:current_toolchain", - "@rules_haskell//haskell:current_haskell_toolchain", - ], - toolchains = [ - "@rules_cc//cc:current_cc_toolchain", - ], - outs = [ - "ghc-lib.cabal", - "ghc-lib-{version}.tar.gz".format(version = GHC_LIB_VERSION), + ghc_srcs = ":srcs", + readme = ":README.md", + ghc_lib_gen = "@ghc-lib-gen//:ghc-lib-gen", + hadrian = ":hadrian", + autotools = "@automake//:automake", + m4 = "@m4//:m4", + perl = "@rules_perl//:current_toolchain", + cabal = "@cabal//:cabal", + component = "", + version = GHC_LIB_VERSION, + ghc_flavor = GHC_FLAVOR, + extra_tools = [ + "@stackage-exe//happy", + "@stackage-exe//alex", ], - cmd = """\ -set -euo pipefail -ORIGIN=$$PWD - -echo "HASKELL: $(locations @rules_haskell//haskell:current_haskell_toolchain)" | tr ' ' '\n' | grep bin/ghc | head -3 -exit - -# Tool paths -M4_DIR="$$(dirname $$(realpath $(execpath @m4//:m4)))" -PERL_DIR="$$(realpath $$(dirname $$(echo "$(locations @rules_perl//:current_toolchain)" | cut -d' ' -f1)))/bin" -AUTOCONF_SRC="$$ORIGIN/$$(dirname $(location @autoconf//:README))" - -export PATH="$$PERL_DIR:$$M4_DIR:$$PATH" - -# Build autoconf inline -AUTOCONF_PREFIX=$$(mktemp -d) -cd $$AUTOCONF_SRC -./configure --prefix=$$AUTOCONF_PREFIX -make install -cd $$ORIGIN -export PATH="$$AUTOCONF_PREFIX/bin:$$PATH" - -# Build automake inline (shares prefix with autoconf) -AUTOMAKE_SRC="$$ORIGIN/$$(dirname $(location @automake//:README))" -cd $$AUTOMAKE_SRC -./configure --prefix=$$AUTOCONF_PREFIX -make install -cd $$ORIGIN - -export LANG={lang} -export CC="$(CC)" -export LD="$(LD)" -export PATH="$$ORIGIN/$$(dirname $(execpath :hadrian)):$$PATH" - -GHC_DIR="$$ORIGIN/$$(dirname $(execpath :README.md))" -TMP=$$(mktemp -d) -trap "rm -rf $$TMP $$AUTOCONF_PREFIX" EXIT -cp -rLt $$TMP $$GHC_DIR/. -export HOME="$$TMP" - -$(execpath @ghc-lib-gen//:ghc-lib-gen) $$TMP \ - --ghc-lib \ - --ghc-flavor={ghc_flavor} \ - {cpp_options} - -sed -i.bak -e "s#$$ORIGIN/##" $$TMP/ghc-lib/stage0/lib/settings -sed -i.bak -e 's#version: 0.1.0#version: {ghc_lib_version}#' $$TMP/ghc-lib.cabal + cpp_options = GHC_CPP_OPTIONS, + visibility = ["//visibility:public"], +) -cp $$TMP/ghc-lib.cabal $(execpath ghc-lib.cabal) -# cabal sdist must run from the source tree; OLDPWD retains the exec root after cd. -cd $$TMP && cabal sdist -o $$OLDPWD/$(RULEDIR) -""".format( - cpp_options = _CPP_OPTIONS, - ghc_flavor = GHC_FLAVOR, - ghc_lib_version = GHC_LIB_VERSION, - lang = _LANG, - ), +ghc_lib_sdist( + name = "ghc-lib-parser", + ghc_srcs = ":srcs", + readme = ":README.md", + ghc_lib_gen = "@ghc-lib-gen//:ghc-lib-gen", + hadrian = ":hadrian", + autotools = "@automake//:automake", + m4 = "@m4//:m4", + perl = "@rules_perl//:current_toolchain", + cabal = "@cabal//:cabal", + component = "-parser", + version = GHC_LIB_VERSION, + ghc_flavor = GHC_FLAVOR, + extra_tools = [ + "@stackage-exe//happy", + "@stackage-exe//alex", + ], + cpp_options = GHC_CPP_OPTIONS, visibility = ["//visibility:public"], ) diff --git a/sdk/bazel/rules/ghc_lib_sdist.bzl b/sdk/bazel/rules/ghc_lib_sdist.bzl new file mode 100644 index 000000000000..b1c45a8d7b8c --- /dev/null +++ b/sdk/bazel/rules/ghc_lib_sdist.bzl @@ -0,0 +1,192 @@ +# Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") +load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain") +load("//bazel/rules:install_gnu_tool.bzl", "InstalledGnuToolInfo") + +def _ghc_lib_sdist_impl(ctx): + component = ctx.attr.component + version = ctx.attr.version + + # -- Outputs -- + cabal_file = ctx.actions.declare_file("ghc-lib{}.cabal".format(component)) + tarball = ctx.actions.declare_file("ghc-lib{}-{}.tar.gz".format(component, version)) + + # -- Haskell toolchain (GHC) -- + hs_toolchain = ctx.toolchains["@rules_haskell//haskell:toolchain"] + ghc = hs_toolchain.tools.ghc + ghc_bindir = hs_toolchain.bindir + ghc_libdir = hs_toolchain.libdir + + # -- CC toolchain (CC / LD) -- + cc_toolchain = find_cc_toolchain(ctx) + feature_configuration = cc_common.configure_features( + ctx = ctx, + cc_toolchain = cc_toolchain, + requested_features = ctx.features, + unsupported_features = ctx.disabled_features, + ) + cc = cc_common.get_tool_for_action( + feature_configuration = feature_configuration, + action_name = ACTION_NAMES.c_compile, + ) + ld = cc_common.get_tool_for_action( + feature_configuration = feature_configuration, + action_name = ACTION_NAMES.cpp_link_executable, + ) + + # -- Autotools prefix (InstalledGnuToolInfo from install_gnu_tool) -- + autotools_info = ctx.attr.autotools[InstalledGnuToolInfo] + + # -- Perl binary -- + perl_files = ctx.files.perl + perl_bin = [f for f in perl_files if f.basename == "perl"][0] + + # -- Extra tools on PATH (e.g. happy, alex) -- + extra_tool_path_entries = [] + for tool in ctx.files.extra_tools: + extra_tool_path_entries.append('"$EXECROOT/{}"'.format(tool.dirname)) + + # -- cpp_options -- + cpp_options = " ".join(["--cpp={}".format(cpp) for cpp in ctx.attr.cpp_options]) + + # -- Shell command -- + shell_cmd = """\ +set -euo pipefail +EXECROOT="$PWD" + +# Set up autotools from pre-built prefix tree. +# The prefix contains __EXECROOT__ placeholders that must be fixed up. +AUTOTOOLS_TMP=$(mktemp -d) +cp -rL "$EXECROOT/{autotools_prefix}/." "$AUTOTOOLS_TMP/" +find "$AUTOTOOLS_TMP" -type f | while IFS= read -r f; do + if file --mime-type "$f" | grep -q text; then + sed -i "s|__EXECROOT__/{autotools_prefix}|$AUTOTOOLS_TMP|g" "$f" + sed -i "s|__EXECROOT__|$EXECROOT|g" "$f" + fi +done +export PATH="$AUTOTOOLS_TMP/{autotools_bindir}:$PATH" + +# Tool paths +export PATH="$(dirname "$EXECROOT/{ghc_path}"):$PATH" +export PATH="$(dirname "$EXECROOT/{perl_path}"):$PATH" +export PATH="$(dirname "$EXECROOT/{m4_path}"):$PATH" +export PATH="$(dirname "$EXECROOT/{hadrian_path}"):$PATH" +export PATH="$(dirname "$EXECROOT/{cabal_path}"):$PATH" +{extra_tool_path} + +# Locale +if [ "$(uname)" = "Darwin" ]; then + export LANG=en_US.UTF-8 +else + export LANG=C.UTF-8 +fi + +CC_PATH="{cc_path}" +LD_PATH="{ld_path}" +case "$CC_PATH" in /*) ;; *) CC_PATH="$EXECROOT/$CC_PATH" ;; esac +case "$LD_PATH" in /*) ;; *) LD_PATH="$EXECROOT/$LD_PATH" ;; esac +export CC="$CC_PATH" +export LD="$LD_PATH" + +# Copy GHC source tree to a writable temp directory +GHC_DIR="$EXECROOT/{ghc_src_dir}" +TMP=$(mktemp -d) +trap "rm -rf $TMP $AUTOTOOLS_TMP" EXIT +cp -rLt $TMP $GHC_DIR/. +export HOME="$TMP" + +# Generate ghc-lib{component} cabal project +$EXECROOT/{ghc_lib_gen_path} $TMP \ + --ghc-lib{component} \ + --ghc-flavor={ghc_flavor} \ + {cpp_options} + +# Remove absolute paths to the execroot from GHC settings +sed -i.bak \ + -e "s#$EXECROOT/##" \ + $TMP/ghc-lib/stage0/lib/settings + +# Patch the ghc-lib version +sed -i.bak \ + -e 's#version: 0.1.0#version: {version}#' \ + $TMP/ghc-lib{component}.cabal + +# Copy cabal file to declared output +cp $TMP/ghc-lib{component}.cabal $EXECROOT/{cabal_output} + +# Create source distribution tarball +(cd $TMP; $EXECROOT/{cabal_path} sdist -o $EXECROOT/{output_dir}) +""".format( + autotools_prefix = autotools_info.prefix.path, + autotools_bindir = autotools_info.bindir, + ghc_path = ghc.path, + perl_path = perl_bin.path, + m4_path = ctx.file.m4.path, + hadrian_path = ctx.executable.hadrian.path, + cabal_path = ctx.file.cabal.path, + ghc_lib_gen_path = ctx.executable.ghc_lib_gen.path, + extra_tool_path = "\n".join( + ['export PATH={}:"$PATH"'.format(d) for d in extra_tool_path_entries] + ), + cc_path = cc, + ld_path = ld, + ghc_src_dir = ctx.file.readme.dirname, + component = component, + version = version, + ghc_flavor = ctx.attr.ghc_flavor, + cpp_options = cpp_options, + cabal_output = cabal_file.path, + output_dir = tarball.dirname, + ) + + # -- Action -- + ctx.actions.run_shell( + outputs = [cabal_file, tarball], + inputs = depset( + direct = [ + ctx.file.readme, + autotools_info.prefix, + ctx.file.m4, + ctx.file.cabal, + perl_bin, + ] + ctx.files.ghc_srcs + ctx.files.perl + ghc_bindir + ghc_libdir + ctx.files.extra_tools, + transitive = [cc_toolchain.all_files], + ), + tools = [ + ctx.executable.ghc_lib_gen, + ctx.executable.hadrian, + ], + command = shell_cmd, + mnemonic = "GhcLibSdist", + progress_message = "Generating ghc-lib%s sdist" % component, + use_default_shell_env = False, + ) + + return [DefaultInfo(files = depset([cabal_file, tarball]))] + +ghc_lib_sdist = rule( + implementation = _ghc_lib_sdist_impl, + attrs = { + "ghc_srcs": attr.label(mandatory = True), + "readme": attr.label(mandatory = True, allow_single_file = True), + "ghc_lib_gen": attr.label(mandatory = True, executable = True, cfg = "exec"), + "hadrian": attr.label(mandatory = True, executable = True, cfg = "exec"), + "autotools": attr.label(mandatory = True, providers = [InstalledGnuToolInfo]), + "m4": attr.label(mandatory = True, allow_single_file = True), + "perl": attr.label(mandatory = True), + "cabal": attr.label(mandatory = True, allow_single_file = True), + "component": attr.string(default = "", values = ["", "-parser"]), + "version": attr.string(mandatory = True), + "ghc_flavor": attr.string(mandatory = True), + "extra_tools": attr.label_list(allow_files = True, doc = "Additional tool binaries needed on PATH (e.g. happy, alex)."), + "cpp_options": attr.string_list(default = []), + "_cc_toolchain": attr.label(default = "@rules_cc//cc:current_cc_toolchain"), + }, + toolchains = [ + "@rules_haskell//haskell:toolchain", + "@rules_cc//cc:toolchain_type", + ], + fragments = ["cpp"], +) From 489ae81a1c15b2dc2d995645d284ae978f42fe49 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 8 Apr 2026 17:43:12 +0200 Subject: [PATCH 079/287] feat: Enable `@ghcide_lib//:ghcide` --- sdk/MODULE.bazel | 6 +- .../haskell/files/haskell_da_ghc.BUILD.bzl | 4 + ...BUILD.bzl => haskell_ghcide_lib.BUILD.bzl} | 0 .../dependencies/haskell/ghcide_extension.bzl | 6 +- sdk/bazel/rules/ghc_lib_sdist.bzl | 8 +- .../ghc-lib/ghc-lib-parser/BUILD.bazel | 169 +++++++++--------- sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel | 169 +++++++++--------- 7 files changed, 187 insertions(+), 175 deletions(-) rename sdk/bazel/extensions/dependencies/haskell/files/{haskell_ghcide_ghc_lib.BUILD.bzl => haskell_ghcide_lib.BUILD.bzl} (100%) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 70816e65b37c..01cfdc0d22a8 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -40,8 +40,8 @@ use_repo(da_ghc_ext, "da-ghc", "ghc-lib-gen") cabal_ext = use_extension("//bazel/extensions/dependencies/haskell:cabal_extension.bzl", "cabal") use_repo(cabal_ext, "cabal") -ghcide_ext = use_extension("//bazel/extensions/dependencies/haskell:ghcide_extension.bzl", "ghcide") -use_repo(ghcide_ext, "ghcide_ghc_lib") +ghcide_lib_ext = use_extension("//bazel/extensions/dependencies/haskell:ghcide_extension.bzl", "ghcide_lib") +use_repo(ghcide_lib_ext, "ghcide_lib") lsp_types_ext = use_extension("//bazel/extensions/dependencies/haskell:lsp_types_extension.bzl", "lsp_types") use_repo(lsp_types_ext, "lsp-types") @@ -155,7 +155,7 @@ stack_snapshot_ext.package( stack_snapshot_ext.package( name = "ghcide", flags = ["ghc-lib"], - vendored = "@ghcide_ghc_lib//:ghcide", + vendored = "@ghcide_lib//:ghcide", ) stack_snapshot_ext.package( name = "proto3-suite", diff --git a/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl b/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl index d8410cd9d8d7..6ec91100aa45 100644 --- a/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl @@ -64,6 +64,8 @@ ghc_lib_sdist( "@stackage-exe//alex", ], cpp_options = GHC_CPP_OPTIONS, + cabal_out = "ghc-lib.cabal", + tarball_out = "ghc-lib-{}.tar.gz".format(GHC_LIB_VERSION), visibility = ["//visibility:public"], ) @@ -85,5 +87,7 @@ ghc_lib_sdist( "@stackage-exe//alex", ], cpp_options = GHC_CPP_OPTIONS, + cabal_out = "ghc-lib-parser.cabal", + tarball_out = "ghc-lib-parser-{}.tar.gz".format(GHC_LIB_VERSION), visibility = ["//visibility:public"], ) diff --git a/sdk/bazel/extensions/dependencies/haskell/files/haskell_ghcide_ghc_lib.BUILD.bzl b/sdk/bazel/extensions/dependencies/haskell/files/haskell_ghcide_lib.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/haskell/files/haskell_ghcide_ghc_lib.BUILD.bzl rename to sdk/bazel/extensions/dependencies/haskell/files/haskell_ghcide_lib.BUILD.bzl diff --git a/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl index 659134e97540..fc05298862a4 100644 --- a/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl @@ -5,8 +5,8 @@ def _impl(module_ctx): GHCIDE_SHA256 = "bc2bd2fbfbfb501e303b35fb4b2f503b122e4eb0aff34472f0e882d2289afc57" http_archive( - name = "ghcide_ghc_lib", - build_file = ":files/haskell_ghcide_ghc_lib.BUILD.bzl", + name = "ghcide_lib", + build_file = ":files/haskell_ghcide_lib.BUILD.bzl", patch_args = ["-p1"], patches = [ "//bazel/patches:haskell/ghcide_binary_q.patch", @@ -16,4 +16,4 @@ def _impl(module_ctx): url = "https://github.com/digital-asset/daml-ghcide/archive/%s.tar.gz" % GHCIDE_REV, ) -ghcide = module_extension(implementation = _impl) +ghcide_lib = module_extension(implementation = _impl) diff --git a/sdk/bazel/rules/ghc_lib_sdist.bzl b/sdk/bazel/rules/ghc_lib_sdist.bzl index b1c45a8d7b8c..162dc34948d1 100644 --- a/sdk/bazel/rules/ghc_lib_sdist.bzl +++ b/sdk/bazel/rules/ghc_lib_sdist.bzl @@ -9,9 +9,9 @@ def _ghc_lib_sdist_impl(ctx): component = ctx.attr.component version = ctx.attr.version - # -- Outputs -- - cabal_file = ctx.actions.declare_file("ghc-lib{}.cabal".format(component)) - tarball = ctx.actions.declare_file("ghc-lib{}-{}.tar.gz".format(component, version)) + # -- Outputs (predeclared via attr.output) -- + cabal_file = ctx.outputs.cabal_out + tarball = ctx.outputs.tarball_out # -- Haskell toolchain (GHC) -- hs_toolchain = ctx.toolchains["@rules_haskell//haskell:toolchain"] @@ -182,6 +182,8 @@ ghc_lib_sdist = rule( "ghc_flavor": attr.string(mandatory = True), "extra_tools": attr.label_list(allow_files = True, doc = "Additional tool binaries needed on PATH (e.g. happy, alex)."), "cpp_options": attr.string_list(default = []), + "cabal_out": attr.output(mandatory = True, doc = "Declared output for the .cabal file."), + "tarball_out": attr.output(mandatory = True, doc = "Declared output for the sdist tarball."), "_cc_toolchain": attr.label(default = "@rules_cc//cc:current_cc_toolchain"), }, toolchains = [ diff --git a/sdk/bazel_tools/ghc-lib/ghc-lib-parser/BUILD.bazel b/sdk/bazel_tools/ghc-lib/ghc-lib-parser/BUILD.bazel index 66d22615e721..74f63524e97a 100644 --- a/sdk/bazel_tools/ghc-lib/ghc-lib-parser/BUILD.bazel +++ b/sdk/bazel_tools/ghc-lib/ghc-lib-parser/BUILD.bazel @@ -1,83 +1,86 @@ -# # Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# # SPDX-License-Identifier: Apache-2.0 -# -# load("@bazel_skylib//rules:copy_file.bzl", "copy_file") -# load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") -# load("@stackage//:packages.bzl", "packages") -# load("//bazel_tools/ghc-lib:version.bzl", "GHC_LIB_VERSION") -# load("//bazel_tools:pkg.bzl", "unpack_tar") -# load( -# "//bazel_tools/sh:sh.bzl", -# "sh_inline_binary", -# "sh_inline_test", -# ) -# -# unpack_tar( -# name = "unpack", -# src = "@da-ghc//:ghc-lib-parser-{}.tar.gz".format(GHC_LIB_VERSION), -# outs = [ -# "srcs/LICENSE", -# "srcs/compiler/", -# "srcs/ghc-lib/", -# "srcs/includes/", -# "srcs/libraries/", -# ], -# prefix = "srcs", -# strip = 1, -# ) -# -# copy_file( -# name = "cabal-file", -# src = "@da-ghc//:ghc-lib-parser.cabal", -# out = "srcs/ghc-lib-parser.cabal", -# ) -# -# sh_inline_binary( -# name = "cabal-update", -# cmd = """\ -# SOURCE=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib-parser.cabal)) -# OUTPUT_DIR=$$BUILD_WORKSPACE_DIRECTORY/bazel_tools/ghc-lib/ghc-lib-parser -# -# cp --no-preserve=mode -t "$$OUTPUT_DIR" "$$SOURCE" -# """, -# data = [ -# "@da-ghc//:ghc-lib-parser.cabal", -# ], -# toolchains = ["@rules_sh//sh/posix:make_variables"], -# ) -# -# sh_inline_test( -# name = "cabal-file-diff", -# cmd = """\ -# EXPECTED=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib-parser.cabal)) -# ACTUAL=$$(canonicalize_rlocation $(rootpath ghc-lib-parser.cabal)) -# $(POSIX_DIFF) -Naur --strip-trailing-cr $$EXPECTED $$ACTUAL || { -# echo "The checked in ghc-lib-parser.cabal file is out of sync" >&2 -# exit 1 -# } -# """, -# data = [ -# "ghc-lib-parser.cabal", -# "@da-ghc//:ghc-lib-parser.cabal", -# ], -# toolchains = ["@rules_sh//sh/posix:make_variables"], -# ) -# -# filegroup( -# name = "srcs", -# srcs = [ -# ":cabal-file", -# ":unpack", -# ], -# ) -# -# haskell_cabal_library( -# name = "ghc-lib-parser", -# srcs = [":srcs"], -# flags = packages["ghc-lib-parser"].flags, -# haddock = False, -# tools = packages["ghc-lib-parser"].tools, -# version = packages["ghc-lib-parser"].version, -# visibility = ["//visibility:public"], -# deps = packages["ghc-lib-parser"].deps, -# ) +# Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +load("@bazel_skylib//rules:copy_file.bzl", "copy_file") +load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") +load("@stackage//:packages.bzl", "packages") +load("//bazel_tools/ghc-lib:version.bzl", "GHC_LIB_VERSION") +load("//bazel_tools:pkg.bzl", "unpack_tar") +load( + "//bazel_tools/sh:sh.bzl", + "sh_inline_binary", + "sh_inline_test", +) + +unpack_tar( + name = "unpack", + src = "@da-ghc//:ghc-lib-parser-{}.tar.gz".format(GHC_LIB_VERSION), + outs = [ + "srcs/LICENSE", + "srcs/compiler/", + "srcs/ghc-lib/", + "srcs/includes/", + "srcs/libraries/", + ], + prefix = "srcs", + strip = 1, +) + +copy_file( + name = "cabal-file", + src = "@da-ghc//:ghc-lib-parser.cabal", + out = "srcs/ghc-lib-parser.cabal", +) + +sh_inline_binary( + name = "cabal-update", + cmd = """\ +SOURCE=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib-parser.cabal)) +OUTPUT_DIR=$$BUILD_WORKSPACE_DIRECTORY/bazel_tools/ghc-lib/ghc-lib-parser + +cp --no-preserve=mode -t "$$OUTPUT_DIR" "$$SOURCE" +""", + data = [ + "@da-ghc//:ghc-lib-parser.cabal", + ], + toolchains = ["@rules_sh//sh/posix:make_variables"], +) + +sh_inline_test( + name = "cabal-file-diff", + cmd = """\ +EXPECTED=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib-parser.cabal)) +ACTUAL=$$(canonicalize_rlocation $(rootpath ghc-lib-parser.cabal)) +$(POSIX_DIFF) -Naur --strip-trailing-cr $$EXPECTED $$ACTUAL || { + echo "The checked in ghc-lib-parser.cabal file is out of sync" >&2 + exit 1 +} +""", + data = [ + "ghc-lib-parser.cabal", + "@da-ghc//:ghc-lib-parser.cabal", + ], + toolchains = ["@rules_sh//sh/posix:make_variables"], +) + +filegroup( + name = "srcs", + srcs = [ + ":cabal-file", + ":unpack", + ], +) + +haskell_cabal_library( + name = "ghc-lib-parser", + srcs = [":srcs"], + flags = packages["ghc-lib-parser"].flags, + haddock = False, + tools = [ + "@stackage-exe//alex", + "@stackage-exe//happy", + ], + version = packages["ghc-lib-parser"].version, + visibility = ["//visibility:public"], + deps = packages["ghc-lib-parser"].deps, +) diff --git a/sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel b/sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel index b4898db0cab7..81828917447d 100644 --- a/sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel +++ b/sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel @@ -1,83 +1,86 @@ -# # Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# # SPDX-License-Identifier: Apache-2.0 -# -# load("@bazel_skylib//rules:copy_file.bzl", "copy_file") -# load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") -# load("@stackage//:packages.bzl", "packages") -# load("//bazel_tools/ghc-lib:version.bzl", "GHC_LIB_VERSION") -# load("//bazel_tools:pkg.bzl", "unpack_tar") -# load( -# "//bazel_tools/sh:sh.bzl", -# "sh_inline_binary", -# "sh_inline_test", -# ) -# -# unpack_tar( -# name = "unpack", -# src = "@da-ghc//:ghc-lib-{}.tar.gz".format(GHC_LIB_VERSION), -# outs = [ -# "srcs/LICENSE", -# "srcs/compiler/", -# "srcs/ghc-lib/", -# "srcs/includes/", -# "srcs/libraries/", -# ], -# prefix = "srcs", -# strip = 1, -# ) -# -# copy_file( -# name = "cabal-file", -# src = "@da-ghc//:ghc-lib.cabal", -# out = "srcs/ghc-lib.cabal", -# ) -# -# sh_inline_binary( -# name = "cabal-update", -# cmd = """\ -# SOURCE=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib.cabal)) -# OUTPUT_DIR=$$BUILD_WORKSPACE_DIRECTORY/bazel_tools/ghc-lib/ghc-lib -# -# cp --no-preserve=mode -t "$$OUTPUT_DIR" "$$SOURCE" -# """, -# data = [ -# "@da-ghc//:ghc-lib.cabal", -# ], -# toolchains = ["@rules_sh//sh/posix:make_variables"], -# ) -# -# sh_inline_test( -# name = "cabal-file-diff", -# cmd = """\ -# EXPECTED=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib.cabal)) -# ACTUAL=$$(canonicalize_rlocation $(rootpath ghc-lib.cabal)) -# $(POSIX_DIFF) -Naur --strip-trailing-cr $$EXPECTED $$ACTUAL || { -# echo "The checked in ghc-lib.cabal file is out of sync" >&2 -# exit 1 -# } -# """, -# data = [ -# "ghc-lib.cabal", -# "@da-ghc//:ghc-lib.cabal", -# ], -# toolchains = ["@rules_sh//sh/posix:make_variables"], -# ) -# -# filegroup( -# name = "srcs", -# srcs = [ -# ":cabal-file", -# ":unpack", -# ], -# ) -# -# haskell_cabal_library( -# name = "ghc-lib", -# srcs = [":srcs"], -# flags = packages["ghc-lib"].flags, -# haddock = False, -# tools = packages["ghc-lib"].tools, -# version = packages["ghc-lib"].version, -# visibility = ["//visibility:public"], -# deps = packages["ghc-lib"].deps, -# ) +# Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +load("@bazel_skylib//rules:copy_file.bzl", "copy_file") +load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") +load("@stackage//:packages.bzl", "packages") +load("//bazel_tools/ghc-lib:version.bzl", "GHC_LIB_VERSION") +load("//bazel_tools:pkg.bzl", "unpack_tar") +load( + "//bazel_tools/sh:sh.bzl", + "sh_inline_binary", + "sh_inline_test", +) + +unpack_tar( + name = "unpack", + src = "@da-ghc//:ghc-lib-{}.tar.gz".format(GHC_LIB_VERSION), + outs = [ + "srcs/LICENSE", + "srcs/compiler/", + "srcs/ghc-lib/", + "srcs/includes/", + "srcs/libraries/", + ], + prefix = "srcs", + strip = 1, +) + +copy_file( + name = "cabal-file", + src = "@da-ghc//:ghc-lib.cabal", + out = "srcs/ghc-lib.cabal", +) + +sh_inline_binary( + name = "cabal-update", + cmd = """\ +SOURCE=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib.cabal)) +OUTPUT_DIR=$$BUILD_WORKSPACE_DIRECTORY/bazel_tools/ghc-lib/ghc-lib + +cp --no-preserve=mode -t "$$OUTPUT_DIR" "$$SOURCE" +""", + data = [ + "@da-ghc//:ghc-lib.cabal", + ], + toolchains = ["@rules_sh//sh/posix:make_variables"], +) + +sh_inline_test( + name = "cabal-file-diff", + cmd = """\ +EXPECTED=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib.cabal)) +ACTUAL=$$(canonicalize_rlocation $(rootpath ghc-lib.cabal)) +$(POSIX_DIFF) -Naur --strip-trailing-cr $$EXPECTED $$ACTUAL || { + echo "The checked in ghc-lib.cabal file is out of sync" >&2 + exit 1 +} +""", + data = [ + "ghc-lib.cabal", + "@da-ghc//:ghc-lib.cabal", + ], + toolchains = ["@rules_sh//sh/posix:make_variables"], +) + +filegroup( + name = "srcs", + srcs = [ + ":cabal-file", + ":unpack", + ], +) + +haskell_cabal_library( + name = "ghc-lib", + srcs = [":srcs"], + flags = packages["ghc-lib"].flags, + haddock = False, + tools = [ + "@stackage-exe//alex", + "@stackage-exe//happy", + ], + version = packages["ghc-lib"].version, + visibility = ["//visibility:public"], + deps = packages["ghc-lib"].deps, +) From fa59cd5a2d4aa481b9497f3559091610dd1f4d14 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 8 Apr 2026 18:36:57 +0200 Subject: [PATCH 080/287] fix: Remove old and unnecessary files from `@ghc-lib` --- sdk/MODULE.bazel | 4 +- .../dependencies/haskell/da_ghc_extension.bzl | 4 +- .../haskell/files/haskell_da_ghc.BUILD.bzl | 4 +- .../dependencies/haskell/ghc_lib_version.bzl} | 2 - sdk/bazel/ghc-lib/BUILD | 2 + sdk/{bazel_tools => bazel}/ghc-lib/README.md | 22 +-- .../ghc-lib/ghc-lib-parser/BUILD.bazel | 4 +- .../ghc-lib-parser/ghc-lib-parser.cabal | 0 .../ghc-lib/ghc-lib/BUILD.bazel | 4 +- .../ghc-lib/ghc-lib/ghc-lib.cabal | 0 sdk/bazel_tools/ghc-lib/BUILD.bazel | 44 ----- sdk/bazel_tools/ghc-lib/BUILD.ghc | 7 - sdk/bazel_tools/ghc-lib/BUILD.ghc-lib-gen | 6 - sdk/bazel_tools/ghc-lib/BUILD.nix-deps | 57 ------ sdk/bazel_tools/ghc-lib/defs.bzl | 153 --------------- .../ghc-lib/ghc-lib-no-stack.patch | 35 ---- sdk/bazel_tools/ghc-lib/lib.sh | 47 ----- sdk/bazel_tools/ghc-lib/repositories.bzl | 185 ------------------ sdk/bazel_tools/haskell.bzl | 2 +- 19 files changed, 20 insertions(+), 562 deletions(-) rename sdk/{bazel_tools/ghc-lib/version.bzl => bazel/extensions/dependencies/haskell/ghc_lib_version.bzl} (97%) create mode 100644 sdk/bazel/ghc-lib/BUILD rename sdk/{bazel_tools => bazel}/ghc-lib/README.md (71%) rename sdk/{bazel_tools => bazel}/ghc-lib/ghc-lib-parser/BUILD.bazel (93%) rename sdk/{bazel_tools => bazel}/ghc-lib/ghc-lib-parser/ghc-lib-parser.cabal (100%) rename sdk/{bazel_tools => bazel}/ghc-lib/ghc-lib/BUILD.bazel (93%) rename sdk/{bazel_tools => bazel}/ghc-lib/ghc-lib/ghc-lib.cabal (100%) delete mode 100644 sdk/bazel_tools/ghc-lib/BUILD.bazel delete mode 100644 sdk/bazel_tools/ghc-lib/BUILD.ghc delete mode 100644 sdk/bazel_tools/ghc-lib/BUILD.ghc-lib-gen delete mode 100644 sdk/bazel_tools/ghc-lib/BUILD.nix-deps delete mode 100644 sdk/bazel_tools/ghc-lib/defs.bzl delete mode 100644 sdk/bazel_tools/ghc-lib/ghc-lib-no-stack.patch delete mode 100644 sdk/bazel_tools/ghc-lib/lib.sh delete mode 100644 sdk/bazel_tools/ghc-lib/repositories.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 01cfdc0d22a8..b71ebde2bdbe 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -146,11 +146,11 @@ stack_snapshot_ext.package( ) stack_snapshot_ext.package( name = "ghc-lib", - vendored = "//bazel_tools/ghc-lib/ghc-lib", + vendored = "//bazel/ghc-lib/ghc-lib", ) stack_snapshot_ext.package( name = "ghc-lib-parser", - vendored = "//bazel_tools/ghc-lib/ghc-lib-parser", + vendored = "//bazel/ghc-lib/ghc-lib-parser", ) stack_snapshot_ext.package( name = "ghcide", diff --git a/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl index 998c2bd6f1ca..396f00c95bb9 100644 --- a/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl @@ -1,12 +1,10 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load( - "//bazel_tools/ghc-lib:version.bzl", - "GHC_LIB_PATCHES", + ":ghc_lib_version.bzl", "GHC_LIB_REPO_URL", "GHC_LIB_REV", "GHC_LIB_SHA256", - "GHC_PATCHES", "GHC_REPO_URL", "GHC_REV", ) diff --git a/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl b/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl index 6ec91100aa45..e8cb76714572 100644 --- a/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl @@ -1,11 +1,11 @@ load( - "@//bazel_tools/ghc-lib:version.bzl", + "@//bazel/extensions/dependencies/haskell:ghc_lib_version.bzl", "GHC_CPP_OPTIONS", "GHC_FLAVOR", "GHC_LIB_VERSION", ) load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_binary") -load("@//bazel/rules:ghc_lib_sdist.bzl", "ghc_lib_sdist") +load("//bazel/rules:ghc_lib_sdist.bzl", "ghc_lib_sdist") filegroup( name = "hadrian-srcs", diff --git a/sdk/bazel_tools/ghc-lib/version.bzl b/sdk/bazel/extensions/dependencies/haskell/ghc_lib_version.bzl similarity index 97% rename from sdk/bazel_tools/ghc-lib/version.bzl rename to sdk/bazel/extensions/dependencies/haskell/ghc_lib_version.bzl index b0f2d430b165..68fc11a0b7aa 100644 --- a/sdk/bazel_tools/ghc-lib/version.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/ghc_lib_version.bzl @@ -10,8 +10,6 @@ GHC_LIB_PATCHES = [ GHC_REPO_URL = "https://github.com/digital-asset/ghc" GHC_REV = "5498b70afa00c93a959ced0f1d974aab73f5a53b" -GHC_PATCHES = [ -] GHC_FLAVOR = "da-ghc-8.8.1" GHC_LIB_VERSION = "8.8.1" diff --git a/sdk/bazel/ghc-lib/BUILD b/sdk/bazel/ghc-lib/BUILD new file mode 100644 index 000000000000..abf57b32b8eb --- /dev/null +++ b/sdk/bazel/ghc-lib/BUILD @@ -0,0 +1,2 @@ +# Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 diff --git a/sdk/bazel_tools/ghc-lib/README.md b/sdk/bazel/ghc-lib/README.md similarity index 71% rename from sdk/bazel_tools/ghc-lib/README.md rename to sdk/bazel/ghc-lib/README.md index 8d7273c17bd8..d5f3b3b751fc 100644 --- a/sdk/bazel_tools/ghc-lib/README.md +++ b/sdk/bazel/ghc-lib/README.md @@ -21,8 +21,8 @@ changes. ``` - To build the Cabal libraries ghc-lib(-parser) use the following commands: ``` - $ bazel build //bazel_tools/ghc-lib/ghc-lib-parser - $ bazel build //bazel_tools/ghc-lib/ghc-lib + $ bazel build //bazel/ghc-lib/ghc-lib-parser + $ bazel build //bazel/ghc-lib/ghc-lib ``` or alternatively you can use the aliases exposed by `stack_snapshot`'s `vendored_packages`. @@ -42,21 +42,15 @@ Note, an update of any of these may affect ghc-lib(-parser)'s Cabal files. If so, see below for updating the checked in Cabal files. - To update the GHC revision used to build ghc-lib change the `GHC_REV` - variable within `bazel_tools/ghc-lib/version.bzl`. - If needed update the patches listed within `GHC_PATCHES`, see below. + variable within `bazel/extensions/dependencies/haskell/ghc_lib_version.bzl`. - To update the GHC version used to build ghc-lib also update the `GHC_FLAVOR` - and `GHC_LIB_VERSION` variables within `bazel_tools/ghc-lib/version.bzl`. + and `GHC_LIB_VERSION` variables within + `bazel/extensions/dependencies/haskell/ghc_lib_version.bzl`. - To update the ghc-lib revision, which provides the `ghc-lib-gen` tool, change the `GHC_LIB_REV` and `GHC_LIB_SHA256` variables within - `bazel_tools/ghc-lib/version.bzl` and update the patches in `GHC_LIB_PATCHES` - if needed. + `bazel/extensions/dependencies/haskell/ghc_lib_version.bzl`. - To update the checked in Cabal files execute the following Bazel commands. ``` - $ bazel run //bazel_tools/ghc-lib/ghc-lib-parser:cabal-update - $ bazel run //bazel_tools/ghc-lib/ghc-lib:cabal-update + $ bazel run //bazel/ghc-lib/ghc-lib-parser:cabal-update + $ bazel run //bazel/ghc-lib/ghc-lib:cabal-update ``` - -## Patches - -- `ghc-lib-no-stack.patch` patch `ghc-lib-gen` to use a prebuilt Hadrian binary. - With this change `ghc-lib-gen` no longer requires `stack`. diff --git a/sdk/bazel_tools/ghc-lib/ghc-lib-parser/BUILD.bazel b/sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel similarity index 93% rename from sdk/bazel_tools/ghc-lib/ghc-lib-parser/BUILD.bazel rename to sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel index 74f63524e97a..a4b43afb214c 100644 --- a/sdk/bazel_tools/ghc-lib/ghc-lib-parser/BUILD.bazel +++ b/sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:copy_file.bzl", "copy_file") load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") load("@stackage//:packages.bzl", "packages") -load("//bazel_tools/ghc-lib:version.bzl", "GHC_LIB_VERSION") +load("//bazel/extensions/dependencies/haskell:ghc_lib_version.bzl", "GHC_LIB_VERSION") load("//bazel_tools:pkg.bzl", "unpack_tar") load( "//bazel_tools/sh:sh.bzl", @@ -36,7 +36,7 @@ sh_inline_binary( name = "cabal-update", cmd = """\ SOURCE=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib-parser.cabal)) -OUTPUT_DIR=$$BUILD_WORKSPACE_DIRECTORY/bazel_tools/ghc-lib/ghc-lib-parser +OUTPUT_DIR=$$BUILD_WORKSPACE_DIRECTORY/bazel/ghc-lib/ghc-lib-parser cp --no-preserve=mode -t "$$OUTPUT_DIR" "$$SOURCE" """, diff --git a/sdk/bazel_tools/ghc-lib/ghc-lib-parser/ghc-lib-parser.cabal b/sdk/bazel/ghc-lib/ghc-lib-parser/ghc-lib-parser.cabal similarity index 100% rename from sdk/bazel_tools/ghc-lib/ghc-lib-parser/ghc-lib-parser.cabal rename to sdk/bazel/ghc-lib/ghc-lib-parser/ghc-lib-parser.cabal diff --git a/sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel b/sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel similarity index 93% rename from sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel rename to sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel index 81828917447d..c5d3b94d1958 100644 --- a/sdk/bazel_tools/ghc-lib/ghc-lib/BUILD.bazel +++ b/sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:copy_file.bzl", "copy_file") load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") load("@stackage//:packages.bzl", "packages") -load("//bazel_tools/ghc-lib:version.bzl", "GHC_LIB_VERSION") +load("//bazel/extensions/dependencies/haskell:ghc_lib_version.bzl", "GHC_LIB_VERSION") load("//bazel_tools:pkg.bzl", "unpack_tar") load( "//bazel_tools/sh:sh.bzl", @@ -36,7 +36,7 @@ sh_inline_binary( name = "cabal-update", cmd = """\ SOURCE=$$(canonicalize_rlocation $(rootpath @da-ghc//:ghc-lib.cabal)) -OUTPUT_DIR=$$BUILD_WORKSPACE_DIRECTORY/bazel_tools/ghc-lib/ghc-lib +OUTPUT_DIR=$$BUILD_WORKSPACE_DIRECTORY/bazel/ghc-lib/ghc-lib cp --no-preserve=mode -t "$$OUTPUT_DIR" "$$SOURCE" """, diff --git a/sdk/bazel_tools/ghc-lib/ghc-lib/ghc-lib.cabal b/sdk/bazel/ghc-lib/ghc-lib/ghc-lib.cabal similarity index 100% rename from sdk/bazel_tools/ghc-lib/ghc-lib/ghc-lib.cabal rename to sdk/bazel/ghc-lib/ghc-lib/ghc-lib.cabal diff --git a/sdk/bazel_tools/ghc-lib/BUILD.bazel b/sdk/bazel_tools/ghc-lib/BUILD.bazel deleted file mode 100644 index 17d58c355dd1..000000000000 --- a/sdk/bazel_tools/ghc-lib/BUILD.bazel +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -load("@rules_sh//sh:sh.bzl", "sh_binaries") -load("@os_info//:os_info.bzl", "is_windows") -load("//bazel_tools:bundle.bzl", "cc_toolchain_binary_bundle", "library_bundle") - -sh_library( - name = "sh-lib", - srcs = ["lib.sh"], - visibility = ["@da-ghc//:__pkg__"], -) - -cc_toolchain_binary_bundle( - name = "cc-tools", -) - -sh_binaries( - name = "tools-windows", - deps = [ - "@cabal_win//:tools", - "@dadew_ghc_lib_deps_git//:tools", - "@dadew_ghc_lib_deps_msys2//:tools", - "@dadew_ghc_lib_deps_python//:tools", - "@ghc_win//:tools", - ], -) if is_windows else None - -sh_binaries( - name = "tools", - srcs = [ - "@stackage-exe//alex", - "@stackage-exe//happy", - ], - visibility = ["@da-ghc//:__pkg__"], - deps = [":cc-tools"] + - ([":tools-windows"] if is_windows else ["@nix_ghc_lib_deps//:tools"]), -) - -library_bundle( - name = "libs", - visibility = ["@da-ghc//:__pkg__"], - deps = [] if is_windows else ["@nix_ghc_lib_deps//:libs"], -) diff --git a/sdk/bazel_tools/ghc-lib/BUILD.ghc b/sdk/bazel_tools/ghc-lib/BUILD.ghc deleted file mode 100644 index 8c17a573e420..000000000000 --- a/sdk/bazel_tools/ghc-lib/BUILD.ghc +++ /dev/null @@ -1,7 +0,0 @@ -load("@com_github_digital_asset_daml//bazel_tools/ghc-lib:defs.bzl", "ghc") - -# Note, we use this indirection to avoid a re-fetch of the GHC repository on -# changes of the build definitions. -# See https://docs.bazel.build/versions/main/external.html#caching-of-external-dependencies -# > Changes to files referenced in the definition (e.g., patches or BUILD files) are also taken into account by bazel. -ghc() diff --git a/sdk/bazel_tools/ghc-lib/BUILD.ghc-lib-gen b/sdk/bazel_tools/ghc-lib/BUILD.ghc-lib-gen deleted file mode 100644 index fa95a479385c..000000000000 --- a/sdk/bazel_tools/ghc-lib/BUILD.ghc-lib-gen +++ /dev/null @@ -1,6 +0,0 @@ -load("@com_github_digital_asset_daml//bazel_tools/ghc-lib:defs.bzl", "ghc_lib_gen") - -# Note, we use this indirection to avoid a re-fetch of the ghc-lib repository -# on changes of the build definitions. -# See https://docs.bazel.build/versions/main/external.html#caching-of-external-dependencies -ghc_lib_gen() diff --git a/sdk/bazel_tools/ghc-lib/BUILD.nix-deps b/sdk/bazel_tools/ghc-lib/BUILD.nix-deps deleted file mode 100644 index 7d3b6905b721..000000000000 --- a/sdk/bazel_tools/ghc-lib/BUILD.nix-deps +++ /dev/null @@ -1,57 +0,0 @@ -load("@rules_sh//sh:sh.bzl", "sh_binaries") -load("@com_github_digital_asset_daml//bazel_tools:bundle.bzl", "library_bundle") - -package(default_visibility = ["//visibility:public"]) - -sh_binaries( - name = "tools", - srcs = glob(["bin/*"]), -) - -library_bundle( - name = "libs", - libs = [ - "libtinfo", - "libncurses", - "libncursesw", - "libform", - "libformw", - "libmenu", - "libmenuw", - "libpanel", - "libpanelw", - ], -) - -cc_library( - name = "libtinfo", - srcs = glob(["lib/libtinfo.*"]), -) - -[ - cc_library( - name = "libncurses{}".format(w), - srcs = glob(["lib/libncurses{}.*".format(w)]), - ) - for w in [ - "", - "w", - ] -] - -[ - cc_library( - name = "lib{}{}".format(name, w), - srcs = glob(["lib/lib{}{}.*".format(name, w)]), - deps = [":libncurses{}".format(w)], - ) - for name in [ - "form", - "menu", - "panel", - ] - for w in [ - "", - "w", - ] -] diff --git a/sdk/bazel_tools/ghc-lib/defs.bzl b/sdk/bazel_tools/ghc-lib/defs.bzl deleted file mode 100644 index 7e44ae3de048..000000000000 --- a/sdk/bazel_tools/ghc-lib/defs.bzl +++ /dev/null @@ -1,153 +0,0 @@ -# Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -load("@os_info//:os_info.bzl", "is_darwin") -load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_binary", "haskell_cabal_library") -load(":version.bzl", "GHC_CPP_OPTIONS", "GHC_FLAVOR", "GHC_LIB_VERSION") - -def ghc_lib_gen(): - """Build the ghc-lib-gen binary provided ghc-lib.""" - native.filegroup( - name = "srcs", - srcs = native.glob(["**"]), - visibility = ["//visibility:public"], - ) - haskell_cabal_library( - name = "ghc-lib-gen-lib", - package_name = "ghc-lib-gen", - version = "0.1.0.0", - haddock = False, - srcs = [":srcs"], - deps = [ - "@stackage//:base", - "@stackage//:process", - "@stackage//:filepath", - "@stackage//:containers", - "@stackage//:directory", - "@stackage//:optparse-applicative", - "@stackage//:bytestring", - "@stackage//:yaml", - "@stackage//:aeson", - "@stackage//:text", - "@stackage//:unordered-containers", - "@stackage//:extra", - ], - ) - haskell_cabal_binary( - name = "ghc-lib-gen", - srcs = [":srcs"], - deps = [ - ":ghc-lib-gen-lib", - "@stackage//:base", - "@stackage//:containers", - "@stackage//:directory", - "@stackage//:extra", - "@stackage//:filepath", - "@stackage//:optparse-applicative", - "@stackage//:process", - ], - visibility = ["//visibility:public"], - ) - -def ghc(): - """Build the ghc-lib(-parser) sdist from GHC using ghc-lib-gen. - - Builds `hadrian` with Bazel and exposes it as a ready-made tool into the - `genrule`s that create the Cabal sdists. - """ - native.filegroup( - name = "hadrian-srcs", - srcs = native.glob(["hadrian/**"]), - visibility = ["//visibility:public"], - ) - haskell_cabal_binary( - name = "hadrian", - flags = ["with_bazel"], - srcs = [":hadrian-srcs"], - deps = [ - "@stackage//:base", - "@stackage//:Cabal", - "@stackage//:containers", - "@stackage//:directory", - "@stackage//:extra", - "@stackage//:mtl", - "@stackage//:parsec", - "@stackage//:QuickCheck", - "@stackage//:shake", - "@stackage//:transformers", - "@stackage//:unordered-containers", - ], - tools = [ - "@stackage-exe//alex", - "@stackage-exe//happy", - ], - cabalopts = [ - "--ghc-option=-Wno-dodgy-imports", - "--ghc-option=-Wno-unused-imports", - ], - ) - native.filegroup( - name = "srcs", - srcs = native.glob(["**"]), - visibility = ["//visibility:public"], - ) - for component in ["", "-parser"]: - native.genrule( - name = "ghc-lib{}".format(component), - srcs = [ - ":srcs", - ":README.md", - ], - tools = [ - "@ghc-lib-gen", - "@//bazel_tools/ghc-lib:sh-lib", - ":hadrian", - ], - toolchains = [ - "@rules_cc//cc:current_cc_toolchain", - "@//bazel_tools/ghc-lib:libs", - "@//bazel_tools/ghc-lib:tools", - ], - outs = [ - "ghc-lib{}.cabal".format(component), - "ghc-lib{}-{}.tar.gz".format(component, GHC_LIB_VERSION), - ], - cmd = """\ -set -euo pipefail -EXECROOT=$$PWD -. $(execpath @//bazel_tools/ghc-lib:sh-lib) - -SEP="$$(path_list_separtor)" -export LIBRARY_PATH="$$(make_all_absolute "$(LIBS_LIBRARY_PATH)")" -export PATH="$$(make_all_absolute "$(_TOOLS_PATH)")$$SEP$$PATH" -export PATH="$$(abs_dirname "$(execpath :hadrian)")$$SEP$$PATH" -export LANG={lang} -export CC="$$(make_absolute $(CC))" -export LD="$$(make_absolute $(LD))" - -GHC="$$(abs_dirname $(execpath :README.md))" -TMP=$$(mktemp -d) -trap "rm -rf $$TMP" EXIT -cp -rLt $$TMP $$GHC/. -export HOME="$$TMP" - -$(execpath @ghc-lib-gen) $$TMP --ghc-lib{component} --ghc-flavor={ghc_flavor} {cpp_options} -# Remove absolute paths to the execroot. -sed -i.bak \\ - -e "s#$$EXECROOT/##" \\ - $$TMP/ghc-lib/stage0/lib/settings -# Patch the ghc-lib version. -sed -i.bak \\ - -e 's#version: 0.1.0#version: {ghc_lib_version}#' \\ - $$TMP/ghc-lib{component}.cabal -cp $$TMP/ghc-lib{component}.cabal $(execpath ghc-lib{component}.cabal) -(cd $$TMP; cabal sdist -o $$EXECROOT/$(RULEDIR)) -""".format( - component = component, - ghc_flavor = GHC_FLAVOR, - ghc_lib_version = GHC_LIB_VERSION, - lang = "en_US.UTF-8" if is_darwin else "C.UTF-8", - cpp_options = " ".join(["--cpp={}".format(cpp) for cpp in GHC_CPP_OPTIONS]), - ), - visibility = ["//visibility:public"], - ) diff --git a/sdk/bazel_tools/ghc-lib/ghc-lib-no-stack.patch b/sdk/bazel_tools/ghc-lib/ghc-lib-no-stack.patch deleted file mode 100644 index e7119de52c57..000000000000 --- a/sdk/bazel_tools/ghc-lib/ghc-lib-no-stack.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/ghc-lib-gen/src/Ghclibgen.hs b/ghc-lib-gen/src/Ghclibgen.hs -index 3574255..4fee612 100644 ---- a/ghc-lib-gen/src/Ghclibgen.hs -+++ b/ghc-lib-gen/src/Ghclibgen.hs -@@ -336,10 +336,7 @@ calcParserModules ghcFlavor = do - hsSrcIncludes = map ("-i" ++ ) (placeholderModulesDir : hsSrcDirs) - -- See [Note: GHC now depends on exceptions package]. - cmd = unwords $ -- [ "stack exec" ] ++ -- [ "--package exceptions" | ghcFlavor >= Ghc901 ] ++ -- [ "--stack-yaml hadrian/stack.yaml" ] ++ -- [ "-- ghc" -+ [ "ghc" - , "-dep-suffix ''" - , "-dep-makefile .parser-depends" - , "-M" -@@ -1258,15 +1255,13 @@ generatePrerequisites ghcFlavor = do - -- If building happy in the next step, the configure it does - -- requires some versions of alex and happy pre-exist. We make sure - -- of this in CI.hs. -- system_ "stack --stack-yaml hadrian/stack.yaml build --only-dependencies" -- system_ "stack --stack-yaml hadrian/stack.yaml exec -- bash -c ./boot" -- system_ "stack --stack-yaml hadrian/stack.yaml exec -- bash -c \"./configure --enable-tarballs-autodownload\"" -+ system_ "bash -c \"./boot --hadrian\"" -+ system_ "bash -c \"./configure --enable-tarballs-autodownload\"" - withCurrentDirectory "hadrian" $ do - -- No need to specify a stack.yaml here, we are in the hadrian - -- directory itself. -- system_ "stack build --no-library-profiling" - system_ $ unwords $ -- [ "stack exec hadrian --" -+ [ "hadrian" - , "--directory=.." - , "--build-root=ghc-lib" - ] ++ diff --git a/sdk/bazel_tools/ghc-lib/lib.sh b/sdk/bazel_tools/ghc-lib/lib.sh deleted file mode 100644 index b2f885aaa838..000000000000 --- a/sdk/bazel_tools/ghc-lib/lib.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -# Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -is_windows() { - case "$OSTYPE" in - win*) return 0;; - msys*) return 0;; - cygwin*) return 0;; - *) return 1;; - esac -} - -path_list_separtor() { - # Use ':' even on Windows because msys2 will automatically convert such - # path lists to the Windows format, using ';' as separator and 'C:\' - # syntax. Be sure that absolute paths use the format '/c/...' instead of - # 'C:\...'. See https://www.msys2.org/docs/filesystem-paths/. - if is_windows; then - echo ":" - else - echo ":" - fi -} - -make_absolute() { - local P="$1" - case "$P" in - /*|[a-zA-Z]:/*|[a-zA-Z]:\\*) echo "$P";; - *) echo "$PWD/$P";; - esac -} - -make_all_absolute() { - local IN="$1" ARR P OUT="" - local SEP="$(path_list_separtor)" - IFS="$SEP" read -ra ARR <<<"$IN" - for P in "${ARR[@]}"; do - OUT="$OUT$(make_absolute "$P")$SEP" - done - echo "${OUT%$SEP}" -} - -abs_dirname() { - local IN="$1" - echo "$(make_absolute "$(dirname "$IN")")" -} diff --git a/sdk/bazel_tools/ghc-lib/repositories.bzl b/sdk/bazel_tools/ghc-lib/repositories.bzl deleted file mode 100644 index b2293e2c7a52..000000000000 --- a/sdk/bazel_tools/ghc-lib/repositories.bzl +++ /dev/null @@ -1,185 +0,0 @@ -# Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "patch", "workspace_and_buildfile") -load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_package") -load("@rules_sh//sh:sh.bzl", "sh_binaries") -load("//bazel_tools/dev_env_tool:dev_env_tool.bzl", "dadew_binary_bundle") -load("//nix:repositories.bzl", "common_nix_file_deps", "dev_env_nix_repos") -load( - ":version.bzl", - "GHC_LIB_PATCHES", - "GHC_LIB_REPO_URL", - "GHC_LIB_REV", - "GHC_LIB_SHA256", - "GHC_PATCHES", - "GHC_REPO_URL", - "GHC_REV", -) - -def _ghc_lib_deps_windows(): - """Import dependencies of ghc-lib on Windows.""" - dadew_binary_bundle( - name = "dadew_ghc_lib_deps_git", - paths = [ - "bin/git", - ], - tool = "git", - ) - - dadew_binary_bundle( - name = "dadew_ghc_lib_deps_msys2", - paths = [ - # msys2 - "msys2", - "usr/bin/bash", - # autoconf - "usr/bin/autoconf", - "usr/bin/autoconf-2.71", - "usr/bin/autoheader", - "usr/bin/autoheader-2.71", - "usr/bin/autom4te", - "usr/bin/autom4te-2.71", - "usr/bin/autoreconf", - "usr/bin/autoreconf-2.71", - "usr/bin/autoscan", - "usr/bin/autoscan-2.71", - "usr/bin/autoupdate", - "usr/bin/autoupdate-2.71", - "usr/bin/ifnames", - "usr/bin/ifnames-2.71", - # automake - "usr/bin/aclocal", - "usr/bin/aclocal-1.16", - "usr/bin/automake", - "usr/bin/automake-1.16", - # diffutils - "usr/bin/cmp", - "usr/bin/diff", - "usr/bin/diff3", - "usr/bin/sdiff", - # gnumake - "usr/bin/make", - # m4 - "usr/bin/m4", - # ncurses - "usr/bin/captoinfo", - "usr/bin/clear", - "usr/bin/infocmp", - "usr/bin/infotocap", - "usr/bin/reset", - "usr/bin/tabs", - "usr/bin/tic", - "usr/bin/tput", - "usr/bin/tset", - # perl - "usr/bin/perl", - # xz - "usr/bin/lzcat", - "usr/bin/lzcmp", - "usr/bin/lzdiff", - "usr/bin/lzegrep", - "usr/bin/lzfgrep", - "usr/bin/lzgrep", - "usr/bin/lzless", - "usr/bin/lzma", - "usr/bin/lzmadec", - "usr/bin/lzmainfo", - "usr/bin/lzmore", - "usr/bin/unlzma", - "usr/bin/unxz", - "usr/bin/xz", - "usr/bin/xzcat", - "usr/bin/xzcmp", - "usr/bin/xzdec", - "usr/bin/xzdiff", - "usr/bin/xzegrep", - "usr/bin/xzfgrep", - "usr/bin/xzgrep", - "usr/bin/xzless", - "usr/bin/xzmore", - ], - tool = "msys2", - ) - - dadew_binary_bundle( - name = "dadew_ghc_lib_deps_python", - paths = [ - "python:python3", - ], - tool = "python-3.8.2", - ) - - http_archive( - name = "ghc_win", - build_file_content = """\ -load("@rules_sh//sh:sh.bzl", "sh_binaries") -sh_binaries( - name = "tools", - srcs = glob(["ghc-9.0.2*/bin/*"]), - visibility = ["//visibility:public"], -) -""", - sha256 = "f6fbb8047ae16049dc6215a6abb652b4307205310bfffddea695a854af92dc99", - urls = ["https://downloads.haskell.org/~ghc/9.0.2/ghc-9.0.2-x86_64-unknown-mingw32.tar.xz"], - ) - - http_archive( - name = "cabal_win", - build_file_content = """\ -load("@rules_sh//sh:sh.bzl", "sh_binaries") -sh_binaries( - name = "tools", - srcs = glob(["cabal.exe"]), - visibility = ["//visibility:public"], -) -""", - sha256 = "8222b49b6eac3d06aaa390bc688f467e8f949a38943567f46246f8320fd72ded", - urls = ["https://downloads.haskell.org/~cabal/cabal-install-3.6.0.0/cabal-install-3.6.0.0-x86_64-windows.zip"], - ) - -def _ghc_lib_deps_unix(): - """Import dependencies of ghc-lib on Linux and MacOS.""" - nixpkgs_package( - name = "nix_ghc_lib_deps", - attribute_path = "ghc_lib_deps", - build_file = "@//bazel_tools/ghc-lib:BUILD.nix-deps", - fail_not_supported = False, - nix_file = "//nix:bazel.nix", - nix_file_deps = common_nix_file_deps, - repositories = dev_env_nix_repos, - ) - -def ghc_lib_and_dependencies(): - """Import ghc-lib and its Bazel dependencies. - - Import the ghc-lib repository and the corresponding GHC repository as well - as any dependencies needed to generate the ghc-lib(-parser) Cabal sdists. - - Note, this does not cover any Stackage dependencies, these are imported - using `stack_snapshot`. The final `ghc-lib(-parser)` Haskell packages are - also exposed via `@stackage` as vendored packages. - """ - _ghc_lib_deps_unix() - _ghc_lib_deps_windows() - http_archive( - name = "ghc-lib-gen", - url = "{}/archive/{}.tar.gz".format(GHC_LIB_REPO_URL, GHC_LIB_REV), - sha256 = GHC_LIB_SHA256, - strip_prefix = "ghc-lib-{}".format(GHC_LIB_REV), - build_file = "@//bazel_tools/ghc-lib:BUILD.ghc-lib-gen", - patches = GHC_LIB_PATCHES, - patch_args = ["-p1"], - ) - new_git_repository( - name = "da-ghc", - remote = GHC_REPO_URL, - commit = GHC_REV, - recursive_init_submodules = True, - build_file = "@//bazel_tools/ghc-lib:BUILD.ghc", - shallow_since = "1639050525 +0100", - patches = GHC_PATCHES, - patch_args = ["-p1"], - ) diff --git a/sdk/bazel_tools/haskell.bzl b/sdk/bazel_tools/haskell.bzl index df4d96b0cbef..2f8b0a3ea7c1 100644 --- a/sdk/bazel_tools/haskell.bzl +++ b/sdk/bazel_tools/haskell.bzl @@ -254,7 +254,7 @@ def da_haskell_repl(**kwargs): }), experimental_from_binary = [ # Workaround for https://github.com/tweag/rules_haskell/issues/1726 - "//bazel_tools/ghc-lib/...", + "//bazel/ghc-lib/...", "//nix/...", ], repl_ghci_args = [ From df20c3ca10899d2d3c3e82e13effce41b905a7b6 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 8 Apr 2026 18:56:51 +0200 Subject: [PATCH 081/287] feat: Move version to specific place, so it's easier to manage --- .../dependencies/haskell/da_ghc_extension.bzl | 2 +- .../haskell/files/haskell_da_ghc.BUILD.bzl | 4 ++-- sdk/bazel/ghc-lib/README.md | 6 +++--- sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel | 2 +- sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel | 2 +- sdk/bazel/versions/BUILD | 0 .../da_ghc.version.bzl} | 12 ++++++------ 7 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 sdk/bazel/versions/BUILD rename sdk/bazel/{extensions/dependencies/haskell/ghc_lib_version.bzl => versions/da_ghc.version.bzl} (63%) diff --git a/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl index 396f00c95bb9..9044a6387912 100644 --- a/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl @@ -1,7 +1,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load( - ":ghc_lib_version.bzl", + "//bazel/versions:da_ghc.version.bzl", "GHC_LIB_REPO_URL", "GHC_LIB_REV", "GHC_LIB_SHA256", diff --git a/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl b/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl index e8cb76714572..bd3d54dc95bc 100644 --- a/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl @@ -1,11 +1,11 @@ load( - "@//bazel/extensions/dependencies/haskell:ghc_lib_version.bzl", + "@//bazel/versions:da_ghc.version.bzl", "GHC_CPP_OPTIONS", "GHC_FLAVOR", "GHC_LIB_VERSION", ) load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_binary") -load("//bazel/rules:ghc_lib_sdist.bzl", "ghc_lib_sdist") +load("@//bazel/rules:ghc_lib_sdist.bzl", "ghc_lib_sdist") filegroup( name = "hadrian-srcs", diff --git a/sdk/bazel/ghc-lib/README.md b/sdk/bazel/ghc-lib/README.md index d5f3b3b751fc..4803ca8858e6 100644 --- a/sdk/bazel/ghc-lib/README.md +++ b/sdk/bazel/ghc-lib/README.md @@ -42,13 +42,13 @@ Note, an update of any of these may affect ghc-lib(-parser)'s Cabal files. If so, see below for updating the checked in Cabal files. - To update the GHC revision used to build ghc-lib change the `GHC_REV` - variable within `bazel/extensions/dependencies/haskell/ghc_lib_version.bzl`. + variable within `bazel/versions/da_ghc.version.bzl`. - To update the GHC version used to build ghc-lib also update the `GHC_FLAVOR` and `GHC_LIB_VERSION` variables within - `bazel/extensions/dependencies/haskell/ghc_lib_version.bzl`. + `bazel/versions/da_ghc.version.bzl`. - To update the ghc-lib revision, which provides the `ghc-lib-gen` tool, change the `GHC_LIB_REV` and `GHC_LIB_SHA256` variables within - `bazel/extensions/dependencies/haskell/ghc_lib_version.bzl`. + `bazel/versions/da_ghc.version.bzl`. - To update the checked in Cabal files execute the following Bazel commands. ``` $ bazel run //bazel/ghc-lib/ghc-lib-parser:cabal-update diff --git a/sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel b/sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel index a4b43afb214c..2062b1b8baf2 100644 --- a/sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel +++ b/sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:copy_file.bzl", "copy_file") load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") load("@stackage//:packages.bzl", "packages") -load("//bazel/extensions/dependencies/haskell:ghc_lib_version.bzl", "GHC_LIB_VERSION") +load("//bazel/versions:da_ghc.version.bzl", "GHC_LIB_VERSION") load("//bazel_tools:pkg.bzl", "unpack_tar") load( "//bazel_tools/sh:sh.bzl", diff --git a/sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel b/sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel index c5d3b94d1958..997982c6156e 100644 --- a/sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel +++ b/sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:copy_file.bzl", "copy_file") load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") load("@stackage//:packages.bzl", "packages") -load("//bazel/extensions/dependencies/haskell:ghc_lib_version.bzl", "GHC_LIB_VERSION") +load("//bazel/versions:da_ghc.version.bzl", "GHC_LIB_VERSION") load("//bazel_tools:pkg.bzl", "unpack_tar") load( "//bazel_tools/sh:sh.bzl", diff --git a/sdk/bazel/versions/BUILD b/sdk/bazel/versions/BUILD new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/sdk/bazel/extensions/dependencies/haskell/ghc_lib_version.bzl b/sdk/bazel/versions/da_ghc.version.bzl similarity index 63% rename from sdk/bazel/extensions/dependencies/haskell/ghc_lib_version.bzl rename to sdk/bazel/versions/da_ghc.version.bzl index 68fc11a0b7aa..bf81dee4dcc1 100644 --- a/sdk/bazel/extensions/dependencies/haskell/ghc_lib_version.bzl +++ b/sdk/bazel/versions/da_ghc.version.bzl @@ -1,6 +1,5 @@ -# Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - +# -- ghc-lib-gen (provides the ghc-lib-gen tool) -- +# https://github.com/digital-asset/ghc-lib GHC_LIB_REPO_URL = "https://github.com/digital-asset/ghc-lib" GHC_LIB_REV = "b503248db52d6049d18a9dbfa31e0f11aef71df7" GHC_LIB_SHA256 = "2d677bd4bfe6c91fd989551b0821b87b48ab49473a747f548cb58766f9636c11" @@ -8,11 +7,12 @@ GHC_LIB_PATCHES = [ "@//bazel_tools/ghc-lib:ghc-lib-no-stack.patch", ] +# -- da-ghc (GHC source tree for sdist generation) -- +# https://github.com/digital-asset/ghc GHC_REPO_URL = "https://github.com/digital-asset/ghc" GHC_REV = "5498b70afa00c93a959ced0f1d974aab73f5a53b" +# -- ghc-lib build parameters -- GHC_FLAVOR = "da-ghc-8.8.1" GHC_LIB_VERSION = "8.8.1" -GHC_CPP_OPTIONS = [ - "-DDAML_PRIM", -] +GHC_CPP_OPTIONS = ["-DDAML_PRIM"] From befcd69b063f1ed7faaaf01ff5de788087fb3a15 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 8 Apr 2026 18:58:04 +0200 Subject: [PATCH 082/287] chore: Remove copyright headers - for now --- sdk/.bazelrc | 3 +++ sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl | 3 --- sdk/bazel/ghc-lib/BUILD | 2 -- sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel | 3 --- sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel | 3 --- sdk/bazel/rules/ghc_lib_sdist.bzl | 3 --- 6 files changed, 3 insertions(+), 14 deletions(-) diff --git a/sdk/.bazelrc b/sdk/.bazelrc index 99ea8ea4920a..3787452d079b 100644 --- a/sdk/.bazelrc +++ b/sdk/.bazelrc @@ -111,6 +111,9 @@ build:windows --crosstool_top=@rules_haskell_ghc_windows_amd64//:cc_toolchain build:windows --remote_accept_cached=true build:windows --jobs=4 +build --action_env=CC=/usr/bin/gcc-14 +build --action_env=CXX=/usr/bin/g++-14 + # Instruct bazel to globally use this flag for compiling protobuf files. # We need the source info for generating proto docs. By default proto_library strips # source information and doesn't provide an option to turn this flag on. diff --git a/sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl index 892d3e9b0817..47927f2cdc00 100644 --- a/sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl @@ -1,6 +1,3 @@ -# Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - CABAL_INSTALL_VERSION = "3.10.3.0" _BASE_URL = "https://downloads.haskell.org/~cabal/cabal-install-{v}/cabal-install-{v}".format( diff --git a/sdk/bazel/ghc-lib/BUILD b/sdk/bazel/ghc-lib/BUILD index abf57b32b8eb..e69de29bb2d1 100644 --- a/sdk/bazel/ghc-lib/BUILD +++ b/sdk/bazel/ghc-lib/BUILD @@ -1,2 +0,0 @@ -# Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 diff --git a/sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel b/sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel index 2062b1b8baf2..737fd4c11fa2 100644 --- a/sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel +++ b/sdk/bazel/ghc-lib/ghc-lib-parser/BUILD.bazel @@ -1,6 +1,3 @@ -# Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - load("@bazel_skylib//rules:copy_file.bzl", "copy_file") load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") load("@stackage//:packages.bzl", "packages") diff --git a/sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel b/sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel index 997982c6156e..c1107e1d2503 100644 --- a/sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel +++ b/sdk/bazel/ghc-lib/ghc-lib/BUILD.bazel @@ -1,6 +1,3 @@ -# Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - load("@bazel_skylib//rules:copy_file.bzl", "copy_file") load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library") load("@stackage//:packages.bzl", "packages") diff --git a/sdk/bazel/rules/ghc_lib_sdist.bzl b/sdk/bazel/rules/ghc_lib_sdist.bzl index 162dc34948d1..8e81243a11e0 100644 --- a/sdk/bazel/rules/ghc_lib_sdist.bzl +++ b/sdk/bazel/rules/ghc_lib_sdist.bzl @@ -1,6 +1,3 @@ -# Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain") load("//bazel/rules:install_gnu_tool.bzl", "InstalledGnuToolInfo") From c2ae1ed4f966475d557843f69e1b946dff0534d1 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 8 Apr 2026 19:06:55 +0200 Subject: [PATCH 083/287] chore: Extract all remaining versions from bazel --- sdk/bazel/extensions/d3plus_extension.bzl | 11 +++++-- .../dependencies/bin/m4_extension.bzl | 11 +++++-- .../dependencies/haskell/cabal_extension.bzl | 31 ++----------------- .../dependencies/haskell/ghcide_extension.bzl | 11 ++++--- .../haskell/lsp_types_extension.bzl | 8 +++-- .../dependencies/haskell/zip_extension.bzl | 9 ++++-- .../dependencies/lib/ncurses_extension.bzl | 11 +++++-- .../scripts/autoconf_extension.bzl | 11 +++++-- .../scripts/automake_extension.bzl | 11 +++++-- .../io_grpc_grpc_java_extension.bzl | 11 +++++-- .../deprecated/rules_proto_extension.bzl | 11 +++++-- sdk/bazel/extensions/dpm_extension.bzl | 17 +++++----- .../extensions/go_googleapis_extension.bzl | 8 +++-- .../extensions/proto3_suite_extension.bzl | 12 ++++--- sdk/bazel/versions/cabal.version.bzl | 30 ++++++++++++++++++ sdk/bazel/versions/d3plus.version.bzl | 4 +++ sdk/bazel/versions/deprecated.version.bzl | 9 ++++++ sdk/bazel/versions/dpm.version.bzl | 9 ++++++ sdk/bazel/versions/ghcide.version.bzl | 5 +++ sdk/bazel/versions/gnu_tools.version.bzl | 19 ++++++++++++ sdk/bazel/versions/googleapis.version.bzl | 4 +++ sdk/bazel/versions/lsp_types.version.bzl | 4 +++ sdk/bazel/versions/proto3_suite.version.bzl | 4 +++ sdk/bazel/versions/zip.version.bzl | 4 +++ 24 files changed, 187 insertions(+), 78 deletions(-) create mode 100644 sdk/bazel/versions/cabal.version.bzl create mode 100644 sdk/bazel/versions/d3plus.version.bzl create mode 100644 sdk/bazel/versions/deprecated.version.bzl create mode 100644 sdk/bazel/versions/dpm.version.bzl create mode 100644 sdk/bazel/versions/ghcide.version.bzl create mode 100644 sdk/bazel/versions/gnu_tools.version.bzl create mode 100644 sdk/bazel/versions/googleapis.version.bzl create mode 100644 sdk/bazel/versions/lsp_types.version.bzl create mode 100644 sdk/bazel/versions/proto3_suite.version.bzl create mode 100644 sdk/bazel/versions/zip.version.bzl diff --git a/sdk/bazel/extensions/d3plus_extension.bzl b/sdk/bazel/extensions/d3plus_extension.bzl index fe9cab4754fb..57092175f8f6 100644 --- a/sdk/bazel/extensions/d3plus_extension.bzl +++ b/sdk/bazel/extensions/d3plus_extension.bzl @@ -1,13 +1,18 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:d3plus.version.bzl", + "D3PLUS_SHA256", + "D3PLUS_VERSION", +) def _get_d3plus(): http_archive( name = "static_asset_d3plus", build_file_content = 'exports_files(["js/d3.min.js", "js/d3plus.min.js"])', - sha256 = "7d31a500a4850364a966ac938eea7f2fa5ce1334966b52729079490636e7049a", - strip_prefix = "d3plus.v1.9.8", + sha256 = D3PLUS_SHA256, + strip_prefix = "d3plus.v{}".format(D3PLUS_VERSION), type = "zip", - urls = ["https://github.com/alexandersimoes/d3plus/releases/download/v1.9.8/d3plus.zip"], + urls = ["https://github.com/alexandersimoes/d3plus/releases/download/v{}/d3plus.zip".format(D3PLUS_VERSION)], ) def _impl(module_ctx): diff --git a/sdk/bazel/extensions/dependencies/bin/m4_extension.bzl b/sdk/bazel/extensions/dependencies/bin/m4_extension.bzl index e75a3ae74b80..5b55fa96e196 100644 --- a/sdk/bazel/extensions/dependencies/bin/m4_extension.bzl +++ b/sdk/bazel/extensions/dependencies/bin/m4_extension.bzl @@ -1,11 +1,16 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:gnu_tools.version.bzl", + "M4_SHA256", + "M4_VERSION", +) def _impl(module_ctx): http_archive( name = "m4", - urls = ["https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.gz"], - strip_prefix = "m4-1.4.19", - sha256 = "3be4a26d825ffdfda52a56fc43246456989a3630093cced3fbddf4771ee58a70", + urls = ["https://ftp.gnu.org/gnu/m4/m4-{}.tar.gz".format(M4_VERSION)], + strip_prefix = "m4-{}".format(M4_VERSION), + sha256 = M4_SHA256, build_file = ":files/m4.BUILD.bzl", ) diff --git a/sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl index 47927f2cdc00..448613d8d811 100644 --- a/sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl @@ -1,31 +1,4 @@ -CABAL_INSTALL_VERSION = "3.10.3.0" - -_BASE_URL = "https://downloads.haskell.org/~cabal/cabal-install-{v}/cabal-install-{v}".format( - v = CABAL_INSTALL_VERSION, -) - -_PLATFORMS = { - "linux-x86_64": { - "url": _BASE_URL + "-x86_64-linux-deb10.tar.xz", - "sha256": "1d7a7131402295b01f25be5373fde095a404c45f9b5a5508fb7474bb0d3d057a", - }, - "linux-aarch64": { - "url": _BASE_URL + "-aarch64-linux-deb10.tar.xz", - "sha256": "92d341620c60294535f03098bff796ef6de2701de0c4fcba249cde18a2923013", - }, - "darwin-x86_64": { - "url": _BASE_URL + "-x86_64-darwin.tar.xz", - "sha256": "3aed78619b2164dd61eb61afb024073ae2c50f6655fa60fcc1080980693e3220", - }, - "darwin-aarch64": { - "url": _BASE_URL + "-aarch64-darwin.tar.xz", - "sha256": "f4f606b1488a4b24c238f7e09619959eed89c550ed8f8478b350643f652dc08c", - }, - "windows-x86_64": { - "url": _BASE_URL + "-x86_64-windows.zip", - "sha256": "b651ca732998eba5c0e54f4329c147664a7fb3fe3e74eac890c31647ce1e179a", - }, -} +load("//bazel/versions:cabal.version.bzl", "CABAL_PLATFORMS") def _cabal_install_impl(repository_ctx): os_name = repository_ctx.os.name @@ -42,7 +15,7 @@ def _cabal_install_impl(repository_ctx): else: fail("Unsupported OS for cabal-install: " + os_name) - platform = _PLATFORMS[platform_key] + platform = CABAL_PLATFORMS[platform_key] repository_ctx.download_and_extract( url = platform["url"], sha256 = platform["sha256"], diff --git a/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl index fc05298862a4..de06a90f2873 100644 --- a/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl @@ -1,9 +1,12 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:ghcide.version.bzl", + "GHCIDE_REPO_URL", + "GHCIDE_REV", + "GHCIDE_SHA256", +) def _impl(module_ctx): - GHCIDE_REV = "2914f9328dc549bd4918c3cf0fc008690a102d70" - GHCIDE_SHA256 = "bc2bd2fbfbfb501e303b35fb4b2f503b122e4eb0aff34472f0e882d2289afc57" - http_archive( name = "ghcide_lib", build_file = ":files/haskell_ghcide_lib.BUILD.bzl", @@ -13,7 +16,7 @@ def _impl(module_ctx): ], sha256 = GHCIDE_SHA256, strip_prefix = "daml-ghcide-%s" % GHCIDE_REV, - url = "https://github.com/digital-asset/daml-ghcide/archive/%s.tar.gz" % GHCIDE_REV, + url = "{}/archive/{}.tar.gz".format(GHCIDE_REPO_URL, GHCIDE_REV), ) ghcide_lib = module_extension(implementation = _impl) diff --git a/sdk/bazel/extensions/dependencies/haskell/lsp_types_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/lsp_types_extension.bzl index 7246a73a981b..1e5102c632db 100644 --- a/sdk/bazel/extensions/dependencies/haskell/lsp_types_extension.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/lsp_types_extension.bzl @@ -1,9 +1,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:lsp_types.version.bzl", + "LSP_TYPES_SHA256", + "LSP_TYPES_VERSION", +) def _impl(module_ctx): - LSP_TYPES_VERSION = "1.4.0.0" - LSP_TYPES_SHA256 = "7ae8a3bad0e91d4a2af9b93e3ad207e3f4c3dace40d420e0592f6323ac93fb67" - http_archive( name = "lsp-types", build_file = ":files/haskell_lsp_types.BUILD.bzl", diff --git a/sdk/bazel/extensions/dependencies/haskell/zip_extension.bzl b/sdk/bazel/extensions/dependencies/haskell/zip_extension.bzl index 56e2e2fcfe4d..34598ddcaa4a 100644 --- a/sdk/bazel/extensions/dependencies/haskell/zip_extension.bzl +++ b/sdk/bazel/extensions/dependencies/haskell/zip_extension.bzl @@ -1,14 +1,17 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:zip.version.bzl", + "ZIP_SHA256", + "ZIP_VERSION", +) def _impl(module_ctx): - ZIP_VERSION = "1.7.1" - http_archive( name = "zip", build_file = ":files/haskell_zip.BUILD.bzl", patch_args = ["-p1"], patches = ["//bazel/patches:haskell/zip.patch"], - sha256 = "0d7f02bbdf6c49e9a33d2eca4b3d7644216a213590866dafdd2b47ddd38eb746", + sha256 = ZIP_SHA256, strip_prefix = "zip-{}".format(ZIP_VERSION), urls = ["http://hackage.haskell.org/package/zip-{version}/zip-{version}.tar.gz".format(version = ZIP_VERSION)], ) diff --git a/sdk/bazel/extensions/dependencies/lib/ncurses_extension.bzl b/sdk/bazel/extensions/dependencies/lib/ncurses_extension.bzl index e1bdb392cbb4..aae9463ea47d 100644 --- a/sdk/bazel/extensions/dependencies/lib/ncurses_extension.bzl +++ b/sdk/bazel/extensions/dependencies/lib/ncurses_extension.bzl @@ -1,11 +1,16 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:gnu_tools.version.bzl", + "NCURSES_SHA256", + "NCURSES_VERSION", +) def _impl(module_ctx): http_archive( name = "ncurses", - url = "https://ftp.gnu.org/gnu/ncurses/ncurses-6.4.tar.gz", - sha256 = "6931283d9ac87c5073f30b6290c4c75f21632bb4fc3603ac8100812bed248159", - strip_prefix = "ncurses-6.4", + url = "https://ftp.gnu.org/gnu/ncurses/ncurses-{}.tar.gz".format(NCURSES_VERSION), + sha256 = NCURSES_SHA256, + strip_prefix = "ncurses-{}".format(NCURSES_VERSION), build_file = Label(":files/ncurses.BUILD.bzl"), ) diff --git a/sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl b/sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl index c4241d6c39d7..7da4841ffc2b 100644 --- a/sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl +++ b/sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl @@ -1,11 +1,16 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:gnu_tools.version.bzl", + "AUTOCONF_SHA256", + "AUTOCONF_VERSION", +) def _impl(module_ctx): http_archive( name = "autoconf", - urls = ["https://ftp.gnu.org/gnu/autoconf/autoconf-2.72.tar.gz"], - strip_prefix = "autoconf-2.72", - sha256 = "afb181a76e1ee72832f6581c0eddf8df032b83e2e0239ef79ebedc4467d92d6e", + urls = ["https://ftp.gnu.org/gnu/autoconf/autoconf-{}.tar.gz".format(AUTOCONF_VERSION)], + strip_prefix = "autoconf-{}".format(AUTOCONF_VERSION), + sha256 = AUTOCONF_SHA256, build_file = ":files/autoconf.BUILD.bzl", ) diff --git a/sdk/bazel/extensions/dependencies/scripts/automake_extension.bzl b/sdk/bazel/extensions/dependencies/scripts/automake_extension.bzl index b3517a076793..f48cb9be5ebf 100644 --- a/sdk/bazel/extensions/dependencies/scripts/automake_extension.bzl +++ b/sdk/bazel/extensions/dependencies/scripts/automake_extension.bzl @@ -1,11 +1,16 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:gnu_tools.version.bzl", + "AUTOMAKE_SHA256", + "AUTOMAKE_VERSION", +) def _impl(module_ctx): http_archive( name = "automake", - urls = ["https://ftp.gnu.org/gnu/automake/automake-1.16.5.tar.gz"], - strip_prefix = "automake-1.16.5", - sha256 = "07bd24ad08a64bc17250ce09ec56e921d6343903943e99ccf63bbf0705e34605", + urls = ["https://ftp.gnu.org/gnu/automake/automake-{}.tar.gz".format(AUTOMAKE_VERSION)], + strip_prefix = "automake-{}".format(AUTOMAKE_VERSION), + sha256 = AUTOMAKE_SHA256, build_file = ":files/automake.BUILD.bzl", ) diff --git a/sdk/bazel/extensions/deprecated/io_grpc_grpc_java_extension.bzl b/sdk/bazel/extensions/deprecated/io_grpc_grpc_java_extension.bzl index d8ffc05c780d..7cdf00e5a008 100644 --- a/sdk/bazel/extensions/deprecated/io_grpc_grpc_java_extension.bzl +++ b/sdk/bazel/extensions/deprecated/io_grpc_grpc_java_extension.bzl @@ -1,11 +1,16 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:deprecated.version.bzl", + "GRPC_JAVA_SHA256", + "GRPC_JAVA_VERSION", +) def _impl(module_ctx): http_archive( name = "io_grpc_grpc_java", - strip_prefix = "grpc-java-1.60.2", - urls = ["https://github.com/grpc/grpc-java/archive/v1.60.2.tar.gz"], - sha256 = "4baf80f35488739d99515d71b8e72bd17a476c214a84106edc66b259fe8ac22c", + strip_prefix = "grpc-java-{}".format(GRPC_JAVA_VERSION), + urls = ["https://github.com/grpc/grpc-java/archive/v{}.tar.gz".format(GRPC_JAVA_VERSION)], + sha256 = GRPC_JAVA_SHA256, ) io_grpc_grpc_java_extension = module_extension(implementation = _impl) diff --git a/sdk/bazel/extensions/deprecated/rules_proto_extension.bzl b/sdk/bazel/extensions/deprecated/rules_proto_extension.bzl index 1b6ece693712..2a9db07d2b36 100644 --- a/sdk/bazel/extensions/deprecated/rules_proto_extension.bzl +++ b/sdk/bazel/extensions/deprecated/rules_proto_extension.bzl @@ -1,13 +1,18 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:deprecated.version.bzl", + "RULES_PROTO_SHA256", + "RULES_PROTO_VERSION", +) # TODO: This is deprecated rules, check https://github.com/protocolbuffers/protobuf for newer version # Check https://github.com/bazelbuild/rules_proto for current version and annotation def _impl(module_ctx): http_archive( name = "rules_proto", - sha256 = "303e86e722a520f6f326a50b41cfc16b98fe6d1955ce46642a5b7a67c11c0f5d", - strip_prefix = "rules_proto-6.0.0", - url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0/rules_proto-6.0.0.tar.gz", + sha256 = RULES_PROTO_SHA256, + strip_prefix = "rules_proto-{}".format(RULES_PROTO_VERSION), + url = "https://github.com/bazelbuild/rules_proto/releases/download/{v}/rules_proto-{v}.tar.gz".format(v = RULES_PROTO_VERSION), ) rules_proto_extension = module_extension(implementation = _impl) diff --git a/sdk/bazel/extensions/dpm_extension.bzl b/sdk/bazel/extensions/dpm_extension.bzl index 1f44c8e9b18c..b78d5b5a42fb 100644 --- a/sdk/bazel/extensions/dpm_extension.bzl +++ b/sdk/bazel/extensions/dpm_extension.bzl @@ -1,18 +1,15 @@ load("//bazel_tools:dpm.bzl", "dpm_binary") +load( + "//bazel/versions:dpm.version.bzl", + "DPM_SHA256", + "DPM_VERSION", +) def _get_dpm(module_ctx): dpm_binary( name = "dpm_binary", - # Hashes taken from the files themselves, not the OCI artifacts - # See `layers[0].digest` in the manifest for each platform - sha256 = { - "linux_arm64": "0a108513d99d3f996282ed85c51dc6c10b5790737a299182671c450f87cdf851", - "darwin_amd64": "edfeeec2ea7ac5eb03b56cc2a912ebc59d4ff9db9831cfa0b6033def218aa637", - "darwin_arm64": "ed9c7c6724efc36ca39cf5193a87a73e146685ae2dd042580ee20ca685aa0e1e", - "linux_amd64": "49dcc18c5dbea13bda52f6668b5831b53b46d209e1e539a1ef2a5553c3df6c09", - "windows_amd64": "594ac706c4eff9f0779d0cf04c18cda5ea8f6e4cf82fbead3f03f6aa7de423f9", - }, - version = "1.0.8", + sha256 = DPM_SHA256, + version = DPM_VERSION, ) def _impl(module_ctx): diff --git a/sdk/bazel/extensions/go_googleapis_extension.bzl b/sdk/bazel/extensions/go_googleapis_extension.bzl index 5bfdca3a0f1f..e251632ca0df 100644 --- a/sdk/bazel/extensions/go_googleapis_extension.bzl +++ b/sdk/bazel/extensions/go_googleapis_extension.bzl @@ -1,9 +1,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:googleapis.version.bzl", + "GOOGLEAPIS_SHA256", + "GOOGLEAPIS_VERSION", +) def _impl(module_ctx): - GOOGLEAPIS_VERSION = "83c3605afb5a39952bf0a0809875d41cf2a558ca" - GOOGLEAPIS_SHA256 = "ba694861340e792fd31cb77274eacaf6e4ca8bda97707898f41d8bebfd8a4984" - http_archive( name = "go_googleapis", # We must use the same version as rules_go diff --git a/sdk/bazel/extensions/proto3_suite_extension.bzl b/sdk/bazel/extensions/proto3_suite_extension.bzl index 9eb9022715df..109f41c00555 100644 --- a/sdk/bazel/extensions/proto3_suite_extension.bzl +++ b/sdk/bazel/extensions/proto3_suite_extension.bzl @@ -1,15 +1,17 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:proto3_suite.version.bzl", + "PROTO3SUITE_SHA256", + "PROTO3SUITE_VERSION", +) def _impl(module_ctx): - PROTO3SUITE_REV = "0.5.1" - PROTO3SUITE_SHA256 = "6e6d514867e8efe90fe6a7e5167b86260da00fdb7ef335af694295a1adde57f4" - http_archive( name = "proto3-suite", build_file = ":files/proto3_suite.BUILD.bzl", sha256 = PROTO3SUITE_SHA256, - strip_prefix = "proto3-suite-{}".format(PROTO3SUITE_REV), - urls = ["https://github.com/awakesecurity/proto3-suite/archive/refs/tags/v{}.tar.gz".format(PROTO3SUITE_REV)], + strip_prefix = "proto3-suite-{}".format(PROTO3SUITE_VERSION), + urls = ["https://github.com/awakesecurity/proto3-suite/archive/refs/tags/v{}.tar.gz".format(PROTO3SUITE_VERSION)], patches = [ "//bazel/patches:proto3_suite/deriving_defaults.patch", "//bazel/patches:proto3_suite/support_reserved_enums.patch", diff --git a/sdk/bazel/versions/cabal.version.bzl b/sdk/bazel/versions/cabal.version.bzl new file mode 100644 index 000000000000..8ad7ba7eca5a --- /dev/null +++ b/sdk/bazel/versions/cabal.version.bzl @@ -0,0 +1,30 @@ +# -- cabal-install -- +# https://www.haskell.org/cabal/ +CABAL_INSTALL_VERSION = "3.10.3.0" + +_BASE_URL = "https://downloads.haskell.org/~cabal/cabal-install-{v}/cabal-install-{v}".format( + v = CABAL_INSTALL_VERSION, +) + +CABAL_PLATFORMS = { + "linux-x86_64": { + "url": _BASE_URL + "-x86_64-linux-deb10.tar.xz", + "sha256": "1d7a7131402295b01f25be5373fde095a404c45f9b5a5508fb7474bb0d3d057a", + }, + "linux-aarch64": { + "url": _BASE_URL + "-aarch64-linux-deb10.tar.xz", + "sha256": "92d341620c60294535f03098bff796ef6de2701de0c4fcba249cde18a2923013", + }, + "darwin-x86_64": { + "url": _BASE_URL + "-x86_64-darwin.tar.xz", + "sha256": "3aed78619b2164dd61eb61afb024073ae2c50f6655fa60fcc1080980693e3220", + }, + "darwin-aarch64": { + "url": _BASE_URL + "-aarch64-darwin.tar.xz", + "sha256": "f4f606b1488a4b24c238f7e09619959eed89c550ed8f8478b350643f652dc08c", + }, + "windows-x86_64": { + "url": _BASE_URL + "-x86_64-windows.zip", + "sha256": "b651ca732998eba5c0e54f4329c147664a7fb3fe3e74eac890c31647ce1e179a", + }, +} diff --git a/sdk/bazel/versions/d3plus.version.bzl b/sdk/bazel/versions/d3plus.version.bzl new file mode 100644 index 000000000000..845868fc9a7f --- /dev/null +++ b/sdk/bazel/versions/d3plus.version.bzl @@ -0,0 +1,4 @@ +# -- d3plus -- +# https://github.com/alexandersimoes/d3plus +D3PLUS_VERSION = "1.9.8" +D3PLUS_SHA256 = "7d31a500a4850364a966ac938eea7f2fa5ce1334966b52729079490636e7049a" diff --git a/sdk/bazel/versions/deprecated.version.bzl b/sdk/bazel/versions/deprecated.version.bzl new file mode 100644 index 000000000000..91405d7363b9 --- /dev/null +++ b/sdk/bazel/versions/deprecated.version.bzl @@ -0,0 +1,9 @@ +# -- rules_proto (deprecated) -- +# https://github.com/bazelbuild/rules_proto +RULES_PROTO_VERSION = "6.0.0" +RULES_PROTO_SHA256 = "303e86e722a520f6f326a50b41cfc16b98fe6d1955ce46642a5b7a67c11c0f5d" + +# -- io_grpc_grpc_java (deprecated) -- +# https://github.com/grpc/grpc-java +GRPC_JAVA_VERSION = "1.60.2" +GRPC_JAVA_SHA256 = "4baf80f35488739d99515d71b8e72bd17a476c214a84106edc66b259fe8ac22c" diff --git a/sdk/bazel/versions/dpm.version.bzl b/sdk/bazel/versions/dpm.version.bzl new file mode 100644 index 000000000000..0ab371112039 --- /dev/null +++ b/sdk/bazel/versions/dpm.version.bzl @@ -0,0 +1,9 @@ +# -- dpm (Daml Package Manager) -- +DPM_VERSION = "1.0.8" +DPM_SHA256 = { + "linux_arm64": "0a108513d99d3f996282ed85c51dc6c10b5790737a299182671c450f87cdf851", + "darwin_amd64": "edfeeec2ea7ac5eb03b56cc2a912ebc59d4ff9db9831cfa0b6033def218aa637", + "darwin_arm64": "ed9c7c6724efc36ca39cf5193a87a73e146685ae2dd042580ee20ca685aa0e1e", + "linux_amd64": "49dcc18c5dbea13bda52f6668b5831b53b46d209e1e539a1ef2a5553c3df6c09", + "windows_amd64": "594ac706c4eff9f0779d0cf04c18cda5ea8f6e4cf82fbead3f03f6aa7de423f9", +} diff --git a/sdk/bazel/versions/ghcide.version.bzl b/sdk/bazel/versions/ghcide.version.bzl new file mode 100644 index 000000000000..f7509c0f2a54 --- /dev/null +++ b/sdk/bazel/versions/ghcide.version.bzl @@ -0,0 +1,5 @@ +# -- daml-ghcide -- +# https://github.com/digital-asset/daml-ghcide +GHCIDE_REPO_URL = "https://github.com/digital-asset/daml-ghcide" +GHCIDE_REV = "2914f9328dc549bd4918c3cf0fc008690a102d70" +GHCIDE_SHA256 = "bc2bd2fbfbfb501e303b35fb4b2f503b122e4eb0aff34472f0e882d2289afc57" diff --git a/sdk/bazel/versions/gnu_tools.version.bzl b/sdk/bazel/versions/gnu_tools.version.bzl new file mode 100644 index 000000000000..8c9d023bdc82 --- /dev/null +++ b/sdk/bazel/versions/gnu_tools.version.bzl @@ -0,0 +1,19 @@ +# -- autoconf -- +# https://ftp.gnu.org/gnu/autoconf/ +AUTOCONF_VERSION = "2.72" +AUTOCONF_SHA256 = "afb181a76e1ee72832f6581c0eddf8df032b83e2e0239ef79ebedc4467d92d6e" + +# -- automake -- +# https://ftp.gnu.org/gnu/automake/ +AUTOMAKE_VERSION = "1.16.5" +AUTOMAKE_SHA256 = "07bd24ad08a64bc17250ce09ec56e921d6343903943e99ccf63bbf0705e34605" + +# -- m4 -- +# https://ftp.gnu.org/gnu/m4/ +M4_VERSION = "1.4.19" +M4_SHA256 = "3be4a26d825ffdfda52a56fc43246456989a3630093cced3fbddf4771ee58a70" + +# -- ncurses -- +# https://ftp.gnu.org/gnu/ncurses/ +NCURSES_VERSION = "6.4" +NCURSES_SHA256 = "6931283d9ac87c5073f30b6290c4c75f21632bb4fc3603ac8100812bed248159" diff --git a/sdk/bazel/versions/googleapis.version.bzl b/sdk/bazel/versions/googleapis.version.bzl new file mode 100644 index 000000000000..47e7e92da461 --- /dev/null +++ b/sdk/bazel/versions/googleapis.version.bzl @@ -0,0 +1,4 @@ +# -- googleapis -- +# https://github.com/googleapis/googleapis +GOOGLEAPIS_VERSION = "83c3605afb5a39952bf0a0809875d41cf2a558ca" +GOOGLEAPIS_SHA256 = "ba694861340e792fd31cb77274eacaf6e4ca8bda97707898f41d8bebfd8a4984" diff --git a/sdk/bazel/versions/lsp_types.version.bzl b/sdk/bazel/versions/lsp_types.version.bzl new file mode 100644 index 000000000000..5d068c621bd9 --- /dev/null +++ b/sdk/bazel/versions/lsp_types.version.bzl @@ -0,0 +1,4 @@ +# -- lsp-types (Haskell package) -- +# http://hackage.haskell.org/package/lsp-types +LSP_TYPES_VERSION = "1.4.0.0" +LSP_TYPES_SHA256 = "7ae8a3bad0e91d4a2af9b93e3ad207e3f4c3dace40d420e0592f6323ac93fb67" diff --git a/sdk/bazel/versions/proto3_suite.version.bzl b/sdk/bazel/versions/proto3_suite.version.bzl new file mode 100644 index 000000000000..cfd43bed65f0 --- /dev/null +++ b/sdk/bazel/versions/proto3_suite.version.bzl @@ -0,0 +1,4 @@ +# -- proto3-suite -- +# https://github.com/awakesecurity/proto3-suite +PROTO3SUITE_VERSION = "0.5.1" +PROTO3SUITE_SHA256 = "6e6d514867e8efe90fe6a7e5167b86260da00fdb7ef335af694295a1adde57f4" diff --git a/sdk/bazel/versions/zip.version.bzl b/sdk/bazel/versions/zip.version.bzl new file mode 100644 index 000000000000..c4813d418499 --- /dev/null +++ b/sdk/bazel/versions/zip.version.bzl @@ -0,0 +1,4 @@ +# -- zip (Haskell package) -- +# http://hackage.haskell.org/package/zip +ZIP_VERSION = "1.7.1" +ZIP_SHA256 = "0d7f02bbdf6c49e9a33d2eca4b3d7644216a213590866dafdd2b47ddd38eb746" From e20bee4c2bcee7e5c82cf681f836d828cc655dfe Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 8 Apr 2026 19:32:35 +0200 Subject: [PATCH 084/287] feat: Add missing stack packages --- sdk/MODULE.bazel | 99 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 29 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index b71ebde2bdbe..4ca846b0f243 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -57,7 +57,10 @@ use_repo(stack_snapshot_ext, "stackage", "stackage-exe") stack_snapshot_ext.snapshot(local_snapshot = "//:stackage_snapshot.yaml") -# stack_snapshot_ext.package(name = "lsp-types") +stack_snapshot_ext.package( + name = "lsp-types", + vendored = "@lsp-types//:lsp-types", +) [ stack_snapshot_ext.package( name = pkg, @@ -66,73 +69,111 @@ stack_snapshot_ext.snapshot(local_snapshot = "//:stackage_snapshot.yaml") "aeson", "aeson-pretty", "ansi-terminal", + "ansi-wl-pprint", + "array", "async", "base", + "base64", + "base64-bytestring", "binary", "blaze-html", "bytestring", + "Cabal", + "clock", + "cmark-gfm", "conduit", + "conduit-extra", "containers", + "cryptonite", + "data-default", + "Decimal", "deepseq", + "Diff", "directory", + "dlist", + "either", "extra", + "file-embed", + "filelock", + "filepattern", "filepath", + "ghc-lib-parser-ex", + "gitrev", "hashable", + "haskell-src-exts", + "hlint", + "hslogger", "http-client", + "http-client-tls", "http-conduit", "http-types", + "jwt", "lens", + "lens-aeson", + "lsp", "lsp-test", + "megaparsec", + "memory", + "mod", "monad-loops", + "mtl", "network", + "network-uri", "optparse-applicative", "parser-combinators", + "parsec", + "pcre-utils", "pretty", + "prettyprinter", "process", + "proto3-wire", + "QuickCheck", + "random", + "random-shuffle", + "recursion-schemes", + "regex-tdfa", + "repline", + "resourcet", + "rope-utf16-splay", "safe", "safe-exceptions", + "scientific", + "semigroupoids", "semver", + "shake", + "silently", + "some", "split", + "stache", + "stm", + "syb", + "tagged", "tar-conduit", "tasty", + "tasty-golden", "tasty-hunit", "tasty-quickcheck", + "template-haskell", + "temporary", + "terminal-progress-bar", "text", "time", + "tls", + "transformers", "typed-process", + "uniplate", + "unix", "unix-compat", + "unliftio", + "unliftio-core", "unordered-containers", + "uri-encode", + "utf8-string", + "validation", "vector", - "unix", + "xml", "yaml", - "regex-tdfa", - "uniplate", - "array", - "transformers", - "Diff", - "data-default", - "dlist", - "hslogger", - "mod", - "mtl", - "network-uri", - "rope-utf16-splay", - "scientific", - "some", - "template-haskell", - "temporary", - # - "Decimal", - "megaparsec", "zip-archive", - # - "hlint", - "ghc-lib-parser-ex", - # - "shake", - "QuickCheck", - "Cabal", - "parsec", ] ] From 272bc0703fe19e55542601f4c65284e36db4bb4b Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 8 Apr 2026 19:42:22 +0200 Subject: [PATCH 085/287] chore: Reduce `//bazel/extensions` tree depth --- sdk/MODULE.bazel | 22 +++++++++---------- .../scripts => }/autoconf_extension.bzl | 0 .../scripts => }/automake_extension.bzl | 0 .../haskell => }/cabal_extension.bzl | 0 .../haskell => }/da_ghc_extension.bzl | 4 ++-- sdk/bazel/extensions/dependencies/bin/BUILD | 0 .../extensions/dependencies/haskell/BUILD | 0 sdk/bazel/extensions/dependencies/lib/BUILD | 16 -------------- .../extensions/dependencies/scripts/BUILD | 0 .../scripts => }/files/autoconf.BUILD.bzl | 0 .../scripts => }/files/automake.BUILD.bzl | 0 .../da_ghc.BUILD.bzl} | 0 .../ghc_lib_gen.BUILD.bzl} | 0 .../ghcide.BUILD.bzl} | 0 .../lsp_types.BUILD.bzl} | 0 .../{dependencies/bin => }/files/m4.BUILD.bzl | 0 .../lib => }/files/ncurses.BUILD.bzl | 0 .../zip.BUILD.bzl} | 0 .../haskell => }/ghcide_extension.bzl | 2 +- .../io_grpc_grpc_java_extension.bzl | 2 +- .../haskell => }/lsp_types_extension.bzl | 2 +- .../{dependencies/bin => }/m4_extension.bzl | 0 .../lib => }/ncurses_extension.bzl | 2 +- .../rules_proto_extension.bzl | 6 ++--- .../haskell => }/zip_extension.bzl | 2 +- sdk/bazel/versions/deprecated.version.bzl | 9 -------- sdk/bazel/versions/grpc_java.version.bzl | 4 ++++ sdk/bazel/versions/rules_proto.version.bzl | 4 ++++ 28 files changed, 29 insertions(+), 46 deletions(-) rename sdk/bazel/extensions/{dependencies/scripts => }/autoconf_extension.bzl (100%) rename sdk/bazel/extensions/{dependencies/scripts => }/automake_extension.bzl (100%) rename sdk/bazel/extensions/{dependencies/haskell => }/cabal_extension.bzl (100%) rename sdk/bazel/extensions/{dependencies/haskell => }/da_ghc_extension.bzl (89%) delete mode 100644 sdk/bazel/extensions/dependencies/bin/BUILD delete mode 100644 sdk/bazel/extensions/dependencies/haskell/BUILD delete mode 100644 sdk/bazel/extensions/dependencies/lib/BUILD delete mode 100644 sdk/bazel/extensions/dependencies/scripts/BUILD rename sdk/bazel/extensions/{dependencies/scripts => }/files/autoconf.BUILD.bzl (100%) rename sdk/bazel/extensions/{dependencies/scripts => }/files/automake.BUILD.bzl (100%) rename sdk/bazel/extensions/{dependencies/haskell/files/haskell_da_ghc.BUILD.bzl => files/da_ghc.BUILD.bzl} (100%) rename sdk/bazel/extensions/{dependencies/haskell/files/haskell_ghc_lib_gen.BUILD.bzl => files/ghc_lib_gen.BUILD.bzl} (100%) rename sdk/bazel/extensions/{dependencies/haskell/files/haskell_ghcide_lib.BUILD.bzl => files/ghcide.BUILD.bzl} (100%) rename sdk/bazel/extensions/{dependencies/haskell/files/haskell_lsp_types.BUILD.bzl => files/lsp_types.BUILD.bzl} (100%) rename sdk/bazel/extensions/{dependencies/bin => }/files/m4.BUILD.bzl (100%) rename sdk/bazel/extensions/{dependencies/lib => }/files/ncurses.BUILD.bzl (100%) rename sdk/bazel/extensions/{dependencies/haskell/files/haskell_zip.BUILD.bzl => files/zip.BUILD.bzl} (100%) rename sdk/bazel/extensions/{dependencies/haskell => }/ghcide_extension.bzl (90%) rename sdk/bazel/extensions/{deprecated => }/io_grpc_grpc_java_extension.bzl (91%) rename sdk/bazel/extensions/{dependencies/haskell => }/lsp_types_extension.bzl (92%) rename sdk/bazel/extensions/{dependencies/bin => }/m4_extension.bzl (100%) rename sdk/bazel/extensions/{dependencies/lib => }/ncurses_extension.bzl (89%) rename sdk/bazel/extensions/{deprecated => }/rules_proto_extension.bzl (68%) rename sdk/bazel/extensions/{dependencies/haskell => }/zip_extension.bzl (91%) delete mode 100644 sdk/bazel/versions/deprecated.version.bzl create mode 100644 sdk/bazel/versions/grpc_java.version.bzl create mode 100644 sdk/bazel/versions/rules_proto.version.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 4ca846b0f243..bfd38c4f94db 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -34,19 +34,19 @@ haskell_toolchains_ext = use_extension( ) haskell_toolchains_ext.bindists(version = "9.0.2") -da_ghc_ext = use_extension("//bazel/extensions/dependencies/haskell:da_ghc_extension.bzl", "da_ghc") +da_ghc_ext = use_extension("//bazel/extensions:da_ghc_extension.bzl", "da_ghc") use_repo(da_ghc_ext, "da-ghc", "ghc-lib-gen") -cabal_ext = use_extension("//bazel/extensions/dependencies/haskell:cabal_extension.bzl", "cabal") +cabal_ext = use_extension("//bazel/extensions:cabal_extension.bzl", "cabal") use_repo(cabal_ext, "cabal") -ghcide_lib_ext = use_extension("//bazel/extensions/dependencies/haskell:ghcide_extension.bzl", "ghcide_lib") +ghcide_lib_ext = use_extension("//bazel/extensions:ghcide_extension.bzl", "ghcide_lib") use_repo(ghcide_lib_ext, "ghcide_lib") -lsp_types_ext = use_extension("//bazel/extensions/dependencies/haskell:lsp_types_extension.bzl", "lsp_types") +lsp_types_ext = use_extension("//bazel/extensions:lsp_types_extension.bzl", "lsp_types") use_repo(lsp_types_ext, "lsp-types") -zip_ext = use_extension("//bazel/extensions/dependencies/haskell:zip_extension.bzl", "zip") +zip_ext = use_extension("//bazel/extensions:zip_extension.bzl", "zip") use_repo(zip_ext, "zip") stack_snapshot_ext = use_extension( @@ -290,24 +290,24 @@ use_repo(maven_ext, "maven") # # # # DEPRECATED -rules_proto_ext = use_extension("//bazel/extensions:deprecated/rules_proto_extension.bzl", "rules_proto_extension") +rules_proto_ext = use_extension("//bazel/extensions:rules_proto_extension.bzl", "rules_proto_extension") use_repo(rules_proto_ext, "rules_proto") -io_grpc_grpc_java_ext = use_extension("//bazel/extensions:deprecated/io_grpc_grpc_java_extension.bzl", "io_grpc_grpc_java_extension") +io_grpc_grpc_java_ext = use_extension("//bazel/extensions:io_grpc_grpc_java_extension.bzl", "io_grpc_grpc_java_extension") use_repo(io_grpc_grpc_java_ext, "io_grpc_grpc_java") # # # # # # # Libs -ncurses_ext = use_extension("//bazel/extensions/dependencies/lib:ncurses_extension.bzl", "ncurses") +ncurses_ext = use_extension("//bazel/extensions:ncurses_extension.bzl", "ncurses") use_repo(ncurses_ext, "ncurses") -m4_ext = use_extension("//bazel/extensions/dependencies/bin:m4_extension.bzl", "m4") +m4_ext = use_extension("//bazel/extensions:m4_extension.bzl", "m4") use_repo(m4_ext, "m4") -autoconf_ext = use_extension("//bazel/extensions/dependencies/scripts:autoconf_extension.bzl", "autoconf") +autoconf_ext = use_extension("//bazel/extensions:autoconf_extension.bzl", "autoconf") use_repo(autoconf_ext, "autoconf") -automake_ext = use_extension("//bazel/extensions/dependencies/scripts:automake_extension.bzl", "automake") +automake_ext = use_extension("//bazel/extensions:automake_extension.bzl", "automake") use_repo(automake_ext, "automake") # # # diff --git a/sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl b/sdk/bazel/extensions/autoconf_extension.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/scripts/autoconf_extension.bzl rename to sdk/bazel/extensions/autoconf_extension.bzl diff --git a/sdk/bazel/extensions/dependencies/scripts/automake_extension.bzl b/sdk/bazel/extensions/automake_extension.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/scripts/automake_extension.bzl rename to sdk/bazel/extensions/automake_extension.bzl diff --git a/sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl b/sdk/bazel/extensions/cabal_extension.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/haskell/cabal_extension.bzl rename to sdk/bazel/extensions/cabal_extension.bzl diff --git a/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl b/sdk/bazel/extensions/da_ghc_extension.bzl similarity index 89% rename from sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl rename to sdk/bazel/extensions/da_ghc_extension.bzl index 9044a6387912..ed05ea620c88 100644 --- a/sdk/bazel/extensions/dependencies/haskell/da_ghc_extension.bzl +++ b/sdk/bazel/extensions/da_ghc_extension.bzl @@ -15,7 +15,7 @@ def _get_ghc_lib_gen(): url = "{}/archive/{}.tar.gz".format(GHC_LIB_REPO_URL, GHC_LIB_REV), sha256 = GHC_LIB_SHA256, strip_prefix = "ghc-lib-{}".format(GHC_LIB_REV), - build_file = ":files/haskell_ghc_lib_gen.BUILD.bzl", + build_file = ":files/ghc_lib_gen.BUILD.bzl", patches = ["//bazel/patches:haskell/ghc_lib_no_stack.patch"], patch_args = ["-p1"], ) @@ -26,7 +26,7 @@ def _get_da_ghc(): remote = GHC_REPO_URL, commit = GHC_REV, recursive_init_submodules = True, - build_file = ":files/haskell_da_ghc.BUILD.bzl", + build_file = ":files/da_ghc.BUILD.bzl", shallow_since = "1771323697 +0100", patch_args = ["-p1"], ) diff --git a/sdk/bazel/extensions/dependencies/bin/BUILD b/sdk/bazel/extensions/dependencies/bin/BUILD deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/sdk/bazel/extensions/dependencies/haskell/BUILD b/sdk/bazel/extensions/dependencies/haskell/BUILD deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/sdk/bazel/extensions/dependencies/lib/BUILD b/sdk/bazel/extensions/dependencies/lib/BUILD deleted file mode 100644 index 297733ac3c20..000000000000 --- a/sdk/bazel/extensions/dependencies/lib/BUILD +++ /dev/null @@ -1,16 +0,0 @@ -genrule( - name = "install", - srcs = glob(["**"]), - outs = ["m4_install"], - cmd = """ - set -euo pipefail - SRC=$$PWD/$$(dirname $(location configure)) - OUT=$$PWD/$@ - mkdir -p $$OUT - cd $$SRC - ./configure --prefix=$$OUT - make -j - make install - """, - visibility = ["//visibility:public"], -) \ No newline at end of file diff --git a/sdk/bazel/extensions/dependencies/scripts/BUILD b/sdk/bazel/extensions/dependencies/scripts/BUILD deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/sdk/bazel/extensions/dependencies/scripts/files/autoconf.BUILD.bzl b/sdk/bazel/extensions/files/autoconf.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/scripts/files/autoconf.BUILD.bzl rename to sdk/bazel/extensions/files/autoconf.BUILD.bzl diff --git a/sdk/bazel/extensions/dependencies/scripts/files/automake.BUILD.bzl b/sdk/bazel/extensions/files/automake.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/scripts/files/automake.BUILD.bzl rename to sdk/bazel/extensions/files/automake.BUILD.bzl diff --git a/sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl b/sdk/bazel/extensions/files/da_ghc.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/haskell/files/haskell_da_ghc.BUILD.bzl rename to sdk/bazel/extensions/files/da_ghc.BUILD.bzl diff --git a/sdk/bazel/extensions/dependencies/haskell/files/haskell_ghc_lib_gen.BUILD.bzl b/sdk/bazel/extensions/files/ghc_lib_gen.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/haskell/files/haskell_ghc_lib_gen.BUILD.bzl rename to sdk/bazel/extensions/files/ghc_lib_gen.BUILD.bzl diff --git a/sdk/bazel/extensions/dependencies/haskell/files/haskell_ghcide_lib.BUILD.bzl b/sdk/bazel/extensions/files/ghcide.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/haskell/files/haskell_ghcide_lib.BUILD.bzl rename to sdk/bazel/extensions/files/ghcide.BUILD.bzl diff --git a/sdk/bazel/extensions/dependencies/haskell/files/haskell_lsp_types.BUILD.bzl b/sdk/bazel/extensions/files/lsp_types.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/haskell/files/haskell_lsp_types.BUILD.bzl rename to sdk/bazel/extensions/files/lsp_types.BUILD.bzl diff --git a/sdk/bazel/extensions/dependencies/bin/files/m4.BUILD.bzl b/sdk/bazel/extensions/files/m4.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/bin/files/m4.BUILD.bzl rename to sdk/bazel/extensions/files/m4.BUILD.bzl diff --git a/sdk/bazel/extensions/dependencies/lib/files/ncurses.BUILD.bzl b/sdk/bazel/extensions/files/ncurses.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/lib/files/ncurses.BUILD.bzl rename to sdk/bazel/extensions/files/ncurses.BUILD.bzl diff --git a/sdk/bazel/extensions/dependencies/haskell/files/haskell_zip.BUILD.bzl b/sdk/bazel/extensions/files/zip.BUILD.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/haskell/files/haskell_zip.BUILD.bzl rename to sdk/bazel/extensions/files/zip.BUILD.bzl diff --git a/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl b/sdk/bazel/extensions/ghcide_extension.bzl similarity index 90% rename from sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl rename to sdk/bazel/extensions/ghcide_extension.bzl index de06a90f2873..d919d591fe54 100644 --- a/sdk/bazel/extensions/dependencies/haskell/ghcide_extension.bzl +++ b/sdk/bazel/extensions/ghcide_extension.bzl @@ -9,7 +9,7 @@ load( def _impl(module_ctx): http_archive( name = "ghcide_lib", - build_file = ":files/haskell_ghcide_lib.BUILD.bzl", + build_file = ":files/ghcide.BUILD.bzl", patch_args = ["-p1"], patches = [ "//bazel/patches:haskell/ghcide_binary_q.patch", diff --git a/sdk/bazel/extensions/deprecated/io_grpc_grpc_java_extension.bzl b/sdk/bazel/extensions/io_grpc_grpc_java_extension.bzl similarity index 91% rename from sdk/bazel/extensions/deprecated/io_grpc_grpc_java_extension.bzl rename to sdk/bazel/extensions/io_grpc_grpc_java_extension.bzl index 7cdf00e5a008..eeb72f9f2c7a 100644 --- a/sdk/bazel/extensions/deprecated/io_grpc_grpc_java_extension.bzl +++ b/sdk/bazel/extensions/io_grpc_grpc_java_extension.bzl @@ -1,6 +1,6 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load( - "//bazel/versions:deprecated.version.bzl", + "//bazel/versions:grpc_java.version.bzl", "GRPC_JAVA_SHA256", "GRPC_JAVA_VERSION", ) diff --git a/sdk/bazel/extensions/dependencies/haskell/lsp_types_extension.bzl b/sdk/bazel/extensions/lsp_types_extension.bzl similarity index 92% rename from sdk/bazel/extensions/dependencies/haskell/lsp_types_extension.bzl rename to sdk/bazel/extensions/lsp_types_extension.bzl index 1e5102c632db..e931cfec6aa2 100644 --- a/sdk/bazel/extensions/dependencies/haskell/lsp_types_extension.bzl +++ b/sdk/bazel/extensions/lsp_types_extension.bzl @@ -8,7 +8,7 @@ load( def _impl(module_ctx): http_archive( name = "lsp-types", - build_file = ":files/haskell_lsp_types.BUILD.bzl", + build_file = ":files/lsp_types.BUILD.bzl", patch_args = ["-p1"], patches = [ "//bazel/patches:haskell/lsp_types_normalisation.patch", diff --git a/sdk/bazel/extensions/dependencies/bin/m4_extension.bzl b/sdk/bazel/extensions/m4_extension.bzl similarity index 100% rename from sdk/bazel/extensions/dependencies/bin/m4_extension.bzl rename to sdk/bazel/extensions/m4_extension.bzl diff --git a/sdk/bazel/extensions/dependencies/lib/ncurses_extension.bzl b/sdk/bazel/extensions/ncurses_extension.bzl similarity index 89% rename from sdk/bazel/extensions/dependencies/lib/ncurses_extension.bzl rename to sdk/bazel/extensions/ncurses_extension.bzl index aae9463ea47d..91e6390d2979 100644 --- a/sdk/bazel/extensions/dependencies/lib/ncurses_extension.bzl +++ b/sdk/bazel/extensions/ncurses_extension.bzl @@ -11,7 +11,7 @@ def _impl(module_ctx): url = "https://ftp.gnu.org/gnu/ncurses/ncurses-{}.tar.gz".format(NCURSES_VERSION), sha256 = NCURSES_SHA256, strip_prefix = "ncurses-{}".format(NCURSES_VERSION), - build_file = Label(":files/ncurses.BUILD.bzl"), + build_file = ":files/ncurses.BUILD.bzl", ) ncurses = module_extension(implementation = _impl) diff --git a/sdk/bazel/extensions/deprecated/rules_proto_extension.bzl b/sdk/bazel/extensions/rules_proto_extension.bzl similarity index 68% rename from sdk/bazel/extensions/deprecated/rules_proto_extension.bzl rename to sdk/bazel/extensions/rules_proto_extension.bzl index 2a9db07d2b36..68424d6b0a9b 100644 --- a/sdk/bazel/extensions/deprecated/rules_proto_extension.bzl +++ b/sdk/bazel/extensions/rules_proto_extension.bzl @@ -1,12 +1,12 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load( - "//bazel/versions:deprecated.version.bzl", + "//bazel/versions:rules_proto.version.bzl", "RULES_PROTO_SHA256", "RULES_PROTO_VERSION", ) -# TODO: This is deprecated rules, check https://github.com/protocolbuffers/protobuf for newer version -# Check https://github.com/bazelbuild/rules_proto for current version and annotation +# TODO: Check https://github.com/bazelbuild/rules_proto for current version +# Check https://github.com/protocolbuffers/protobuf for newer version def _impl(module_ctx): http_archive( name = "rules_proto", diff --git a/sdk/bazel/extensions/dependencies/haskell/zip_extension.bzl b/sdk/bazel/extensions/zip_extension.bzl similarity index 91% rename from sdk/bazel/extensions/dependencies/haskell/zip_extension.bzl rename to sdk/bazel/extensions/zip_extension.bzl index 34598ddcaa4a..a6ebe0f4d786 100644 --- a/sdk/bazel/extensions/dependencies/haskell/zip_extension.bzl +++ b/sdk/bazel/extensions/zip_extension.bzl @@ -8,7 +8,7 @@ load( def _impl(module_ctx): http_archive( name = "zip", - build_file = ":files/haskell_zip.BUILD.bzl", + build_file = ":files/zip.BUILD.bzl", patch_args = ["-p1"], patches = ["//bazel/patches:haskell/zip.patch"], sha256 = ZIP_SHA256, diff --git a/sdk/bazel/versions/deprecated.version.bzl b/sdk/bazel/versions/deprecated.version.bzl deleted file mode 100644 index 91405d7363b9..000000000000 --- a/sdk/bazel/versions/deprecated.version.bzl +++ /dev/null @@ -1,9 +0,0 @@ -# -- rules_proto (deprecated) -- -# https://github.com/bazelbuild/rules_proto -RULES_PROTO_VERSION = "6.0.0" -RULES_PROTO_SHA256 = "303e86e722a520f6f326a50b41cfc16b98fe6d1955ce46642a5b7a67c11c0f5d" - -# -- io_grpc_grpc_java (deprecated) -- -# https://github.com/grpc/grpc-java -GRPC_JAVA_VERSION = "1.60.2" -GRPC_JAVA_SHA256 = "4baf80f35488739d99515d71b8e72bd17a476c214a84106edc66b259fe8ac22c" diff --git a/sdk/bazel/versions/grpc_java.version.bzl b/sdk/bazel/versions/grpc_java.version.bzl new file mode 100644 index 000000000000..21acfb1d696f --- /dev/null +++ b/sdk/bazel/versions/grpc_java.version.bzl @@ -0,0 +1,4 @@ +# -- grpc-java -- +# https://github.com/grpc/grpc-java +GRPC_JAVA_VERSION = "1.60.2" +GRPC_JAVA_SHA256 = "4baf80f35488739d99515d71b8e72bd17a476c214a84106edc66b259fe8ac22c" diff --git a/sdk/bazel/versions/rules_proto.version.bzl b/sdk/bazel/versions/rules_proto.version.bzl new file mode 100644 index 000000000000..5326727ebd3f --- /dev/null +++ b/sdk/bazel/versions/rules_proto.version.bzl @@ -0,0 +1,4 @@ +# -- rules_proto -- +# https://github.com/bazelbuild/rules_proto +RULES_PROTO_VERSION = "6.0.0" +RULES_PROTO_SHA256 = "303e86e722a520f6f326a50b41cfc16b98fe6d1955ce46642a5b7a67c11c0f5d" From d10853f58fe21fe5f0a179db0d8fd9e2bca0175a Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 8 Apr 2026 20:17:11 +0200 Subject: [PATCH 086/287] fix: Solve proto issue (for now) --- sdk/MODULE.bazel | 4 ++-- sdk/bazel/extensions/rules_proto_extension.bzl | 18 ------------------ sdk/bazel/versions/rules_proto.version.bzl | 4 ---- 3 files changed, 2 insertions(+), 24 deletions(-) delete mode 100644 sdk/bazel/extensions/rules_proto_extension.bzl delete mode 100644 sdk/bazel/versions/rules_proto.version.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index bfd38c4f94db..747c4c2e8097 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -134,6 +134,7 @@ stack_snapshot_ext.package( "regex-tdfa", "repline", "resourcet", + "retry", "rope-utf16-splay", "safe", "safe-exceptions", @@ -290,8 +291,7 @@ use_repo(maven_ext, "maven") # # # # DEPRECATED -rules_proto_ext = use_extension("//bazel/extensions:rules_proto_extension.bzl", "rules_proto_extension") -use_repo(rules_proto_ext, "rules_proto") +bazel_dep(name = "rules_proto", version = "6.0.0") io_grpc_grpc_java_ext = use_extension("//bazel/extensions:io_grpc_grpc_java_extension.bzl", "io_grpc_grpc_java_extension") use_repo(io_grpc_grpc_java_ext, "io_grpc_grpc_java") diff --git a/sdk/bazel/extensions/rules_proto_extension.bzl b/sdk/bazel/extensions/rules_proto_extension.bzl deleted file mode 100644 index 68424d6b0a9b..000000000000 --- a/sdk/bazel/extensions/rules_proto_extension.bzl +++ /dev/null @@ -1,18 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load( - "//bazel/versions:rules_proto.version.bzl", - "RULES_PROTO_SHA256", - "RULES_PROTO_VERSION", -) - -# TODO: Check https://github.com/bazelbuild/rules_proto for current version -# Check https://github.com/protocolbuffers/protobuf for newer version -def _impl(module_ctx): - http_archive( - name = "rules_proto", - sha256 = RULES_PROTO_SHA256, - strip_prefix = "rules_proto-{}".format(RULES_PROTO_VERSION), - url = "https://github.com/bazelbuild/rules_proto/releases/download/{v}/rules_proto-{v}.tar.gz".format(v = RULES_PROTO_VERSION), - ) - -rules_proto_extension = module_extension(implementation = _impl) diff --git a/sdk/bazel/versions/rules_proto.version.bzl b/sdk/bazel/versions/rules_proto.version.bzl deleted file mode 100644 index 5326727ebd3f..000000000000 --- a/sdk/bazel/versions/rules_proto.version.bzl +++ /dev/null @@ -1,4 +0,0 @@ -# -- rules_proto -- -# https://github.com/bazelbuild/rules_proto -RULES_PROTO_VERSION = "6.0.0" -RULES_PROTO_SHA256 = "303e86e722a520f6f326a50b41cfc16b98fe6d1955ce46642a5b7a67c11c0f5d" From 5059f512a2c65da32a0d5a455c497de364e4238c Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Wed, 8 Apr 2026 23:57:11 +0200 Subject: [PATCH 087/287] fix: Change `@ghcide_ghc_lib` name to correct `@ghcide_lib` --- sdk/compiler/lsp-tests/BUILD.bazel | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/compiler/lsp-tests/BUILD.bazel b/sdk/compiler/lsp-tests/BUILD.bazel index 25de03a6410e..9b52198c4038 100644 --- a/sdk/compiler/lsp-tests/BUILD.bazel +++ b/sdk/compiler/lsp-tests/BUILD.bazel @@ -46,7 +46,8 @@ da_haskell_test( "//component-version/hs:component-version-lib", "//libs-haskell/bazel-runfiles", "//libs-haskell/test-utils", - "@ghcide_ghc_lib//:testing", + "//sdk-version/hs:sdk-version-lib", + "@ghcide_lib//:testing", ], ) From 0d4d91867a62e762e8df4e89764e9497a34e29bf Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 9 Apr 2026 01:17:57 +0200 Subject: [PATCH 088/287] feat: Address missing maven deps --- sdk/MODULE.bazel | 152 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 149 insertions(+), 3 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 747c4c2e8097..11df40874890 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -255,28 +255,158 @@ scala_deps_ext = use_extension( ) scala_deps_ext.scala() scala_deps_ext.scalatest() +use_repo( + scala_deps_ext, + "io_bazel_rules_scala_scala_compiler", + "io_bazel_rules_scala_scala_library", + "io_bazel_rules_scala_scala_reflect", + "io_bazel_rules_scala_scala_parser_combinators", +) maven_ext = use_extension("@rules_jvm_external//:extensions.bzl", "maven") maven_ext.install( artifacts = [ + # com.daml / canton (version: 3.5.0-snapshot.20260225.18149.0.vc28e7872) + "com.daml:base-errors_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:bindings-java:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:community-admin-api_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:community-base_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.daml:contextualized-logging_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:crypto_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-grpc-utils_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-jwt_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.daml:daml-lf-api-type-signature_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.daml:daml-lf-archive_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-archive-encoder_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.daml:daml-lf-data_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-encoder_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-engine_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-ide-ledger_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-interpreter_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.daml:daml-lf-language_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-parser_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-stable-packages_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-transaction_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-lf-validation_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-resources_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:daml-tls_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:ledger-api-core_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:ledger-api-proto:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:ledger-api-scala_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.daml:ledger-api-value_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:ledger-resources_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.daml:logging-entries_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:magnolify-addon_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:nonempty_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:observability-metrics_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:ports_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:rs-grpc-bridge_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:rs-grpc-pekko_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", "com.daml:scala-utils_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-transaction_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:timer-utils_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.daml:util-observability_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + "com.digitalasset.canton:testing-utils_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + + # auth + "com.auth0:java-jwt:4.2.1", + + # Scala extras + "com.chuusai:shapeless_2.13:2.4.0-M1", + "com.github.scopt:scopt_2.13:4.1.0", + "com.typesafe.scala-logging:scala-logging_2.13:3.9.5", + + # Google + "com.google.api.grpc:proto-google-common-protos:2.59.2", + "com.google.code.findbugs:jsr305:3.0.2", + "com.google.code.gson:gson:2.11.0", + "com.google.guava:guava:33.3.0-jre", "com.google.protobuf:protobuf-java:3.25.5", + + # gRPC Java + "io.grpc:grpc-api:1.77.0", + "io.grpc:grpc-core:1.77.0", + "io.grpc:grpc-netty-shaded:1.77.0", + "io.grpc:grpc-protobuf:1.77.0", + "io.grpc:grpc-stub:1.77.0", + + # build tools + "com.oracle.database.jdbc:ojdbc8:19.18.0.0", + "com.sparkjava:spark-core:2.9.4", + "com.squareup:javapoet:1.13.0", + + # ScalaPB + "com.thesamet.scalapb.common-protos:proto-google-common-protos-scalapb_0.11_2.13:2.9.6-0", + "com.thesamet.scalapb:compilerplugin_2.13:0.11.14", "com.thesamet.scalapb:lenses_2.13:0.11.14", + "com.thesamet.scalapb:protoc-bridge_2.13:0.9.5", + "com.thesamet.scalapb:protoc-gen_2.13:0.9.5", "com.thesamet.scalapb:scalapb-runtime_2.13:0.11.14", - "io.grpc:grpc-protobuf:1.77.0", + "com.thesamet.scalapb:scalapb-runtime-grpc_2.13:0.11.14", + + # Circe + "io.circe:circe-core_2.13:0.14.5", + "io.circe:circe-optics_2.13:0.15.0", + "io.circe:circe-yaml_2.13:0.15.0-RC1", + "io.circe:circe-yaml-common_2.13:0.15.0-RC1", + + # RxJava + "io.reactivex.rxjava2:rxjava:2.2.21", + + # Spray + "io.spray:spray-json_2.13:1.3.6", + + # javax + "javax.annotation:javax.annotation-api:1.3.2", + + # Logging + "ch.qos.logback:logback-classic:1.5.3", + "ch.qos.logback:logback-core:1.5.3", + "org.slf4j:slf4j-api:2.0.17", + + # Optics + "dev.optics:monocle-core_2.13:3.2.0", + + # Pekko + "org.apache.pekko:pekko-actor_2.13:1.2.1", + "org.apache.pekko:pekko-slf4j_2.13:1.2.1", + "org.apache.pekko:pekko-stream_2.13:1.2.1", + + # JUnit + "org.junit.jupiter:junit-jupiter-api:5.9.2", + "org.junit.jupiter:junit-jupiter-engine:5.9.2", + "org.junit.platform:junit-platform-commons:1.9.2", + "org.junit.platform:junit-platform-runner:1.9.2", + + # Scala test + "org.scalacheck:scalacheck_2.13:1.15.4", + "org.scalactic:scalactic_2.13:3.2.19", + "org.scalatest:scalatest_2.13:3.2.19", + "org.scalatest:scalatest-compatible:3.2.19", + "org.scalatest:scalatest-core_2.13:3.2.19", + "org.scalatest:scalatest-flatspec_2.13:3.2.19", + "org.scalatest:scalatest-matchers-core_2.13:3.2.19", + "org.scalatest:scalatest-shouldmatchers_2.13:3.2.19", + "org.scalatest:scalatest-wordspec_2.13:3.2.19", + "org.scalatestplus:scalacheck-1-15_2.13:3.2.11.0", + + # Scalaz "org.scalaz:scalaz-core_2.13:7.2.33", + "org.scalaz:scalaz-scalacheck-binding_2.13:7.2.33-scalacheck-1.15", + + # Typelevel + "org.typelevel:cats-core_2.13:2.9.0", + "org.typelevel:cats-kernel_2.13:2.9.0", + "org.typelevel:paiges-core_2.13:0.4.2", + + # Database + "org.tpolecat:doobie-postgres_2.13:0.13.4", + + # Code quality + "org.typelevel:kind-projector_2.13.16:0.13.3", "org.wartremover:wartremover_2.13.16:3.2.5", "org.jline:jline:3.27.1", - "io.spray:spray-json_2.13:1.3.6", ], + fetch_sources = True, known_contributing_modules = [ "bazel_jar_jar", "bazel_worker_java", @@ -287,6 +417,22 @@ maven_ext.install( "https://europe-maven.pkg.dev/da-images/public-maven-unstable", ], ) +maven_ext.override( + coordinates = "org.scala-lang:scala-compiler", + target = "@io_bazel_rules_scala_scala_compiler//:io_bazel_rules_scala_scala_compiler", +) +maven_ext.override( + coordinates = "org.scala-lang:scala-library", + target = "@io_bazel_rules_scala_scala_library//:io_bazel_rules_scala_scala_library", +) +maven_ext.override( + coordinates = "org.scala-lang:scala-reflect", + target = "@io_bazel_rules_scala_scala_reflect//:io_bazel_rules_scala_scala_reflect", +) +maven_ext.override( + coordinates = "org.scala-lang.modules:scala-parser-combinators", + target = "@io_bazel_rules_scala_scala_parser_combinators//:io_bazel_rules_scala_scala_parser_combinators", +) use_repo(maven_ext, "maven") # # # From 4ecdf63b6bba9be0df21bb8ce7356f5677af8601 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 9 Apr 2026 17:43:09 +0200 Subject: [PATCH 089/287] feat: Partially enable `//compiler` targets --- sdk/3rdparty/haskell/BUILD.bazel | 12 +++-- sdk/MODULE.bazel | 2 +- sdk/bazel_tools/proto.bzl | 4 +- sdk/bazel_tools/scalapb/BUILD.bazel | 2 +- sdk/compiler/damlc/tests/BUILD.bazel | 4 +- sdk/libs-haskell/google-proto-hs/BUILD.bazel | 49 +++++++++++++------- 6 files changed, 46 insertions(+), 27 deletions(-) diff --git a/sdk/3rdparty/haskell/BUILD.bazel b/sdk/3rdparty/haskell/BUILD.bazel index e29300830bd9..48acf84cc89c 100644 --- a/sdk/3rdparty/haskell/BUILD.bazel +++ b/sdk/3rdparty/haskell/BUILD.bazel @@ -7,7 +7,7 @@ genrule( name = "remote_apis_src", srcs = [ "@com_github_bazelbuild_remote_apis//build/bazel/remote/execution/v2:remote_execution.proto", - "@com_google_protobuf//:well_known_protos", + "@protobuf//:well_known_type_protos", "@go_googleapis//google/rpc:status.proto", ], outs = ["Build/Bazel/Remote/Execution/V2/RemoteExecution.hs"], @@ -16,11 +16,17 @@ genrule( PROTO_FILE="$(location @com_github_bazelbuild_remote_apis//build/bazel/remote/execution/v2:remote_execution.proto)" PROTO_FILE_NAME="$$(echo "$$PROTO_FILE" | sed 's|^.*\\(build/bazel/.*\\)|\\1|g')" PROTO_DIR=$$(echo $${PROTO_FILE%$$PROTO_FILE_NAME}) + for f in $(locations @protobuf//:well_known_type_protos); do + PROTOBUF_INCLUDE=$${f%%/google/protobuf/*} + break + done + RPC_STATUS="$(location @go_googleapis//google/rpc:status.proto)" + RPC_INCLUDE=$${RPC_STATUS%%/google/rpc/*} $(location @proto3-suite//:compile-proto-file) \ --proto "$$PROTO_FILE_NAME" \ --includeDir "$$PROTO_DIR" \ - --includeDir "external/com_google_protobuf/src" \ - --includeDir "external/go_googleapis" \ + --includeDir "$$PROTOBUF_INCLUDE" \ + --includeDir "$$RPC_INCLUDE" \ --out $(RULEDIR) """, tools = [ diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 11df40874890..13debd1e0ee7 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -3,7 +3,7 @@ bazel_dep(name = "bazel_skylib", version = "1.9.0") bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1") bazel_dep(name = "gazelle", version = "0.47.0") bazel_dep(name = "google_bazel_common", version = "0.0.1") -bazel_dep(name = "protobuf", version = "33.4") +bazel_dep(name = "protobuf", version = "25.6") bazel_dep(name = "rules_cc", version = "0.2.16") bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_haskell", version = "0.18") diff --git a/sdk/bazel_tools/proto.bzl b/sdk/bazel_tools/proto.bzl index 9ab7cf031c0a..b817bf40f85b 100644 --- a/sdk/bazel_tools/proto.bzl +++ b/sdk/bazel_tools/proto.bzl @@ -9,7 +9,7 @@ load("//bazel_tools:scala.bzl", "scala_source_jar", "scaladoc_jar") load("@rules_scala//scala:scala.bzl", "scala_library") load("@os_info//:os_info.bzl", "is_windows") load("@rules_pkg//:pkg.bzl", "pkg_tar") -load("@protobuf//bazel:proto_library.bzl", "proto_library") +load("@rules_proto//proto:defs.bzl", "proto_library") load("@scala_version//:index.bzl", "scala_major_version_suffix") # taken from rules_proto: @@ -140,7 +140,7 @@ proto_gen = rule( allow_files = True, ), "protoc": attr.label( - default = Label("@com_google_protobuf//:protoc"), + default = Label("@protobuf//:protoc"), cfg = "host", allow_files = True, executable = True, diff --git a/sdk/bazel_tools/scalapb/BUILD.bazel b/sdk/bazel_tools/scalapb/BUILD.bazel index 35b2807bd9ff..20dbc2165a72 100644 --- a/sdk/bazel_tools/scalapb/BUILD.bazel +++ b/sdk/bazel_tools/scalapb/BUILD.bazel @@ -5,7 +5,7 @@ # They play havoc both with `unapply` calls, as you always need an extra `_` to ignore them, # and also with automatically-derived Circe JSON encoders and decoders. -load("@protobuf//bazel:proto_library.bzl", "proto_library") +load("@rules_proto//proto:defs.bzl", "proto_library") load("@scala_version//:index.bzl", "scala_major_version_suffix") proto_library( diff --git a/sdk/compiler/damlc/tests/BUILD.bazel b/sdk/compiler/damlc/tests/BUILD.bazel index 0306795f0e28..432dec1378a9 100644 --- a/sdk/compiler/damlc/tests/BUILD.bazel +++ b/sdk/compiler/damlc/tests/BUILD.bazel @@ -918,7 +918,7 @@ sh_test( srcs = ["src/daml-ghc-deterministic.sh"], args = [ "$(location //compiler/damlc)", - "$(location @com_google_protobuf//:protoc)", + "$(location @protobuf//:protoc)", "$(POSIX_DIFF)", "$(location //daml-script/daml:daml-script.dar)", sdk_version, @@ -929,7 +929,7 @@ sh_test( "//compiler/damlc", "//compiler/damlc/pkg-db", "//daml-script/daml:daml-script.dar", - "@com_google_protobuf//:protoc", + "@protobuf//:protoc", ], toolchains = [ "@rules_sh//sh/posix:make_variables", diff --git a/sdk/libs-haskell/google-proto-hs/BUILD.bazel b/sdk/libs-haskell/google-proto-hs/BUILD.bazel index 68fe0b178b08..2b20ad48a0d5 100644 --- a/sdk/libs-haskell/google-proto-hs/BUILD.bazel +++ b/sdk/libs-haskell/google-proto-hs/BUILD.bazel @@ -1,6 +1,8 @@ # Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +load("//bazel_tools:haskell.bzl", "da_haskell_library") + google_protobuf_src = "external/com_google_protobuf/src" genrule( @@ -15,18 +17,19 @@ genrule( "FieldMask.hs", ]], cmd = """ - for src in \ - external/com_google_protobuf/src/google/protobuf/any.proto \ - external/com_google_protobuf/src/google/protobuf/duration.proto \ - external/com_google_protobuf/src/google/protobuf/empty.proto \ - external/com_google_protobuf/src/google/protobuf/wrappers.proto \ - external/com_google_protobuf/src/google/protobuf/struct.proto \ - external/com_google_protobuf/src/google/protobuf/field_mask.proto \ - ; do - $(location @proto3-suite//:compile-proto-file) \ - --includeDir """ + google_protobuf_src + """ \ - --proto google/protobuf/$$(basename $$src) \ - --out $(@D) + for f in $(locations @protobuf//:well_known_type_protos); do + PROTOBUF_INCLUDE=$${f%%/google/protobuf/*} + break + done + for src in $(locations @protobuf//:well_known_type_protos); do + case $$(basename $$src) in + any.proto|duration.proto|empty.proto|wrappers.proto|struct.proto|field_mask.proto) + $(location @proto3-suite//:compile-proto-file) \ + --includeDir "$$PROTOBUF_INCLUDE" \ + --proto google/protobuf/$$(basename $$src) \ + --out $(@D) + ;; + esac done """, tools = [ @@ -35,8 +38,6 @@ genrule( visibility = ["//visibility:public"], ) -google_rpc_src = "external/go_googleapis" - filegroup( name = "google-rpc-source-protos", srcs = [ @@ -56,10 +57,16 @@ genrule( "Google/Rpc/ErrorDetails.hs", ], cmd = """ + for f in $(locations @protobuf//:well_known_type_protos); do + PROTOBUF_INCLUDE=$${f%%/google/protobuf/*} + break + done + FIRST_RPC=$$(echo $(locations :google-rpc-source-protos) | cut -d' ' -f1) + RPC_INCLUDE=$${FIRST_RPC%%/google/rpc/*} for src in $(locations :google-rpc-source-protos); do $(location @proto3-suite//:compile-proto-file) \ - --includeDir """ + google_protobuf_src + """ \ - --includeDir """ + google_rpc_src + """ \ + --includeDir "$$PROTOBUF_INCLUDE" \ + --includeDir "$$RPC_INCLUDE" \ --proto google/rpc/$$(basename $$src) \ --out $(@D) done @@ -91,10 +98,16 @@ genrule( "Com/Daml/Ledger/Api/V2/Admin/UserManagementService.hs", ], cmd = """ + for f in $(locations @protobuf//:well_known_type_protos); do + PROTOBUF_INCLUDE=$${f%%/google/protobuf/*} + break + done + RPC_STATUS="$(location @go_googleapis//google/rpc:status.proto)" + RPC_INCLUDE=$${RPC_STATUS%%/google/rpc/*} for src in $(locations :ledger-api-protos-fg); do $(location @proto3-suite//:compile-proto-file) \ - --includeDir """ + google_protobuf_src + """ \ - --includeDir """ + google_rpc_src + """ \ + --includeDir "$$PROTOBUF_INCLUDE" \ + --includeDir "$$RPC_INCLUDE" \ --includeDir libs-haskell/ledger-api-pb/src/protobuf \ --proto $${src#libs-haskell/ledger-api-pb/src/protobuf/} \ --out $(@D) From bd7a3dc5f864cf1b6d859f3c0c8501d7c779cf33 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 9 Apr 2026 18:17:56 +0200 Subject: [PATCH 090/287] feat: Add `@protoc_bindist`, to support protoc in version `3.25.5` --- sdk/MODULE.bazel | 3 + sdk/bazel/extensions/protoc_extension.bzl | 67 +++++++++++++++++++++++ sdk/bazel/versions/protoc.version.bzl | 12 ++++ 3 files changed, 82 insertions(+) create mode 100644 sdk/bazel/extensions/protoc_extension.bzl create mode 100644 sdk/bazel/versions/protoc.version.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 13debd1e0ee7..007f7f68a782 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -441,6 +441,9 @@ bazel_dep(name = "rules_proto", version = "6.0.0") io_grpc_grpc_java_ext = use_extension("//bazel/extensions:io_grpc_grpc_java_extension.bzl", "io_grpc_grpc_java_extension") use_repo(io_grpc_grpc_java_ext, "io_grpc_grpc_java") + +protoc_ext = use_extension("//bazel/extensions:protoc_extension.bzl", "protoc_extension") +use_repo(protoc_ext, "protoc_bindist") # # # # # # diff --git a/sdk/bazel/extensions/protoc_extension.bzl b/sdk/bazel/extensions/protoc_extension.bzl new file mode 100644 index 000000000000..735b6d5bf4c2 --- /dev/null +++ b/sdk/bazel/extensions/protoc_extension.bzl @@ -0,0 +1,67 @@ +load( + "//bazel/versions:protoc.version.bzl", + "PROTOC_SHA256S", + "PROTOC_VERSION", +) + +_PROTOC_URL_TEMPLATE = "https://github.com/protocolbuffers/protobuf/releases/download/v{version}/protoc-{version}-{platform}.zip" + +def _detect_platform(rctx): + """Map host OS/arch to protoc release platform string. + + Returns: + (platform_string, is_windows) tuple. + """ + os = rctx.os.name.lower() + arch = rctx.os.arch + + if "mac os x" in os: + if arch == "aarch64": + return "osx-aarch_64", False + return "osx-x86_64", False + + if "windows" in os: + return "win64", True + + if arch == "aarch64": + return "linux-aarch_64", False + return "linux-x86_64", False + +def _protoc_bindist_impl(rctx): + platform, is_windows = _detect_platform(rctx) + sha256 = rctx.attr.sha256s.get(platform, "") + url = _PROTOC_URL_TEMPLATE.format( + version = rctx.attr.version, + platform = platform, + ) + + rctx.download_and_extract(url = url, sha256 = sha256) + + actual_binary = "bin/protoc.exe" if is_windows else "bin/protoc" + rctx.file("BUILD.bazel", """\ +package(default_visibility = ["//visibility:public"]) + +exports_files(["{binary}"]) + +alias( + name = "protoc", + actual = "{binary}", +) +""".format(binary = actual_binary)) + +_protoc_bindist = repository_rule( + implementation = _protoc_bindist_impl, + attrs = { + "version": attr.string(mandatory = True), + "sha256s": attr.string_dict(), + }, +) + +def _impl(module_ctx): + _protoc_bindist( + name = "protoc_bindist", + version = PROTOC_VERSION, + sha256s = PROTOC_SHA256S, + ) + +protoc_extension = module_extension(implementation = _impl) diff --git a/sdk/bazel/versions/protoc.version.bzl b/sdk/bazel/versions/protoc.version.bzl new file mode 100644 index 000000000000..150a5da1ce5b --- /dev/null +++ b/sdk/bazel/versions/protoc.version.bzl @@ -0,0 +1,12 @@ +# -- protoc (prebuilt binary) -- +# https://github.com/protocolbuffers/protobuf/releases/tag/v25.5 +# Must stay aligned with Maven's com.google.protobuf:protobuf-java:3.25.5 +PROTOC_VERSION = "25.5" + +PROTOC_SHA256S = { + "linux-x86_64": "e1ed237a17b2e851cf9662cb5ad02b46e70ff8e060e05984725bc4b4228c6b28", + "linux-aarch_64": "dc715bb5aab2ebf9653d7d3efbe55e01a035e45c26f391ff6d9b7923e22914b7", + "osx-x86_64": "c5447e4f0d5caffb18d9ff21eae7bc7faf2bb2000083d6f49e5b6000b30fceae", + "osx-aarch_64": "781a6fc4c265034872cadc65e63dd3c0fc49245b70917821b60e2d457a6876ab", + "win64": "d2861b0e3131660e5522d0f348dd95e656a5d35f37554c5c2722190ce4b0000b", +} From 18e552b4a6a4f6c4a1412d035cffdb386d668027 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 9 Apr 2026 18:24:13 +0200 Subject: [PATCH 091/287] chore: Add `module` to the top of `MODULE.bazel` --- sdk/MODULE.bazel | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 007f7f68a782..5d30021008e0 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -1,3 +1,8 @@ +module( + name = "daml-sdk", + version = "0.0.0", +) + bazel_dep(name = "bazel_jar_jar", version = "0.1.14") bazel_dep(name = "bazel_skylib", version = "1.9.0") bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1") From b9ccc13014cf9b9116f807b72b35885a1b432b18 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 9 Apr 2026 18:25:55 +0200 Subject: [PATCH 092/287] chore: Cleanup `bazel_dep`s --- sdk/MODULE.bazel | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 5d30021008e0..a1582d85c488 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -8,25 +8,22 @@ bazel_dep(name = "bazel_skylib", version = "1.9.0") bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1") bazel_dep(name = "gazelle", version = "0.47.0") bazel_dep(name = "google_bazel_common", version = "0.0.1") +bazel_dep(name = "patchelf", version = "0.18.0.bcr.1") +bazel_dep(name = "pigz", version = "2.8.bcr.1") bazel_dep(name = "protobuf", version = "25.6") bazel_dep(name = "rules_cc", version = "0.2.16") bazel_dep(name = "rules_go", version = "0.59.0") bazel_dep(name = "rules_haskell", version = "0.18") bazel_dep(name = "rules_java", version = "9.5.0") +bazel_dep(name = "rules_jvm_external", version = "6.10") +bazel_dep(name = "rules_perl", version = "1.1.0") bazel_dep(name = "rules_pkg", version = "1.2.0") - -# # # +bazel_dep(name = "rules_proto", version = "6.0.0") +# TODO: Verify if rules_scala can be upgraded past 7.1.2 (last version supporting scala 2.13.16) bazel_dep(name = "rules_scala", version = "7.1.2") -# 7.1.2 is last version supporting scala 2.13.16. -# TODO: Verify if there is no need to up it -# # # - bazel_dep(name = "rules_sh", version = "0.5.0") -bazel_dep(name = "zlib", version = "1.3.1.bcr.8") -bazel_dep(name = "rules_jvm_external", version = "6.10") -bazel_dep(name = "patchelf", version = "0.18.0.bcr.1") bazel_dep(name = "tar.bzl", version = "0.8.1") -bazel_dep(name = "pigz", version = "2.8.bcr.1") +bazel_dep(name = "zlib", version = "1.3.1.bcr.8") bazel_lib_toolchains_ext = use_extension("@tar.bzl//tar:extensions.bzl", "toolchains") use_repo(bazel_lib_toolchains_ext, "bsd_tar_toolchains") @@ -442,8 +439,6 @@ use_repo(maven_ext, "maven") # # # # DEPRECATED -bazel_dep(name = "rules_proto", version = "6.0.0") - io_grpc_grpc_java_ext = use_extension("//bazel/extensions:io_grpc_grpc_java_extension.bzl", "io_grpc_grpc_java_extension") use_repo(io_grpc_grpc_java_ext, "io_grpc_grpc_java") @@ -463,6 +458,4 @@ autoconf_ext = use_extension("//bazel/extensions:autoconf_extension.bzl", "autoc use_repo(autoconf_ext, "autoconf") automake_ext = use_extension("//bazel/extensions:automake_extension.bzl", "automake") use_repo(automake_ext, "automake") -# # # - -bazel_dep(name = "rules_perl", version = "1.1.0") \ No newline at end of file +# # # \ No newline at end of file From 9611ea5970160e6a9e78ccd00f02a6fc477d7dcf Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 9 Apr 2026 18:27:51 +0200 Subject: [PATCH 093/287] chore: Add reasonable comments to `MODULE.bazel` --- sdk/MODULE.bazel | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index a1582d85c488..09751099cb42 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -25,11 +25,15 @@ bazel_dep(name = "rules_sh", version = "0.5.0") bazel_dep(name = "tar.bzl", version = "0.8.1") bazel_dep(name = "zlib", version = "1.3.1.bcr.8") +# --- Toolchains --- + bazel_lib_toolchains_ext = use_extension("@tar.bzl//tar:extensions.bzl", "toolchains") use_repo(bazel_lib_toolchains_ext, "bsd_tar_toolchains") register_toolchains("@bsd_tar_toolchains//:all") +# --- Haskell toolchain and extensions --- + haskell_toolchains_ext = use_extension( "@rules_haskell//extensions:haskell_toolchains.bzl", "haskell_toolchains", @@ -51,6 +55,8 @@ use_repo(lsp_types_ext, "lsp-types") zip_ext = use_extension("//bazel/extensions:zip_extension.bzl", "zip") use_repo(zip_ext, "zip") +# --- Haskell packages (stack_snapshot) --- + stack_snapshot_ext = use_extension( "@rules_haskell//extensions:stack_snapshot.bzl", "stack_snapshot", @@ -226,6 +232,8 @@ stack_snapshot_ext.package( ], ) +# --- Project-specific extensions --- + module_temporary_ext = use_extension("//bazel/extensions:module_temporary_extension.bzl", "temporary_extension") use_repo(module_temporary_ext, "build_environment", "daml_versions_data", "os_info", "scala_version") @@ -244,6 +252,8 @@ use_repo(import_googleapis_ext, "com_google_googleapis_imports") proto3_suite_ext = use_extension("//bazel/extensions:proto3_suite_extension.bzl", "proto3_suite_extension") use_repo(proto3_suite_ext, "proto3-suite") +# --- Scala configuration --- + scala_config_ext = use_extension( "@rules_scala//scala/extensions:config.bzl", "scala_config", @@ -265,6 +275,8 @@ use_repo( "io_bazel_rules_scala_scala_parser_combinators", ) +# --- Maven / JVM dependencies --- + maven_ext = use_extension("@rules_jvm_external//:extensions.bzl", "maven") maven_ext.install( artifacts = [ @@ -437,17 +449,16 @@ maven_ext.override( ) use_repo(maven_ext, "maven") -# # # -# DEPRECATED +# --- Deprecated (pending removal) --- + io_grpc_grpc_java_ext = use_extension("//bazel/extensions:io_grpc_grpc_java_extension.bzl", "io_grpc_grpc_java_extension") use_repo(io_grpc_grpc_java_ext, "io_grpc_grpc_java") protoc_ext = use_extension("//bazel/extensions:protoc_extension.bzl", "protoc_extension") use_repo(protoc_ext, "protoc_bindist") -# # # -# # # -# Libs +# --- Native libraries --- + ncurses_ext = use_extension("//bazel/extensions:ncurses_extension.bzl", "ncurses") use_repo(ncurses_ext, "ncurses") @@ -457,5 +468,4 @@ use_repo(m4_ext, "m4") autoconf_ext = use_extension("//bazel/extensions:autoconf_extension.bzl", "autoconf") use_repo(autoconf_ext, "autoconf") automake_ext = use_extension("//bazel/extensions:automake_extension.bzl", "automake") -use_repo(automake_ext, "automake") -# # # \ No newline at end of file +use_repo(automake_ext, "automake") \ No newline at end of file From f022f885a15738883e6c084d6d6becf2c4c81866 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 9 Apr 2026 18:37:45 +0200 Subject: [PATCH 094/287] chore: Mark `buildifier_prebuild` as `dev_dependency` --- sdk/MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 09751099cb42..b87c805d6cde 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -5,7 +5,7 @@ module( bazel_dep(name = "bazel_jar_jar", version = "0.1.14") bazel_dep(name = "bazel_skylib", version = "1.9.0") -bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.1") +bazel_dep(name = "buildifier_prebuilt", version = "8.5.1.2", dev_dependency = True) bazel_dep(name = "gazelle", version = "0.47.0") bazel_dep(name = "google_bazel_common", version = "0.0.1") bazel_dep(name = "patchelf", version = "0.18.0.bcr.1") From c4dec5e09c9aacd9abe5adca03001d2ff6f9b3bc Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 9 Apr 2026 18:56:34 +0200 Subject: [PATCH 095/287] chore: Extract maven versions outside of definition --- sdk/MODULE.bazel | 244 +++++++++++++++++++++++++++-------------------- 1 file changed, 143 insertions(+), 101 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index b87c805d6cde..fc6bf3545b27 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -275,150 +275,192 @@ use_repo( "io_bazel_rules_scala_scala_parser_combinators", ) +# --- Maven version constants --- + +CANTON_VERSION = "3.5.0-snapshot.20260225.18149.0.vc28e7872" +AUTH0_JWT_VERSION = "4.2.1" +SHAPELESS_VERSION = "2.4.0-M1" +SCOPT_VERSION = "4.1.0" +SCALA_LOGGING_VERSION = "3.9.5" +PROTO_GOOGLE_COMMON_PROTOS_VERSION = "2.59.2" +JSR305_VERSION = "3.0.2" +GSON_VERSION = "2.11.0" +GUAVA_VERSION = "33.3.0-jre" +PROTOBUF_JAVA_VERSION = "3.25.5" +GRPC_JAVA_MAVEN_VERSION = "1.77.0" +OJDBC_VERSION = "19.18.0.0" +SPARK_CORE_VERSION = "2.9.4" +JAVAPOET_VERSION = "1.13.0" +SCALAPB_COMMON_PROTOS_VERSION = "2.9.6-0" +SCALAPB_VERSION = "0.11.14" +SCALAPB_PROTOC_VERSION = "0.9.5" +CIRCE_CORE_VERSION = "0.14.5" +CIRCE_OPTICS_VERSION = "0.15.0" +CIRCE_YAML_VERSION = "0.15.0-RC1" +RXJAVA_VERSION = "2.2.21" +SPRAY_JSON_VERSION = "1.3.6" +JAVAX_ANNOTATION_VERSION = "1.3.2" +LOGBACK_VERSION = "1.5.3" +SLF4J_VERSION = "2.0.17" +MONOCLE_VERSION = "3.2.0" +PEKKO_VERSION = "1.2.1" +JUNIT_JUPITER_VERSION = "5.9.2" +JUNIT_PLATFORM_VERSION = "1.9.2" +SCALACHECK_VERSION = "1.15.4" +SCALATEST_VERSION = "3.2.19" +SCALATESTPLUS_VERSION = "3.2.11.0" +SCALAZ_VERSION = "7.2.33" +CATS_VERSION = "2.9.0" +PAIGES_VERSION = "0.4.2" +DOOBIE_VERSION = "0.13.4" +KIND_PROJECTOR_VERSION = "0.13.3" +WARTREMOVER_VERSION = "3.2.5" +JLINE_VERSION = "3.27.1" + # --- Maven / JVM dependencies --- maven_ext = use_extension("@rules_jvm_external//:extensions.bzl", "maven") maven_ext.install( artifacts = [ - # com.daml / canton (version: 3.5.0-snapshot.20260225.18149.0.vc28e7872) - "com.daml:base-errors_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:bindings-java:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:community-admin-api_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:community-base_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:contextualized-logging_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:crypto_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-grpc-utils_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-jwt_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-api-type-signature_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-archive_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-archive-encoder_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-data_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-encoder_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-engine_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-ide-ledger_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-interpreter_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-language_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-parser_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-stable-packages_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-transaction_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-lf-validation_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-resources_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:daml-tls_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:ledger-api-core_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:ledger-api-proto:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:ledger-api-scala_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:ledger-api-value_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:ledger-resources_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:logging-entries_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:magnolify-addon_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:nonempty_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:observability-metrics_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:ports_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:rs-grpc-bridge_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:rs-grpc-pekko_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:scala-utils_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:timer-utils_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.daml:util-observability_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", - "com.digitalasset.canton:testing-utils_2.13:3.5.0-snapshot.20260225.18149.0.vc28e7872", + # com.daml / canton + "com.daml:base-errors_2.13:" + CANTON_VERSION, + "com.daml:bindings-java:" + CANTON_VERSION, + "com.daml:community-admin-api_2.13:" + CANTON_VERSION, + "com.daml:community-base_2.13:" + CANTON_VERSION, + "com.daml:contextualized-logging_2.13:" + CANTON_VERSION, + "com.daml:crypto_2.13:" + CANTON_VERSION, + "com.daml:daml-grpc-utils_2.13:" + CANTON_VERSION, + "com.daml:daml-jwt_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-api-type-signature_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-archive_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-archive-encoder_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-data_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-encoder_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-engine_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-ide-ledger_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-interpreter_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-language_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-parser_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-stable-packages_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-transaction_2.13:" + CANTON_VERSION, + "com.daml:daml-lf-validation_2.13:" + CANTON_VERSION, + "com.daml:daml-resources_2.13:" + CANTON_VERSION, + "com.daml:daml-tls_2.13:" + CANTON_VERSION, + "com.daml:ledger-api-core_2.13:" + CANTON_VERSION, + "com.daml:ledger-api-proto:" + CANTON_VERSION, + "com.daml:ledger-api-scala_2.13:" + CANTON_VERSION, + "com.daml:ledger-api-value_2.13:" + CANTON_VERSION, + "com.daml:ledger-resources_2.13:" + CANTON_VERSION, + "com.daml:logging-entries_2.13:" + CANTON_VERSION, + "com.daml:magnolify-addon_2.13:" + CANTON_VERSION, + "com.daml:nonempty_2.13:" + CANTON_VERSION, + "com.daml:observability-metrics_2.13:" + CANTON_VERSION, + "com.daml:ports_2.13:" + CANTON_VERSION, + "com.daml:rs-grpc-bridge_2.13:" + CANTON_VERSION, + "com.daml:rs-grpc-pekko_2.13:" + CANTON_VERSION, + "com.daml:scala-utils_2.13:" + CANTON_VERSION, + "com.daml:timer-utils_2.13:" + CANTON_VERSION, + "com.daml:util-observability_2.13:" + CANTON_VERSION, + "com.digitalasset.canton:testing-utils_2.13:" + CANTON_VERSION, # auth - "com.auth0:java-jwt:4.2.1", + "com.auth0:java-jwt:" + AUTH0_JWT_VERSION, # Scala extras - "com.chuusai:shapeless_2.13:2.4.0-M1", - "com.github.scopt:scopt_2.13:4.1.0", - "com.typesafe.scala-logging:scala-logging_2.13:3.9.5", + "com.chuusai:shapeless_2.13:" + SHAPELESS_VERSION, + "com.github.scopt:scopt_2.13:" + SCOPT_VERSION, + "com.typesafe.scala-logging:scala-logging_2.13:" + SCALA_LOGGING_VERSION, # Google - "com.google.api.grpc:proto-google-common-protos:2.59.2", - "com.google.code.findbugs:jsr305:3.0.2", - "com.google.code.gson:gson:2.11.0", - "com.google.guava:guava:33.3.0-jre", - "com.google.protobuf:protobuf-java:3.25.5", + "com.google.api.grpc:proto-google-common-protos:" + PROTO_GOOGLE_COMMON_PROTOS_VERSION, + "com.google.code.findbugs:jsr305:" + JSR305_VERSION, + "com.google.code.gson:gson:" + GSON_VERSION, + "com.google.guava:guava:" + GUAVA_VERSION, + "com.google.protobuf:protobuf-java:" + PROTOBUF_JAVA_VERSION, # gRPC Java - "io.grpc:grpc-api:1.77.0", - "io.grpc:grpc-core:1.77.0", - "io.grpc:grpc-netty-shaded:1.77.0", - "io.grpc:grpc-protobuf:1.77.0", - "io.grpc:grpc-stub:1.77.0", + "io.grpc:grpc-api:" + GRPC_JAVA_MAVEN_VERSION, + "io.grpc:grpc-core:" + GRPC_JAVA_MAVEN_VERSION, + "io.grpc:grpc-netty-shaded:" + GRPC_JAVA_MAVEN_VERSION, + "io.grpc:grpc-protobuf:" + GRPC_JAVA_MAVEN_VERSION, + "io.grpc:grpc-stub:" + GRPC_JAVA_MAVEN_VERSION, # build tools - "com.oracle.database.jdbc:ojdbc8:19.18.0.0", - "com.sparkjava:spark-core:2.9.4", - "com.squareup:javapoet:1.13.0", + "com.oracle.database.jdbc:ojdbc8:" + OJDBC_VERSION, + "com.sparkjava:spark-core:" + SPARK_CORE_VERSION, + "com.squareup:javapoet:" + JAVAPOET_VERSION, # ScalaPB - "com.thesamet.scalapb.common-protos:proto-google-common-protos-scalapb_0.11_2.13:2.9.6-0", - "com.thesamet.scalapb:compilerplugin_2.13:0.11.14", - "com.thesamet.scalapb:lenses_2.13:0.11.14", - "com.thesamet.scalapb:protoc-bridge_2.13:0.9.5", - "com.thesamet.scalapb:protoc-gen_2.13:0.9.5", - "com.thesamet.scalapb:scalapb-runtime_2.13:0.11.14", - "com.thesamet.scalapb:scalapb-runtime-grpc_2.13:0.11.14", + "com.thesamet.scalapb.common-protos:proto-google-common-protos-scalapb_0.11_2.13:" + SCALAPB_COMMON_PROTOS_VERSION, + "com.thesamet.scalapb:compilerplugin_2.13:" + SCALAPB_VERSION, + "com.thesamet.scalapb:lenses_2.13:" + SCALAPB_VERSION, + "com.thesamet.scalapb:protoc-bridge_2.13:" + SCALAPB_PROTOC_VERSION, + "com.thesamet.scalapb:protoc-gen_2.13:" + SCALAPB_PROTOC_VERSION, + "com.thesamet.scalapb:scalapb-runtime_2.13:" + SCALAPB_VERSION, + "com.thesamet.scalapb:scalapb-runtime-grpc_2.13:" + SCALAPB_VERSION, # Circe - "io.circe:circe-core_2.13:0.14.5", - "io.circe:circe-optics_2.13:0.15.0", - "io.circe:circe-yaml_2.13:0.15.0-RC1", - "io.circe:circe-yaml-common_2.13:0.15.0-RC1", + "io.circe:circe-core_2.13:" + CIRCE_CORE_VERSION, + "io.circe:circe-optics_2.13:" + CIRCE_OPTICS_VERSION, + "io.circe:circe-yaml_2.13:" + CIRCE_YAML_VERSION, + "io.circe:circe-yaml-common_2.13:" + CIRCE_YAML_VERSION, # RxJava - "io.reactivex.rxjava2:rxjava:2.2.21", + "io.reactivex.rxjava2:rxjava:" + RXJAVA_VERSION, # Spray - "io.spray:spray-json_2.13:1.3.6", + "io.spray:spray-json_2.13:" + SPRAY_JSON_VERSION, # javax - "javax.annotation:javax.annotation-api:1.3.2", + "javax.annotation:javax.annotation-api:" + JAVAX_ANNOTATION_VERSION, # Logging - "ch.qos.logback:logback-classic:1.5.3", - "ch.qos.logback:logback-core:1.5.3", - "org.slf4j:slf4j-api:2.0.17", + "ch.qos.logback:logback-classic:" + LOGBACK_VERSION, + "ch.qos.logback:logback-core:" + LOGBACK_VERSION, + "org.slf4j:slf4j-api:" + SLF4J_VERSION, # Optics - "dev.optics:monocle-core_2.13:3.2.0", + "dev.optics:monocle-core_2.13:" + MONOCLE_VERSION, # Pekko - "org.apache.pekko:pekko-actor_2.13:1.2.1", - "org.apache.pekko:pekko-slf4j_2.13:1.2.1", - "org.apache.pekko:pekko-stream_2.13:1.2.1", + "org.apache.pekko:pekko-actor_2.13:" + PEKKO_VERSION, + "org.apache.pekko:pekko-slf4j_2.13:" + PEKKO_VERSION, + "org.apache.pekko:pekko-stream_2.13:" + PEKKO_VERSION, # JUnit - "org.junit.jupiter:junit-jupiter-api:5.9.2", - "org.junit.jupiter:junit-jupiter-engine:5.9.2", - "org.junit.platform:junit-platform-commons:1.9.2", - "org.junit.platform:junit-platform-runner:1.9.2", + "org.junit.jupiter:junit-jupiter-api:" + JUNIT_JUPITER_VERSION, + "org.junit.jupiter:junit-jupiter-engine:" + JUNIT_JUPITER_VERSION, + "org.junit.platform:junit-platform-commons:" + JUNIT_PLATFORM_VERSION, + "org.junit.platform:junit-platform-runner:" + JUNIT_PLATFORM_VERSION, # Scala test - "org.scalacheck:scalacheck_2.13:1.15.4", - "org.scalactic:scalactic_2.13:3.2.19", - "org.scalatest:scalatest_2.13:3.2.19", - "org.scalatest:scalatest-compatible:3.2.19", - "org.scalatest:scalatest-core_2.13:3.2.19", - "org.scalatest:scalatest-flatspec_2.13:3.2.19", - "org.scalatest:scalatest-matchers-core_2.13:3.2.19", - "org.scalatest:scalatest-shouldmatchers_2.13:3.2.19", - "org.scalatest:scalatest-wordspec_2.13:3.2.19", - "org.scalatestplus:scalacheck-1-15_2.13:3.2.11.0", + "org.scalacheck:scalacheck_2.13:" + SCALACHECK_VERSION, + "org.scalactic:scalactic_2.13:" + SCALATEST_VERSION, + "org.scalatest:scalatest_2.13:" + SCALATEST_VERSION, + "org.scalatest:scalatest-compatible:" + SCALATEST_VERSION, + "org.scalatest:scalatest-core_2.13:" + SCALATEST_VERSION, + "org.scalatest:scalatest-flatspec_2.13:" + SCALATEST_VERSION, + "org.scalatest:scalatest-matchers-core_2.13:" + SCALATEST_VERSION, + "org.scalatest:scalatest-shouldmatchers_2.13:" + SCALATEST_VERSION, + "org.scalatest:scalatest-wordspec_2.13:" + SCALATEST_VERSION, + "org.scalatestplus:scalacheck-1-15_2.13:" + SCALATESTPLUS_VERSION, # Scalaz - "org.scalaz:scalaz-core_2.13:7.2.33", - "org.scalaz:scalaz-scalacheck-binding_2.13:7.2.33-scalacheck-1.15", + "org.scalaz:scalaz-core_2.13:" + SCALAZ_VERSION, + "org.scalaz:scalaz-scalacheck-binding_2.13:" + SCALAZ_VERSION + "-scalacheck-1.15", # Typelevel - "org.typelevel:cats-core_2.13:2.9.0", - "org.typelevel:cats-kernel_2.13:2.9.0", - "org.typelevel:paiges-core_2.13:0.4.2", + "org.typelevel:cats-core_2.13:" + CATS_VERSION, + "org.typelevel:cats-kernel_2.13:" + CATS_VERSION, + "org.typelevel:paiges-core_2.13:" + PAIGES_VERSION, # Database - "org.tpolecat:doobie-postgres_2.13:0.13.4", + "org.tpolecat:doobie-postgres_2.13:" + DOOBIE_VERSION, # Code quality - "org.typelevel:kind-projector_2.13.16:0.13.3", - "org.wartremover:wartremover_2.13.16:3.2.5", - "org.jline:jline:3.27.1", + "org.typelevel:kind-projector_2.13.16:" + KIND_PROJECTOR_VERSION, + "org.wartremover:wartremover_2.13.16:" + WARTREMOVER_VERSION, + "org.jline:jline:" + JLINE_VERSION, ], fetch_sources = True, known_contributing_modules = [ From a4dbfd55f6ce5a6d2791c912627475854806a8c3 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 9 Apr 2026 19:03:28 +0200 Subject: [PATCH 096/287] fix: Apply changes to buildifier --- sdk/.pre-commit-config.yaml | 2 +- sdk/BUILD | 38 ++++++++++++++++++++++++++++--------- sdk/WORKSPACE | 4 ---- sdk/compatibility/deps.bzl | 10 ---------- sdk/deps.bzl | 13 ------------- 5 files changed, 30 insertions(+), 37 deletions(-) diff --git a/sdk/.pre-commit-config.yaml b/sdk/.pre-commit-config.yaml index 0d7601cd7ab4..95d543a2866f 100644 --- a/sdk/.pre-commit-config.yaml +++ b/sdk/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: name: buildifier language: system require_serial: true - entry: "bash -c 'root=$PWD && cd sdk/ && bazel run @com_github_bazelbuild_buildtools//buildifier -- -mode=fix -v \"${@/#/$root/}\"' bash" + entry: "bash -c 'cd sdk/; bazel run //:buildifier-fix'" types: [bazel] - id: copyrights name: copyright headers diff --git a/sdk/BUILD b/sdk/BUILD index bf7147e9aa5f..db9fcd0c03f8 100644 --- a/sdk/BUILD +++ b/sdk/BUILD @@ -13,6 +13,7 @@ load("//bazel_tools:haskell.bzl", "da_haskell_library", "da_haskell_repl") load("//bazel_tools:scala.bzl", "da_scala_library") load("@os_info//:os_info.bzl", "is_windows") load("@build_environment//:configuration.bzl", "ghc_version", "mvn_version", "sdk_version") +load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test") exports_files([".hlint.yaml"]) @@ -165,23 +166,42 @@ exports_files([ "maven_install_2.13.json", ]) -# Buildifier. -buildifier_excluded_patterns = [ +_BUILDIFIER_EXCLUDE_PATTERNS = [ "./3rdparty/haskell/c2hs-package.bzl", "./3rdparty/haskell/network-package.bzl", - "**/node_modules/*", + "./**/node_modules/*", ] -# Run this to check if BUILD files are well-formatted. -alias( +_BUILDIFIER_WARNINGS = [ + "+unsorted-dict-items", + "+out-of-order-load", + "+load", +] + +buildifier( name = "buildifier", - actual = "@buildifier_prebuilt//:buildifier", + exclude_patterns = _BUILDIFIER_EXCLUDE_PATTERNS, + lint_mode = "warn", + lint_warnings = _BUILDIFIER_WARNINGS, + mode = "diff", + verbose = True, ) -# Run this to fix the errors in BUILD files. -alias( +buildifier( name = "buildifier-fix", - actual = "@buildifier_prebuilt//:buildifier.fix", + exclude_patterns = _BUILDIFIER_EXCLUDE_PATTERNS, + lint_mode = "fix", + lint_warnings = _BUILDIFIER_WARNINGS, + mode = "fix", + verbose = True, +) + +buildifier_test( + name = "buildifier_test", + lint_mode = "warn", + lint_warnings = _BUILDIFIER_WARNINGS, + no_sandbox = True, + workspace = "//:MODULE.bazel", ) # Default target for da-ghci, da-ghcid. diff --git a/sdk/WORKSPACE b/sdk/WORKSPACE index 14147da22574..f2fd3f0e940f 100644 --- a/sdk/WORKSPACE +++ b/sdk/WORKSPACE @@ -780,10 +780,6 @@ load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependenci apple_rules_dependencies() -load("@com_github_bazelbuild_buildtools//buildifier:deps.bzl", "buildifier_dependencies") - -buildifier_dependencies() - nixpkgs_package( name = "postgresql_nix", attribute_path = "postgresql_12", diff --git a/sdk/compatibility/deps.bzl b/sdk/compatibility/deps.bzl index c6aa3a31e9e1..6ffabf80c72b 100644 --- a/sdk/compatibility/deps.bzl +++ b/sdk/compatibility/deps.bzl @@ -32,8 +32,6 @@ load( "@daml//:deps.bzl", "bazel_gazelle_sha256", "bazel_gazelle_version", - "buildifier_sha256", - "buildifier_version", "rules_bazel_common_sha256", "rules_bazel_common_version", "rules_go_sha256", @@ -115,14 +113,6 @@ def daml_deps(): sha256 = rules_nixpkgs_sha256, ) - if "com_github_bazelbuild_buildtools" not in native.existing_rules(): - http_archive( - name = "com_github_bazelbuild_buildtools", - sha256 = buildifier_sha256, - strip_prefix = "buildtools-{}".format(buildifier_version), - url = "https://github.com/bazelbuild/buildtools/archive/{}.tar.gz".format(buildifier_version), - ) - if "com_github_madler_zlib" not in native.existing_rules(): http_archive( name = "com_github_madler_zlib", diff --git a/sdk/deps.bzl b/sdk/deps.bzl index 5cd86099facf..4fa8b8b11c69 100644 --- a/sdk/deps.bzl +++ b/sdk/deps.bzl @@ -62,9 +62,6 @@ rules_nixpkgs_toolchain_patches = { "posix": [], } -buildifier_version = "b163fcf72b7def638f364ed129c9b28032c1d39b" -buildifier_sha256 = "c2399161fa569f7c815f8e27634035557a2e07a557996df579412ac73bf52c23" - zlib_version = "1.2.11" zlib_sha256 = "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff" rules_nodejs_version = "5.8.5" @@ -346,16 +343,6 @@ def daml_deps(): patch_args = ["-p1"], ) - # Buildifier. - # It is written in Go and hence needs rules_go to be available. - if "com_github_bazelbuild_buildtools" not in native.existing_rules(): - http_archive( - name = "com_github_bazelbuild_buildtools", - sha256 = buildifier_sha256, - strip_prefix = "buildtools-{}".format(buildifier_version), - url = "https://github.com/bazelbuild/buildtools/archive/{}.tar.gz".format(buildifier_version), - ) - native.bind( name = "guava", actual = "@com_google_guava_guava//jar", From ecd82055191591a95e6d2a2ec13aec0f61422c25 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 9 Apr 2026 19:21:02 +0200 Subject: [PATCH 097/287] chore: Extract and document packages for haskell --- sdk/MODULE.bazel | 246 +++++++++++++++++++++++++---------------------- 1 file changed, 131 insertions(+), 115 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index fc6bf3545b27..0eb17db6ea69 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -69,123 +69,139 @@ stack_snapshot_ext.package( name = "lsp-types", vendored = "@lsp-types//:lsp-types", ) -[ - stack_snapshot_ext.package( - name = pkg, - ) - for pkg in [ - "aeson", - "aeson-pretty", - "ansi-terminal", - "ansi-wl-pprint", - "array", - "async", - "base", - "base64", - "base64-bytestring", - "binary", - "blaze-html", - "bytestring", - "Cabal", - "clock", - "cmark-gfm", - "conduit", - "conduit-extra", - "containers", - "cryptonite", - "data-default", - "Decimal", - "deepseq", - "Diff", - "directory", - "dlist", - "either", - "extra", - "file-embed", - "filelock", - "filepattern", - "filepath", - "ghc-lib-parser-ex", - "gitrev", - "hashable", - "haskell-src-exts", - "hlint", - "hslogger", - "http-client", - "http-client-tls", - "http-conduit", - "http-types", - "jwt", - "lens", - "lens-aeson", - "lsp", - "lsp-test", - "megaparsec", - "memory", - "mod", - "monad-loops", - "mtl", - "network", - "network-uri", - "optparse-applicative", - "parser-combinators", - "parsec", - "pcre-utils", - "pretty", - "prettyprinter", - "process", - "proto3-wire", - "QuickCheck", - "random", - "random-shuffle", - "recursion-schemes", - "regex-tdfa", - "repline", - "resourcet", - "retry", - "rope-utf16-splay", - "safe", - "safe-exceptions", - "scientific", - "semigroupoids", - "semver", - "shake", - "silently", - "some", - "split", - "stache", - "stm", - "syb", - "tagged", - "tar-conduit", - "tasty", - "tasty-golden", - "tasty-hunit", - "tasty-quickcheck", - "template-haskell", - "temporary", - "terminal-progress-bar", - "text", - "time", - "tls", - "transformers", - "typed-process", - "uniplate", - "unix", - "unix-compat", - "unliftio", - "unliftio-core", - "unordered-containers", - "uri-encode", - "utf8-string", - "validation", - "vector", - "xml", - "yaml", - "zip-archive", - ] +HASKELL_PACKAGES = [ + # Core / GHC base + "array", + "base", + "binary", + "bytestring", + "containers", + "deepseq", + "directory", + "filepath", + "mtl", + "pretty", + "process", + "stm", + "text", + "time", + "transformers", + "unix", + "unix-compat", + + # Data structures & utilities + "data-default", + "Decimal", + "Diff", + "dlist", + "either", + "extra", + "hashable", + "mod", + "safe", + "safe-exceptions", + "scientific", + "semigroupoids", + "some", + "split", + "tagged", + "unordered-containers", + "validation", + "vector", + + # Concurrency & IO + "async", + "monad-loops", + "resourcet", + "typed-process", + "unliftio", + "unliftio-core", + + # Text processing & parsing + "ansi-terminal", + "ansi-wl-pprint", + "blaze-html", + "cmark-gfm", + "haskell-src-exts", + "megaparsec", + "parsec", + "parser-combinators", + "pcre-utils", + "prettyprinter", + "recursion-schemes", + "regex-tdfa", + "rope-utf16-splay", + "stache", + "syb", + "uniplate", + "utf8-string", + + # Serialization & encoding + "aeson", + "aeson-pretty", + "base64", + "base64-bytestring", + "proto3-wire", + "xml", + "yaml", + + # Networking, HTTP & security + "conduit", + "conduit-extra", + "cryptonite", + "http-client", + "http-client-tls", + "http-conduit", + "http-types", + "jwt", + "memory", + "network", + "network-uri", + "tar-conduit", + "tls", + "uri-encode", + + # Filesystem & archives + "file-embed", + "filelock", + "filepattern", + "temporary", + "zip-archive", + + # Optics & CLI + "lens", + "lens-aeson", + "optparse-applicative", + "repline", + "terminal-progress-bar", + + # Compiler tooling, build & misc + "Cabal", + "clock", + "ghc-lib-parser-ex", + "gitrev", + "hlint", + "hslogger", + "lsp", + "lsp-test", + "random", + "random-shuffle", + "retry", + "semver", + "shake", + "template-haskell", + + # Testing + "QuickCheck", + "silently", + "tasty", + "tasty-golden", + "tasty-hunit", + "tasty-quickcheck", ] +[stack_snapshot_ext.package(name = pkg) for pkg in HASKELL_PACKAGES] + stack_snapshot_ext.package( name = "attoparsec", components = [ From d0d4c8db367e55fe56009908cdf2ddf23d44f26b Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Thu, 9 Apr 2026 19:26:19 +0200 Subject: [PATCH 098/287] chore: Move extensions to more fitting place --- sdk/MODULE.bazel | 47 +++++++++++-------- .../extensions/module_temporary_extension.bzl | 17 ------- 2 files changed, 27 insertions(+), 37 deletions(-) delete mode 100644 sdk/bazel/extensions/module_temporary_extension.bzl diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 0eb17db6ea69..6df9e28f89ed 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -248,26 +248,6 @@ stack_snapshot_ext.package( ], ) -# --- Project-specific extensions --- - -module_temporary_ext = use_extension("//bazel/extensions:module_temporary_extension.bzl", "temporary_extension") -use_repo(module_temporary_ext, "build_environment", "daml_versions_data", "os_info", "scala_version") - -dpm_ext = use_extension("//bazel/extensions:dpm_extension.bzl", "dpm_extension") -use_repo(dpm_ext, "dpm_binary") - -d3plus_ext = use_extension("//bazel/extensions:d3plus_extension.bzl", "d3plus_extension") -use_repo(d3plus_ext, "static_asset_d3plus") - -googleapis_ext = use_extension("//bazel/extensions:go_googleapis_extension.bzl", "googleapis_extension") -use_repo(googleapis_ext, "go_googleapis") - -import_googleapis_ext = use_extension("//bazel/extensions:go_googleapis_import_extension.bzl", "import_googleapis_extension") -use_repo(import_googleapis_ext, "com_google_googleapis_imports") - -proto3_suite_ext = use_extension("//bazel/extensions:proto3_suite_extension.bzl", "proto3_suite_extension") -use_repo(proto3_suite_ext, "proto3-suite") - # --- Scala configuration --- scala_config_ext = use_extension( @@ -507,7 +487,34 @@ maven_ext.override( ) use_repo(maven_ext, "maven") +# --- Project-specific extensions --- + +# Workspace configuration: bundles build_environment (SDK version from env), +# os_info (platform detection), scala_version (Scala version from env), +# and daml_versions_data (LF version data from JSON). +# TODO: Split into per-concern extensions. +workspace_config_ext = use_extension("//bazel/extensions:daml_workspace_config_extension.bzl", "daml_workspace_config") +use_repo(workspace_config_ext, "build_environment", "daml_versions_data", "os_info", "scala_version") + +dpm_ext = use_extension("//bazel/extensions:dpm_extension.bzl", "dpm_extension") +use_repo(dpm_ext, "dpm_binary") + +d3plus_ext = use_extension("//bazel/extensions:d3plus_extension.bzl", "d3plus_extension") +use_repo(d3plus_ext, "static_asset_d3plus") + +googleapis_ext = use_extension("//bazel/extensions:go_googleapis_extension.bzl", "googleapis_extension") +use_repo(googleapis_ext, "go_googleapis") + +import_googleapis_ext = use_extension("//bazel/extensions:go_googleapis_import_extension.bzl", "import_googleapis_extension") +use_repo(import_googleapis_ext, "com_google_googleapis_imports") + +proto3_suite_ext = use_extension("//bazel/extensions:proto3_suite_extension.bzl", "proto3_suite_extension") +use_repo(proto3_suite_ext, "proto3-suite") + # --- Deprecated (pending removal) --- +# io_grpc_grpc_java: legacy gRPC Java codegen; to be replaced by rules_proto + protobuf bazel_dep. +# protoc_bindist: legacy protoc binary distribution; to be replaced by the protobuf bazel_dep toolchain. +# TODO: Remove once all targets have migrated to the new protobuf/gRPC setup. io_grpc_grpc_java_ext = use_extension("//bazel/extensions:io_grpc_grpc_java_extension.bzl", "io_grpc_grpc_java_extension") use_repo(io_grpc_grpc_java_ext, "io_grpc_grpc_java") diff --git a/sdk/bazel/extensions/module_temporary_extension.bzl b/sdk/bazel/extensions/module_temporary_extension.bzl deleted file mode 100644 index 00a340fbd0e6..000000000000 --- a/sdk/bazel/extensions/module_temporary_extension.bzl +++ /dev/null @@ -1,17 +0,0 @@ -load("//bazel_tools:build_environment.bzl", "build_environment") -load("//bazel_tools:os_info.bzl", "os_info") -load("//bazel_tools:scala_version.bzl", "scala_version_configure") -load("//daml-lf:json_repo.bzl", "daml_versions_repo") - -def _temporary_extension_impl(module_ctx): - scala_version_configure(name = "scala_version") - os_info(name = "os_info") - build_environment(name = "build_environment") - daml_versions_repo( - name = "daml_versions_data", - json_file = "//daml-lf:daml-lf-versions.json", - ) - -temporary_extension = module_extension( - implementation = _temporary_extension_impl, -) From 457ebc1add534c63df5bbacd1432b0efdd19aef2 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 13 Apr 2026 17:00:12 +0200 Subject: [PATCH 099/287] chore: Cleanup old files --- sdk/bazel-haskell-deps.bzl | 8 +-- sdk/bazel_tools/googleapis-status-proto.patch | 12 ---- sdk/bazel_tools/haskell-ghcide-binary-q.patch | 20 ------- sdk/bazel_tools/haskell-zip.patch | 57 ------------------- .../lsp-types-expose-other-modules.patch | 20 ------- sdk/bazel_tools/lsp-types-normalisation.patch | 44 -------------- sdk/deps.bzl | 2 +- 7 files changed, 5 insertions(+), 158 deletions(-) delete mode 100644 sdk/bazel_tools/googleapis-status-proto.patch delete mode 100644 sdk/bazel_tools/haskell-ghcide-binary-q.patch delete mode 100644 sdk/bazel_tools/haskell-zip.patch delete mode 100644 sdk/bazel_tools/lsp-types-expose-other-modules.patch delete mode 100644 sdk/bazel_tools/lsp-types-normalisation.patch diff --git a/sdk/bazel-haskell-deps.bzl b/sdk/bazel-haskell-deps.bzl index 62f2d6a14d6f..766f8246ac10 100644 --- a/sdk/bazel-haskell-deps.bzl +++ b/sdk/bazel-haskell-deps.bzl @@ -59,8 +59,8 @@ haskell_cabal_library( )""", patch_args = ["-p1"], patches = [ - "@com_github_digital_asset_daml//bazel_tools:lsp-types-normalisation.patch", - "@com_github_digital_asset_daml//bazel_tools:lsp-types-expose-other-modules.patch", + "//bazel/patches:haskell/lsp_types_normalisation.patch", + "//bazel/patches:haskell/lsp_types_expose_other_modules.patch", ], sha256 = LSP_TYPES_SHA256, strip_prefix = "lsp-types-{}".format(LSP_TYPES_VERSION), @@ -119,7 +119,7 @@ haskell_library( """, patch_args = ["-p1"], patches = [ - "@com_github_digital_asset_daml//bazel_tools:haskell-ghcide-binary-q.patch", + "//bazel/patches:haskell/ghcide_binary_q.patch", ], sha256 = None if GHCIDE_LOCAL_PATH != None else GHCIDE_SHA256, strip_prefix = None if GHCIDE_LOCAL_PATH != None else "daml-ghcide-%s" % GHCIDE_REV, @@ -420,7 +420,7 @@ haskell_cabal_library( """, patch_args = ["-p1"], patches = [ - "@com_github_digital_asset_daml//bazel_tools:haskell-zip.patch", + "//bazel/patches:haskell/zip.patch", ], sha256 = "0d7f02bbdf6c49e9a33d2eca4b3d7644216a213590866dafdd2b47ddd38eb746", strip_prefix = "zip-{}".format(ZIP_VERSION), diff --git a/sdk/bazel_tools/googleapis-status-proto.patch b/sdk/bazel_tools/googleapis-status-proto.patch deleted file mode 100644 index 1ca75cb04013..000000000000 --- a/sdk/bazel_tools/googleapis-status-proto.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/google/rpc/BUILD.bazel b/google/rpc/BUILD.bazel -index 8ffa5a49c..eb0a8127b 100644 ---- a/google/rpc/BUILD.bazel -+++ b/google/rpc/BUILD.bazel -@@ -1,5 +1,7 @@ - load("@rules_proto//proto:defs.bzl", "proto_library") - -+exports_files(["status.proto", "error_details.proto"]) -+ - # This is an API workspace, having public visibility by default makes perfect sense. - package(default_visibility = ["//visibility:public"]) - diff --git a/sdk/bazel_tools/haskell-ghcide-binary-q.patch b/sdk/bazel_tools/haskell-ghcide-binary-q.patch deleted file mode 100644 index 05d61b2d0abd..000000000000 --- a/sdk/bazel_tools/haskell-ghcide-binary-q.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/src/Development/IDE/Core/Shake.hs b/src/Development/IDE/Core/Shake.hs -index a471070..a2b3183 100644 ---- a/src/Development/IDE/Core/Shake.hs -+++ b/src/Development/IDE/Core/Shake.hs -@@ -503,7 +503,14 @@ isBadDependency x - newtype Q k = Q (k, NormalizedFilePath) - deriving (Eq,Hashable,NFData, Generic) - --instance Binary k => Binary (Q k) -+instance Binary k => Binary (Q k) where -+ put (Q (k, fp)) = put (k, fp) -+ get = do -+ (k, fp) <- get -+ -- The `get` implementation of NormalizedFilePath -+ -- does not handle empty file paths so we -+ -- need to handle this ourselves here. -+ pure (Q (k, toNormalizedFilePath' fp)) - - instance Show k => Show (Q k) where - show (Q (k, file)) = show k ++ "; " ++ fromNormalizedFilePath file diff --git a/sdk/bazel_tools/haskell-zip.patch b/sdk/bazel_tools/haskell-zip.patch deleted file mode 100644 index 46440bbc72ef..000000000000 --- a/sdk/bazel_tools/haskell-zip.patch +++ /dev/null @@ -1,57 +0,0 @@ -The use of temp files in `zip` sadly runs into an issue -with GHC’s `openBinaryTempFile` function which seems -to have a race condition where multiple processes can get -the same temp file name. Then one process will move away the temp -file of the other process resulting in the following error: - -damlc.exe: C:\users\\…\\ghc77D0.zip" Just "\\\\?\\C:\\users\\…\\daml-script-1.dev.dar": does not exist (The system cannot find the file specified.) - -We don’t need the atomic write of the zip (DAR) file here so -we simply patch `zip` to write to the file directly. -It doesn’t really make sense to upstream this. The code in the -zip library is correct, it’s `openBinaryTempFile` that is broken. - -diff --git a/Codec/Archive/Zip/Internal.hs b/Codec/Archive/Zip/Internal.hs -index b3fa27f..31e34b0 100644 ---- a/Codec/Archive/Zip/Internal.hs -+++ b/Codec/Archive/Zip/Internal.hs -@@ -27,7 +27,6 @@ import Codec.Archive.Zip.CP437 (decodeCP437) - import Codec.Archive.Zip.Type - import Conduit (PrimMonad) - import Control.Applicative (many, (<|>)) --import Control.Exception (bracketOnError, catchJust) - import Control.Monad - import Control.Monad.Catch (MonadThrow (..)) - import Control.Monad.Trans.Maybe -@@ -60,10 +59,7 @@ import Data.Version - import Data.Void - import Data.Word (Word16, Word32) - import Numeric.Natural (Natural) --import System.Directory --import System.FilePath - import System.IO --import System.IO.Error (isDoesNotExistError) - - #ifndef mingw32_HOST_OS - import qualified Codec.Archive.Zip.Unix as Unix -@@ -302,19 +298,7 @@ withNewFile :: - (Handle -> IO ()) -> - IO () - withNewFile fpath action = -- bracketOnError allocate release $ \(path, h) -> do -- action h -- hClose h -- renameFile path fpath -- where -- allocate = openBinaryTempFile (takeDirectory fpath) ".zip" -- release (path, h) = do -- hClose h -- -- Despite using `bracketOnError` the file is not guaranteed to exist -- -- here since we could be interrupted with an async exception after -- -- the file has been renamed. Therefore, we silentely ignore -- -- `DoesNotExistError`. -- catchJust (guard . isDoesNotExistError) (removeFile path) (const $ pure ()) -+ withBinaryFile fpath ReadWriteMode action - - -- | Determine what comment in new archive will look like given its original - -- value and a collection of pending actions. diff --git a/sdk/bazel_tools/lsp-types-expose-other-modules.patch b/sdk/bazel_tools/lsp-types-expose-other-modules.patch deleted file mode 100644 index eafabbfcc91f..000000000000 --- a/sdk/bazel_tools/lsp-types-expose-other-modules.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/lsp-types.cabal b/lsp-types.cabal -index 1af6907..1443cc0 100644 ---- a/lsp-types.cabal -+++ b/lsp-types.cabal -@@ -21,6 +21,7 @@ library - , Language.LSP.Types.Capabilities - , Language.LSP.Types.Lens - , Language.LSP.Types.SMethodMap -+ , Language.LSP.Types.Utils - , Language.LSP.VFS - , Data.IxMap - other-modules: Language.LSP.Types.CallHierarchy -@@ -63,7 +64,6 @@ library - , Language.LSP.Types.TextDocument - , Language.LSP.Types.TypeDefinition - , Language.LSP.Types.Uri -- , Language.LSP.Types.Utils - , Language.LSP.Types.Window - , Language.LSP.Types.WatchedFiles - , Language.LSP.Types.WorkspaceEdit diff --git a/sdk/bazel_tools/lsp-types-normalisation.patch b/sdk/bazel_tools/lsp-types-normalisation.patch deleted file mode 100644 index df2212488ee2..000000000000 --- a/sdk/bazel_tools/lsp-types-normalisation.patch +++ /dev/null @@ -1,44 +0,0 @@ -diff --git a/src/Language/LSP/Types/Uri.hs b/src/Language/LSP/Types/Uri.hs -index 8d2d43f..8477dde 100644 ---- a/src/Language/LSP/Types/Uri.hs -+++ b/src/Language/LSP/Types/Uri.hs -@@ -112,12 +112,12 @@ platformAdjustFromUriPath systemOS authority srcPath = - else let - firstSegment:rest = (FPP.splitDirectories . tail) srcPath -- Drop leading '/' for absolute Windows paths - drive = if FPW.isDrive firstSegment -- then FPW.addTrailingPathSeparator firstSegment -+ then FPP.addTrailingPathSeparator firstSegment - else firstSegment -- in FPW.joinDrive drive $ FPW.joinPath rest -+ in FPP.joinDrive drive $ FPP.joinPath rest - - filePathToUri :: FilePath -> Uri --filePathToUri = (platformAwareFilePathToUri System.Info.os) . FP.normalise -+filePathToUri = (platformAwareFilePathToUri System.Info.os) . normalise' - - {-# WARNING platformAwareFilePathToUri "This function is considered private. Use normalizedUriToFilePath instead." #-} - platformAwareFilePathToUri :: SystemOS -> FilePath -> Uri -@@ -193,10 +193,22 @@ instance Hashable NormalizedFilePath where - instance IsString NormalizedFilePath where - fromString = toNormalizedFilePath - -+-- | Normalise a file path, but always convert to POSIX style file paths. -+normalise' :: FilePath -> FilePath -+normalise' fp = nfp -+ where -+ (drv, nfp0) = FP.splitDrive fp -+ nfp = convertDrive drv `FPP.joinDrive` (FPP.joinPath $ FP.splitDirectories nfp0) -+ -+ convertDrive drv -+ | System.Info.os == windowsOS && FPW.hasTrailingPathSeparator drv = -+ FPP.addTrailingPathSeparator (init drv) -+ | otherwise = drv -+ - toNormalizedFilePath :: FilePath -> NormalizedFilePath - toNormalizedFilePath fp = normalizedFilePath nuri nfp - where -- nfp = FP.normalise fp -+ nfp = normalise' fp - nuri = internalNormalizedFilePathToUri nfp - - fromNormalizedFilePath :: NormalizedFilePath -> FilePath diff --git a/sdk/deps.bzl b/sdk/deps.bzl index 4fa8b8b11c69..acd23a0da8f4 100644 --- a/sdk/deps.bzl +++ b/sdk/deps.bzl @@ -197,7 +197,7 @@ def daml_deps(): strip_prefix = "googleapis-{}".format(go_googleapis_version), patches = [ # The Haskell gRPC bindings require access to the status.proto source file. - "//bazel_tools:googleapis-status-proto.patch", + "//bazel/patches:go_googleapis/status-proto.patch", ], patch_args = ["-E", "-p1"], ) From 53f05b54c90f92910e782c594c1b6d7fda25ff7c Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 13 Apr 2026 17:05:42 +0200 Subject: [PATCH 100/287] fix: Add missing extension file --- .../daml_workspace_config_extension.bzl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 sdk/bazel/extensions/daml_workspace_config_extension.bzl diff --git a/sdk/bazel/extensions/daml_workspace_config_extension.bzl b/sdk/bazel/extensions/daml_workspace_config_extension.bzl new file mode 100644 index 000000000000..a0608ad237cb --- /dev/null +++ b/sdk/bazel/extensions/daml_workspace_config_extension.bzl @@ -0,0 +1,17 @@ +load("//bazel_tools:build_environment.bzl", "build_environment") +load("//bazel_tools:os_info.bzl", "os_info") +load("//bazel_tools:scala_version.bzl", "scala_version_configure") +load("//daml-lf:json_repo.bzl", "daml_versions_repo") + +def _daml_workspace_config_impl(module_ctx): + scala_version_configure(name = "scala_version") + os_info(name = "os_info") + build_environment(name = "build_environment") + daml_versions_repo( + name = "daml_versions_data", + json_file = "//daml-lf:daml-lf-versions.json", + ) + +daml_workspace_config = module_extension( + implementation = _daml_workspace_config_impl, +) From 8dc9afe03caacebc1a20368eabb6fb1807430152 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 13 Apr 2026 19:46:38 +0200 Subject: [PATCH 101/287] feat: Migrate `@grpc` to 1.75.0 --- sdk/.gitignore | 2 + sdk/MODULE.bazel | 14 ++ .../extensions/files/grpc_haskell.BUILD.bzl | 9 ++ .../files/grpc_haskell_core.BUILD.bzl | 25 ++++ .../files/grpc_haskell_core_cbits.BUILD.bzl | 17 +++ .../extensions/grpc_haskell_extension.bzl | 51 ++++++++ .../grpc-haskell-core-bad-status-meta.patch | 79 ++++++++++++ .../grpc-haskell-core-grpc-compat.patch | 121 ++++++++++++++++++ sdk/bazel/versions/grpc_haskell.version.bzl | 4 + sdk/bazel_tools/fat_cc_library.bzl | 35 +++-- 10 files changed, 345 insertions(+), 12 deletions(-) create mode 100644 sdk/bazel/extensions/files/grpc_haskell.BUILD.bzl create mode 100644 sdk/bazel/extensions/files/grpc_haskell_core.BUILD.bzl create mode 100644 sdk/bazel/extensions/files/grpc_haskell_core_cbits.BUILD.bzl create mode 100644 sdk/bazel/extensions/grpc_haskell_extension.bzl create mode 100644 sdk/bazel/patches/haskell/grpc-haskell-core-bad-status-meta.patch create mode 100644 sdk/bazel/patches/haskell/grpc-haskell-core-grpc-compat.patch create mode 100644 sdk/bazel/versions/grpc_haskell.version.bzl diff --git a/sdk/.gitignore b/sdk/.gitignore index d4a7676af845..0b4601753d15 100644 --- a/sdk/.gitignore +++ b/sdk/.gitignore @@ -93,3 +93,5 @@ out /.canton docs/build/ + +bzlmigration/ \ No newline at end of file diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 6df9e28f89ed..7829b9c4fe3c 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -8,6 +8,7 @@ bazel_dep(name = "bazel_skylib", version = "1.9.0") bazel_dep(name = "buildifier_prebuilt", version = "8.5.1.2", dev_dependency = True) bazel_dep(name = "gazelle", version = "0.47.0") bazel_dep(name = "google_bazel_common", version = "0.0.1") +bazel_dep(name = "grpc", version = "1.75.0") bazel_dep(name = "patchelf", version = "0.18.0.bcr.1") bazel_dep(name = "pigz", version = "2.8.bcr.1") bazel_dep(name = "protobuf", version = "25.6") @@ -55,6 +56,9 @@ use_repo(lsp_types_ext, "lsp-types") zip_ext = use_extension("//bazel/extensions:zip_extension.bzl", "zip") use_repo(zip_ext, "zip") +grpc_haskell_ext = use_extension("//bazel/extensions:grpc_haskell_extension.bzl", "grpc_haskell") +use_repo(grpc_haskell_ext, "grpc_haskell", "grpc_haskell_core", "grpc_haskell_core_cbits") + # --- Haskell packages (stack_snapshot) --- stack_snapshot_ext = use_extension( @@ -97,12 +101,14 @@ HASKELL_PACKAGES = [ "either", "extra", "hashable", + "managed", "mod", "safe", "safe-exceptions", "scientific", "semigroupoids", "some", + "sorted-list", "split", "tagged", "unordered-containers", @@ -232,6 +238,14 @@ stack_snapshot_ext.package( name = "zip", vendored = "@zip//:zip", ) +stack_snapshot_ext.package( + name = "grpc-haskell-core", + vendored = "@grpc_haskell_core//:grpc-haskell-core", +) +stack_snapshot_ext.package( + name = "grpc-haskell", + vendored = "@grpc_haskell//:grpc-haskell", +) stack_snapshot_ext.package( name = "happy", components = ["exe"], diff --git a/sdk/bazel/extensions/files/grpc_haskell.BUILD.bzl b/sdk/bazel/extensions/files/grpc_haskell.BUILD.bzl new file mode 100644 index 000000000000..0c7e6a0e7a68 --- /dev/null +++ b/sdk/bazel/extensions/files/grpc_haskell.BUILD.bzl @@ -0,0 +1,9 @@ +load("@rules_haskell//haskell:defs.bzl", "haskell_library") +load("@stackage//:packages.bzl", "packages") + +haskell_library( + name = "grpc-haskell", + srcs = glob(["src/**/*.hs"]), + deps = packages["grpc-haskell"].deps, + visibility = ["//visibility:public"], +) diff --git a/sdk/bazel/extensions/files/grpc_haskell_core.BUILD.bzl b/sdk/bazel/extensions/files/grpc_haskell_core.BUILD.bzl new file mode 100644 index 000000000000..637fd2e0005c --- /dev/null +++ b/sdk/bazel/extensions/files/grpc_haskell_core.BUILD.bzl @@ -0,0 +1,25 @@ +load("@daml-sdk//bazel_tools:haskell.bzl", "c2hs_suite") + +c2hs_suite( + name = "grpc-haskell-core", + srcs = [ + "src/Network/GRPC/Unsafe/Constants.hsc", + ] + glob(["src/**/*.hs"]), + c2hs_src_strip_prefix = "src", + c2hs_srcs = [ + "src/Network/GRPC/Unsafe/Time.chs", + "src/Network/GRPC/Unsafe/ChannelArgs.chs", + "src/Network/GRPC/Unsafe/Slice.chs", + "src/Network/GRPC/Unsafe/ByteBuffer.chs", + "src/Network/GRPC/Unsafe/Metadata.chs", + "src/Network/GRPC/Unsafe/Op.chs", + "src/Network/GRPC/Unsafe.chs", + "src/Network/GRPC/Unsafe/Security.chs", + ], + compiler_flags = ["-XCPP", "-Wno-unused-imports", "-Wno-unused-record-wildcards"], + hackage_deps = ["clock", "managed", "base", "sorted-list", "bytestring", "containers", "stm", "transformers", "template-haskell"], + visibility = ["//visibility:public"], + deps = [ + "@grpc_haskell_core_cbits//:merged_cbits", + ], +) diff --git a/sdk/bazel/extensions/files/grpc_haskell_core_cbits.BUILD.bzl b/sdk/bazel/extensions/files/grpc_haskell_core_cbits.BUILD.bzl new file mode 100644 index 000000000000..57fb979bb74a --- /dev/null +++ b/sdk/bazel/extensions/files/grpc_haskell_core_cbits.BUILD.bzl @@ -0,0 +1,17 @@ +load("@daml-sdk//bazel_tools:fat_cc_library.bzl", "fat_cc_library") + +fat_cc_library( + name = "merged_cbits", + input_lib = "cbits", + visibility = ["//visibility:public"], +) + +cc_library( + name = "cbits", + srcs = glob(["cbits/*.c"]), + hdrs = glob(["include/*.h"]), + includes = ["include/"], + deps = [ + "@grpc//:grpc", + ], +) diff --git a/sdk/bazel/extensions/grpc_haskell_extension.bzl b/sdk/bazel/extensions/grpc_haskell_extension.bzl new file mode 100644 index 000000000000..dba6e3678c21 --- /dev/null +++ b/sdk/bazel/extensions/grpc_haskell_extension.bzl @@ -0,0 +1,51 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel/versions:grpc_haskell.version.bzl", + "GRPC_HASKELL_REV", + "GRPC_HASKELL_SHA256", +) + +_URLS = [ + "https://codeload.github.com/awakesecurity/gRPC-haskell/tar.gz/{}".format(GRPC_HASKELL_REV), + "https://github.com/awakesecurity/gRPC-haskell/archive/{}.tar.gz".format(GRPC_HASKELL_REV), +] +_PATCHES = [ + # Includes MetadataMap in GRPCIOBadStatusCode for richer error reporting. + "//bazel/patches:haskell/grpc-haskell-core-bad-status-meta.patch", + # Stubs out C API types/functions removed in gRPC >= 1.74 (auth metadata + # plugin, SSL credential helpers). daml never calls these; see + # bzlmigration/CRITICAL_CHANGES/01_grpc-haskell-c-api-compat.md + "//bazel/patches:haskell/grpc-haskell-core-grpc-compat.patch", +] + +def _impl(module_ctx): + http_archive( + name = "grpc_haskell_core", + build_file = ":files/grpc_haskell_core.BUILD.bzl", + patch_args = ["-p1"], + patches = _PATCHES, + sha256 = GRPC_HASKELL_SHA256, + strip_prefix = "gRPC-haskell-{}/core".format(GRPC_HASKELL_REV), + type = "tar.gz", + urls = _URLS, + ) + http_archive( + name = "grpc_haskell_core_cbits", + build_file = ":files/grpc_haskell_core_cbits.BUILD.bzl", + patch_args = ["-p1"], + patches = _PATCHES, + sha256 = GRPC_HASKELL_SHA256, + strip_prefix = "gRPC-haskell-{}/core".format(GRPC_HASKELL_REV), + type = "tar.gz", + urls = _URLS, + ) + http_archive( + name = "grpc_haskell", + build_file = ":files/grpc_haskell.BUILD.bzl", + sha256 = GRPC_HASKELL_SHA256, + strip_prefix = "gRPC-haskell-{}".format(GRPC_HASKELL_REV), + type = "tar.gz", + urls = _URLS, + ) + +grpc_haskell = module_extension(implementation = _impl) diff --git a/sdk/bazel/patches/haskell/grpc-haskell-core-bad-status-meta.patch b/sdk/bazel/patches/haskell/grpc-haskell-core-bad-status-meta.patch new file mode 100644 index 000000000000..150a99b2b689 --- /dev/null +++ b/sdk/bazel/patches/haskell/grpc-haskell-core-bad-status-meta.patch @@ -0,0 +1,79 @@ +diff --git a/src/Network/GRPC/LowLevel/Client.hs b/src/Network/GRPC/LowLevel/Client.hs +index b617d91..74adbd4 100644 +--- a/src/Network/GRPC/LowLevel/Client.hs ++++ b/src/Network/GRPC/LowLevel/Client.hs +@@ -277,8 +277,8 @@ compileNormalRequestResults + compileNormalRequestResults x = + case extractStatusInfo x of + Nothing -> Left GRPCIOUnknownError +- Just (_meta, status, details) -> +- Left (GRPCIOBadStatusCode status (StatusDetails details)) ++ Just (meta, status, details) -> ++ Left (GRPCIOBadStatusCode status (StatusDetails details) meta) + + -------------------------------------------------------------------------------- + -- clientReader (client side of server streaming mode) +diff --git a/src/Network/GRPC/LowLevel/GRPC.hs b/src/Network/GRPC/LowLevel/GRPC.hs +index 1f1a532..84f5d20 100644 +--- a/src/Network/GRPC/LowLevel/GRPC.hs ++++ b/src/Network/GRPC/LowLevel/GRPC.hs +@@ -64,7 +64,7 @@ data GRPCIOError + -- reasonable amount of time. + GRPCIOShutdownFailure + | GRPCIOUnknownError +- | GRPCIOBadStatusCode C.StatusCode C.StatusDetails ++ | GRPCIOBadStatusCode C.StatusCode C.StatusDetails MetadataMap + | GRPCIODecodeError String + | GRPCIOInternalUnexpectedRecv String -- debugging description + | GRPCIOHandlerException String +diff --git a/tests/LowLevelTests.hs b/tests/LowLevelTests.hs +index 7e82e27..e2708ac 100644 +--- a/tests/LowLevelTests.hs ++++ b/tests/LowLevelTests.hs +@@ -233,7 +233,7 @@ testServerAuthProcessorCancel = + rm <- clientRegisterMethodNormal c "/foo" + r <- clientRequest c rm 10 "hi" mempty + -- TODO: using checkReqRslt on this first result causes the test to hang! +- r @?= Left (GRPCIOBadStatusCode StatusUnauthenticated "denied!") ++ r @?= Left (GRPCIOBadStatusCode StatusUnauthenticated "denied!" mempty) + clientRequest c rm 10 "hi" [("foo", "bar")] >>= do + checkReqRslt $ \NormalRequestResult{..} -> do + rspCode @?= StatusOk +@@ -442,7 +442,7 @@ testServerCancel = + where + client c = do + rm <- clientRegisterMethodNormal c "/foo" +- Left (GRPCIOBadStatusCode s _) <- clientRequest c rm 10 "" mempty ++ Left (GRPCIOBadStatusCode s _ _) <- clientRequest c rm 10 "" mempty + s @?= StatusCancelled + server s = do + let rm = head (normalMethods s) +@@ -678,8 +678,8 @@ testGoaway = + clientRequest c rm 10 "" mempty + eer <- clientRequest c rm 1 "" mempty + assertBool "Client handles server shutdown gracefully" $ case eer of +- Left (GRPCIOBadStatusCode StatusUnavailable _) -> True +- Left (GRPCIOBadStatusCode StatusDeadlineExceeded "Deadline Exceeded") -> True ++ Left (GRPCIOBadStatusCode StatusUnavailable _ _) -> True ++ Left (GRPCIOBadStatusCode StatusDeadlineExceeded "Deadline Exceeded" _) -> True + Left GRPCIOTimeout -> True + _ -> False + +@@ -696,7 +696,7 @@ testSlowServer = + client c = do + rm <- clientRegisterMethodNormal c "/foo" + result <- clientRequest c rm 1 "" mempty +- result @?= Left (GRPCIOBadStatusCode StatusDeadlineExceeded "Deadline Exceeded") ++ result @?= Left (GRPCIOBadStatusCode StatusDeadlineExceeded "Deadline Exceeded" mempty) + server s = do + let rm = head (normalMethods s) + serverHandleNormalCall s rm mempty $ \_ -> do +@@ -875,7 +875,7 @@ testClientMaxReceiveMessageLengthChannelArg = do + -- Expect failure when the max recv payload size is set to 3 bytes, and we + -- are sent 4. + shouldFail = clientMax 3 $ \case +- Left (GRPCIOBadStatusCode StatusResourceExhausted _) -> ++ Left (GRPCIOBadStatusCode StatusResourceExhausted _ _) -> + pure () + rsp -> + clientFail ("Expected failure response, but got: " ++ show rsp) diff --git a/sdk/bazel/patches/haskell/grpc-haskell-core-grpc-compat.patch b/sdk/bazel/patches/haskell/grpc-haskell-core-grpc-compat.patch new file mode 100644 index 000000000000..827dd285008b --- /dev/null +++ b/sdk/bazel/patches/haskell/grpc-haskell-core-grpc-compat.patch @@ -0,0 +1,121 @@ +diff -ruN a/cbits/grpc_haskell.c b/cbits/grpc_haskell.c +--- a/cbits/grpc_haskell.c 2026-04-13 18:40:59.701737256 +0200 ++++ b/cbits/grpc_haskell.c 2026-04-13 18:42:45.532380683 +0200 +@@ -455,32 +455,24 @@ + + grpc_server_credentials* ssl_server_credentials_create_internal( + const char* pem_root_certs, const char* pem_key, const char* pem_cert, +- grpc_ssl_client_certificate_request_type force_client_auth){ +- +- grpc_ssl_pem_key_cert_pair pair = {pem_key, pem_cert}; +- grpc_server_credentials* creds = grpc_ssl_server_credentials_create_ex( +- pem_root_certs, &pair, 1, force_client_auth, NULL); +- return creds; ++ grpc_ssl_client_certificate_request_type force_client_auth) { ++ /* Removed in gRPC 1.74; daml never calls this wrapper. */ ++ (void)pem_root_certs; (void)pem_key; (void)pem_cert; (void)force_client_auth; ++ return NULL; + } + + grpc_channel_credentials* grpc_ssl_credentials_create_internal( +- const char* pem_root_certs, const char* pem_key, const char* pem_cert){ +- +- grpc_channel_credentials* creds; +- if(pem_key && pem_cert){ +- grpc_ssl_pem_key_cert_pair pair = {pem_key, pem_cert}; +- creds = grpc_ssl_credentials_create(pem_root_certs, &pair, NULL, NULL); +- } +- else{ +- creds = grpc_ssl_credentials_create(pem_root_certs, NULL, NULL, NULL); +- } +- return creds; ++ const char* pem_root_certs, const char* pem_key, const char* pem_cert) { ++ /* Removed in gRPC 1.74; daml never calls this wrapper. */ ++ (void)pem_root_certs; (void)pem_key; (void)pem_cert; ++ return NULL; + } + + void grpc_server_credentials_set_auth_metadata_processor_( +- grpc_server_credentials* creds, grpc_auth_metadata_processor* p){ +- +- grpc_server_credentials_set_auth_metadata_processor(creds, *p); ++ grpc_server_credentials* creds, grpc_auth_metadata_processor* p) { ++ /* Removed in gRPC 1.74; daml never calls this wrapper. */ ++ (void)creds; ++ (void)p; + } + + grpc_auth_metadata_processor* mk_auth_metadata_processor( +@@ -497,9 +489,10 @@ + } + + grpc_call_credentials* grpc_metadata_credentials_create_from_plugin_( +- grpc_metadata_credentials_plugin* plugin){ +- +- return grpc_metadata_credentials_create_from_plugin(*plugin, GRPC_PRIVACY_AND_INTEGRITY, NULL); ++ grpc_metadata_credentials_plugin* plugin) { ++ /* Removed in gRPC 1.74; daml never calls this wrapper. */ ++ (void)plugin; ++ return NULL; + } + + //This is a hack to work around GHC being unable to deal with raw struct params. +diff -ruN a/include/grpc_haskell.h b/include/grpc_haskell.h +--- a/include/grpc_haskell.h 2026-04-13 18:40:59.698987139 +0200 ++++ b/include/grpc_haskell.h 2026-04-13 18:41:18.050228775 +0200 +@@ -8,6 +8,55 @@ + #include + #include + ++/* ++ * Compatibility shims for gRPC >= 1.74 which removed the legacy ++ * auth-metadata-processor / credentials-plugin C API. ++ * The daml codebase does not call these APIs; the stubs exist ++ * only to keep the c2hs bindings and FFI wrappers compiling. ++ */ ++#ifndef GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX ++#define GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX 4 ++ ++typedef struct grpc_auth_metadata_context { ++ const char *service_url; ++ const char *method_name; ++ const grpc_auth_context *channel_auth_context; ++} grpc_auth_metadata_context; ++ ++typedef void (*grpc_process_auth_metadata_done_cb)( ++ void *user_data, const grpc_metadata *consumed_md, ++ size_t num_consumed_md, const grpc_metadata *response_md, ++ size_t num_response_md, grpc_status_code status, ++ const char *error_details); ++ ++typedef void (*grpc_credentials_plugin_metadata_cb)( ++ void *user_data, const grpc_metadata *creds_md, size_t num_creds_md, ++ grpc_status_code status, const char *error_details); ++ ++typedef struct grpc_auth_metadata_processor { ++ void (*process)(void *state, grpc_auth_context *context, ++ const grpc_metadata *md, size_t num_md, ++ grpc_process_auth_metadata_done_cb cb, void *user_data); ++ void (*destroy)(void *state); ++ void *state; ++} grpc_auth_metadata_processor; ++ ++typedef struct grpc_metadata_credentials_plugin { ++ int (*get_metadata)(void *state, ++ grpc_auth_metadata_context context, ++ grpc_credentials_plugin_metadata_cb cb, ++ void *user_data, ++ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], ++ size_t *num_creds_md, ++ grpc_status_code *status, ++ const char **error_details); ++ void (*destroy)(void *state); ++ void *state; ++ const char *type; ++} grpc_metadata_credentials_plugin; ++ ++#endif /* GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX */ ++ + grpc_event *grpc_completion_queue_next_(grpc_completion_queue *cq, + gpr_timespec *deadline, + void *reserved); diff --git a/sdk/bazel/versions/grpc_haskell.version.bzl b/sdk/bazel/versions/grpc_haskell.version.bzl new file mode 100644 index 000000000000..06e2cecd9985 --- /dev/null +++ b/sdk/bazel/versions/grpc_haskell.version.bzl @@ -0,0 +1,4 @@ +# -- grpc-haskell -- +# https://github.com/awakesecurity/gRPC-haskell +GRPC_HASKELL_REV = "4b3b04d0ac9d1db53033fb4f0b6864f25b6e945d" +GRPC_HASKELL_SHA256 = "" diff --git a/sdk/bazel_tools/fat_cc_library.bzl b/sdk/bazel_tools/fat_cc_library.bzl index a858591827e6..891919e85df1 100644 --- a/sdk/bazel_tools/fat_cc_library.bzl +++ b/sdk/bazel_tools/fat_cc_library.bzl @@ -56,18 +56,9 @@ def _fat_cc_library_impl(ctx): # On Windows we have some extra deps. (["-lws2_32"] if is_windows else []), inputs = static_libs, - env = {"PATH": ""}, + env = {"PATH": "/usr/bin:/bin"}, ) - mri_script_content = "\n".join( - ["create {}".format(static_lib.path)] + - ["addlib {}".format(lib.path) for lib in static_libs] + - ["save", "end"], - ) + "\n" - - mri_script = ctx.actions.declare_file(ctx.label.name + "_mri") - ctx.actions.write(mri_script, mri_script_content) - ar = toolchain.ar_executable if ar.find("libtool") >= 0: @@ -83,11 +74,31 @@ def _fat_cc_library_impl(ctx): [f.path for f in static_libs], ) else: + # Avoid ar MRI mode (-M) because it treats '~' as a line + # continuation character, which breaks with bzlmod repo paths + # that contain '~' (e.g. _main~ext~repo). Instead, extract + # object files from each input archive and re-pack them. + extract_cmds = ["set -e", "D=$(mktemp -d)"] + for i, lib in enumerate(static_libs): + extract_cmds.append( + "mkdir \"$D/{idx}\" && (cd \"$D/{idx}\" && \"{ar}\" x \"$OLDPWD/{path}\")".format( + idx = i, + ar = ar, + path = lib.path, + ), + ) + extract_cmds.append( + "\"{ar}\" crs \"{out}\" \"$D\"/*/*.o \"$D\"/*/*.obj 2>/dev/null || \"{ar}\" crs \"{out}\" \"$D\"/*/*.o".format( + ar = ar, + out = static_lib.path, + ), + ) + extract_cmds.append("rm -rf \"$D\"") ctx.actions.run_shell( mnemonic = "CppLinkFatStaticLib", outputs = [static_lib], - inputs = [mri_script] + static_libs, - command = "{ar} -M < {mri_script}".format(ar = ar, mri_script = mri_script.path), + inputs = static_libs, + command = "\n".join(extract_cmds), ) fat_lib = cc_common.create_library_to_link( From d3e1fe9ff135fcb51f932ef134edc758a52287d9 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 13 Apr 2026 21:31:27 +0200 Subject: [PATCH 102/287] feat: Add ghc_pkg (to replace ghc_nix) --- sdk/MODULE.bazel | 8 ++++ sdk/compiler/damlc/BUILD.bazel | 9 ++--- .../damlc/lib/DA/Cli/Damlc/Packaging.hs | 28 +++++++------- sdk/compiler/damlc/util.bzl | 38 +++++++++++++++---- 4 files changed, 56 insertions(+), 27 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 7829b9c4fe3c..ae943a8d4e9e 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -40,6 +40,14 @@ haskell_toolchains_ext = use_extension( "haskell_toolchains", ) haskell_toolchains_ext.bindists(version = "9.0.2") +use_repo( + haskell_toolchains_ext, + "rules_haskell_ghc_darwin_amd64", + "rules_haskell_ghc_darwin_arm64", + "rules_haskell_ghc_linux_amd64", + "rules_haskell_ghc_linux_arm64", + "rules_haskell_ghc_windows_amd64", +) da_ghc_ext = use_extension("//bazel/extensions:da_ghc_extension.bzl", "da_ghc") use_repo(da_ghc_ext, "da-ghc", "ghc-lib-gen") diff --git a/sdk/compiler/damlc/BUILD.bazel b/sdk/compiler/damlc/BUILD.bazel index 36fad83e642e..184121669adf 100644 --- a/sdk/compiler/damlc/BUILD.bazel +++ b/sdk/compiler/damlc/BUILD.bazel @@ -160,14 +160,11 @@ package_oci_component( visibility = ["//visibility:public"], ) -# ghc-pkg is linked dynamically on Linux by default so we need to run it through package_app -# before we distribute it. +# ghc-pkg is linked dynamically on Linux by default so we need to run it +# through package_app before we distribute it. package_app( name = "ghc-pkg-dist", - # bin/ghc-pkg is actually a wrapper script on Unix systems so it is - # important that we use lib/ghc-$VERSION/bin/ghc-pkg instead which is the - # actual executable. - binary = "@ghc_nix//:lib/ghc-9.0.2/bin/ghc-pkg", + binary = ghc_pkg, visibility = ["//visibility:public"], ) if not is_windows else genrule( name = "ghc-pkg-dist", diff --git a/sdk/compiler/damlc/lib/DA/Cli/Damlc/Packaging.hs b/sdk/compiler/damlc/lib/DA/Cli/Damlc/Packaging.hs index 3f07caa348af..128a3d80b888 100644 --- a/sdk/compiler/damlc/lib/DA/Cli/Damlc/Packaging.hs +++ b/sdk/compiler/damlc/lib/DA/Cli/Damlc/Packaging.hs @@ -48,6 +48,7 @@ import System.Exit import System.FileLock import System.FilePath import System.IO.Extra (hFlush, hPutStrLn, stderr, writeFileUTF8) +import System.Info (arch) import System.Info.Extra import System.Process (callProcess) import "ghc-lib-parser" UniqSet @@ -561,27 +562,28 @@ writeSrc (fp, content) = do createDirectoryIfMissing True $ takeDirectory path writeFileUTF8 path content --- | Locate ghc-pkg +-- | Locate ghc-pkg from the GHC bindist matching the current platform. +-- See @compiler/damlc/util.bzl@ for the corresponding Bazel-side label. getGhcPkgExe :: IO FilePath getGhcPkgExe = locateResource Resource { resourcesPath = exe "ghc-pkg" - -- //compiler/damlc:ghc-pkg-dist - -- In a packaged application, the executable is stored directly underneath - -- the resources directory because the target produces a tarball which has - -- the executable directly under the top directory. - -- See @bazel_tools/packaging/packaging.bzl@. , runfilesPathPrefix = - -- when running as a bazel target, the executable has the same name - -- but comes from the a different target depending on the OS, so the - -- prefix used changes. - -- see @compiler/damlc/util.bzl@ if isWindows then - -- @rules_haskell_ghc_windows_amd64//:bin/ghc-pkg.exe "rules_haskell_ghc_windows_amd64" "bin" else - -- @ghc_nix//:lib/ghc-9.0.2/bin/ghc-pkg - "ghc_nix" "lib" "ghc-9.0.2" "bin" + ghcBindistRepo ghcPkgSubpath } + where + ghcBindistRepo + | isLinux && arch == "x86_64" = "rules_haskell_ghc_linux_amd64" + | isLinux && arch == "aarch64" = "rules_haskell_ghc_linux_arm64" + | isMac && arch == "aarch64" = "rules_haskell_ghc_darwin_arm64" + | isMac = "rules_haskell_ghc_darwin_amd64" + | otherwise = error $ "Unsupported platform for ghc-pkg: " ++ show (os, arch) + ghcPkgSubpath + | isLinux = "lib" "bin" + | isMac = "lib" "lib" "bin" + | otherwise = error "unreachable" -- | Fail with an exit failure and errror message when Nothing is returned. mbErr :: String -> Maybe a -> IO a diff --git a/sdk/compiler/damlc/util.bzl b/sdk/compiler/damlc/util.bzl index 658cf847a043..e5a6bf9b8456 100644 --- a/sdk/compiler/damlc/util.bzl +++ b/sdk/compiler/damlc/util.bzl @@ -1,11 +1,33 @@ # Copyright (c) 2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -load("@os_info//:os_info.bzl", "is_windows") - -# This is a gross hack: ghc-pkg is linked dynamically so to distribute -# it we have to throw it at package_app. However, the result of that -# is a tarball so if we try to add that to resources `bazel run` is -# not going to work. We thus use the dynamically linked executable in the runfiles of damlc -# and the tarball produced by package_app in the resources of damlc-dist. -ghc_pkg = "@rules_haskell_ghc_windows_amd64//:bin/ghc-pkg.exe" if is_windows else "@ghc_nix//:lib/ghc-9.0.2/bin/ghc-pkg" +load("@os_info//:os_info.bzl", "is_darwin", "is_darwin_arm64", "is_linux_arm", "is_linux_intel", "is_windows") + +# ghc-pkg is linked dynamically so to distribute it we have to throw it at +# package_app. However, the result of that is a tarball so if we try to add +# that to resources `bazel run` is not going to work. We thus use the +# dynamically linked executable in the runfiles of damlc and the tarball +# produced by package_app in the resources of damlc-dist. +# +# On Unix the real binary lives under lib/, not bin/ (bin/ghc-pkg is a wrapper +# script). The libdir differs between Linux and macOS: +# Linux: lib/bin/ghc-pkg (libdir = lib) +# macOS: lib/lib/bin/ghc-pkg (libdir = lib/lib) +_GHC_PKG_LINUX = "lib/bin/ghc-pkg" +_GHC_PKG_DARWIN = "lib/lib/bin/ghc-pkg" + +def _ghc_pkg_label(): + if is_windows: + return "@rules_haskell_ghc_windows_amd64//:bin/ghc-pkg.exe" + elif is_linux_intel: + return "@rules_haskell_ghc_linux_amd64//:" + _GHC_PKG_LINUX + elif is_linux_arm: + return "@rules_haskell_ghc_linux_arm64//:" + _GHC_PKG_LINUX + elif is_darwin_arm64: + return "@rules_haskell_ghc_darwin_arm64//:" + _GHC_PKG_DARWIN + elif is_darwin: + return "@rules_haskell_ghc_darwin_amd64//:" + _GHC_PKG_DARWIN + else: + fail("Unsupported platform for ghc-pkg") + +ghc_pkg = _ghc_pkg_label() From 8f9df7c8adb817bbfa08caa4fd56d259350f3954 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Mon, 13 Apr 2026 22:12:56 +0200 Subject: [PATCH 103/287] feat: "Migrate" scalapb to module --- sdk/MODULE.bazel | 17 +- .../extensions/remote_apis_extension.bzl | 19 + sdk/bazel/extensions/scalapb_extension.bzl | 27 ++ .../patches/remote_apis_build_files.patch | 114 ++++++ .../patches/remote_apis_no_services.patch | 374 ++++++++++++++++++ sdk/bazel_tools/proto.bzl | 2 +- sdk/canton/BUILD.bazel | 2 +- 7 files changed, 549 insertions(+), 6 deletions(-) create mode 100644 sdk/bazel/extensions/remote_apis_extension.bzl create mode 100644 sdk/bazel/extensions/scalapb_extension.bzl create mode 100644 sdk/bazel/patches/remote_apis_build_files.patch create mode 100644 sdk/bazel/patches/remote_apis_no_services.patch diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index ae943a8d4e9e..8c6e5fd5ffd2 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -533,17 +533,26 @@ use_repo(import_googleapis_ext, "com_google_googleapis_imports") proto3_suite_ext = use_extension("//bazel/extensions:proto3_suite_extension.bzl", "proto3_suite_extension") use_repo(proto3_suite_ext, "proto3-suite") +scalapb_ext = use_extension("//bazel/extensions:scalapb_extension.bzl", "scalapb_extension") +use_repo(scalapb_ext, "scalapb") + +remote_apis_ext = use_extension("//bazel/extensions:remote_apis_extension.bzl", "remote_apis_extension") +use_repo(remote_apis_ext, "com_github_bazelbuild_remote_apis") + +# Prebuilt protoc 25.5 for Java/Scala codegen (proto_gen rule). +# Must stay aligned with Maven's protobuf-java version (currently 3.25.5). +# The BCR protobuf module resolves to 32.x via MVS, whose protoc would generate +# stubs incompatible with protobuf-java 3.x, so we use this pinned binary instead. +protoc_ext = use_extension("//bazel/extensions:protoc_extension.bzl", "protoc_extension") +use_repo(protoc_ext, "protoc_bindist") + # --- Deprecated (pending removal) --- # io_grpc_grpc_java: legacy gRPC Java codegen; to be replaced by rules_proto + protobuf bazel_dep. -# protoc_bindist: legacy protoc binary distribution; to be replaced by the protobuf bazel_dep toolchain. # TODO: Remove once all targets have migrated to the new protobuf/gRPC setup. io_grpc_grpc_java_ext = use_extension("//bazel/extensions:io_grpc_grpc_java_extension.bzl", "io_grpc_grpc_java_extension") use_repo(io_grpc_grpc_java_ext, "io_grpc_grpc_java") -protoc_ext = use_extension("//bazel/extensions:protoc_extension.bzl", "protoc_extension") -use_repo(protoc_ext, "protoc_bindist") - # --- Native libraries --- ncurses_ext = use_extension("//bazel/extensions:ncurses_extension.bzl", "ncurses") diff --git a/sdk/bazel/extensions/remote_apis_extension.bzl b/sdk/bazel/extensions/remote_apis_extension.bzl new file mode 100644 index 000000000000..d9642af5a1fc --- /dev/null +++ b/sdk/bazel/extensions/remote_apis_extension.bzl @@ -0,0 +1,19 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +_VERSION = "2.0.0" +_SHA256 = "79204ed1fa385c03b5235f65b25ced6ac51cf4b00e45e1157beca6a28bdb8043" + +def _impl(module_ctx): + http_archive( + name = "com_github_bazelbuild_remote_apis", + strip_prefix = "remote-apis-{}".format(_VERSION), + urls = ["https://github.com/bazelbuild/remote-apis/archive/v{}.tar.gz".format(_VERSION)], + sha256 = _SHA256, + patches = [ + "//bazel/patches:remote_apis_no_services.patch", + "//bazel/patches:remote_apis_build_files.patch", + ], + patch_args = ["-p1"], + ) + +remote_apis_extension = module_extension(implementation = _impl) diff --git a/sdk/bazel/extensions/scalapb_extension.bzl b/sdk/bazel/extensions/scalapb_extension.bzl new file mode 100644 index 000000000000..57d1cbcee24b --- /dev/null +++ b/sdk/bazel/extensions/scalapb_extension.bzl @@ -0,0 +1,27 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load( + "//bazel_tools:scalapb.bzl", + "scalapb_sha256", + "scalapb_version", +) + +def _impl(module_ctx): + http_archive( + name = "scalapb", + build_file_content = """\ +proto_library( + name = "scalapb_proto", + srcs = ["protobuf/scalapb/scalapb.proto"], + strip_import_prefix = "protobuf/", + deps = [ + "@protobuf//:descriptor_proto", + ], + visibility = ["//visibility:public"], +) +""", + sha256 = scalapb_sha256, + strip_prefix = "ScalaPB-{}".format(scalapb_version), + urls = ["https://github.com/scalapb/ScalaPB/archive/refs/tags/v{}.tar.gz".format(scalapb_version)], + ) + +scalapb_extension = module_extension(implementation = _impl) diff --git a/sdk/bazel/patches/remote_apis_build_files.patch b/sdk/bazel/patches/remote_apis_build_files.patch new file mode 100644 index 000000000000..3ce09a7ac11d --- /dev/null +++ b/sdk/bazel/patches/remote_apis_build_files.patch @@ -0,0 +1,114 @@ +Replace BUILD files to remove dependency on @bazel_remote_apis_imports. +We only need the proto files, not language-specific codegen targets. +diff --git a/build/bazel/remote/execution/v2/BUILD b/build/bazel/remote/execution/v2/BUILD +index 1111111..2222222 100644 +--- a/build/bazel/remote/execution/v2/BUILD ++++ b/build/bazel/remote/execution/v2/BUILD +@@ -1,59 +1,3 @@ +-package(default_visibility = ["//visibility:public"]) +- +-load("@rules_proto//proto:defs.bzl", "proto_library") +-load("@bazel_remote_apis_imports//:imports.bzl", "java_proto_library", "go_library", "go_proto_library", "cc_grpc_library") +- +-licenses(["notice"]) +- +-proto_library( +- name = "remote_execution_proto", +- srcs = ["remote_execution.proto"], +- deps = [ +- "//build/bazel/semver:semver_proto", +- "@com_google_protobuf//:duration_proto", +- "@com_google_protobuf//:timestamp_proto", +- "@googleapis//:google_api_annotations_proto", +- "@googleapis//:google_api_http_proto", +- "@googleapis//:google_longrunning_operations_proto", +- "@googleapis//:google_rpc_status_proto", +- ], +-) +- +-java_proto_library( +- name = "remote_execution_java_proto", +- deps = [":remote_execution_proto"], +-) +- +-cc_grpc_library( +- name = "remote_execution_cc_proto", +- srcs = ["remote_execution.proto"], +- proto_only = False, +- use_external = False, +- well_known_protos = True, +- deps = [ +- "//build/bazel/semver:semver_cc_proto", +- "@googleapis//:google_api_annotations_cc_proto", +- "@googleapis//:google_api_http_cc_proto", +- "@googleapis//:google_longrunning_operations_cc_proto", +- "@googleapis//:google_rpc_status_cc_proto", +- ], +-) +- +-go_proto_library( +- name = "remote_execution_go_proto", +- compilers = ["@io_bazel_rules_go//proto:go_grpc"], +- importpath = "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2", +- proto = ":remote_execution_proto", +- deps = [ +- "//build/bazel/semver:go_default_library", +- "@go_googleapis//google/api:annotations_go_proto", +- "@go_googleapis//google/longrunning:longrunning_go_proto", +- "@go_googleapis//google/rpc:status_go_proto", +- ], +-) +- +-go_library( +- name = "go_default_library", +- embed = [":remote_execution_go_proto"], +- importpath = "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2", +-) ++exports_files(["remote_execution.proto"]) ++ ++licenses(["notice"]) +diff --git a/build/bazel/semver/BUILD b/build/bazel/semver/BUILD +index 3333333..4444444 100644 +--- a/build/bazel/semver/BUILD ++++ b/build/bazel/semver/BUILD +@@ -1,37 +1,3 @@ +-package(default_visibility = ["//visibility:public"]) +- +-load("@rules_proto//proto:defs.bzl", "proto_library") +-load("@bazel_remote_apis_imports//:imports.bzl", "java_proto_library", "go_library", "go_proto_library", "cc_grpc_library") +- +-licenses(["notice"]) +- +-proto_library( +- name = "semver_proto", +- srcs = ["semver.proto"], +-) +- +-java_proto_library( +- name = "semver_java_proto", +- deps = [":semver_proto"], +-) +- +-cc_grpc_library( +- name = "semver_cc_proto", +- srcs = ["semver.proto"], +- proto_only = False, +- use_external = False, +- well_known_protos = True, +- deps = [], +-) +- +-go_proto_library( +- name = "semver_go_proto", +- importpath = "github.com/bazelbuild/remote-apis/build/bazel/semver", +- proto = ":semver_proto", +-) +- +-go_library( +- name = "go_default_library", +- embed = [":semver_go_proto"], +- importpath = "github.com/bazelbuild/remote-apis/build/bazel/semver", +-) ++exports_files(["semver.proto"]) ++ ++licenses(["notice"]) diff --git a/sdk/bazel/patches/remote_apis_no_services.patch b/sdk/bazel/patches/remote_apis_no_services.patch new file mode 100644 index 000000000000..f1e10e40277e --- /dev/null +++ b/sdk/bazel/patches/remote_apis_no_services.patch @@ -0,0 +1,374 @@ +We only need the protobuf message for ActionResult. +To reduce dependencies, we patch out other things +that would pull in extra dependencies or fail to parse +in proto3-suite. +diff --git a/build/bazel/remote/execution/v2/remote_execution.proto b/build/bazel/remote/execution/v2/remote_execution.proto +index 052c222..c988be5 100644 +--- a/build/bazel/remote/execution/v2/remote_execution.proto ++++ b/build/bazel/remote/execution/v2/remote_execution.proto +@@ -16,9 +16,6 @@ syntax = "proto3"; + + package build.bazel.remote.execution.v2; + +-import "build/bazel/semver/semver.proto"; +-import "google/api/annotations.proto"; +-import "google/longrunning/operations.proto"; + import "google/protobuf/duration.proto"; + import "google/protobuf/timestamp.proto"; + import "google/rpc/status.proto"; +@@ -30,329 +27,6 @@ option java_outer_classname = "RemoteExecutionProto"; + option java_package = "build.bazel.remote.execution.v2"; + option objc_class_prefix = "REX"; + +- +-// The Remote Execution API is used to execute an +-// [Action][build.bazel.remote.execution.v2.Action] on the remote +-// workers. +-// +-// As with other services in the Remote Execution API, any call may return an +-// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing +-// information about when the client should retry the request; clients SHOULD +-// respect the information provided. +-service Execution { +- // Execute an action remotely. +- // +- // In order to execute an action, the client must first upload all of the +- // inputs, the +- // [Command][build.bazel.remote.execution.v2.Command] to run, and the +- // [Action][build.bazel.remote.execution.v2.Action] into the +- // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. +- // It then calls `Execute` with an `action_digest` referring to them. The +- // server will run the action and eventually return the result. +- // +- // The input `Action`'s fields MUST meet the various canonicalization +- // requirements specified in the documentation for their types so that it has +- // the same digest as other logically equivalent `Action`s. The server MAY +- // enforce the requirements and return errors if a non-canonical input is +- // received. It MAY also proceed without verifying some or all of the +- // requirements, such as for performance reasons. If the server does not +- // verify the requirement, then it will treat the `Action` as distinct from +- // another logically equivalent action if they hash differently. +- // +- // Returns a stream of +- // [google.longrunning.Operation][google.longrunning.Operation] messages +- // describing the resulting execution, with eventual `response` +- // [ExecuteResponse][build.bazel.remote.execution.v2.ExecuteResponse]. The +- // `metadata` on the operation is of type +- // [ExecuteOperationMetadata][build.bazel.remote.execution.v2.ExecuteOperationMetadata]. +- // +- // If the client remains connected after the first response is returned after +- // the server, then updates are streamed as if the client had called +- // [WaitExecution][build.bazel.remote.execution.v2.Execution.WaitExecution] +- // until the execution completes or the request reaches an error. The +- // operation can also be queried using [Operations +- // API][google.longrunning.Operations.GetOperation]. +- // +- // The server NEED NOT implement other methods or functionality of the +- // Operations API. +- // +- // Errors discovered during creation of the `Operation` will be reported +- // as gRPC Status errors, while errors that occurred while running the +- // action will be reported in the `status` field of the `ExecuteResponse`. The +- // server MUST NOT set the `error` field of the `Operation` proto. +- // The possible errors include: +- // +- // * `INVALID_ARGUMENT`: One or more arguments are invalid. +- // * `FAILED_PRECONDITION`: One or more errors occurred in setting up the +- // action requested, such as a missing input or command or no worker being +- // available. The client may be able to fix the errors and retry. +- // * `RESOURCE_EXHAUSTED`: There is insufficient quota of some resource to run +- // the action. +- // * `UNAVAILABLE`: Due to a transient condition, such as all workers being +- // occupied (and the server does not support a queue), the action could not +- // be started. The client should retry. +- // * `INTERNAL`: An internal error occurred in the execution engine or the +- // worker. +- // * `DEADLINE_EXCEEDED`: The execution timed out. +- // * `CANCELLED`: The operation was cancelled by the client. This status is +- // only possible if the server implements the Operations API CancelOperation +- // method, and it was called for the current execution. +- // +- // In the case of a missing input or command, the server SHOULD additionally +- // send a [PreconditionFailure][google.rpc.PreconditionFailure] error detail +- // where, for each requested blob not present in the CAS, there is a +- // `Violation` with a `type` of `MISSING` and a `subject` of +- // `"blobs/{hash}/{size}"` indicating the digest of the missing blob. +- rpc Execute(ExecuteRequest) returns (stream google.longrunning.Operation) { +- option (google.api.http) = { post: "/v2/{instance_name=**}/actions:execute" body: "*" }; +- } +- +- // Wait for an execution operation to complete. When the client initially +- // makes the request, the server immediately responds with the current status +- // of the execution. The server will leave the request stream open until the +- // operation completes, and then respond with the completed operation. The +- // server MAY choose to stream additional updates as execution progresses, +- // such as to provide an update as to the state of the execution. +- rpc WaitExecution(WaitExecutionRequest) returns (stream google.longrunning.Operation) { +- option (google.api.http) = { post: "/v2/{name=operations/**}:waitExecution" body: "*" }; +- } +-} +- +-// The action cache API is used to query whether a given action has already been +-// performed and, if so, retrieve its result. Unlike the +-// [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage], +-// which addresses blobs by their own content, the action cache addresses the +-// [ActionResult][build.bazel.remote.execution.v2.ActionResult] by a +-// digest of the encoded [Action][build.bazel.remote.execution.v2.Action] +-// which produced them. +-// +-// The lifetime of entries in the action cache is implementation-specific, but +-// the server SHOULD assume that more recently used entries are more likely to +-// be used again. +-// +-// As with other services in the Remote Execution API, any call may return an +-// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing +-// information about when the client should retry the request; clients SHOULD +-// respect the information provided. +-service ActionCache { +- // Retrieve a cached execution result. +- // +- // Implementations SHOULD ensure that any blobs referenced from the +- // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage] +- // are available at the time of returning the +- // [ActionResult][build.bazel.remote.execution.v2.ActionResult] and will be +- // for some period of time afterwards. The TTLs of the referenced blobs SHOULD be increased +- // if necessary and applicable. +- // +- // Errors: +- // +- // * `NOT_FOUND`: The requested `ActionResult` is not in the cache. +- rpc GetActionResult(GetActionResultRequest) returns (ActionResult) { +- option (google.api.http) = { get: "/v2/{instance_name=**}/actionResults/{action_digest.hash}/{action_digest.size_bytes}" }; +- } +- +- // Upload a new execution result. +- // +- // In order to allow the server to perform access control based on the type of +- // action, and to assist with client debugging, the client MUST first upload +- // the [Action][build.bazel.remote.execution.v2.Execution] that produced the +- // result, along with its +- // [Command][build.bazel.remote.execution.v2.Command], into the +- // `ContentAddressableStorage`. +- // +- // Errors: +- // +- // * `INVALID_ARGUMENT`: One or more arguments are invalid. +- // * `FAILED_PRECONDITION`: One or more errors occurred in updating the +- // action result, such as a missing command or action. +- // * `RESOURCE_EXHAUSTED`: There is insufficient storage space to add the +- // entry to the cache. +- rpc UpdateActionResult(UpdateActionResultRequest) returns (ActionResult) { +- option (google.api.http) = { put: "/v2/{instance_name=**}/actionResults/{action_digest.hash}/{action_digest.size_bytes}" body: "action_result" }; +- } +-} +- +-// The CAS (content-addressable storage) is used to store the inputs to and +-// outputs from the execution service. Each piece of content is addressed by the +-// digest of its binary data. +-// +-// Most of the binary data stored in the CAS is opaque to the execution engine, +-// and is only used as a communication medium. In order to build an +-// [Action][build.bazel.remote.execution.v2.Action], +-// however, the client will need to also upload the +-// [Command][build.bazel.remote.execution.v2.Command] and input root +-// [Directory][build.bazel.remote.execution.v2.Directory] for the Action. +-// The Command and Directory messages must be marshalled to wire format and then +-// uploaded under the hash as with any other piece of content. In practice, the +-// input root directory is likely to refer to other Directories in its +-// hierarchy, which must also each be uploaded on their own. +-// +-// For small file uploads the client should group them together and call +-// [BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs]. +-// For large uploads, the client must use the +-// [Write method][google.bytestream.ByteStream.Write] of the ByteStream API. The +-// `resource_name` is `{instance_name}/uploads/{uuid}/blobs/{hash}/{size}`, +-// where `instance_name` is as described in the next paragraph, `uuid` is a +-// version 4 UUID generated by the client, and `hash` and `size` are the +-// [Digest][build.bazel.remote.execution.v2.Digest] of the blob. The +-// `uuid` is used only to avoid collisions when multiple clients try to upload +-// the same file (or the same client tries to upload the file multiple times at +-// once on different threads), so the client MAY reuse the `uuid` for uploading +-// different blobs. The `resource_name` may optionally have a trailing filename +-// (or other metadata) for a client to use if it is storing URLs, as in +-// `{instance}/uploads/{uuid}/blobs/{hash}/{size}/foo/bar/baz.cc`. Anything +-// after the `size` is ignored. +-// +-// A single server MAY support multiple instances of the execution system, each +-// with their own workers, storage, cache, etc. The exact relationship between +-// instances is up to the server. If the server does, then the `instance_name` +-// is an identifier, possibly containing multiple path segments, used to +-// distinguish between the various instances on the server, in a manner defined +-// by the server. For servers which do not support multiple instances, then the +-// `instance_name` is the empty path and the leading slash is omitted, so that +-// the `resource_name` becomes `uploads/{uuid}/blobs/{hash}/{size}`. +-// To simplify parsing, a path segment cannot equal any of the following +-// keywords: `blobs`, `uploads`, `actions`, `actionResults`, `operations` and +-// `capabilities`. +-// +-// When attempting an upload, if another client has already completed the upload +-// (which may occur in the middle of a single upload if another client uploads +-// the same blob concurrently), the request will terminate immediately with +-// a response whose `committed_size` is the full size of the uploaded file +-// (regardless of how much data was transmitted by the client). If the client +-// completes the upload but the +-// [Digest][build.bazel.remote.execution.v2.Digest] does not match, an +-// `INVALID_ARGUMENT` error will be returned. In either case, the client should +-// not attempt to retry the upload. +-// +-// For downloading blobs, the client must use the +-// [Read method][google.bytestream.ByteStream.Read] of the ByteStream API, with +-// a `resource_name` of `"{instance_name}/blobs/{hash}/{size}"`, where +-// `instance_name` is the instance name (see above), and `hash` and `size` are +-// the [Digest][build.bazel.remote.execution.v2.Digest] of the blob. +-// +-// The lifetime of entries in the CAS is implementation specific, but it SHOULD +-// be long enough to allow for newly-added and recently looked-up entries to be +-// used in subsequent calls (e.g. to +-// [Execute][build.bazel.remote.execution.v2.Execution.Execute]). +-// +-// As with other services in the Remote Execution API, any call may return an +-// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing +-// information about when the client should retry the request; clients SHOULD +-// respect the information provided. +-service ContentAddressableStorage { +- // Determine if blobs are present in the CAS. +- // +- // Clients can use this API before uploading blobs to determine which ones are +- // already present in the CAS and do not need to be uploaded again. +- // +- // There are no method-specific errors. +- rpc FindMissingBlobs(FindMissingBlobsRequest) returns (FindMissingBlobsResponse) { +- option (google.api.http) = { post: "/v2/{instance_name=**}/blobs:findMissing" body: "*" }; +- } +- +- // Upload many blobs at once. +- // +- // The server may enforce a limit of the combined total size of blobs +- // to be uploaded using this API. This limit may be obtained using the +- // [Capabilities][build.bazel.remote.execution.v2.Capabilities] API. +- // Requests exceeding the limit should either be split into smaller +- // chunks or uploaded using the +- // [ByteStream API][google.bytestream.ByteStream], as appropriate. +- // +- // This request is equivalent to calling a Bytestream `Write` request +- // on each individual blob, in parallel. The requests may succeed or fail +- // independently. +- // +- // Errors: +- // +- // * `INVALID_ARGUMENT`: The client attempted to upload more than the +- // server supported limit. +- // +- // Individual requests may return the following errors, additionally: +- // +- // * `RESOURCE_EXHAUSTED`: There is insufficient disk quota to store the blob. +- // * `INVALID_ARGUMENT`: The +- // [Digest][build.bazel.remote.execution.v2.Digest] does not match the +- // provided data. +- rpc BatchUpdateBlobs(BatchUpdateBlobsRequest) returns (BatchUpdateBlobsResponse) { +- option (google.api.http) = { post: "/v2/{instance_name=**}/blobs:batchUpdate" body: "*" }; +- } +- +- // Download many blobs at once. +- // +- // The server may enforce a limit of the combined total size of blobs +- // to be downloaded using this API. This limit may be obtained using the +- // [Capabilities][build.bazel.remote.execution.v2.Capabilities] API. +- // Requests exceeding the limit should either be split into smaller +- // chunks or downloaded using the +- // [ByteStream API][google.bytestream.ByteStream], as appropriate. +- // +- // This request is equivalent to calling a Bytestream `Read` request +- // on each individual blob, in parallel. The requests may succeed or fail +- // independently. +- // +- // Errors: +- // +- // * `INVALID_ARGUMENT`: The client attempted to read more than the +- // server supported limit. +- // +- // Every error on individual read will be returned in the corresponding digest +- // status. +- rpc BatchReadBlobs(BatchReadBlobsRequest) returns (BatchReadBlobsResponse) { +- option (google.api.http) = { post: "/v2/{instance_name=**}/blobs:batchRead" body: "*" }; +- } +- +- // Fetch the entire directory tree rooted at a node. +- // +- // This request must be targeted at a +- // [Directory][build.bazel.remote.execution.v2.Directory] stored in the +- // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage] +- // (CAS). The server will enumerate the `Directory` tree recursively and +- // return every node descended from the root. +- // +- // The GetTreeRequest.page_token parameter can be used to skip ahead in +- // the stream (e.g. when retrying a partially completed and aborted request), +- // by setting it to a value taken from GetTreeResponse.next_page_token of the +- // last successfully processed GetTreeResponse). +- // +- // The exact traversal order is unspecified and, unless retrieving subsequent +- // pages from an earlier request, is not guaranteed to be stable across +- // multiple invocations of `GetTree`. +- // +- // If part of the tree is missing from the CAS, the server will return the +- // portion present and omit the rest. +- // +- // Errors: +- // +- // * `NOT_FOUND`: The requested tree root is not present in the CAS. +- rpc GetTree(GetTreeRequest) returns (stream GetTreeResponse) { +- option (google.api.http) = { get: "/v2/{instance_name=**}/blobs/{root_digest.hash}/{root_digest.size_bytes}:getTree" }; +- } +-} +- +-// The Capabilities service may be used by remote execution clients to query +-// various server properties, in order to self-configure or return meaningful +-// error messages. +-// +-// The query may include a particular `instance_name`, in which case the values +-// returned will pertain to that instance. +-service Capabilities { +- // GetCapabilities returns the server capabilities configuration of the +- // remote endpoint. +- // Only the capabilities of the services supported by the endpoint will +- // be returned: +- // * Execution + CAS + Action Cache endpoints should return both +- // CacheCapabilities and ExecutionCapabilities. +- // * Execution only endpoints should return ExecutionCapabilities. +- // * CAS + Action Cache only endpoints should return CacheCapabilities. +- rpc GetCapabilities(GetCapabilitiesRequest) returns (ServerCapabilities) { +- option (google.api.http) = { +- get: "/v2/{instance_name=**}/capabilities" +- }; +- } +-} +- + // An `Action` captures all the information about an execution which is required + // to reproduce it. + // +@@ -1383,25 +1057,6 @@ message GetCapabilitiesRequest { + string instance_name = 1; + } + +-// A response message for +-// [Capabilities.GetCapabilities][build.bazel.remote.execution.v2.Capabilities.GetCapabilities]. +-message ServerCapabilities { +- // Capabilities of the remote cache system. +- CacheCapabilities cache_capabilities = 1; +- +- // Capabilities of the remote execution system. +- ExecutionCapabilities execution_capabilities = 2; +- +- // Earliest RE API version supported, including deprecated versions. +- build.bazel.semver.SemVer deprecated_api_version = 3; +- +- // Earliest non-deprecated RE API version supported. +- build.bazel.semver.SemVer low_api_version = 4; +- +- // Latest RE API version supported. +- build.bazel.semver.SemVer high_api_version = 5; +-} +- + // The digest function used for converting values into keys for CAS and Action + // Cache. + message DigestFunction { diff --git a/sdk/bazel_tools/proto.bzl b/sdk/bazel_tools/proto.bzl index b817bf40f85b..15d3201ab460 100644 --- a/sdk/bazel_tools/proto.bzl +++ b/sdk/bazel_tools/proto.bzl @@ -140,7 +140,7 @@ proto_gen = rule( allow_files = True, ), "protoc": attr.label( - default = Label("@protobuf//:protoc"), + default = Label("@protoc_bindist//:protoc"), cfg = "host", allow_files = True, executable = True, diff --git a/sdk/canton/BUILD.bazel b/sdk/canton/BUILD.bazel index b5c13aacd732..c5e99baba98c 100644 --- a/sdk/canton/BUILD.bazel +++ b/sdk/canton/BUILD.bazel @@ -3,7 +3,7 @@ load("@bazel_skylib//rules:copy_file.bzl", "copy_file") load("@rules_scala//scala:scala.bzl", "scala_binary") -load("//bazel_tools:proto.bzl", "proto_gen", "proto_jars") +load("//bazel_tools:proto.bzl", "proto_gen") load("//bazel_tools/packaging:packaging.bzl", "package_oci_component") load("//canton:canton_jar.bzl", "canton_jar") From d4264fa17c67f4c77ab1269f64c183facacc1018 Mon Sep 17 00:00:00 2001 From: wojciechormaniec-da Date: Tue, 14 Apr 2026 12:01:22 +0200 Subject: [PATCH 104/287] tmp: save state for future reference --- sdk/MODULE.bazel | 104 ++++++++++++++++++ .../io_grpc_grpc_java_extension.bzl | 24 ++++ .../grpc-haskell-core-grpc-compat.patch | 5 +- sdk/bazel_tools/fat_cc_library.bzl | 18 ++- .../damlc/lib/DA/Cli/Damlc/Packaging.hs | 2 +- 5 files changed, 147 insertions(+), 6 deletions(-) diff --git a/sdk/MODULE.bazel b/sdk/MODULE.bazel index 8c6e5fd5ffd2..1f93d6c04e1c 100644 --- a/sdk/MODULE.bazel +++ b/sdk/MODULE.bazel @@ -32,6 +32,7 @@ bazel_lib_toolchains_ext = use_extension("@tar.bzl//tar:extensions.bzl", "toolch use_repo(bazel_lib_toolchains_ext, "bsd_tar_toolchains") register_toolchains("@bsd_tar_toolchains//:all") +register_toolchains("//:c2hs-toolchain") # --- Haskell toolchain and extensions --- @@ -163,6 +164,7 @@ HASKELL_PACKAGES = [ "conduit", "conduit-extra", "cryptonite", + "exceptions", "http-client", "http-client-tls", "http-conduit", @@ -171,9 +173,11 @@ HASKELL_PACKAGES = [ "memory", "network", "network-uri", + "open-browser", "tar-conduit", "tls", "uri-encode", + "uuid", # Filesystem & archives "file-embed", @@ -254,6 +258,10 @@ stack_snapshot_ext.package( name = "grpc-haskell", vendored = "@grpc_haskell//:grpc-haskell", ) +stack_snapshot_ext.package( + name = "c2hs", + components = ["exe"], +) stack_snapshot_ext.package( name = "happy", components = ["exe"], @@ -403,6 +411,33 @@ maven_ext.install( "io.grpc:grpc-protobuf:" + GRPC_JAVA_MAVEN_VERSION, "io.grpc:grpc-stub:" + GRPC_JAVA_MAVEN_VERSION, + # IO_GRPC_GRPC_JAVA_ARTIFACTS: artifacts declared by the grpc-java BCR module + # (@@grpc-java~). That module is a transitive dep via googleapis~ → grpc~, and its + # BUILD files reference these via artifact() which resolves against our shared @maven. + # We must therefore declare them here even though we don't use them directly. + # Versions match grpc-java 1.66.0 (IO_GRPC_GRPC_JAVA_ARTIFACTS). + "com.google.android:annotations:4.1.1.4", + "com.google.api.grpc:proto-google-common-protos:2.29.0", + "com.google.auth:google-auth-library-credentials:1.23.0", + "com.google.auth:google-auth-library-oauth2-http:1.23.0", + "com.google.auto.value:auto-value-annotations:1.11.0", + "com.google.auto.value:auto-value:1.11.0", + "com.google.j2objc:j2objc-annotations:3.0.0", + "com.google.re2j:re2j:1.7", + "com.google.truth:truth:1.4.2", + "com.squareup.okhttp:okhttp:2.7.5", + "com.squareup.okio:okio:2.10.0", + "io.netty:netty-codec-socks:4.1.100.Final", + "io.netty:netty-handler-proxy:4.1.100.Final", + "io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.100.Final", + "io.netty:netty-tcnative-boringssl-static:2.0.61.Final", + "io.netty:netty-tcnative-classes:2.0.61.Final", + "io.opencensus:opencensus-api:0.31.0", + "io.opencensus:opencensus-contrib-grpc-metrics:0.31.0", + "io.perfmark:perfmark-api:0.27.0", + "org.apache.tomcat:annotations-api:6.0.53", + "org.codehaus.mojo:animal-sniffer-annotations:1.24", + # build tools "com.oracle.database.jdbc:ojdbc8:" + OJDBC_VERSION, "com.sparkjava:spark-core:" + SPARK_CORE_VERSION, @@ -484,6 +519,7 @@ maven_ext.install( known_contributing_modules = [ "bazel_jar_jar", "bazel_worker_java", + "grpc-java", "protobuf", ], repositories = [ @@ -491,6 +527,74 @@ maven_ext.install( "https://europe-maven.pkg.dev/da-images/public-maven-unstable", ], ) +# Counter-overrides for io.grpc:* coordinates. +# The grpc-java BCR module (@@grpc-java~), which is a transitive dep via +# googleapis~ → grpc~, provides maven.override() calls that redirect all +# io.grpc:* Maven coordinates to its own source-built Bazel targets. +# Those source builds have unresolved dependencies in our setup (e.g. +# @@googleapis~//google/rpc:rpc_java_proto). The root module's overrides +# take precedence, so we redirect each coordinate back to the pre-override +# Maven JAR that rules_jvm_external stores as original_