Set INCLUDE and LIB env var for actions that actually need them

This makes console output of `bazel build -s` shorter when debugging `CROSSTOOL`.

/cc @meteorcloudy

Closes #5539.

PiperOrigin-RevId: 203899866
diff --git a/tools/cpp/CROSSTOOL.tpl b/tools/cpp/CROSSTOOL.tpl
index 2460b33..0a4b940 100644
--- a/tools/cpp/CROSSTOOL.tpl
+++ b/tools/cpp/CROSSTOOL.tpl
@@ -492,14 +492,6 @@
         value: "%{msvc_env_path}"
       }
       env_entry {
-        key: "INCLUDE"
-        value: "%{msvc_env_include}"
-      }
-      env_entry {
-        key: "LIB"
-        value: "%{msvc_env_lib}"
-      }
-      env_entry {
         key: "TMP"
         value: "%{msvc_env_tmp}"
       }
@@ -508,6 +500,39 @@
         value: "%{msvc_env_tmp}"
       }
     }
+    implies: 'msvc_compile_env'
+    implies: 'msvc_link_env'
+  }
+
+  feature {
+    name: "msvc_compile_env"
+    env_set {
+      action: "c-compile"
+      action: "c++-compile"
+      action: "c++-module-compile"
+      action: "c++-module-codegen"
+      action: "c++-header-parsing"
+      action: "assemble"
+      action: "preprocess-assemble"
+      env_entry {
+        key: "INCLUDE"
+        value: "%{msvc_env_include}"
+      }
+    }
+  }
+
+  feature {
+    name: "msvc_link_env"
+    env_set {
+      action: "c++-link-executable"
+      action: "c++-link-dynamic-library"
+      action: "c++-link-nodeps-dynamic-library"
+      action: "c++-link-static-library"
+      env_entry {
+        key: "LIB"
+        value: "%{msvc_env_lib}"
+      }
+    }
   }
 
   feature {