From 852753b202609ed879524b389eb5808f54de95e6 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Wed, 11 Feb 2026 13:34:23 +0000 Subject: [PATCH 1/3] chore: have uvm_config_image accept a srcmap dict instead of srcs and remap_paths --- bazel/defs.bzl | 20 ++++-- rs/tests/BUILD.bazel | 67 +++++++------------ rs/tests/cross_chain/BUILD.bazel | 28 +++----- rs/tests/networking/canister_http/BUILD.bazel | 17 ++--- rs/tests/node/BUILD.bazel | 12 ++-- rs/tests/system_tests.bzl | 11 ++- 6 files changed, 66 insertions(+), 89 deletions(-) diff --git a/bazel/defs.bzl b/bazel/defs.bzl index 0591f63d6824..e3190dd864e1 100644 --- a/bazel/defs.bzl +++ b/bazel/defs.bzl @@ -85,12 +85,24 @@ def _mcopy(ctx): out = ctx.actions.declare_file(ctx.label.name) command = "cp -p {fs} {output} && chmod +w {output} ".format(fs = ctx.file.fs.path, output = out.path) - for src in ctx.files.srcs: - command += "&& mcopy -mi {output} -sQ {src_path} ::/{filename} ".format(output = out.path, src_path = src.path, filename = ctx.attr.remap_paths.get(src.basename, src.basename)) + inputs = [] + for srcs, dest in ctx.attr.srcmap.items(): + src_files = srcs[DefaultInfo].files.to_list() + for src_file in src_files: + inputs.append(src_file) + if dest.endswith("/"): + dest_path = dest + src_file.basename + else: + dest_path = dest + command += "&& mcopy -mi {output} -sQ {src_path} ::/{dest} ".format( + output = out.path, + src_path = src_file.path, + dest = dest_path.removeprefix("/"), + ) ctx.actions.run_shell( command = command, - inputs = ctx.files.srcs + [ctx.file.fs], + inputs = inputs + [ctx.file.fs], outputs = [out], ) return [DefaultInfo(files = depset([out]), runfiles = ctx.runfiles(files = [out]))] @@ -98,7 +110,7 @@ def _mcopy(ctx): mcopy = rule( implementation = _mcopy, attrs = { - "srcs": attr.label_list(allow_files = True), + "srcmap": attr.label_keyed_string_dict(allow_files = True), "fs": attr.label(allow_single_file = True), "remap_paths": attr.string_dict(), }, diff --git a/rs/tests/BUILD.bazel b/rs/tests/BUILD.bazel index 5e7d964a5b9a..6d5abb4d7bb3 100644 --- a/rs/tests/BUILD.bazel +++ b/rs/tests/BUILD.bazel @@ -135,12 +135,9 @@ oci_tar( uvm_config_image( name = "colocate_uvm_config_image", - srcs = [ - ":ubuntu_test_runtime.tar", - "//rs/tests:activate-systest-uvm-config", - ], - remap_paths = { - "activate-systest-uvm-config": "activate", + srcmap = { + ":ubuntu_test_runtime.tar": "ubuntu_test_runtime.tar", + "//rs/tests:activate-systest-uvm-config": "activate", }, tags = ["manual"], # this target will be built if required as a dependency of another target ) @@ -161,12 +158,9 @@ exports_files([ uvm_config_image( name = "jaeger_uvm_config_image", - srcs = [ - ":jaeger.tar", - ":jaeger_activate.sh", - ], - remap_paths = { - "jaeger_activate.sh": "activate", + srcmap = { + ":jaeger.tar": "jaeger.tar", + ":jaeger_activate.sh": "activate", }, tags = ["manual"], # this target will be built if required as a dependency of another target ) @@ -213,42 +207,34 @@ oci_tar( uvm_config_image( name = "ckbtc_uvm_config_image", - srcs = [ - ":bitcoind.tar", - ":dogecoind.tar", - ":minica.tar", - ":nginx-proxy.tar", - "//ic-os/components:networking/dev-certs/canister_http_test_ca.cert", - "//ic-os/components:networking/dev-certs/canister_http_test_ca.key", - "//rs/tests/httpbin-rs:httpbin.tar", - ], - remap_paths = { - "canister_http_test_ca.cert": "cert.pem", - "canister_http_test_ca.key": "key.pem", + srcmap = { + ":bitcoind.tar": "bitcoind.tar", + ":dogecoind.tar": "dogecoind.tar", + ":minica.tar": "minica.tar", + ":nginx-proxy.tar": "nginx-proxy.tar", + "//ic-os/components:networking/dev-certs/canister_http_test_ca.cert": "cert.pem", + "//ic-os/components:networking/dev-certs/canister_http_test_ca.key": "key.pem", + "//rs/tests/httpbin-rs:httpbin.tar": "httpbin.tar", }, tags = ["manual"], # this target will be built if required as a dependency of another target ) uvm_config_image( name = "impersonate_upstreams_uvm_config_image", - srcs = [ - ":minica.tar", - ":static-file-server.tar", - "//ic-os/components:networking/dev-certs/canister_http_test_ca.cert", - "//ic-os/components:networking/dev-certs/canister_http_test_ca.key", - ], - remap_paths = { - "canister_http_test_ca.cert": "minica.pem", - "canister_http_test_ca.key": "minica-key.pem", + srcmap = { + ":minica.tar": "minica.tar", + ":static-file-server.tar": "static-file-server.tar", + "//ic-os/components:networking/dev-certs/canister_http_test_ca.cert": "minica.pem", + "//ic-os/components:networking/dev-certs/canister_http_test_ca.key": "minica-key.pem", }, tags = ["manual"], # this target will be built if required as a dependency of another target ) uvm_config_image( name = "ic_gateway_uvm_config_image", - srcs = [ - ":ic_gatewayd.tar", - ], + srcmap = { + ":ic_gatewayd.tar": "ic_gatewayd.tar", + }, tags = ["manual"], # this target will be built if required as a dependency of another target ) @@ -266,12 +252,9 @@ exports_files([ uvm_config_image( name = "vector_with_log_fetcher_image", - srcs = [ - ":vector-with-log-fetcher.tar", - ":vector_activate.sh", - ], - remap_paths = { - "vector_activate.sh": "activate", + srcmap = { + ":vector-with-log-fetcher.tar": "vector-with-log-fetcher.tar", + ":vector_activate.sh": "activate", }, tags = ["manual"], ) diff --git a/rs/tests/cross_chain/BUILD.bazel b/rs/tests/cross_chain/BUILD.bazel index 6109dd877ed0..35cfa8d4071a 100644 --- a/rs/tests/cross_chain/BUILD.bazel +++ b/rs/tests/cross_chain/BUILD.bazel @@ -68,13 +68,6 @@ system_test_nns( ], ) -filegroup( - name = "erc20_contract", - srcs = [ - "ERC20.sol", - ], -) - oci_tar( name = "foundry.tar", image = "@foundry", @@ -83,11 +76,11 @@ oci_tar( uvm_config_image( name = "cketh_uvm_config_image", - srcs = [ - ":erc20_contract", - ":foundry.tar", - "//rs/ethereum/cketh/minter:helper_contracts", - ], + srcmap = { + ":ERC20.sol": "ERC20.sol", + ":foundry.tar": "foundry.tar", + "//rs/ethereum/cketh/minter:helper_contracts": "/", + }, tags = ["manual"], # this target will be built if required as a dependency of another target ) @@ -98,13 +91,10 @@ exports_files([ uvm_config_image( name = "btc_uvm_config_image", - srcs = [ - ":bitcoind.tar", - ":btc_integration/bitcoin.conf", - ":btc_integration/btc_activate.sh", - ], - remap_paths = { - "btc_activate.sh": "activate", + srcmap = { + ":bitcoind.tar": "bitcoind.tar", + ":btc_integration/bitcoin.conf": "bitcoin.conf", + ":btc_integration/btc_activate.sh": "activate", }, tags = ["manual"], # this target will be built if required as a dependency of another target ) diff --git a/rs/tests/networking/canister_http/BUILD.bazel b/rs/tests/networking/canister_http/BUILD.bazel index 879755405b1d..48ac5875cb78 100644 --- a/rs/tests/networking/canister_http/BUILD.bazel +++ b/rs/tests/networking/canister_http/BUILD.bazel @@ -33,17 +33,12 @@ oci_tar( uvm_config_image( name = "http_uvm_config_image", - srcs = [ - ":minica.tar", - ":universal_vm_activation.sh", - "//ic-os/components:networking/dev-certs/canister_http_test_ca.cert", - "//ic-os/components:networking/dev-certs/canister_http_test_ca.key", - "//rs/tests/httpbin-rs:httpbin.tar", - ], - remap_paths = { - "universal_vm_activation.sh": "activate", - "canister_http_test_ca.cert": "cert.pem", - "canister_http_test_ca.key": "key.pem", + srcmap = { + ":minica.tar": "minica.tar", + ":universal_vm_activation.sh": "activate", + "//ic-os/components:networking/dev-certs/canister_http_test_ca.cert": "cert.pem", + "//ic-os/components:networking/dev-certs/canister_http_test_ca.key": "key.pem", + "//rs/tests/httpbin-rs:httpbin.tar": "httpbin.tar", }, tags = ["manual"], # this target will be built if required as a dependency of another target ) diff --git a/rs/tests/node/BUILD.bazel b/rs/tests/node/BUILD.bazel index 179f4dc2a53b..b2944ab6ec42 100644 --- a/rs/tests/node/BUILD.bazel +++ b/rs/tests/node/BUILD.bazel @@ -50,12 +50,12 @@ system_test( uvm_config_image( name = "root_tests_config_image", testonly = True, - srcs = [ - "//rs/ic_os/device:device_test", - "//rs/ic_os/os_tools/guest_disk:guest_disk_test", - "//rs/ic_os/os_tools/guest_vm_runner:upgrade_device_mapper_test", - "//rs/tests:ubuntu_test_runtime.tar", - ], + srcmap = { + "//rs/ic_os/device:device_test": "device_test", + "//rs/ic_os/os_tools/guest_disk:guest_disk_test": "guest_disk_test", + "//rs/ic_os/os_tools/guest_vm_runner:upgrade_device_mapper_test": "upgrade_device_mapper_test", + "//rs/tests:ubuntu_test_runtime.tar": "ubuntu_test_runtime.tar", + }, tags = ["manual"], ) diff --git a/rs/tests/system_tests.bzl b/rs/tests/system_tests.bzl index 6a74b279751c..45a9fd28b34a 100644 --- a/rs/tests/system_tests.bzl +++ b/rs/tests/system_tests.bzl @@ -327,21 +327,19 @@ def system_test_nns(name, enable_head_nns_variant = True, enable_mainnet_nns_var ) return struct(test_driver_target = mainnet_nns_systest.test_driver_target) -def uvm_config_image(name, tags = None, visibility = None, srcs = None, remap_paths = None, testonly = True): +def uvm_config_image(name, tags = None, visibility = None, srcmap = None, testonly = True): """This macro creates bazel targets for uvm config images. Args: name: This name will be used for the target. tags: Controls execution of targets. "manual" excludes a target from wildcard targets like (..., :*, :all). See: https://bazel.build/reference/test-encyclopedia#tag-conventions visibility: Target visibility controls who may depend on a target. - srcs: Source files that are copied into a vfat image. - remap_paths: Dict that maps a current filename to a desired filename, - e.g. {"activate.sh": "activate"} + srcmap: Dictionary of source files to copy into a vfat image mapped to their desired path in the image. testonly: If True, the target is only available in test configurations. """ native.genrule( name = name + "_size", - srcs = srcs, + srcs = srcmap.keys(), outs = [name + "_size.txt"], cmd = "du --bytes -csL $(SRCS) | awk '$$2 == \"total\" {print 2 * $$1 + 1048576}' > $@", tags = ["manual"], @@ -367,9 +365,8 @@ def uvm_config_image(name, tags = None, visibility = None, srcs = None, remap_pa mcopy( name = name + "_mcopy", - srcs = srcs, + srcmap = srcmap, fs = ":" + name + "_vfat", - remap_paths = remap_paths, tags = ["manual"], target_compatible_with = ["@platforms//os:linux"], visibility = ["//visibility:private"], From bf54f2406e2b49f04260cebd3f4395f734a80b50 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Wed, 11 Feb 2026 21:35:19 +0000 Subject: [PATCH 2/3] trigger From 7cf65b291a3f440967ef1ca43c4516886a87171f Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Wed, 11 Feb 2026 23:02:05 +0000 Subject: [PATCH 3/3] actually remove the remap_paths argument --- bazel/defs.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/bazel/defs.bzl b/bazel/defs.bzl index e3190dd864e1..f964d2aa3941 100644 --- a/bazel/defs.bzl +++ b/bazel/defs.bzl @@ -112,7 +112,6 @@ mcopy = rule( attrs = { "srcmap": attr.label_keyed_string_dict(allow_files = True), "fs": attr.label(allow_single_file = True), - "remap_paths": attr.string_dict(), }, )