aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-11-02 10:20:27 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-02 10:20:27 -0800
commit1ee76510f5dbf632d30975fc3509ef4f609156d2 (patch)
treea2d6b772ec69a735bd37ebdbdc6864cfe823a7cc
parent3f0424ff57f93666df7347d4787816b210233eb0 (diff)
Start making all .cpp files compile-able on all platforms.
I sometimes dream to hone our build process down to something as simple as $ find src -name '*.cpp' | xargs c++ <some cflags> -c -o skia.o To start, it helps if we can compile all files on all platforms. Each non-portable file guards itself with defines provided by SkTypes.h. This does not convert all non-portable code, but it's a good representative chunk. E.g. instead of having to remember which SkDebug_*.cpp to compile on which platform we can just compile all three and let the code itself sort it out. This has the nice side effect of making non-portable code declare the conditions under which it can compile explicitly. I've been testing mostly with the CMake build as it's easiest, but this should apply equally to BUILD, Gyp, and GN files... to any build system really. BUG=skia:4269 CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac10.9-Clang-x86_64-Release-CMake-Trybot Review URL: https://codereview.chromium.org/1411283005
-rw-r--r--cmake/CMakeLists.txt27
-rw-r--r--src/device/xps/SkXPSDevice.cpp2
-rw-r--r--src/doc/SkDocument_XPS.cpp5
-rw-r--r--src/doc/SkDocument_XPS_None.cpp6
-rw-r--r--src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp5
-rw-r--r--src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp4
-rw-r--r--src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp5
-rw-r--r--src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp4
-rw-r--r--src/ports/SkDebug_android.cpp4
-rw-r--r--src/ports/SkDebug_nacl.cpp38
-rw-r--r--src/ports/SkDebug_stdio.cpp2
-rw-r--r--src/ports/SkDebug_win.cpp2
-rw-r--r--src/ports/SkFontHost_mac.cpp3
-rw-r--r--src/ports/SkFontHost_win.cpp5
-rw-r--r--src/ports/SkFontMgr_android.cpp5
-rw-r--r--src/ports/SkFontMgr_android_factory.cpp4
-rw-r--r--src/ports/SkFontMgr_android_parser.cpp2
-rw-r--r--src/ports/SkFontMgr_win_dw.cpp4
-rw-r--r--src/ports/SkFontMgr_win_dw_factory.cpp5
-rw-r--r--src/ports/SkFontMgr_win_gdi_factory.cpp5
-rw-r--r--src/ports/SkImageDecoder_CG.cpp5
-rw-r--r--src/ports/SkImageDecoder_WIC.cpp4
-rw-r--r--src/ports/SkOSFile_win.cpp5
-rw-r--r--src/ports/SkOSLibrary_posix.cpp4
-rw-r--r--src/ports/SkOSLibrary_win.cpp5
-rw-r--r--src/ports/SkRemotableFontMgr_win_dw.cpp3
-rw-r--r--src/ports/SkScalerContext_win_dw.cpp4
-rw-r--r--src/ports/SkTLS_win.cpp4
-rw-r--r--src/ports/SkTime_win.cpp3
-rw-r--r--src/ports/SkTypeface_win_dw.cpp3
-rw-r--r--src/utils/SkThreadUtils_win.cpp3
-rw-r--r--src/utils/mac/SkCreateCGImageRef.cpp6
-rw-r--r--src/utils/mac/SkStream_mac.cpp5
-rw-r--r--src/utils/win/SkAutoCoInitialize.cpp5
-rw-r--r--src/utils/win/SkDWrite.cpp4
-rw-r--r--src/utils/win/SkDWriteFontFileStream.cpp4
-rw-r--r--src/utils/win/SkDWriteGeometrySink.cpp3
-rw-r--r--src/utils/win/SkHRESULT.cpp3
-rw-r--r--src/utils/win/SkIStream.cpp3
-rw-r--r--src/utils/win/SkWGL_win.cpp5
40 files changed, 162 insertions, 56 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 348b72475a..c6614f3fec 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -52,16 +52,8 @@ remove_srcs (../src/ports/SkFontMgr_custom*.cpp)
remove_srcs (../src/animator/* ../src/*nacl* ../src/svg/* ../src/views/* ../src/xml/*)
# Remove OS-specific source files.
-if (NOT WIN32)
- remove_srcs(../src/*XPS*
- ../src/*_win*.cpp
- ../src/ports/SkImageDecoder_WIC.cpp
- ../src/utils/win/*)
-endif()
if (NOT UNIX)
- remove_srcs(../src/doc/SkDocument_XPS_None.cpp
- ../src/ports/*_posix.cpp
- ../src/ports/SkDebug_stdio.cpp
+ remove_srcs(../src/ports/*_posix.cpp
../src/ports/SkTLS_pthread.cpp
../src/ports/SkTime_Unix.cpp
../src/utils/SkThreadUtils_pthread.cpp)
@@ -72,15 +64,6 @@ if (APPLE OR NOT UNIX)
../src/ports/SkFontMgr_fontconfig*.cpp
../src/*FreeType*)
endif()
-if (NOT ANDROID)
- remove_srcs(../src/*Hwui* ../src/*android*)
-endif()
-if (NOT APPLE)
- remove_srcs(../src/*darwin*
- ../src/ports/SkImageDecoder_CG.cpp
- ../src/utils/mac/*
- ../src/*_mac*)
-endif()
# Remove processor-specific source files.
if (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ARM)
@@ -128,6 +111,7 @@ set_source_files_properties(${sse41_srcs} PROPERTIES COMPILE_FLAGS -msse4.1)
# Detect our optional dependencies.
# If we can't find them, don't build the parts of Skia that use them.
+find_package (EXPAT)
find_package (Lua)
find_package (ZLIB)
# No find_package for libwebp as far as I can tell, so simulate it here.
@@ -148,6 +132,13 @@ endif()
# TODO: macro away this if (found) ... else() ... endif() stuff.
+if (EXPAT_FOUND)
+ list (APPEND private_includes ${EXPAT_INCLUDE_DIRS})
+ list (APPEND libs ${EXPAT_LIBRARIES})
+else()
+ remove_srcs (../src/ports/SkFontMgr_android_parser.cpp)
+endif()
+
if (GIF_FOUND)
list (APPEND private_includes ${GIF_INCLUDE_DIRS})
list (APPEND libs ${GIF_LIBRARIES})
diff --git a/src/device/xps/SkXPSDevice.cpp b/src/device/xps/SkXPSDevice.cpp
index 74fda4b3b8..43c5c6cee6 100644
--- a/src/device/xps/SkXPSDevice.cpp
+++ b/src/device/xps/SkXPSDevice.cpp
@@ -6,6 +6,7 @@
*/
#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#ifndef UNICODE
#define UNICODE
@@ -2265,3 +2266,4 @@ SkBaseDevice* SkXPSDevice::onCreateDevice(const CreateInfo& info, const SkPaint*
return new SkXPSDevice(this->fXpsFactory.get());
}
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/doc/SkDocument_XPS.cpp b/src/doc/SkDocument_XPS.cpp
index 57fa0b80c6..0e241d9aaa 100644
--- a/src/doc/SkDocument_XPS.cpp
+++ b/src/doc/SkDocument_XPS.cpp
@@ -5,6 +5,9 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
+
#include "SkDocument.h"
#include "SkXPSDevice.h"
#include "SkStream.h"
@@ -75,3 +78,5 @@ SkDocument* SkDocument::CreateXPS(const char path[], SkScalar dpi) {
}
return new SkDocument_XPS(stream.detach(), delete_wstream, dpi);
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/doc/SkDocument_XPS_None.cpp b/src/doc/SkDocument_XPS_None.cpp
index 9d51ea25d7..32b18fb221 100644
--- a/src/doc/SkDocument_XPS_None.cpp
+++ b/src/doc/SkDocument_XPS_None.cpp
@@ -4,6 +4,12 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
+#include "SkTypes.h"
+#if !defined(SK_BUILD_FOR_WIN32)
+
#include "SkDocument.h"
SkDocument* SkDocument::CreateXPS(SkWStream*, SkScalar) { return nullptr; }
SkDocument* SkDocument::CreateXPS(const char path[], SkScalar) { return nullptr; }
+
+#endif//!defined(SK_BUILD_FOR_WIN32)
diff --git a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
index 39a6673b99..1df4a950c1 100644
--- a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
+++ b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
@@ -5,6 +5,9 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_ANDROID)
+
#include "gl/GrGLInterface.h"
#include "gl/GrGLAssembleInterface.h"
#include "gl/GrGLUtil.h"
@@ -227,3 +230,5 @@ static GrGLFuncPtr android_get_gl_proc(void* ctx, const char name[]) {
const GrGLInterface* GrGLCreateNativeInterface() {
return GrGLAssembleInterface(nullptr, android_get_gl_proc);
}
+
+#endif//defined(SK_BUILD_FOR_ANDROID)
diff --git a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
index 9a2abfe066..83e559339a 100644
--- a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
+++ b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
@@ -5,6 +5,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_MAC)
#include "gl/GrGLInterface.h"
@@ -56,3 +58,5 @@ const GrGLInterface* GrGLCreateNativeInterface() {
GLProcGetter getter;
return GrGLAssembleGLInterface(&getter, mac_get_gl_proc);
}
+
+#endif//defined(SK_BUILD_FOR_MAC)
diff --git a/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp b/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp
index fa4126a62c..41585c8632 100644
--- a/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp
+++ b/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp
@@ -5,6 +5,9 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_MAC)
+
#include "gl/SkGLContext.h"
#include "AvailabilityMacros.h"
@@ -117,3 +120,5 @@ SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) {
}
return ctx;
}
+
+#endif//defined(SK_BUILD_FOR_MAC)
diff --git a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
index c2fcca5469..b0eaa548f1 100644
--- a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
+++ b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
@@ -5,6 +5,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "gl/GrGLInterface.h"
#include "gl/GrGLAssembleInterface.h"
@@ -85,3 +87,5 @@ const GrGLInterface* GrGLCreateNativeInterface() {
}
return nullptr;
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkDebug_android.cpp b/src/ports/SkDebug_android.cpp
index 4ab9ad24d3..0a1b59a2cd 100644
--- a/src/ports/SkDebug_android.cpp
+++ b/src/ports/SkDebug_android.cpp
@@ -6,6 +6,8 @@
*/
#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_ANDROID)
+
#include <stdio.h>
#define LOG_TAG "skia"
@@ -30,3 +32,5 @@ void SkDebugf(const char format[], ...) {
va_end(args1);
}
+
+#endif//defined(SK_BUILD_FOR_ANDROID)
diff --git a/src/ports/SkDebug_nacl.cpp b/src/ports/SkDebug_nacl.cpp
deleted file mode 100644
index 6e35f0965a..0000000000
--- a/src/ports/SkDebug_nacl.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-
-#include "SkTypes.h"
-
-static const size_t kBufferSize = 2048;
-
-#include <stdarg.h>
-#include <stdio.h>
-
-#include "ppapi/cpp/instance.h"
-#include "ppapi/cpp/var.h"
-
-extern pp::Instance* gPluginInstance;
-
-namespace {
-static const char* kLogPrefix = "SkDebugf:";
-}
-
-void SkDebugf(const char format[], ...) {
- if (gPluginInstance) {
- char buffer[kBufferSize + 1];
- va_list args;
- va_start(args, format);
- sprintf(buffer, kLogPrefix);
- vsnprintf(buffer + strlen(kLogPrefix), kBufferSize, format, args);
- va_end(args);
- pp::Var msg = pp::Var(buffer);
- gPluginInstance->PostMessage(msg);
- }
-}
diff --git a/src/ports/SkDebug_stdio.cpp b/src/ports/SkDebug_stdio.cpp
index 9e72d4797e..230c5f2c5d 100644
--- a/src/ports/SkDebug_stdio.cpp
+++ b/src/ports/SkDebug_stdio.cpp
@@ -6,6 +6,7 @@
*/
#include "SkTypes.h"
+#if !defined(SK_BUILD_FOR_WIN32) && !defined(SK_BUILD_FOR_ANDROID)
#include <stdarg.h>
#include <stdio.h>
@@ -16,3 +17,4 @@ void SkDebugf(const char format[], ...) {
vfprintf(stderr, format, args);
va_end(args);
}
+#endif//!defined(SK_BUILD_FOR_WIN32) && !defined(SK_BUILD_FOR_ANDROID)
diff --git a/src/ports/SkDebug_win.cpp b/src/ports/SkDebug_win.cpp
index 67c2397ce5..6e0576652f 100644
--- a/src/ports/SkDebug_win.cpp
+++ b/src/ports/SkDebug_win.cpp
@@ -9,6 +9,7 @@
#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
static const size_t kBufferSize = 2048;
@@ -31,3 +32,4 @@ void SkDebugf(const char format[], ...) {
OutputDebugStringA(buffer);
}
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 772fe74f48..25030be413 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -7,6 +7,7 @@
*/
#include "SkTypes.h" // Keep this before any #ifdef ...
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
#ifdef SK_BUILD_FOR_MAC
#import <ApplicationServices/ApplicationServices.h>
@@ -2491,3 +2492,5 @@ protected:
///////////////////////////////////////////////////////////////////////////////
SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; }
+
+#endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index e263cc28e7..76b876411a 100644
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -5,6 +5,9 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
+
#include "SkAdvancedTypefaceMetrics.h"
#include "SkBase64.h"
#include "SkColorPriv.h"
@@ -2511,3 +2514,5 @@ private:
///////////////////////////////////////////////////////////////////////////////
SkFontMgr* SkFontMgr_New_GDI() { return new SkFontMgrGDI; }
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp
index 0fd121e5ca..11244c55ee 100644
--- a/src/ports/SkFontMgr_android.cpp
+++ b/src/ports/SkFontMgr_android.cpp
@@ -5,6 +5,9 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_ANDROID)
+
#include "SkFixed.h"
#include "SkFontDescriptor.h"
#include "SkFontHost_FreeType_common.h"
@@ -586,3 +589,5 @@ SkFontMgr* SkFontMgr_New_Android(const SkFontMgr_Android_CustomFonts* custom) {
return new SkFontMgr_Android(custom);
}
+
+#endif//defined(SK_BUILD_FOR_ANDROID)
diff --git a/src/ports/SkFontMgr_android_factory.cpp b/src/ports/SkFontMgr_android_factory.cpp
index 96d89314d0..99f654d838 100644
--- a/src/ports/SkFontMgr_android_factory.cpp
+++ b/src/ports/SkFontMgr_android_factory.cpp
@@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_ANDROID)
#include "SkFontMgr.h"
#include "SkFontMgr_android.h"
@@ -41,3 +43,5 @@ SkFontMgr* SkFontMgr::Factory() {
return SkFontMgr_New_Android(nullptr);
}
+
+#endif//defined(SK_BUILD_FOR_ANDROID)
diff --git a/src/ports/SkFontMgr_android_parser.cpp b/src/ports/SkFontMgr_android_parser.cpp
index 83b1c4aa3b..ba2296bffa 100644
--- a/src/ports/SkFontMgr_android_parser.cpp
+++ b/src/ports/SkFontMgr_android_parser.cpp
@@ -5,6 +5,8 @@
* found in the LICENSE file.
*/
+// Despite the name and location, this is portable code.
+
#include "SkFontMgr_android_parser.h"
#include "SkStream.h"
#include "SkTDArray.h"
diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp
index e40c5e4faa..585d809406 100644
--- a/src/ports/SkFontMgr_win_dw.cpp
+++ b/src/ports/SkFontMgr_win_dw.cpp
@@ -5,6 +5,9 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
+
#include "SkDWrite.h"
#include "SkDWriteFontFileStream.h"
#include "SkFontMgr.h"
@@ -1103,3 +1106,4 @@ SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) {
}
return new SkFontMgr_Indirect(impl.get(), proxy);
}
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkFontMgr_win_dw_factory.cpp b/src/ports/SkFontMgr_win_dw_factory.cpp
index 85ed56d695..52e22aec52 100644
--- a/src/ports/SkFontMgr_win_dw_factory.cpp
+++ b/src/ports/SkFontMgr_win_dw_factory.cpp
@@ -5,9 +5,14 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32) // And !SKIA_GDI?
+
#include "SkFontMgr.h"
#include "SkTypeface_win.h"
SkFontMgr* SkFontMgr::Factory() {
return SkFontMgr_New_DirectWrite();
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkFontMgr_win_gdi_factory.cpp b/src/ports/SkFontMgr_win_gdi_factory.cpp
index de68ae8d30..c1ca822c28 100644
--- a/src/ports/SkFontMgr_win_gdi_factory.cpp
+++ b/src/ports/SkFontMgr_win_gdi_factory.cpp
@@ -5,9 +5,14 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32) // And SKIA_GDI?
+
#include "SkFontMgr.h"
#include "SkTypeface_win.h"
SkFontMgr* SkFontMgr::Factory() {
return SkFontMgr_New_GDI();
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp
index bd94764c3a..4be5874253 100644
--- a/src/ports/SkImageDecoder_CG.cpp
+++ b/src/ports/SkImageDecoder_CG.cpp
@@ -5,6 +5,9 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
+
#include "SkCGUtils.h"
#include "SkColorPriv.h"
#include "SkImageDecoder.h"
@@ -401,3 +404,5 @@ static SkImageDecoder::Format get_format_cg(SkStreamRewindable* stream) {
}
static SkImageDecoder_FormatReg gFormatReg(get_format_cg);
+
+#endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
diff --git a/src/ports/SkImageDecoder_WIC.cpp b/src/ports/SkImageDecoder_WIC.cpp
index 3cc9a32b68..fa408836a4 100644
--- a/src/ports/SkImageDecoder_WIC.cpp
+++ b/src/ports/SkImageDecoder_WIC.cpp
@@ -8,6 +8,8 @@
#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
+
// Workaround for:
// http://connect.microsoft.com/VisualStudio/feedback/details/621653/
// http://crbug.com/225822
@@ -462,3 +464,5 @@ static SkImageDecoder::Format get_format_wic(SkStreamRewindable* stream) {
}
static SkImageDecoder_FormatReg gFormatReg(get_format_wic);
+
+#endif // defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkOSFile_win.cpp b/src/ports/SkOSFile_win.cpp
index 14af458a44..395a3c80a9 100644
--- a/src/ports/SkOSFile_win.cpp
+++ b/src/ports/SkOSFile_win.cpp
@@ -5,6 +5,9 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
+
#include "SkOSFile.h"
#include "SkTFitsIn.h"
@@ -240,3 +243,5 @@ bool SkOSFile::Iter::next(SkString* name, bool getDir) {
}
return self.fHandle != (HANDLE)~0 && get_the_file(self.fHandle, name, dataPtr, getDir);
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkOSLibrary_posix.cpp b/src/ports/SkOSLibrary_posix.cpp
index cca55f16a1..1571e20085 100644
--- a/src/ports/SkOSLibrary_posix.cpp
+++ b/src/ports/SkOSLibrary_posix.cpp
@@ -5,6 +5,9 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if !defined(SK_BUILD_FOR_WIN32)
+
#include "SkOSLibrary.h"
#include <dlfcn.h>
@@ -16,3 +19,4 @@ void* DynamicLoadLibrary(const char* libraryName) {
void* GetProcedureAddress(void* library, const char* functionName) {
return dlsym(library, functionName);
}
+#endif//!defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkOSLibrary_win.cpp b/src/ports/SkOSLibrary_win.cpp
index ca80415391..69754db375 100644
--- a/src/ports/SkOSLibrary_win.cpp
+++ b/src/ports/SkOSLibrary_win.cpp
@@ -5,6 +5,9 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
+
#include "SkOSLibrary.h"
#include <windows.h>
@@ -15,3 +18,5 @@ void* DynamicLoadLibrary(const char* libraryName) {
void* GetProcedureAddress(void* library, const char* functionName) {
return ::GetProcAddress((HMODULE)library, functionName);
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkRemotableFontMgr_win_dw.cpp b/src/ports/SkRemotableFontMgr_win_dw.cpp
index aaef3a40a9..6c021a1ca6 100644
--- a/src/ports/SkRemotableFontMgr_win_dw.cpp
+++ b/src/ports/SkRemotableFontMgr_win_dw.cpp
@@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkDWrite.h"
#include "SkDWriteFontFileStream.h"
@@ -504,3 +506,4 @@ SkRemotableFontMgr* SkRemotableFontMgr_New_DirectWrite() {
return new SkRemotableFontMgr_DirectWrite(sysFontCollection.get(), localeName, localeNameLen);
}
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkScalerContext_win_dw.cpp b/src/ports/SkScalerContext_win_dw.cpp
index 3a2db14e57..097db865e1 100644
--- a/src/ports/SkScalerContext_win_dw.cpp
+++ b/src/ports/SkScalerContext_win_dw.cpp
@@ -6,6 +6,8 @@
*/
#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
+
#undef GetGlyphIndices
#include "SkDWrite.h"
@@ -776,3 +778,5 @@ void SkScalerContext_DW::generatePath(const SkGlyph& glyph, SkPath* path) {
path->transform(fSkXform);
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkTLS_win.cpp b/src/ports/SkTLS_win.cpp
index cdfb465a7e..8bc55a0f2c 100644
--- a/src/ports/SkTLS_win.cpp
+++ b/src/ports/SkTLS_win.cpp
@@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkTLS.h"
#include "SkMutex.h"
@@ -73,3 +75,5 @@ PIMAGE_TLS_CALLBACK skia_tls_callback = onTLSCallback;
#endif
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkTime_win.cpp b/src/ports/SkTime_win.cpp
index 2bd5062c3c..2589d43d44 100644
--- a/src/ports/SkTime_win.cpp
+++ b/src/ports/SkTime_win.cpp
@@ -5,6 +5,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkTime.h"
@@ -39,3 +41,4 @@ void SkTime::GetDateTime(DateTime* dt)
dt->fSecond = SkToU8(st.wSecond);
}
}
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/ports/SkTypeface_win_dw.cpp b/src/ports/SkTypeface_win_dw.cpp
index 144d4c7367..38d09e85ec 100644
--- a/src/ports/SkTypeface_win_dw.cpp
+++ b/src/ports/SkTypeface_win_dw.cpp
@@ -6,6 +6,8 @@
*/
#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
+
// SkTypes will include Windows.h, which will pull in all of the GDI defines.
// GDI #defines GetGlyphIndices to GetGlyphIndicesA or GetGlyphIndicesW, but
// IDWriteFontFace has a method called GetGlyphIndices. Since this file does
@@ -459,3 +461,4 @@ SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics(
return info;
}
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/SkThreadUtils_win.cpp b/src/utils/SkThreadUtils_win.cpp
index 07cceee142..0da339aa84 100644
--- a/src/utils/SkThreadUtils_win.cpp
+++ b/src/utils/SkThreadUtils_win.cpp
@@ -6,6 +6,7 @@
*/
#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkThreadUtils.h"
#include "SkThreadUtils_win.h"
@@ -96,3 +97,5 @@ void SkThread::join() {
WaitForSingleObject(winData->fHandle, INFINITE);
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/mac/SkCreateCGImageRef.cpp b/src/utils/mac/SkCreateCGImageRef.cpp
index 0cbf704a41..3fd9057c35 100644
--- a/src/utils/mac/SkCreateCGImageRef.cpp
+++ b/src/utils/mac/SkCreateCGImageRef.cpp
@@ -5,6 +5,10 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
+
#include "SkCGUtils.h"
#include "SkBitmap.h"
#include "SkColorPriv.h"
@@ -306,3 +310,5 @@ bool SkCreateBitmapFromCGImage(SkBitmap* dst, CGImageRef image, SkISize* scaleTo
*dst = tmp;
return true;
}
+
+#endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
diff --git a/src/utils/mac/SkStream_mac.cpp b/src/utils/mac/SkStream_mac.cpp
index e62ced220f..36e5194a19 100644
--- a/src/utils/mac/SkStream_mac.cpp
+++ b/src/utils/mac/SkStream_mac.cpp
@@ -5,6 +5,9 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
+
#include "SkCGUtils.h"
#include "SkStream.h"
@@ -74,3 +77,5 @@ CGDataProviderRef SkCreateDataProviderFromData(SkData* data) {
return CGDataProviderCreateWithData(data, data->data(), data->size(),
unref_proc);
}
+
+#endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
diff --git a/src/utils/win/SkAutoCoInitialize.cpp b/src/utils/win/SkAutoCoInitialize.cpp
index 78326a5608..83f23bda0b 100644
--- a/src/utils/win/SkAutoCoInitialize.cpp
+++ b/src/utils/win/SkAutoCoInitialize.cpp
@@ -6,6 +6,9 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
+
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -27,3 +30,5 @@ SkAutoCoInitialize::~SkAutoCoInitialize() {
bool SkAutoCoInitialize::succeeded() {
return SUCCEEDED(this->fHR) || RPC_E_CHANGED_MODE == this->fHR;
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/win/SkDWrite.cpp b/src/utils/win/SkDWrite.cpp
index 2254961d14..2fdd6115b0 100644
--- a/src/utils/win/SkDWrite.cpp
+++ b/src/utils/win/SkDWrite.cpp
@@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkDWrite.h"
#include "SkHRESULT.h"
@@ -122,3 +124,5 @@ HRESULT SkGetGetUserDefaultLocaleNameProc(SkGetUserDefaultLocaleNameProc* proc)
}
return S_OK;
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/win/SkDWriteFontFileStream.cpp b/src/utils/win/SkDWriteFontFileStream.cpp
index 0e3d4fc202..d4bf8a2023 100644
--- a/src/utils/win/SkDWriteFontFileStream.cpp
+++ b/src/utils/win/SkDWriteFontFileStream.cpp
@@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkTypes.h"
#include "SkDWriteFontFileStream.h"
@@ -229,3 +231,5 @@ HRESULT STDMETHODCALLTYPE SkDWriteFontFileStreamWrapper::GetLastWriteTime(UINT64
*lastWriteTime = 0;
return E_NOTIMPL;
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/win/SkDWriteGeometrySink.cpp b/src/utils/win/SkDWriteGeometrySink.cpp
index 066d4a4674..9f6a97caf1 100644
--- a/src/utils/win/SkDWriteGeometrySink.cpp
+++ b/src/utils/win/SkDWriteGeometrySink.cpp
@@ -6,6 +6,7 @@
*/
#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkDWriteGeometrySink.h"
#include "SkFloatUtils.h"
@@ -144,3 +145,5 @@ HRESULT SkDWriteGeometrySink::Create(SkPath* path, IDWriteGeometrySink** geometr
*geometryToPath = new SkDWriteGeometrySink(path);
return S_OK;
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/win/SkHRESULT.cpp b/src/utils/win/SkHRESULT.cpp
index d565986d10..d95629961b 100644
--- a/src/utils/win/SkHRESULT.cpp
+++ b/src/utils/win/SkHRESULT.cpp
@@ -6,6 +6,7 @@
*/
#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkHRESULT.h"
@@ -35,3 +36,5 @@ void SkTraceHR(const char* file, unsigned long line, HRESULT hr, const char* msg
errorText = nullptr;
}
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/win/SkIStream.cpp b/src/utils/win/SkIStream.cpp
index f1dbcb274c..fdb6ce6eff 100644
--- a/src/utils/win/SkIStream.cpp
+++ b/src/utils/win/SkIStream.cpp
@@ -6,6 +6,8 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -275,3 +277,4 @@ HRESULT STDMETHODCALLTYPE SkWIStream::Stat(STATSTG* pStatstg
pStatstg->grfMode = STGM_WRITE;
return S_OK;
}
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/win/SkWGL_win.cpp b/src/utils/win/SkWGL_win.cpp
index ef07bea61e..bc22795e2f 100644
--- a/src/utils/win/SkWGL_win.cpp
+++ b/src/utils/win/SkWGL_win.cpp
@@ -6,6 +6,9 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
+
#include "SkWGL.h"
#include "SkTDArray.h"
@@ -455,3 +458,5 @@ SkWGLPbufferContext::SkWGLPbufferContext(HPBUFFER pbuffer, HDC dc, HGLRC glrc)
, fDC(dc)
, fGLRC(glrc) {
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)