Add DEPS_SCANNER_OUTPUT_FILE env variable for cpp_module_deps_scanning action

Copybara Import from https://github.com/bazelbuild/rules_cc/pull/428

BEGIN_PUBLIC
Add DEPS_SCANNER_OUTPUT_FILE env variable for cpp_module_deps_scanning action (#428)

see https://github.com/bazelbuild/bazel/pull/22553#discussion_r2169097119

Closes #428
END_PUBLIC

COPYBARA_INTEGRATE_REVIEW=https://github.com/bazelbuild/rules_cc/pull/428 from PikachuHyA:env_entry c668abdc059e3c2963784d764ddd181b24cf1397
PiperOrigin-RevId: 780093903
Change-Id: I0762df638e30054ce33e051522f22ad5a89e633f
diff --git a/cc/private/toolchain/unix_cc_toolchain_config.bzl b/cc/private/toolchain/unix_cc_toolchain_config.bzl
index fcc7a24..ed61d2e 100644
--- a/cc/private/toolchain/unix_cc_toolchain_config.bzl
+++ b/cc/private/toolchain/unix_cc_toolchain_config.bzl
@@ -563,6 +563,20 @@
                 ],
             ),
         ],
+        env_sets = [
+            env_set(
+                actions = [
+                    ACTION_NAMES.cpp_module_deps_scanning,
+                ],
+                env_entries = [
+                    env_entry(
+                        key = "DEPS_SCANNER_OUTPUT_FILE",
+                        value = "%{output_file}",
+                        expand_if_available = "output_file",
+                    ),
+                ],
+            ),
+        ],
     )
 
     fdo_optimize_feature = feature(