diff options
author | Loo Rong Jie <loorongjie@gmail.com> | 2018-06-11 02:04:52 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-11 02:06:38 -0700 |
commit | 4022bac855a790b3a42fcb44c06f62dbbe078c5a (patch) | |
tree | c4f4a7b5fb602020c724b23e3ffcca3804e1207f /src/main/cpp | |
parent | 2c89206a407d8cae0945abe7eb179ee6bb77d9de (diff) |
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
Diffstat (limited to 'src/main/cpp')
-rw-r--r-- | src/main/cpp/blaze_util_platform.h | 2 | ||||
-rw-r--r-- | src/main/cpp/option_processor.cc | 8 | ||||
-rw-r--r-- | src/main/cpp/startup_options.cc | 8 | ||||
-rw-r--r-- | src/main/cpp/startup_options.h | 2 | ||||
-rw-r--r-- | src/main/cpp/util/file_platform.h | 10 | ||||
-rw-r--r-- | src/main/cpp/util/md5.h | 4 | ||||
-rw-r--r-- | src/main/cpp/util/path_platform.h | 4 | ||||
-rw-r--r-- | src/main/cpp/util/port.h | 4 |
8 files changed, 21 insertions, 21 deletions
diff --git a/src/main/cpp/blaze_util_platform.h b/src/main/cpp/blaze_util_platform.h index f08aa567e4..078e2711ca 100644 --- a/src/main/cpp/blaze_util_platform.h +++ b/src/main/cpp/blaze_util_platform.h @@ -128,7 +128,7 @@ extern const char kListSeparator; bool SymlinkDirectories(const std::string& target, const std::string& link); struct BlazeLock { -#if defined(COMPILER_MSVC) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__CYGWIN__) /* HANDLE */ void* handle; #else int lockfd; diff --git a/src/main/cpp/option_processor.cc b/src/main/cpp/option_processor.cc index c2f480f545..582833ab88 100644 --- a/src/main/cpp/option_processor.cc +++ b/src/main/cpp/option_processor.cc @@ -387,7 +387,7 @@ blaze_exit_code::ExitCode OptionProcessor::ParseStartupOptions( } static bool IsValidEnvName(const char* p) { -#if defined(COMPILER_MSVC) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__CYGWIN__) for (; *p && *p != '='; ++p) { if (!((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9') || *p == '_')) { @@ -398,7 +398,7 @@ static bool IsValidEnvName(const char* p) { return true; } -#if defined(COMPILER_MSVC) +#if defined(_WIN32) static void PreprocessEnvString(string* env_str) { static constexpr const char* vars_to_uppercase[] = {"PATH", "SYSTEMROOT", "TEMP", "TEMPDIR", "TMP"}; @@ -415,7 +415,7 @@ static void PreprocessEnvString(string* env_str) { } } -#elif defined(__CYGWIN__) // not defined(COMPILER_MSVC) +#elif defined(__CYGWIN__) // not defined(_WIN32) static void PreprocessEnvString(string* env_str) { int pos = env_str->find_first_of('='); @@ -435,7 +435,7 @@ static void PreprocessEnvString(string* env_str) { static void PreprocessEnvString(const string* env_str) { // do nothing. } -#endif // defined(COMPILER_MSVC) +#endif // defined(_WIN32) static std::vector<std::string> GetProcessedEnv() { std::vector<std::string> processed_env; diff --git a/src/main/cpp/startup_options.cc b/src/main/cpp/startup_options.cc index 67e0d55add..8f028f55c6 100644 --- a/src/main/cpp/startup_options.cc +++ b/src/main/cpp/startup_options.cc @@ -108,13 +108,13 @@ StartupOptions::StartupOptions(const string &product_name, << "'."; } -#if defined(COMPILER_MSVC) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__CYGWIN__) string windows_unix_root = WindowsUnixRoot(blaze::GetEnv("BAZEL_SH")); if (!windows_unix_root.empty()) { host_jvm_args.push_back(string("-Dbazel.windows_unix_root=") + windows_unix_root); } -#endif // defined(COMPILER_MSVC) || defined(__CYGWIN__) +#endif // defined(_WIN32) || defined(__CYGWIN__) const string product_name_lower = GetLowercaseProductName(); output_user_root = blaze_util::JoinPath( @@ -528,7 +528,7 @@ blaze_exit_code::ExitCode StartupOptions::AddJVMMemoryArguments( return blaze_exit_code::SUCCESS; } -#if defined(COMPILER_MSVC) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__CYGWIN__) // Extract the Windows path of "/" from $BAZEL_SH. // $BAZEL_SH usually has the form `<prefix>/usr/bin/bash.exe` or // `<prefix>/bin/bash.exe`, and this method returns that `<prefix>` part. @@ -554,6 +554,6 @@ string StartupOptions::WindowsUnixRoot(const string &bazel_sh) { return split.first; } } -#endif // defined(COMPILER_MSVC) || defined(__CYGWIN__) +#endif // defined(_WIN32) || defined(__CYGWIN__) } // namespace blaze diff --git a/src/main/cpp/startup_options.h b/src/main/cpp/startup_options.h index f6ffd25b6e..84079f1b3f 100644 --- a/src/main/cpp/startup_options.h +++ b/src/main/cpp/startup_options.h @@ -312,7 +312,7 @@ class StartupOptions { // Contains the collection of startup flags that Bazel accepts. std::set<std::unique_ptr<StartupFlag>> valid_startup_flags; -#if defined(COMPILER_MSVC) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__CYGWIN__) static std::string WindowsUnixRoot(const std::string &bazel_sh); #endif }; diff --git a/src/main/cpp/util/file_platform.h b/src/main/cpp/util/file_platform.h index ac4fc3ab00..861ca9e997 100644 --- a/src/main/cpp/util/file_platform.h +++ b/src/main/cpp/util/file_platform.h @@ -50,7 +50,7 @@ class IFileMtime { // 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 @@ IFileMtime *CreateFileMtime(); // (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 @@ class DirectoryEntryConsumer { 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 d153a44ad4..3bf1acf433 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 1f14bd6ab0..9653a676bb 100644 --- a/src/main/cpp/util/path_platform.h +++ b/src/main/cpp/util/path_platform.h @@ -59,7 +59,7 @@ std::string MakeAbsolute(const std::string &path); // 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 @@ bool IsPathSeparator(char_type ch); 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 ea5f560330..fa5a600cbf 100644 --- a/src/main/cpp/util/port.h +++ b/src/main/cpp/util/port.h @@ -135,12 +135,12 @@ char (&ArraySizeHelper(const T (&array)[N]))[N]; #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_ |