From 1ee76510f5dbf632d30975fc3509ef4f609156d2 Mon Sep 17 00:00:00 2001 From: mtklein Date: Mon, 2 Nov 2015 10:20:27 -0800 Subject: 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++ -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 --- src/utils/SkThreadUtils_win.cpp | 3 +++ src/utils/mac/SkCreateCGImageRef.cpp | 6 ++++++ src/utils/mac/SkStream_mac.cpp | 5 +++++ src/utils/win/SkAutoCoInitialize.cpp | 5 +++++ src/utils/win/SkDWrite.cpp | 4 ++++ src/utils/win/SkDWriteFontFileStream.cpp | 4 ++++ src/utils/win/SkDWriteGeometrySink.cpp | 3 +++ src/utils/win/SkHRESULT.cpp | 3 +++ src/utils/win/SkIStream.cpp | 3 +++ src/utils/win/SkWGL_win.cpp | 5 +++++ 10 files changed, 41 insertions(+) (limited to 'src/utils') 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 @@ -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 @@ -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) -- cgit v1.2.3