diff options
author | tfarina <tfarina@chromium.org> | 2014-10-06 10:46:50 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-06 10:46:51 -0700 |
commit | 6b87df2997980218308954ade47df7fdd6680bc7 (patch) | |
tree | 492da565c06966435b40c50bffebeae9c12faad6 /tools | |
parent | 8d56e27ef5d734b4579325be86da6c3ab682345c (diff) |
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
Diffstat (limited to 'tools')
-rw-r--r-- | tools/skdiff.h | 2 | ||||
-rw-r--r-- | tools/skpdiff/SkCLImageDiffer.h | 2 | ||||
-rw-r--r-- | tools/skpdiff/skpdiff_main.cpp | 2 | ||||
-rw-r--r-- | tools/skpdiff/skpdiff_util.cpp | 22 | ||||
-rw-r--r-- | tools/skpdiff/skpdiff_util.h | 2 |
5 files changed, 15 insertions, 15 deletions
diff --git a/tools/skdiff.h b/tools/skdiff.h index 6abaf6c405..e508275eeb 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 6e9c2dc0cf..56eccfbbc9 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 c01767ef14..92f1307eca 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 498f657f9e..4b5d52110b 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 @@ const char* cl_error_to_string(cl_int err) { // 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 @@ double get_seconds() { 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 @@ double get_seconds() { } 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 @@ bool get_directory(const char path[], SkTArray<SkString>* entries) { 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 get_directory(const char path[], SkTArray<SkString>* entries) { } 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 @@ bool glob_files(const char globPattern[], SkTArray<SkString>* entries) { } 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 8750bf6b54..f626ac99df 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> |