Fix usage of SK_BUILD_* defines.
Since we just 'define' them, but not attribute anything to them, like
'1' for example, cpp expands it to nothing and that breaks the "#if"
clauses.
To fix that, uses "#if defined(...)" which will correctly check if your
macro name was defined or not.
BUG=skia:2850
TEST=make most
R=robertphillips@google.com
Review URL: https://codereview.chromium.org/628763005
diff --git a/dm/DMWriteTask.cpp b/dm/DMWriteTask.cpp
index 7d0df94..819d7e8 100644
--- a/dm/DMWriteTask.cpp
+++ b/dm/DMWriteTask.cpp
@@ -119,7 +119,7 @@
}
SkString dir(FLAGS_writePath[0]);
-#if SK_BUILD_FOR_IOS
+#if defined(SK_BUILD_FOR_IOS)
if (dir.equals("@")) {
dir.set(FLAGS_resourcePath[0]);
}
diff --git a/src/core/SkUtilsArm.cpp b/src/core/SkUtilsArm.cpp
index 1ff5bf0..9fd19a5 100644
--- a/src/core/SkUtilsArm.cpp
+++ b/src/core/SkUtilsArm.cpp
@@ -16,7 +16,7 @@
#include <string.h>
#include <pthread.h>
-#if SK_BUILD_FOR_ANDROID
+#if defined(SK_BUILD_FOR_ANDROID)
# include <cpu-features.h>
#endif
diff --git a/tools/skdiff.h b/tools/skdiff.h
index 6abaf6c..e508275 100644
--- a/tools/skdiff.h
+++ b/tools/skdiff.h
@@ -14,7 +14,7 @@
#include "SkString.h"
#include "SkTDArray.h"
-#if SK_BUILD_FOR_WIN32
+#if defined(SK_BUILD_FOR_WIN32)
#define PATH_DIV_STR "\\"
#define PATH_DIV_CHAR '\\'
#else
diff --git a/tools/skpdiff/SkCLImageDiffer.h b/tools/skpdiff/SkCLImageDiffer.h
index 6e9c2dc..56eccfb 100644
--- a/tools/skpdiff/SkCLImageDiffer.h
+++ b/tools/skpdiff/SkCLImageDiffer.h
@@ -8,7 +8,7 @@
#ifndef SkCLImageDiffer_DEFINED
#define SkCLImageDiffer_DEFINED
-#if SK_BUILD_FOR_MAC
+#if defined(SK_BUILD_FOR_MAC)
# include <OpenCL/cl.h>
#else
# include <CL/cl.h>
diff --git a/tools/skpdiff/skpdiff_main.cpp b/tools/skpdiff/skpdiff_main.cpp
index c01767e..92f1307 100644
--- a/tools/skpdiff/skpdiff_main.cpp
+++ b/tools/skpdiff/skpdiff_main.cpp
@@ -14,7 +14,7 @@
#define __NO_STD_VECTOR // Uses cl::vectpr instead of std::vectpr
#define __NO_STD_STRING // Uses cl::STRING_CLASS instead of std::string
-#if SK_BUILD_FOR_MAC
+#if defined(SK_BUILD_FOR_MAC)
// Note that some macs don't have this header and it can be downloaded from the Khronos registry
# include <OpenCL/cl.hpp>
#else
diff --git a/tools/skpdiff/skpdiff_util.cpp b/tools/skpdiff/skpdiff_util.cpp
index 498f657..4b5d521 100644
--- a/tools/skpdiff/skpdiff_util.cpp
+++ b/tools/skpdiff/skpdiff_util.cpp
@@ -5,21 +5,21 @@
* found in the LICENSE file.
*/
-#if SK_BUILD_FOR_MAC || SK_BUILD_FOR_UNIX || SK_BUILD_FOR_ANDROID
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
# include <unistd.h>
# include <sys/time.h>
# include <dirent.h>
#endif
-#if SK_BUILD_FOR_MAC || SK_BUILD_FOR_UNIX
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX)
# include <glob.h>
#endif
-#if SK_BUILD_FOR_MAC
+#if defined(SK_BUILD_FOR_MAC)
# include <sys/syslimits.h> // PATH_MAX is here for Macs
#endif
-#if SK_BUILD_FOR_WIN32
+#if defined(SK_BUILD_FOR_WIN32)
# include <windows.h>
#endif
@@ -85,7 +85,7 @@
// TODO refactor Timer to be used here
double get_seconds() {
-#if SK_BUILD_FOR_WIN32
+#if defined(SK_BUILD_FOR_WIN32)
LARGE_INTEGER currentTime;
LARGE_INTEGER frequency;
QueryPerformanceCounter(¤tTime);
@@ -95,7 +95,7 @@
struct timespec currentTime;
clock_gettime(CLOCK_REALTIME, ¤tTime);
return currentTime.tv_sec + (double)currentTime.tv_nsec / 1e9;
-#elif SK_BUILD_FOR_MAC || SK_BUILD_FOR_UNIX || SK_BUILD_FOR_ANDROID
+#elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
struct timeval currentTime;
gettimeofday(¤tTime, NULL);
return currentTime.tv_sec + (double)currentTime.tv_usec / 1e6;
@@ -105,7 +105,7 @@
}
bool get_directory(const char path[], SkTArray<SkString>* entries) {
-#if SK_BUILD_FOR_MAC || SK_BUILD_FOR_UNIX || SK_BUILD_FOR_ANDROID
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
// Open the directory and check for success
DIR* dir = opendir(path);
if (NULL == dir) {
@@ -128,7 +128,7 @@
closedir(dir);
return true;
-#elif SK_BUILD_FOR_WIN32
+#elif defined(SK_BUILD_FOR_WIN32)
char pathDirGlob[MAX_PATH];
size_t pathLength = strlen(path);
strncpy(pathDirGlob, path, pathLength);
@@ -164,7 +164,7 @@
}
bool glob_files(const char globPattern[], SkTArray<SkString>* entries) {
-#if SK_BUILD_FOR_MAC || SK_BUILD_FOR_UNIX
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX)
// TODO Make sure this works on windows. This may require use of FindNextFile windows function.
glob_t globBuffer;
if (glob(globPattern, 0, NULL, &globBuffer) != 0) {
@@ -188,13 +188,13 @@
}
SkString get_absolute_path(const SkString& path) {
-#if SK_BUILD_FOR_MAC || SK_BUILD_FOR_UNIX || SK_BUILD_FOR_ANDROID
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
SkString fullPath(PATH_MAX + 1);
if (realpath(path.c_str(), fullPath.writable_str()) == NULL) {
fullPath.reset();
}
return fullPath;
-#elif SK_BUILD_FOR_WIN32
+#elif defined(SK_BUILD_FOR_WIN32)
SkString fullPath(MAX_PATH);
if (_fullpath(fullPath.writable_str(), path.c_str(), MAX_PATH) == NULL) {
fullPath.reset();
diff --git a/tools/skpdiff/skpdiff_util.h b/tools/skpdiff/skpdiff_util.h
index 8750bf6..f626ac9 100644
--- a/tools/skpdiff/skpdiff_util.h
+++ b/tools/skpdiff/skpdiff_util.h
@@ -12,7 +12,7 @@
#include "SkTArray.h"
#if SK_SUPPORT_OPENCL
-#if SK_BUILD_FOR_MAC
+#if defined(SK_BUILD_FOR_MAC)
# include <OpenCL/cl.h>
#else
# include <CL/cl.h>