From 7cef7b9cded82c29a6e715364ff5f45e28e382c5 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 11:25:42 -0700 Subject: [PATCH 01/21] Add MODULE.bazel for bzlmod support Migrate from WORKSPACE-only to bzlmod: - Add MODULE.bazel declaring valdi dependency and sub-module overrides - Bundle third-party patches (rules_swift, rules_kotlin, rules_android_ndk, websocketpp) needed because Valdi's single_version_override entries only apply when Valdi is the root module - Remove --noenable_bzlmod from .bazelrc - Fix per_file_copt patterns for bzlmod compatibility - WORKSPACE kept for backwards compatibility Co-Authored-By: Claude Opus 4.6 --- .bazelrc | 18 +--- .gitignore | 1 + MODULE.bazel | 102 ++++++++++++++++++++ third-party/patches/BUILD.bazel | 1 + third-party/patches/rules_android_ndk.patch | 21 ++++ third-party/patches/rules_kotlin.patch | 12 +++ third-party/patches/rules_swift.patch | 19 ++++ third-party/patches/websocketpp.patch | 17 ++++ 8 files changed, 178 insertions(+), 13 deletions(-) create mode 100644 MODULE.bazel create mode 100644 third-party/patches/BUILD.bazel create mode 100644 third-party/patches/rules_android_ndk.patch create mode 100644 third-party/patches/rules_kotlin.patch create mode 100644 third-party/patches/rules_swift.patch create mode 100644 third-party/patches/websocketpp.patch diff --git a/.bazelrc b/.bazelrc index 329926a..637161b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,6 +1,3 @@ -# No bzlmod yet -common --noenable_bzlmod - common --bes_instance_name=client common --enable_platform_specific_config @@ -57,19 +54,15 @@ build --define=android_incremental_dexing_tool=d8_dexbuilder build --define=android_standalone_dexing_tool=d8_compat_dx build --incremental_dexing -# Disable 3rd party libs warnings -build --per_file_copt=external/com_github_grpc_grpc/.*\$@-Wno-everything -build --per_file_copt=external/snap_protobuf/.*\$@-Wno-everything -build --per_file_copt=external/boringssl/.*\$@-Wno-everything -build --per_file_copt=external/com_github_google_flatbuffers/.*\$@-Wno-everything +# Disable 3rd party libs warnings (bzlmod-compatible patterns) +build --per_file_copt=external/protobuf[^/]*/.*\$@-Wno-everything +build --per_file_copt=external/boringssl[^/]*/.*\$@-Wno-everything +build --per_file_copt=external/grpc[^/]*/.*\$@-Wno-everything +build --per_file_copt=external/flatbuffers[^/]*/.*\$@-Wno-everything # Enable persistent worker for Valdi compilation build --strategy=ValdiCompile=worker -## Disable sandboxing for macs, both laptops and in CI; the performance hit is much too high. -build:macos --spawn_strategy=local -build:linux --sandbox_writable_path=/var/tmp - # Disable disk cache to save disk space build --disk_cache="" @@ -86,6 +79,5 @@ build --flag_alias=valdi_js_engine=@valdi//bzl/valdi:js_engine # Enable web compilation (generates JS outputs from Valdi compiler for web targets) common --define=enable_web=true -build --android_crosstool_top="@snap_client_toolchains//:android_crosstool" # Web build configuration (used by scripts/bazel_web_serve.sh) build:web --build_tag_filters=web diff --git a/.gitignore b/.gitignore index f0fb03c..2b1b47e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.DS_Store bazel-* +MODULE.bazel.lock .cursor/rules/remote # Web playground dev server dependencies diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..ed7e92f --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,102 @@ +module(name = "valdi_widgets", version = "0.1") + +# Valdi release beta-0.0.3 (https://github.com/Snapchat/Valdi/releases) +VALDI_RELEASE_TAG = "beta-0.0.3" + +VALDI_URL = "https://github.com/Snapchat/Valdi/archive/refs/tags/{}.tar.gz".format(VALDI_RELEASE_TAG) + +VALDI_STRIP_PREFIX = "Valdi-{}".format(VALDI_RELEASE_TAG) + +bazel_dep(name = "valdi") +archive_override( + module_name = "valdi", + urls = [VALDI_URL], + strip_prefix = VALDI_STRIP_PREFIX, +) + +bazel_dep(name = "android_macros") +archive_override( + module_name = "android_macros", + urls = [VALDI_URL], + strip_prefix = VALDI_STRIP_PREFIX + "/bzl/macros", +) + +bazel_dep(name = "snap_macros") +archive_override( + module_name = "snap_macros", + urls = [VALDI_URL], + strip_prefix = VALDI_STRIP_PREFIX + "/bzl/valdi/snap_macros", +) + +bazel_dep(name = "snap_client_toolchains") +archive_override( + module_name = "snap_client_toolchains", + urls = [VALDI_URL], + strip_prefix = VALDI_STRIP_PREFIX + "/bzl/toolchains", +) + +bazel_dep(name = "snap_platforms") +archive_override( + module_name = "snap_platforms", + urls = [VALDI_URL], + strip_prefix = VALDI_STRIP_PREFIX + "/bzl/platforms", +) + +bazel_dep(name = "skia_user_config") +archive_override( + module_name = "skia_user_config", + urls = [VALDI_URL], + strip_prefix = VALDI_STRIP_PREFIX + "/third-party/skia_user_config", +) + +bazel_dep(name = "rules_hdrs") +archive_override( + module_name = "rules_hdrs", + urls = [VALDI_URL], + strip_prefix = VALDI_STRIP_PREFIX + "/third-party/rules_hdrs", +) + +bazel_dep(name = "valdi_toolchain") +archive_override( + module_name = "valdi_toolchain", + urls = [VALDI_URL], + strip_prefix = VALDI_STRIP_PREFIX + "/bin", +) + +bazel_dep(name = "resvg_libs") +archive_override( + module_name = "resvg_libs", + urls = [VALDI_URL], + strip_prefix = VALDI_STRIP_PREFIX + "/third-party/resvg/resvg_libs", +) + +# Required for widgets/BUILD.bazel which uses ts_project directly +bazel_dep(name = "aspect_rules_ts", version = "3.7.0") + +rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext") +rules_ts_ext.deps(ts_version = "5.3.3") +use_repo(rules_ts_ext, "npm_typescript") + +# Third-party patches required because Valdi's single_version_override +# entries only take effect when Valdi is the root module. +single_version_override( + module_name = "rules_swift", + patches = ["//third-party/patches:rules_swift.patch"], + patch_strip = 1, +) + +single_version_override( + module_name = "rules_kotlin", + patches = ["//third-party/patches:rules_kotlin.patch"], +) + +single_version_override( + module_name = "rules_android_ndk", + patches = ["//third-party/patches:rules_android_ndk.patch"], +) + +single_version_override( + module_name = "websocketpp", + patches = ["//third-party/patches:websocketpp.patch"], + patch_strip = 1, +) diff --git a/third-party/patches/BUILD.bazel b/third-party/patches/BUILD.bazel new file mode 100644 index 0000000..d518110 --- /dev/null +++ b/third-party/patches/BUILD.bazel @@ -0,0 +1 @@ +exports_files(glob(["*.patch"])) diff --git a/third-party/patches/rules_android_ndk.patch b/third-party/patches/rules_android_ndk.patch new file mode 100644 index 0000000..3d2aafb --- /dev/null +++ b/third-party/patches/rules_android_ndk.patch @@ -0,0 +1,21 @@ +--- BUILD.ndk_root.tpl ++++ BUILD.ndk_root.tpl +@@ -12,6 +12,18 @@ alias( + actual = "//{clang_directory}:cc_toolchain_suite", + ) + ++filegroup( ++ name = "strip", ++ srcs = ["//{clang_directory}:bin/llvm-strip"], ++ visibility = ["//visibility:public"], ++) ++ ++filegroup( ++ name = "strip_libs", ++ srcs = glob(["{clang_directory}/lib64/**/libc++.so.1"]), ++ visibility = ["//visibility:public"], ++) ++ + # Loop over TARGET_SYSTEM_NAMES and define all toolchain targets. + [toolchain( + name = "toolchain_%s" % target_system_name, diff --git a/third-party/patches/rules_kotlin.patch b/third-party/patches/rules_kotlin.patch new file mode 100644 index 0000000..c0d2e45 --- /dev/null +++ b/third-party/patches/rules_kotlin.patch @@ -0,0 +1,12 @@ +--- kotlin/internal/jvm/android.bzl ++++ kotlin/internal/jvm/android.bzl +@@ -119,6 +119,9 @@ def kt_android_library(name, exports = [], visibility = None, exec_properties = + tags = kwargs.get("tags", default = None), + testonly = kwargs.get("testonly", default = 0), + exec_properties = exec_properties, ++ manifest = kwargs.get("manifest", default = None), ++ custom_package = kwargs.get("custom_package", default = None), ++ resource_files = kwargs.get("resource_files", default= None), + ) + + def kt_android_local_test( diff --git a/third-party/patches/rules_swift.patch b/third-party/patches/rules_swift.patch new file mode 100644 index 0000000..07fc598 --- /dev/null +++ b/third-party/patches/rules_swift.patch @@ -0,0 +1,19 @@ +diff --git a/swift/swift_interop_hint.bzl b/swift/swift_interop_hint.bzl +index 8ccb1bd..afc7a51 100644 +--- a/swift/swift_interop_hint.bzl ++++ b/swift/swift_interop_hint.bzl +@@ -73,6 +73,14 @@ other non-identifier characters with underscores. + doc = """\ + If `True`, the hinted target should suppress any module that it would otherwise + generate. ++""", ++ mandatory = False, ++ ), ++ "system_pcms": attr.label_list( ++ allow_files = True, ++ doc = """\ ++A list of system PCM files that should be included in the Clang module generated ++for the target to which this hint is applied. + """, + mandatory = False, + ), diff --git a/third-party/patches/websocketpp.patch b/third-party/patches/websocketpp.patch new file mode 100644 index 0000000..10ddaca --- /dev/null +++ b/third-party/patches/websocketpp.patch @@ -0,0 +1,17 @@ +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -23,12 +23,12 @@ + }), + includes = ["."], + linkopts = select({ +- "@platforms//os:osx": [ ++ "@platforms//os:linux": [ + "-lpthread", ++ "-lrt", + ], + "//conditions:default": [ + "-lpthread", +- "-lrt", + ], + }), + visibility = ["//visibility:public"], From 1f50351e593df3122928426d3732acdf6e193913 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 11:39:25 -0700 Subject: [PATCH 02/21] Fix MODULE.bazel to use same Valdi commit as WORKSPACE The beta-0.0.3 release predates the macos_deps feature in valdi_module. Point to the same commit SHA the WORKSPACE uses. Co-Authored-By: Claude Opus 4.6 --- MODULE.bazel | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index ed7e92f..1f0cb97 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,11 +1,12 @@ module(name = "valdi_widgets", version = "0.1") -# Valdi release beta-0.0.3 (https://github.com/Snapchat/Valdi/releases) -VALDI_RELEASE_TAG = "beta-0.0.3" +# Valdi bleeding edge (https://github.com/Snapchat/Valdi) +# Must match the commit in WORKSPACE for consistency. +VALDI_COMMIT = "45b28375a189da8f9c24544e3b2d40318d3386a9" -VALDI_URL = "https://github.com/Snapchat/Valdi/archive/refs/tags/{}.tar.gz".format(VALDI_RELEASE_TAG) +VALDI_URL = "https://github.com/Snapchat/Valdi/archive/{}.tar.gz".format(VALDI_COMMIT) -VALDI_STRIP_PREFIX = "Valdi-{}".format(VALDI_RELEASE_TAG) +VALDI_STRIP_PREFIX = "Valdi-{}".format(VALDI_COMMIT) bazel_dep(name = "valdi") archive_override( From d326afbd4498a6be262e93bc5599bc316f609b57 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 11:43:25 -0700 Subject: [PATCH 03/21] Fix CI: clone Valdi locally instead of downloading per sub-module Each archive_override sub-module downloads the full Valdi tarball separately, causing timeouts in CI. Clone Valdi once and use --override_module flags to point all sub-modules to the local checkout. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/test.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 97d72dc..e7e4b86 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,6 +16,13 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Checkout Valdi + uses: actions/checkout@v4 + with: + repository: Snapchat/Valdi + ref: 45b28375a189da8f9c24544e3b2d40318d3386a9 + path: .valdi + - name: Setup Bazel uses: bazel-contrib/setup-bazel@0.8.5 with: @@ -24,7 +31,23 @@ jobs: repository-cache: true - name: Run all tests - run: bazel test --test_output=all //valdi_modules/widgets:test //valdi_modules/navigation:test //valdi_modules/valdi_standalone_ui:test //valdi_modules/navigation_internal:test //valdi_modules/playground:test + run: | + VALDI=${{ github.workspace }}/.valdi + bazel test --test_output=all \ + --override_module=valdi=$VALDI \ + --override_module=android_macros=$VALDI/bzl/macros \ + --override_module=snap_macros=$VALDI/bzl/valdi/snap_macros \ + --override_module=snap_client_toolchains=$VALDI/bzl/toolchains \ + --override_module=snap_platforms=$VALDI/bzl/platforms \ + --override_module=skia_user_config=$VALDI/third-party/skia_user_config \ + --override_module=rules_hdrs=$VALDI/third-party/rules_hdrs \ + --override_module=valdi_toolchain=$VALDI/bin \ + --override_module=resvg_libs=$VALDI/third-party/resvg/resvg_libs \ + //valdi_modules/widgets:test \ + //valdi_modules/navigation:test \ + //valdi_modules/valdi_standalone_ui:test \ + //valdi_modules/navigation_internal:test \ + //valdi_modules/playground:test - name: Upload test results if: always() From bfd59d86e5e558a759af26810c4c84da86a4fd65 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 11:46:44 -0700 Subject: [PATCH 04/21] Add toolchains_llvm extension (root-module-only) The llvm extension in toolchains_llvm enforces that only the root module can invoke it. Since Valdi_Widgets is the root module (not Valdi), we must declare and configure the extension here. Co-Authored-By: Claude Opus 4.6 --- MODULE.bazel | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MODULE.bazel b/MODULE.bazel index 1f0cb97..a62afe9 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -71,6 +71,15 @@ archive_override( strip_prefix = VALDI_STRIP_PREFIX + "/third-party/resvg/resvg_libs", ) +# Root-module-only extensions that Valdi declares but can only be +# invoked by the root module. +bazel_dep(name = "toolchains_llvm", version = "1.3.0") + +llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") +llvm.toolchain(name = "llvm_toolchain", llvm_version = "16.0.0") +use_repo(llvm, "llvm_toolchain") +register_toolchains("@llvm_toolchain//:all") + # Required for widgets/BUILD.bazel which uses ts_project directly bazel_dep(name = "aspect_rules_ts", version = "3.7.0") From 70aef69b958393efe2021e94fe92d6f2ba731035 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 11:51:53 -0700 Subject: [PATCH 05/21] Patch Valdi MODULE.bazel to remove root-module-only llvm extension The toolchains_llvm extension enforces root-module-only usage. When Valdi is a dependency (not root), its use_extension call fails. Patch it out of Valdi's MODULE.bazel and declare the extension from Valdi_Widgets (the actual root module) instead. Co-Authored-By: Claude Opus 4.6 --- MODULE.bazel | 2 ++ .../patches/valdi_remove_llvm_extension.patch | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 third-party/patches/valdi_remove_llvm_extension.patch diff --git a/MODULE.bazel b/MODULE.bazel index a62afe9..5060143 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -13,6 +13,8 @@ archive_override( module_name = "valdi", urls = [VALDI_URL], strip_prefix = VALDI_STRIP_PREFIX, + patches = ["//third-party/patches:valdi_remove_llvm_extension.patch"], + patch_strip = 1, ) bazel_dep(name = "android_macros") diff --git a/third-party/patches/valdi_remove_llvm_extension.patch b/third-party/patches/valdi_remove_llvm_extension.patch new file mode 100644 index 0000000..72dd58e --- /dev/null +++ b/third-party/patches/valdi_remove_llvm_extension.patch @@ -0,0 +1,13 @@ +--- a/MODULE.bazel ++++ b/MODULE.bazel +@@ -431,10 +431,6 @@ + use_repo(apple_cc_configure, "local_config_apple_cc_toolchains", "local_config_apple_cc") + register_toolchains("@local_config_apple_cc_toolchains//:all") + +-llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") +-llvm.toolchain(name = "llvm_toolchain", llvm_version = "16.0.0") +-use_repo(llvm, "llvm_toolchain") +-register_toolchains("@llvm_toolchain//:all") + + # Swift Package Manager deps for //compiler/compiler:local_valdi_compiler. + # Consumers loading @valdi via bzlmod should also use this extension; see From b20f8f8047133dd56d33df31e23d4265bbb2923c Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 11:55:41 -0700 Subject: [PATCH 06/21] Fix CI: patch Valdi checkout to remove root-module-only llvm extension The --override_module flags bypass archive_override patches, so the llvm extension removal patch wasn't being applied. Patch the local Valdi clone directly via sed before running bazel. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e7e4b86..a7cd227 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,6 +23,11 @@ jobs: ref: 45b28375a189da8f9c24544e3b2d40318d3386a9 path: .valdi + - name: Patch Valdi for non-root module usage + run: | + # Remove root-module-only llvm extension from Valdi's MODULE.bazel + sed -i '' '/^llvm = use_extension/d; /^llvm\.toolchain/d; /^use_repo(llvm/d; /^register_toolchains("@llvm_toolchain/d' .valdi/MODULE.bazel + - name: Setup Bazel uses: bazel-contrib/setup-bazel@0.8.5 with: From eeb2ab85ac9210f59fbe28de964d8c6ec2c84d63 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 11:59:45 -0700 Subject: [PATCH 07/21] Remove duplicate rules_ts extension declaration Valdi's MODULE.bazel already declares the rules_ts extension with npm_typescript. Declaring it again from Valdi_Widgets causes a duplicate repo error. Keep only the bazel_dep for visibility. Co-Authored-By: Claude Opus 4.6 --- MODULE.bazel | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 5060143..fd23548 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -82,13 +82,11 @@ llvm.toolchain(name = "llvm_toolchain", llvm_version = "16.0.0") use_repo(llvm, "llvm_toolchain") register_toolchains("@llvm_toolchain//:all") -# Required for widgets/BUILD.bazel which uses ts_project directly +# Required for widgets/BUILD.bazel which uses ts_project directly. +# The extension (rules_ts_ext.deps) is declared by Valdi's MODULE.bazel; +# declaring it here too causes a duplicate npm_typescript repo error. bazel_dep(name = "aspect_rules_ts", version = "3.7.0") -rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext") -rules_ts_ext.deps(ts_version = "5.3.3") -use_repo(rules_ts_ext, "npm_typescript") - # Third-party patches required because Valdi's single_version_override # entries only take effect when Valdi is the root module. single_version_override( From 2a322940a3871981321366956e64e013b1a159d7 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 12:10:56 -0700 Subject: [PATCH 08/21] fix: add missing bazel_dep entries to Valdi sub-modules in CI At commit 45b28375, three sub-module MODULE.bazel files are missing deps that were added later: snap_client_toolchains needs snap_platforms, android_macros needs rules_android, and rules_hdrs needs rules_pkg. Append the missing entries in the CI patch step. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a7cd227..b64fa0f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,11 @@ jobs: # Remove root-module-only llvm extension from Valdi's MODULE.bazel sed -i '' '/^llvm = use_extension/d; /^llvm\.toolchain/d; /^use_repo(llvm/d; /^register_toolchains("@llvm_toolchain/d' .valdi/MODULE.bazel + # Add missing bazel_dep entries that were added after this commit + echo 'bazel_dep(name = "snap_platforms")' >> .valdi/bzl/toolchains/MODULE.bazel + echo 'bazel_dep(name = "rules_android", version = "0.5.1")' >> .valdi/bzl/macros/MODULE.bazel + echo 'bazel_dep(name = "rules_pkg", version = "0.9.1")' >> .valdi/third-party/rules_hdrs/MODULE.bazel + - name: Setup Bazel uses: bazel-contrib/setup-bazel@0.8.5 with: From 47c7f940f60e1851a298d1fbc7ff76faf239a4f6 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 12:12:13 -0700 Subject: [PATCH 09/21] fix: use printf with leading newline for MODULE.bazel appends The sub-module MODULE.bazel files may not end with a trailing newline, causing echo >> to concatenate on the same line. Use printf with a leading \n to ensure proper line separation. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b64fa0f..58cb80e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,9 +29,9 @@ jobs: sed -i '' '/^llvm = use_extension/d; /^llvm\.toolchain/d; /^use_repo(llvm/d; /^register_toolchains("@llvm_toolchain/d' .valdi/MODULE.bazel # Add missing bazel_dep entries that were added after this commit - echo 'bazel_dep(name = "snap_platforms")' >> .valdi/bzl/toolchains/MODULE.bazel - echo 'bazel_dep(name = "rules_android", version = "0.5.1")' >> .valdi/bzl/macros/MODULE.bazel - echo 'bazel_dep(name = "rules_pkg", version = "0.9.1")' >> .valdi/third-party/rules_hdrs/MODULE.bazel + printf '\nbazel_dep(name = "snap_platforms")\n' >> .valdi/bzl/toolchains/MODULE.bazel + printf '\nbazel_dep(name = "rules_android", version = "0.5.1")\n' >> .valdi/bzl/macros/MODULE.bazel + printf '\nbazel_dep(name = "rules_pkg", version = "0.9.1")\n' >> .valdi/third-party/rules_hdrs/MODULE.bazel - name: Setup Bazel uses: bazel-contrib/setup-bazel@0.8.5 From 0e57f00e85fb93db8bb8fc0b15cd797d2d3fb840 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 12:13:32 -0700 Subject: [PATCH 10/21] fix: remove duplicate rules_android dep from CI patches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit android_macros already has bazel_dep(name = "rules_android") at the pinned commit — appending it again causes a duplicate repo name error. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 58cb80e..0870ec1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,6 @@ jobs: # Add missing bazel_dep entries that were added after this commit printf '\nbazel_dep(name = "snap_platforms")\n' >> .valdi/bzl/toolchains/MODULE.bazel - printf '\nbazel_dep(name = "rules_android", version = "0.5.1")\n' >> .valdi/bzl/macros/MODULE.bazel printf '\nbazel_dep(name = "rules_pkg", version = "0.9.1")\n' >> .valdi/third-party/rules_hdrs/MODULE.bazel - name: Setup Bazel From cce88dc6fee6689c3478f6785acc57006f19786e Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 12:58:27 -0700 Subject: [PATCH 11/21] fix: register Apple CC toolchain before LLVM in root module Root module toolchain registrations shadow dependency module registrations. Since Valdi (a dependency) registers Apple CC before LLVM for ObjC compilation priority, the root module must do the same or the LLVM toolchain (root-registered) will be selected for ObjC targets, which fails. Co-Authored-By: Claude Opus 4.6 --- MODULE.bazel | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index fd23548..d66fbb1 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -73,8 +73,15 @@ archive_override( strip_prefix = VALDI_STRIP_PREFIX + "/third-party/resvg/resvg_libs", ) -# Root-module-only extensions that Valdi declares but can only be -# invoked by the root module. +# Apple CC toolchains must be registered before LLVM so they take priority +# for ObjC compilation on macOS. Root module toolchains shadow dependency +# module toolchains, so we must register both here. +bazel_dep(name = "apple_support", version = "1.21.0", repo_name = "build_bazel_apple_support") + +apple_cc_configure = use_extension("@build_bazel_apple_support//crosstool:setup.bzl", "apple_cc_configure_extension") +use_repo(apple_cc_configure, "local_config_apple_cc_toolchains", "local_config_apple_cc") +register_toolchains("@local_config_apple_cc_toolchains//:all") + bazel_dep(name = "toolchains_llvm", version = "1.3.0") llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") From 995eb7d1be0be50e6498383f7b7a613615274df1 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 14:43:29 -0700 Subject: [PATCH 12/21] Add version-only single_version_override pins Pin protobuf (27.0), rules_apple (4.0.0), rules_pkg (0.9.1), and zlib (1.3.2) to prevent MVS from escalating to incompatible versions when Valdi's own overrides are ignored as a non-root module. Co-Authored-By: Claude Opus 4.6 --- MODULE.bazel | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/MODULE.bazel b/MODULE.bazel index d66fbb1..bb374fb 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -117,3 +117,23 @@ single_version_override( patches = ["//third-party/patches:websocketpp.patch"], patch_strip = 1, ) + +single_version_override( + module_name = "protobuf", + version = "27.0", +) + +single_version_override( + module_name = "rules_apple", + version = "4.0.0", +) + +single_version_override( + module_name = "rules_pkg", + version = "0.9.1", +) + +single_version_override( + module_name = "zlib", + version = "1.3.2", +) From 5d0b9adb5c8a04ecb92fe64b6fc13cb4b2536e2e Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Thu, 30 Apr 2026 14:59:29 -0700 Subject: [PATCH 13/21] Add missing -Wno-nullability-extension compiler flags abseil-cpp headers use Clang nullability extensions that trigger -Werror in both target and exec (tool) configurations. Add the suppression flags matching Valdi's own .bazelrc. Co-Authored-By: Claude Opus 4.6 --- .bazelrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.bazelrc b/.bazelrc index 637161b..573a41f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -17,8 +17,11 @@ build:linux --sandbox_writable_path=/var/tmp # common cc configuration build --cxxopt=-std=c++20 build --cxxopt=-Wno-ambiguous-reversed-operator +build --cxxopt=-Wno-gcc-compat +build --cxxopt=-Wno-nullability-extension build --cxxopt=-D_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS build --host_cxxopt=-std=c++20 +build --host_cxxopt=-Wno-nullability-extension ## we need to disable this due to a bug in bazel ## see https://github.com/bazelbuild/bazel/issues/12381 From 8626ff07d90f0443da1f699346fc3d72fbf3903a Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Wed, 6 May 2026 10:40:55 -0700 Subject: [PATCH 14/21] Migrate to release tags, valdi_toolchains, and Bazel registry Switch from commit SHA to release tag (beta-0.1.0) for Valdi pinning. Replace manual Apple CC + LLVM toolchain setup with Valdi's unified valdi_toolchains extension. Remove stale valdi_remove_llvm_extension patch. Add Valdi custom Bazel registry for patched deps (rules_swift, rules_kotlin, rules_android_ndk). Remove WORKSPACE (bzlmod only). Co-Authored-By: Claude Opus 4.6 --- .bazelrc | 4 +++ MODULE.bazel | 83 +++++++++++++--------------------------------------- WORKSPACE | 70 -------------------------------------------- 3 files changed, 24 insertions(+), 133 deletions(-) delete mode 100644 WORKSPACE diff --git a/.bazelrc b/.bazelrc index 573a41f..4437f85 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,3 +1,7 @@ +# Valdi custom Bazel registry (patched rules_swift, rules_kotlin, etc.) +common --registry=https://raw.githubusercontent.com/Snapchat/Valdi/beta-0.1.0/registry +common --registry=https://bcr.bazel.build + common --bes_instance_name=client common --enable_platform_specific_config diff --git a/MODULE.bazel b/MODULE.bazel index bb374fb..2695070 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,20 +1,17 @@ module(name = "valdi_widgets", version = "0.1") -# Valdi bleeding edge (https://github.com/Snapchat/Valdi) -# Must match the commit in WORKSPACE for consistency. -VALDI_COMMIT = "45b28375a189da8f9c24544e3b2d40318d3386a9" - -VALDI_URL = "https://github.com/Snapchat/Valdi/archive/{}.tar.gz".format(VALDI_COMMIT) - -VALDI_STRIP_PREFIX = "Valdi-{}".format(VALDI_COMMIT) - -bazel_dep(name = "valdi") +# Valdi framework (https://github.com/Snapchat/Valdi) +# For development against a local checkout, replace archive_override with +# local_path_override entries (see CONTRIBUTING.md). +VALDI_TAG = "beta-0.1.0" +VALDI_URL = "https://github.com/Snapchat/Valdi/archive/refs/tags/{}.tar.gz".format(VALDI_TAG) +VALDI_STRIP_PREFIX = "Valdi-{}".format(VALDI_TAG) + +bazel_dep(name = "valdi", version = "0.1") archive_override( module_name = "valdi", urls = [VALDI_URL], strip_prefix = VALDI_STRIP_PREFIX, - patches = ["//third-party/patches:valdi_remove_llvm_extension.patch"], - patch_strip = 1, ) bazel_dep(name = "android_macros") @@ -73,67 +70,27 @@ archive_override( strip_prefix = VALDI_STRIP_PREFIX + "/third-party/resvg/resvg_libs", ) -# Apple CC toolchains must be registered before LLVM so they take priority -# for ObjC compilation on macOS. Root module toolchains shadow dependency -# module toolchains, so we must register both here. -bazel_dep(name = "apple_support", version = "1.21.0", repo_name = "build_bazel_apple_support") - -apple_cc_configure = use_extension("@build_bazel_apple_support//crosstool:setup.bzl", "apple_cc_configure_extension") -use_repo(apple_cc_configure, "local_config_apple_cc_toolchains", "local_config_apple_cc") +# C++ toolchains via Valdi's unified extension (Apple CC before LLVM for ObjC priority). +valdi_toolchains = use_extension("@valdi//bzl:valdi_toolchains.bzl", "valdi_toolchains") +use_repo(valdi_toolchains, "local_config_apple_cc_toolchains", "local_config_apple_cc", "llvm_toolchain", "llvm_toolchain_llvm") register_toolchains("@local_config_apple_cc_toolchains//:all") - -bazel_dep(name = "toolchains_llvm", version = "1.3.0") - -llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") -llvm.toolchain(name = "llvm_toolchain", llvm_version = "16.0.0") -use_repo(llvm, "llvm_toolchain") register_toolchains("@llvm_toolchain//:all") # Required for widgets/BUILD.bazel which uses ts_project directly. -# The extension (rules_ts_ext.deps) is declared by Valdi's MODULE.bazel; -# declaring it here too causes a duplicate npm_typescript repo error. bazel_dep(name = "aspect_rules_ts", version = "3.7.0") -# Third-party patches required because Valdi's single_version_override -# entries only take effect when Valdi is the root module. -single_version_override( - module_name = "rules_swift", - patches = ["//third-party/patches:rules_swift.patch"], - patch_strip = 1, -) - -single_version_override( - module_name = "rules_kotlin", - patches = ["//third-party/patches:rules_kotlin.patch"], -) - -single_version_override( - module_name = "rules_android_ndk", - patches = ["//third-party/patches:rules_android_ndk.patch"], -) - +# Third-party patches: Valdi's single_version_override entries only take +# effect when Valdi is the root module. The Valdi Bazel registry provides +# pre-patched versions of rules_swift, rules_kotlin, and rules_android_ndk. +# Websocketpp still needs a local patch. single_version_override( module_name = "websocketpp", patches = ["//third-party/patches:websocketpp.patch"], patch_strip = 1, ) -single_version_override( - module_name = "protobuf", - version = "27.0", -) - -single_version_override( - module_name = "rules_apple", - version = "4.0.0", -) - -single_version_override( - module_name = "rules_pkg", - version = "0.9.1", -) - -single_version_override( - module_name = "zlib", - version = "1.3.2", -) +# Version pins (must match Valdi's MODULE.bazel). +single_version_override(module_name = "protobuf", version = "27.0") +single_version_override(module_name = "rules_apple", version = "4.0.0") +single_version_override(module_name = "rules_pkg", version = "0.9.1") +single_version_override(module_name = "zlib", version = "1.3.2") diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index b300988..0000000 --- a/WORKSPACE +++ /dev/null @@ -1,70 +0,0 @@ -workspace(name = "valdi_widgets") - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") - -# Valdi bleeding edge (https://github.com/Snapchat/Valdi) -http_archive( - name = "valdi", - strip_prefix = "Valdi-45b28375a189da8f9c24544e3b2d40318d3386a9", - url = "https://github.com/Snapchat/Valdi/archive/45b28375a189da8f9c24544e3b2d40318d3386a9.tar.gz", -) - -# For local development (uncomment to use local Valdi checkout): -# local_repository(name = "valdi", path = "/Users/cholgate/Snapchat/Dev/mobile/client/src/open_source") - -# Valdi release beta-0.0.2 (https://github.com/Snapchat/Valdi/releases) -# http_archive( -# name = "valdi", -# strip_prefix = "Valdi-beta-0.0.2", -# url = "https://github.com/Snapchat/Valdi/archive/refs/tags/beta-0.0.2.tar.gz", -# ) - -load("@valdi//bzl:workspace_prepare.bzl", "valdi_prepare_workspace") - -valdi_prepare_workspace() - -load("@valdi//bzl:workspace_preinit.bzl", "valdi_preinitialize_workspace") - -valdi_preinitialize_workspace() - -load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "aspect_bazel_lib_register_toolchains", "register_yq_toolchains") - -register_yq_toolchains() - -# Required bazel-lib dependencies - -aspect_bazel_lib_dependencies() - -# Required rules_shell dependencies -load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains") - -rules_shell_dependencies() - -rules_shell_toolchains() - -# Register bazel-lib toolchains - -aspect_bazel_lib_register_toolchains() - -# Create the host platform repository transitively required by bazel-lib - -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") -load("@platforms//host:extension.bzl", "host_platform_repo") - -maybe( - host_platform_repo, - name = "host_platform", -) - -load("@valdi//bzl:workspace_init.bzl", "valdi_initialize_workspace") - -valdi_initialize_workspace() - -load("@valdi_npm//:repositories.bzl", "npm_repositories") - -npm_repositories() - -load("@valdi//bzl:workspace_postinit.bzl", "valdi_post_initialize_workspace") - -valdi_post_initialize_workspace() \ No newline at end of file From 56f20f20743f8f765bb59767e41dff7ce7e42d0a Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Wed, 6 May 2026 10:48:24 -0700 Subject: [PATCH 15/21] Remove unused patch files, support any git ref in archive URLs The Bazel registry now provides pre-patched rules_swift, rules_kotlin, and rules_android_ndk. The valdi_toolchains extension handles LLVM setup so valdi_remove_llvm_extension.patch is also unnecessary. Only websocketpp.patch remains (still needed). Also drop refs/tags/ from the Valdi archive URL so branch names and commit SHAs work too (e.g. VALDI_TAG = "main" for bleeding edge). Co-Authored-By: Claude Opus 4.6 --- MODULE.bazel | 2 +- third-party/patches/rules_android_ndk.patch | 21 ------------------- third-party/patches/rules_kotlin.patch | 12 ----------- third-party/patches/rules_swift.patch | 19 ----------------- .../patches/valdi_remove_llvm_extension.patch | 13 ------------ 5 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 third-party/patches/rules_android_ndk.patch delete mode 100644 third-party/patches/rules_kotlin.patch delete mode 100644 third-party/patches/rules_swift.patch delete mode 100644 third-party/patches/valdi_remove_llvm_extension.patch diff --git a/MODULE.bazel b/MODULE.bazel index 2695070..c493179 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -4,7 +4,7 @@ module(name = "valdi_widgets", version = "0.1") # For development against a local checkout, replace archive_override with # local_path_override entries (see CONTRIBUTING.md). VALDI_TAG = "beta-0.1.0" -VALDI_URL = "https://github.com/Snapchat/Valdi/archive/refs/tags/{}.tar.gz".format(VALDI_TAG) +VALDI_URL = "https://github.com/Snapchat/Valdi/archive/{}.tar.gz".format(VALDI_TAG) VALDI_STRIP_PREFIX = "Valdi-{}".format(VALDI_TAG) bazel_dep(name = "valdi", version = "0.1") diff --git a/third-party/patches/rules_android_ndk.patch b/third-party/patches/rules_android_ndk.patch deleted file mode 100644 index 3d2aafb..0000000 --- a/third-party/patches/rules_android_ndk.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- BUILD.ndk_root.tpl -+++ BUILD.ndk_root.tpl -@@ -12,6 +12,18 @@ alias( - actual = "//{clang_directory}:cc_toolchain_suite", - ) - -+filegroup( -+ name = "strip", -+ srcs = ["//{clang_directory}:bin/llvm-strip"], -+ visibility = ["//visibility:public"], -+) -+ -+filegroup( -+ name = "strip_libs", -+ srcs = glob(["{clang_directory}/lib64/**/libc++.so.1"]), -+ visibility = ["//visibility:public"], -+) -+ - # Loop over TARGET_SYSTEM_NAMES and define all toolchain targets. - [toolchain( - name = "toolchain_%s" % target_system_name, diff --git a/third-party/patches/rules_kotlin.patch b/third-party/patches/rules_kotlin.patch deleted file mode 100644 index c0d2e45..0000000 --- a/third-party/patches/rules_kotlin.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- kotlin/internal/jvm/android.bzl -+++ kotlin/internal/jvm/android.bzl -@@ -119,6 +119,9 @@ def kt_android_library(name, exports = [], visibility = None, exec_properties = - tags = kwargs.get("tags", default = None), - testonly = kwargs.get("testonly", default = 0), - exec_properties = exec_properties, -+ manifest = kwargs.get("manifest", default = None), -+ custom_package = kwargs.get("custom_package", default = None), -+ resource_files = kwargs.get("resource_files", default= None), - ) - - def kt_android_local_test( diff --git a/third-party/patches/rules_swift.patch b/third-party/patches/rules_swift.patch deleted file mode 100644 index 07fc598..0000000 --- a/third-party/patches/rules_swift.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff --git a/swift/swift_interop_hint.bzl b/swift/swift_interop_hint.bzl -index 8ccb1bd..afc7a51 100644 ---- a/swift/swift_interop_hint.bzl -+++ b/swift/swift_interop_hint.bzl -@@ -73,6 +73,14 @@ other non-identifier characters with underscores. - doc = """\ - If `True`, the hinted target should suppress any module that it would otherwise - generate. -+""", -+ mandatory = False, -+ ), -+ "system_pcms": attr.label_list( -+ allow_files = True, -+ doc = """\ -+A list of system PCM files that should be included in the Clang module generated -+for the target to which this hint is applied. - """, - mandatory = False, - ), diff --git a/third-party/patches/valdi_remove_llvm_extension.patch b/third-party/patches/valdi_remove_llvm_extension.patch deleted file mode 100644 index 72dd58e..0000000 --- a/third-party/patches/valdi_remove_llvm_extension.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/MODULE.bazel -+++ b/MODULE.bazel -@@ -431,10 +431,6 @@ - use_repo(apple_cc_configure, "local_config_apple_cc_toolchains", "local_config_apple_cc") - register_toolchains("@local_config_apple_cc_toolchains//:all") - --llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") --llvm.toolchain(name = "llvm_toolchain", llvm_version = "16.0.0") --use_repo(llvm, "llvm_toolchain") --register_toolchains("@llvm_toolchain//:all") - - # Swift Package Manager deps for //compiler/compiler:local_valdi_compiler. - # Consumers loading @valdi via bzlmod should also use this extension; see From da300a98226cb9ecc979c117ff54a6bfcc516f29 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Wed, 6 May 2026 14:32:33 -0700 Subject: [PATCH 16/21] Fix CI: use Valdi HEAD with registry instead of pinned old commit The pinned commit predates the Bazel registry and missing bazel_dep fixes. Checking out main and passing --registry=file://$VALDI/registry gives CI access to pre-patched deps (rules_swift, websocketpp, etc.) without manual sed workarounds. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/test.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0870ec1..addee0f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,6 @@ jobs: uses: actions/checkout@v4 with: repository: Snapchat/Valdi - ref: 45b28375a189da8f9c24544e3b2d40318d3386a9 path: .valdi - name: Patch Valdi for non-root module usage @@ -28,10 +27,6 @@ jobs: # Remove root-module-only llvm extension from Valdi's MODULE.bazel sed -i '' '/^llvm = use_extension/d; /^llvm\.toolchain/d; /^use_repo(llvm/d; /^register_toolchains("@llvm_toolchain/d' .valdi/MODULE.bazel - # Add missing bazel_dep entries that were added after this commit - printf '\nbazel_dep(name = "snap_platforms")\n' >> .valdi/bzl/toolchains/MODULE.bazel - printf '\nbazel_dep(name = "rules_pkg", version = "0.9.1")\n' >> .valdi/third-party/rules_hdrs/MODULE.bazel - - name: Setup Bazel uses: bazel-contrib/setup-bazel@0.8.5 with: @@ -43,6 +38,7 @@ jobs: run: | VALDI=${{ github.workspace }}/.valdi bazel test --test_output=all \ + --registry=file://$VALDI/registry \ --override_module=valdi=$VALDI \ --override_module=android_macros=$VALDI/bzl/macros \ --override_module=snap_macros=$VALDI/bzl/valdi/snap_macros \ From 8bd61bbe5541bd1625ecdcf465841b6ea9f74a75 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Wed, 6 May 2026 14:45:31 -0700 Subject: [PATCH 17/21] Fix CI: patch .bazelrc registry to use local Valdi checkout The .bazelrc points at a registry URL for a release tag that may not exist yet. BCR (listed second) resolves rules_swift before the local registry appended via --registry CLI flag, so the unpatched version is used. Fix by sed-replacing the .bazelrc URL with file://$VALDI/registry so the patched registry is checked first. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index addee0f..07be733 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,10 +22,13 @@ jobs: repository: Snapchat/Valdi path: .valdi - - name: Patch Valdi for non-root module usage + - name: Patch for CI (local Valdi checkout) run: | + VALDI=${{ github.workspace }}/.valdi # Remove root-module-only llvm extension from Valdi's MODULE.bazel sed -i '' '/^llvm = use_extension/d; /^llvm\.toolchain/d; /^use_repo(llvm/d; /^register_toolchains("@llvm_toolchain/d' .valdi/MODULE.bazel + # Point .bazelrc registry at local Valdi checkout (release tag may not exist yet) + sed -i '' "s|--registry=https://raw.githubusercontent.com/Snapchat/Valdi/.*/registry|--registry=file://$VALDI/registry|" .bazelrc - name: Setup Bazel uses: bazel-contrib/setup-bazel@0.8.5 @@ -38,7 +41,6 @@ jobs: run: | VALDI=${{ github.workspace }}/.valdi bazel test --test_output=all \ - --registry=file://$VALDI/registry \ --override_module=valdi=$VALDI \ --override_module=android_macros=$VALDI/bzl/macros \ --override_module=snap_macros=$VALDI/bzl/valdi/snap_macros \ From bb34cbe69bbdd3c6802f4cdc1bd966122be15a7f Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Wed, 6 May 2026 14:47:56 -0700 Subject: [PATCH 18/21] Add rules_ts extension for npm_typescript visibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ts_project in widgets/BUILD.bazel needs @npm_typescript, which is created by the rules_ts extension. Valdi declares its own, but bzlmod scopes use_repo to the declaring module — consumers must redeclare. Co-Authored-By: Claude Opus 4.6 --- MODULE.bazel | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MODULE.bazel b/MODULE.bazel index c493179..86c55a5 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -78,6 +78,9 @@ register_toolchains("@llvm_toolchain//:all") # Required for widgets/BUILD.bazel which uses ts_project directly. bazel_dep(name = "aspect_rules_ts", version = "3.7.0") +rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext") +rules_ts_ext.deps(ts_version = "5.3.3") +use_repo(rules_ts_ext, "npm_typescript") # Third-party patches: Valdi's single_version_override entries only take # effect when Valdi is the root module. The Valdi Bazel registry provides From 984bbadd1857b8d9635ccab15514a975918242dd Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Wed, 6 May 2026 14:49:39 -0700 Subject: [PATCH 19/21] Fix rules_ts: import npm_typescript without redeclaring deps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Valdi's MODULE.bazel already calls rules_ts_ext.deps() which creates the npm_typescript repo. In bzlmod, extension repos are global — a second .deps() tag causes a duplicate repo error. Widgets only needs use_repo to import the repo Valdi already creates. Co-Authored-By: Claude Opus 4.6 --- MODULE.bazel | 1 - 1 file changed, 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index 86c55a5..299f23b 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -79,7 +79,6 @@ register_toolchains("@llvm_toolchain//:all") # Required for widgets/BUILD.bazel which uses ts_project directly. bazel_dep(name = "aspect_rules_ts", version = "3.7.0") rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext") -rules_ts_ext.deps(ts_version = "5.3.3") use_repo(rules_ts_ext, "npm_typescript") # Third-party patches: Valdi's single_version_override entries only take From 45d99b0888d58704887d45b8d20c1556fc0b7048 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Wed, 6 May 2026 14:52:00 -0700 Subject: [PATCH 20/21] Fix CI: stub open_source_archives.bzl (stripped by Copybara) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The public Valdi mirror doesn't include open_source_archives.bzl (Copybara strips it), but valdi_compiler_repos_extension.bzl loads it. Create an empty ARCHIVES stub so the extension falls back to empty repos — the compiler binaries are in the checkout path anyway. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 07be733..6d97d41 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,6 +29,8 @@ jobs: sed -i '' '/^llvm = use_extension/d; /^llvm\.toolchain/d; /^use_repo(llvm/d; /^register_toolchains("@llvm_toolchain/d' .valdi/MODULE.bazel # Point .bazelrc registry at local Valdi checkout (release tag may not exist yet) sed -i '' "s|--registry=https://raw.githubusercontent.com/Snapchat/Valdi/.*/registry|--registry=file://$VALDI/registry|" .bazelrc + # Stub out open_source_archives.bzl (stripped by Copybara, not on public repo) + echo 'ARCHIVES = {}' > .valdi/bzl/open_source_archives.bzl - name: Setup Bazel uses: bazel-contrib/setup-bazel@0.8.5 From 5f307de0a6edc51591e066bc3118824f831b46d2 Mon Sep 17 00:00:00 2001 From: Carson Holgate Date: Wed, 6 May 2026 15:30:25 -0700 Subject: [PATCH 21/21] Fix CI: enable git-lfs for Valdi checkout (resvg binary libs) libresvg.a is tracked by git-lfs. Without lfs: true, the checkout gets 133-byte pointer files instead of actual binaries, causing "unknown file type" linker errors. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d97d41..c1e5b5e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,7 @@ jobs: uses: actions/checkout@v4 with: repository: Snapchat/Valdi + lfs: true path: .valdi - name: Patch for CI (local Valdi checkout)