Remove usage of COMPILER_MSVC in Bazel and ijar

Convert most `COMPILER_MSVC` to `_WIN32` (as they apply to Windows platform, not MSVC compiler). Only `src/tools/singlejar/zip_headers.h` and `src/main/cpp/util/md5.h` actually need `_MSC_VER`.

`COMPILER_MSVC` in `third_party/protobuf` are not removed. They can be fixed by updating dependency to newer version.

/cc @meteorcloudy

Closes #5350.

Change-Id: Ibc131abfaf34a0cb2bd338549983ea9d28eaabfe
PiperOrigin-RevId: 200019793
diff --git a/src/main/cpp/util/file_platform.h b/src/main/cpp/util/file_platform.h
index ac4fc3a..861ca9e9 100644
--- a/src/main/cpp/util/file_platform.h
+++ b/src/main/cpp/util/file_platform.h
@@ -50,7 +50,7 @@
 // Creates a platform-specific implementation of `IFileMtime`.
 IFileMtime *CreateFileMtime();
 
-#if defined(COMPILER_MSVC) || defined(__CYGWIN__)
+#if defined(_WIN32) || defined(__CYGWIN__)
 // We cannot include <windows.h> because it #defines many symbols that conflict
 // with our function names, e.g. GetUserName, SendMessage.
 // Instead of typedef'ing HANDLE, let's use the actual type, void*. If that ever
@@ -58,9 +58,9 @@
 // (very unlikely, given how fundamental this type is in Windows), then we'd get
 // a compilation error.
 typedef /* HANDLE */ void *file_handle_type;
-#else   // !(defined(COMPILER_MSVC) || defined(__CYGWIN__))
+#else   // !(defined(_WIN32) || defined(__CYGWIN__))
 typedef int file_handle_type;
-#endif  // defined(COMPILER_MSVC) || defined(__CYGWIN__)
+#endif  // defined(_WIN32) || defined(__CYGWIN__)
 
 // Result of a `ReadFromHandle` operation.
 //
@@ -199,9 +199,9 @@
 void ForEachDirectoryEntry(const std::string &path,
                            DirectoryEntryConsumer *consume);
 
-#if defined(COMPILER_MSVC) || defined(__CYGWIN__)
+#if defined(_WIN32) || defined(__CYGWIN__)
 std::wstring GetCwdW();
-#endif  // defined(COMPILER_MSVC) || defined(__CYGWIN__)
+#endif  // defined(_WIN32) || defined(__CYGWIN__)
 
 }  // namespace blaze_util
 
diff --git a/src/main/cpp/util/md5.h b/src/main/cpp/util/md5.h
index d153a44..3bf1acf 100644
--- a/src/main/cpp/util/md5.h
+++ b/src/main/cpp/util/md5.h
@@ -20,9 +20,9 @@
 
 #include <string>
 
-#if defined(COMPILER_MSVC) && !defined(__alignof__)
+#if defined(_MSC_VER) && !defined(__alignof__)
 #define __alignof__ __alignof
-#endif  // COMPILER_MSVC && !__alignof__
+#endif  // _MSC_VER && !__alignof__
 
 namespace blaze_util {
 
diff --git a/src/main/cpp/util/path_platform.h b/src/main/cpp/util/path_platform.h
index 1f14bd6..9653a67 100644
--- a/src/main/cpp/util/path_platform.h
+++ b/src/main/cpp/util/path_platform.h
@@ -59,7 +59,7 @@
 // are included by an import statement. The downside to this gain in clarity
 // is that this would add more complexity to the implementation file(s)? of
 // path.h, which would have to have the platform-specific implementations.
-#if defined(COMPILER_MSVC) || defined(__CYGWIN__)
+#if defined(_WIN32) || defined(__CYGWIN__)
 const wchar_t *RemoveUncPrefixMaybe(const wchar_t *ptr);
 void AddUncPrefixMaybe(std::wstring *path);
 
@@ -122,7 +122,7 @@
 template <typename char_type>
 bool HasDriveSpecifierPrefix(const char_type *ch);
 
-#endif  // defined(COMPILER_MSVC) || defined(__CYGWIN__)
+#endif  // defined(_WIN32) || defined(__CYGWIN__)
 }  // namespace blaze_util
 
 #endif  // BAZEL_SRC_MAIN_CPP_UTIL_PATH_PLATFORM_H_
diff --git a/src/main/cpp/util/port.h b/src/main/cpp/util/port.h
index ea5f560..fa5a600 100644
--- a/src/main/cpp/util/port.h
+++ b/src/main/cpp/util/port.h
@@ -135,12 +135,12 @@
 
 #define arraysize(array) (sizeof(ArraySizeHelper(array)))
 
-#ifdef COMPILER_MSVC
+#ifdef _WIN32
 // TODO(laszlocsomor) 2016-11-28: move pid_t usage out of global_variables.h and
 // whereever else it appears. Find some way to not have to declare a pid_t here,
 // either by making PID handling platform-independent or some other idea; remove
 // the following typedef afterwards.
 typedef int pid_t;
-#endif  // COMPILER_MSVC
+#endif  // _WIN32
 
 #endif  // BAZEL_SRC_MAIN_CPP_UTIL_PORT_H_