[Libreoffice-commits] core.git: Branch 'private/llunak/skia' - 6 commits - external/skia solenv/clang-format solenv/gbuild vcl/inc vcl/Library_vclplug_gen.mk vcl/opengl vcl/skia vcl/unx

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 3 23:27:31 UTC 2019


Rebased ref, commits from common ancestor:
commit 50bdecc398b496fda948568bb97caf78bb5b2112
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Oct 3 16:00:13 2019 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Fri Oct 4 01:26:04 2019 +0200

    ok, skia on linux actually really needs -DSK_R32_SHIFT=16
    
    Otherwise the RGB order is swapped.
    Interestingly SkSurface::makeImageSnapshot() then returns the non-native
    32bit format, but that doesn't seem to actually matter.
    
    Change-Id: I5ab2f339e1a8d3a73bf0a76c640051e0e96e5d59

diff --git a/external/skia/Library_skia.mk b/external/skia/Library_skia.mk
index 6fde1684de44..60eb173f9628 100644
--- a/external/skia/Library_skia.mk
+++ b/external/skia/Library_skia.mk
@@ -68,6 +68,7 @@ $(eval $(call gb_Library_use_system_win32_libs,skia,\
 else
 $(eval $(call gb_Library_add_defs,skia,\
 	-DSK_BUILD_FOR_UNIX \
+	-DSK_R32_SHIFT=16 \
 ))
 
 # TODO
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 332a5972bab2..b066569e1a45 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -45,7 +45,6 @@ static bool isValidBitCount(sal_uInt16 nBitCount)
 
 SkiaSalBitmap::SkiaSalBitmap(const SkImage& image)
 {
-    assert(image.colorType() == kN32_SkColorType);
     if (Create(Size(image.width(), image.height()), 32, BitmapPalette()))
     {
         SkCanvas canvas(mBitmap);
commit a71e6c5c13b9b8d8fe6037ee3997252fdc0001ec
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Oct 3 15:47:08 2019 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Fri Oct 4 01:26:03 2019 +0200

    implement skia x11 cairo text drawing
    
    Change-Id: Id7d29980d2ea82b98e478e24b7e3189c31fa7257

diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index c72c5979464d..28f088179611 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -183,6 +183,8 @@ public:
     virtual bool drawGradient(const tools::PolyPolygon& rPolygon,
                               const Gradient& rGradient) override;
 
+    void drawBitmap(const SalTwoRect& rPosAry, const SkBitmap& bitmap);
+
     // To be called after any drawing.
     void scheduleFlush();
 
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 4a42ea503985..07937c6b9cb0 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -490,14 +490,19 @@ bool SkiaSalGraphicsImpl::drawAlphaBitmap(const SalTwoRect& rPosAry, const SalBi
                       &paint);
     paint.setBlendMode(SkBlendMode::kSrcIn);
     canvas.drawBitmap(static_cast<const SkiaSalBitmap&>(rSourceBitmap).GetSkBitmap(), 0, 0, &paint);
+    drawBitmap(rPosAry, tmpBitmap);
+    return true;
+}
+
+void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SkBitmap& bitmap)
+{
     mSurface->getCanvas()->drawBitmapRect(
-        tmpBitmap,
+        bitmap,
         SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight),
         SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth,
                          rPosAry.mnDestHeight),
         nullptr);
     scheduleFlush();
-    return true;
 }
 
 bool SkiaSalGraphicsImpl::drawTransformedBitmap(const basegfx::B2DPoint& rNull,
diff --git a/vcl/skia/x11/cairotextrender.cxx b/vcl/skia/x11/cairotextrender.cxx
index 7c2402b2c869..f3cc30b709fe 100644
--- a/vcl/skia/x11/cairotextrender.cxx
+++ b/vcl/skia/x11/cairotextrender.cxx
@@ -38,7 +38,6 @@ cairo_t* SkiaX11CairoTextRender::getCairoContext()
     if (!surface)
         return nullptr;
     cairo_t* cr = cairo_create(surface);
-    // TODO
     cairo_surface_destroy(surface);
     return cr;
 }
@@ -56,7 +55,6 @@ void SkiaX11CairoTextRender::getSurfaceOffset(double& nDX, double& nDY)
 
 void SkiaX11CairoTextRender::releaseCairoContext(cairo_t* cr)
 {
-    // XXX: lfrb: GLES 2.0 doesn't support GL_UNSIGNED_INT_8_8_8_8_REV
     SkiaSalGraphicsImpl* pImpl = dynamic_cast<SkiaSalGraphicsImpl*>(mrParent.GetImpl());
     if (!pImpl)
     {
@@ -70,19 +68,15 @@ void SkiaX11CairoTextRender::releaseCairoContext(cairo_t* cr)
     cairo_surface_flush(pSurface);
     unsigned char* pSrc = cairo_image_surface_get_data(pSurface);
 
-    // XXX: lfrb: GLES 2.0 doesn't support GL_UNSIGNED_INT_8_8_8_8_REV
     tools::Rectangle aClipRect = pImpl->getClipRegion().GetBoundRect();
-
     SalTwoRect aRect(0, 0, nWidth, nHeight, aClipRect.Left(), aClipRect.Top(), nWidth, nHeight);
 
-    // Cairo surface data is ARGB with premultiplied alpha and is Y-inverted
-    // TODO
-    //    SkiaTexture aTexture( nWidth, nHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pSrc );
-    //    pImpl->PreDraw();
-    //    pImpl->DrawAlphaTexture( aTexture, aRect, true, true );
-    //    pImpl->PostDraw();
-    //    abort();
+    SkBitmap bitmap;
+    if (!bitmap.installPixels(SkImageInfo::MakeN32Premul(nWidth, nHeight), pSrc, nWidth * 4))
+        abort();
 
+    pImpl->drawBitmap(aRect, bitmap);
+    bitmap.reset();
     cairo_destroy(cr);
 }
 
commit dced897eecc5d2227b4d546cd573875bd69de667
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Oct 3 15:28:52 2019 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Fri Oct 4 01:26:02 2019 +0200

    move opengl and skia cairotextrender.cxx to their dirs
    
    Change-Id: I67a87db644dc6fd7d69d615f7b4c388c3a1d97f6

diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 8dae6b74e154..51bbb87ce0d8 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -17482,6 +17482,7 @@ vcl/inc/unx/screensaverinhibitor.hxx
 vcl/inc/unx/sm.hxx
 vcl/inc/unx/svsys.h
 vcl/inc/unx/wmadaptor.hxx
+vcl/inc/unx/x11/x11cairotextrender.hxx
 vcl/inc/unx/x11/x11gdiimpl.h
 vcl/inc/unx/x11/x11sys.hxx
 vcl/inc/unx/x11/xlimits.hxx
@@ -17650,6 +17651,8 @@ vcl/opengl/texture.cxx
 vcl/opengl/win/WinDeviceInfo.cxx
 vcl/opengl/win/blocklist_parser.cxx
 vcl/opengl/win/gdiimpl.cxx
+vcl/opengl/x11/cairotextrender.cxx
+vcl/opengl/x11/cairotextrender.hxx
 vcl/opengl/x11/X11DeviceInfo.cxx
 vcl/opengl/x11/gdiimpl.cxx
 vcl/opengl/x11/salvd.cxx
@@ -18119,14 +18122,11 @@ vcl/unx/generic/gdi/font.cxx
 vcl/unx/generic/gdi/gdiimpl.cxx
 vcl/unx/generic/gdi/gdiimpl.hxx
 vcl/unx/generic/gdi/nativewindowhandleprovider.cxx
-vcl/unx/generic/gdi/openglx11cairotextrender.cxx
-vcl/unx/generic/gdi/openglx11cairotextrender.hxx
 vcl/unx/generic/gdi/salbmp.cxx
 vcl/unx/generic/gdi/salgdi.cxx
 vcl/unx/generic/gdi/salgdi2.cxx
 vcl/unx/generic/gdi/salvd.cxx
 vcl/unx/generic/gdi/x11cairotextrender.cxx
-vcl/unx/generic/gdi/x11cairotextrender.hxx
 vcl/unx/generic/gdi/xrender_peer.cxx
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx
 vcl/unx/generic/glyphs/glyphcache.cxx
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index f0fb9d39c259..54751adec6c4 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -94,7 +94,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
     vcl/unx/generic/gdi/cairo_xlib_cairo \
     vcl/unx/generic/gdi/x11cairotextrender \
 	vcl/unx/generic/gdi/gdiimpl \
-	vcl/unx/generic/gdi/openglx11cairotextrender \
     vcl/unx/generic/gdi/salbmp \
     vcl/unx/generic/gdi/salgdi2 \
     vcl/unx/generic/gdi/font \
@@ -105,10 +104,11 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
     vcl/unx/generic/window/salobj \
     vcl/unx/x11/x11sys \
     vcl/unx/x11/xlimits \
+	vcl/opengl/x11/cairotextrender \
 	vcl/opengl/x11/gdiimpl \
 	vcl/opengl/x11/salvd \
+	vcl/skia/x11/cairotextrender \
 	vcl/skia/x11/gdiimpl \
-	vcl/unx/generic/gdi/skiax11cairotextrender \
 	vcl/skia/x11/salvd \
 ))
 
diff --git a/vcl/unx/generic/gdi/openglx11cairotextrender.hxx b/vcl/inc/opengl/x11/cairotextrender.hxx
similarity index 95%
rename from vcl/unx/generic/gdi/openglx11cairotextrender.hxx
rename to vcl/inc/opengl/x11/cairotextrender.hxx
index 46a11cba5a0e..c515b90da732 100644
--- a/vcl/unx/generic/gdi/openglx11cairotextrender.hxx
+++ b/vcl/inc/opengl/x11/cairotextrender.hxx
@@ -10,7 +10,7 @@
 #ifndef INCLUDED_VCL_UNX_GENERIC_GDI_OPENGLX11CAIROTEXTRENDER_HXX
 #define INCLUDED_VCL_UNX_GENERIC_GDI_OPENGLX11CAIROTEXTRENDER_HXX
 
-#include "x11cairotextrender.hxx"
+#include <unx/x11/x11cairotextrender.hxx>
 
 class OpenGLX11CairoTextRender : public X11CairoTextRender
 {
diff --git a/vcl/unx/generic/gdi/skiax11cairotextrender.hxx b/vcl/inc/skia/x11/cairotextrender.hxx
similarity index 95%
rename from vcl/unx/generic/gdi/skiax11cairotextrender.hxx
rename to vcl/inc/skia/x11/cairotextrender.hxx
index e46ac36ba54a..fe904327fdfa 100644
--- a/vcl/unx/generic/gdi/skiax11cairotextrender.hxx
+++ b/vcl/inc/skia/x11/cairotextrender.hxx
@@ -10,7 +10,7 @@
 #ifndef INCLUDED_VCL_UNX_GENERIC_GDI_SKIAX11CAIROTEXTRENDER_HXX
 #define INCLUDED_VCL_UNX_GENERIC_GDI_SKIAX11CAIROTEXTRENDER_HXX
 
-#include "x11cairotextrender.hxx"
+#include <unx/x11/x11cairotextrender.hxx>
 
 class SkiaX11CairoTextRender : public X11CairoTextRender
 {
diff --git a/vcl/unx/generic/gdi/x11cairotextrender.hxx b/vcl/inc/unx/x11/x11cairotextrender.hxx
similarity index 100%
rename from vcl/unx/generic/gdi/x11cairotextrender.hxx
rename to vcl/inc/unx/x11/x11cairotextrender.hxx
diff --git a/vcl/unx/generic/gdi/openglx11cairotextrender.cxx b/vcl/opengl/x11/cairotextrender.cxx
similarity index 98%
rename from vcl/unx/generic/gdi/openglx11cairotextrender.cxx
rename to vcl/opengl/x11/cairotextrender.cxx
index 436120b8b0c6..2b90de4e2fb5 100644
--- a/vcl/unx/generic/gdi/openglx11cairotextrender.cxx
+++ b/vcl/opengl/x11/cairotextrender.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "openglx11cairotextrender.hxx"
+#include <opengl/x11/cairotextrender.hxx>
 
 #include <opengl/gdiimpl.hxx>
 #include <salbmp.hxx>
diff --git a/vcl/unx/generic/gdi/skiax11cairotextrender.cxx b/vcl/skia/x11/cairotextrender.cxx
similarity index 97%
rename from vcl/unx/generic/gdi/skiax11cairotextrender.cxx
rename to vcl/skia/x11/cairotextrender.cxx
index 4af382592f7b..7c2402b2c869 100644
--- a/vcl/unx/generic/gdi/skiax11cairotextrender.cxx
+++ b/vcl/skia/x11/cairotextrender.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "skiax11cairotextrender.hxx"
+#include <skia/x11/cairotextrender.hxx>
 
 #include <salbmp.hxx>
 #include <vcl/salbtype.hxx>
@@ -38,6 +38,7 @@ cairo_t* SkiaX11CairoTextRender::getCairoContext()
     if (!surface)
         return nullptr;
     cairo_t* cr = cairo_create(surface);
+    // TODO
     cairo_surface_destroy(surface);
     return cr;
 }
@@ -80,6 +81,7 @@ void SkiaX11CairoTextRender::releaseCairoContext(cairo_t* cr)
     //    pImpl->PreDraw();
     //    pImpl->DrawAlphaTexture( aTexture, aRect, true, true );
     //    pImpl->PostDraw();
+    //    abort();
 
     cairo_destroy(cr);
 }
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 680a1f6a57b8..3649a0b4c219 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -59,9 +59,9 @@
 #include "gdiimpl.hxx"
 #include <opengl/x11/gdiimpl.hxx>
 #include <skia/x11/gdiimpl.hxx>
-#include "x11cairotextrender.hxx"
-#include "openglx11cairotextrender.hxx"
-#include "skiax11cairotextrender.hxx"
+#include <unx/x11/x11cairotextrender.hxx>
+#include <opengl/x11/cairotextrender.hxx>
+#include <skia/x11/cairotextrender.hxx>
 
 #include <unx/printergfx.hxx>
 #include <unx/x11/xrender_peer.hxx>
diff --git a/vcl/unx/generic/gdi/x11cairotextrender.cxx b/vcl/unx/generic/gdi/x11cairotextrender.cxx
index 88d5b49a1823..496d6952aec0 100644
--- a/vcl/unx/generic/gdi/x11cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/x11cairotextrender.cxx
@@ -17,7 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "x11cairotextrender.hxx"
+#include <unx/x11/x11cairotextrender.hxx>
 #include <unx/saldisp.hxx>
 #include <unx/salvd.h>
 #include <unx/glyphcache.hxx>
commit 0d43d20a7d5940c33029f8662ba03b81ec646ead
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Oct 3 13:43:23 2019 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Fri Oct 4 01:26:02 2019 +0200

    filter arguments to MSVC to avoid the annoying D9025 warning
    
    GCC/Clang do not bother with warning about overriding e.g. -O2
    with -O0, AFAICT it's quite a common practice, and I really don't
    see any good reason for the warning, and even less so for not even
    being able to disable it. Without this, enabling SSE2/AVX2
    would warn about overriding the default -arch:SSE (that's hardcoded
    by configure to be part of the compiler command).
    
    Change-Id: I9f9109b77de90085486bc2a98f1b453a41755e60

diff --git a/solenv/gbuild/platform/com_GCC_class.mk b/solenv/gbuild/platform/com_GCC_class.mk
index 18170c8eae2d..fd3703b875b5 100644
--- a/solenv/gbuild/platform/com_GCC_class.mk
+++ b/solenv/gbuild/platform/com_GCC_class.mk
@@ -65,7 +65,8 @@ $(call gb_Helper_abbreviate_dirs,\
 		$(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
 		$(if $(5),$(gb_COMPILER_PLUGINS)) \
 		$(if $(COMPILER_TEST),-fsyntax-only -ferror-limit=0 -Xclang -verify) \
-		$(if $(WARNINGS_DISABLED),$(call gb_Helper_disable_warnings,$(2)),$(2)) \
+		$(2) \
+		$(if $(WARNINGS_DISABLED),$(gb_CXXFLAGS_DISABLE_WARNINGS)) \
 		$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
 		-c $(3) \
 		-o $(1) \
@@ -98,7 +99,8 @@ $(call gb_Helper_abbreviate_dirs,\
 	CCACHE_DISABLE=1 $(gb_COMPILER_SETUP) \
 	$(gb_CXX) \
 		-x c++-header \
-		$(if $(WARNINGS_DISABLED),$(call gb_Helper_disable_warnings,$(4) $(5)),$(4) $(5)) \
+		$(4) $(5) \
+		$(if $(WARNINGS_DISABLED),$(gb_CXXFLAGS_DISABLE_WARNINGS)) \
 		$(gb_COMPILERDEPFLAGS) \
 		$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
 		$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
@@ -123,7 +125,8 @@ $(call gb_Helper_abbreviate_dirs,\
 	CCACHE_DISABLE=1 $(gb_COMPILER_SETUP) \
 	$(gb_CXX) \
 		-x c++-header \
-		$(if $(WARNINGS_DISABLED),$(call gb_Helper_disable_warnings,$(4) $(5)),$(4) $(5)) \
+		$(4) $(5) \
+		$(if $(WARNINGS_DISABLED),$(gb_CXXFLAGS_DISABLE_WARNINGS)) \
 		$(gb_COMPILERDEPFLAGS) \
 		$(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
 		$(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk
index 4a4688dd3a1f..8db137e97265 100644
--- a/solenv/gbuild/platform/com_GCC_defs.mk
+++ b/solenv/gbuild/platform/com_GCC_defs.mk
@@ -82,7 +82,7 @@ gb_CXXFLAGS_COMMON := \
 	-fno-common \
 	-pipe \
 
-gb_Helper_disable_warnings = $(1) -w
+gb_CXXFLAGS_DISABLE_WARNINGS = -w
 
 ifeq ($(HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED),TRUE)
 gb_CXXFLAGS_COMMON += -Wno-maybe-uninitialized
diff --git a/solenv/gbuild/platform/com_MSC_class.mk b/solenv/gbuild/platform/com_MSC_class.mk
index 66f252838024..71a175903505 100644
--- a/solenv/gbuild/platform/com_MSC_class.mk
+++ b/solenv/gbuild/platform/com_MSC_class.mk
@@ -43,15 +43,23 @@ define gb_CObject__compiler
 					$(MSVC_CXX) -I$(SRCDIR)/solenv/clang-cl,$(gb_CXX)))))
 endef
 
+# Avoid annoying warning D9025 about overriding command-line arguments.
+gb_Helper_remove_overriden_flags = \
+    $(filter-out -W4 -w -arch:SSE -arch:AVX2 -Od -O2,$(1)) \
+    $(lastword $(filter -W4 -w,$(1))) \
+    $(lastword $(filter -Od -O2,$(1))) \
+    $(lastword $(filter -arch:SSE -arch:AVX2,$(1)))
+
 # $(call gb_CObject__command_pattern,object,flags,source,dep-file,compiler-plugins,symbols)
 define gb_CObject__command_pattern
 $(call gb_Helper_abbreviate_dirs,\
 	mkdir -p $(dir $(1)) $(dir $(4)) && \
 	unset INCLUDE && \
-	$(call gb_CObject__compiler,$(2),$(3)) \
+	$(filter-out -arch:SSE,$(call gb_CObject__compiler,$(2),$(3))) \
 		$(DEFS) \
 		$(gb_LTOFLAGS) \
-		$(if $(WARNINGS_DISABLED),$(call gb_Helper_disable_warnings,$(2)),$(2)) \
+		$(call gb_Helper_remove_overriden_flags,$(filter -arch:SSE,$(call gb_CObject__compiler,$(2),$(3))) \
+			$(2) $(if $(WARNINGS_DISABLED),$(gb_CXXFLAGS_DISABLE_WARNINGS))) \
 		$(if $(EXTERNAL_CODE), \
 			$(if $(filter -clr,$(2)),,$(if $(COM_IS_CLANG),-Wno-undef)), \
 			$(gb_DEFS_INTERNAL)) \
@@ -86,8 +94,9 @@ $(call gb_Output_announce,$(2),$(true),PCH,1)
 $(call gb_Helper_abbreviate_dirs,\
 	mkdir -p $(dir $(1)) $(dir $(call gb_PrecompiledHeader_get_dep_target,$(2),$(7))) && \
 	unset INCLUDE && \
-	$(call gb_CObject__compiler,$(4) $(5),$(3)) \
-		$(if $(WARNINGS_DISABLED),$(call gb_Helper_disable_warnings,$(4) $(5)),$(4) $(5)) \
+	$(filter-out -arch:SSE,$(call gb_CObject__compiler,$(4) $(5),$(3))) \
+		$(call gb_Helper_remove_overriden_flags,$(filter -arch:SSE,$(call gb_CObject__compiler,$(4) $(5),$(3))) \
+			$(4) $(5) $(if $(WARNINGS_DISABLED),$(gb_CXXFLAGS_DISABLE_WARNINGS))) \
 		-Fd$(PDBFILE) \
 		$(if $(EXTERNAL_CODE),$(if $(COM_IS_CLANG),-Wno-undef),$(gb_DEFS_INTERNAL)) \
 		$(gb_LTOFLAGS) \
diff --git a/solenv/gbuild/platform/com_MSC_defs.mk b/solenv/gbuild/platform/com_MSC_defs.mk
index 0c0ba3807003..590af0439ccc 100644
--- a/solenv/gbuild/platform/com_MSC_defs.mk
+++ b/solenv/gbuild/platform/com_MSC_defs.mk
@@ -156,7 +156,7 @@ gb_CFLAGS := \
 	-wd4800 \
 	-wd4267 \
 
-gb_Helper_disable_warnings = $(filter-out -W4,$(1)) -w
+gb_CXXFLAGS_DISABLE_WARNINGS = -w
 
 ifneq ($(COM_IS_CLANG),TRUE)
 
commit 237ffc31e44265ba61467b9b92ca49fff955d518
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Oct 3 13:34:35 2019 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Fri Oct 4 01:26:01 2019 +0200

    common gbuild function for getting the correct windows compiler
    
    Change-Id: Ia4001a4a3a0ac8490ab7104a25ccd688d18b8aa1

diff --git a/solenv/gbuild/platform/com_MSC_class.mk b/solenv/gbuild/platform/com_MSC_class.mk
index 02f7f44d5143..66f252838024 100644
--- a/solenv/gbuild/platform/com_MSC_class.mk
+++ b/solenv/gbuild/platform/com_MSC_class.mk
@@ -34,16 +34,21 @@ endef
 
 # CObject class
 
+# $(call gb_CObject__compiler,flags,source)
+define gb_CObject__compiler
+	$(if $(filter YES,$(LIBRARY_X64)), $(CXX_X64_BINARY), \
+		$(if $(filter YES,$(PE_X86)), $(CXX_X86_BINARY), \
+			$(if $(filter %.c,$(2)), $(gb_CC), \
+				$(if $(filter -clr,$(1)), \
+					$(MSVC_CXX) -I$(SRCDIR)/solenv/clang-cl,$(gb_CXX)))))
+endef
+
 # $(call gb_CObject__command_pattern,object,flags,source,dep-file,compiler-plugins,symbols)
 define gb_CObject__command_pattern
 $(call gb_Helper_abbreviate_dirs,\
 	mkdir -p $(dir $(1)) $(dir $(4)) && \
 	unset INCLUDE && \
-	$(if $(filter YES,$(LIBRARY_X64)), $(CXX_X64_BINARY), \
-		$(if $(filter YES,$(PE_X86)), $(CXX_X86_BINARY), \
-			$(if $(filter %.c,$(3)), $(gb_CC), \
-				$(if $(filter -clr,$(2)), \
-					$(MSVC_CXX) -I$(SRCDIR)/solenv/clang-cl,$(gb_CXX))))) \
+	$(call gb_CObject__compiler,$(2),$(3)) \
 		$(DEFS) \
 		$(gb_LTOFLAGS) \
 		$(if $(WARNINGS_DISABLED),$(call gb_Helper_disable_warnings,$(2)),$(2)) \
@@ -81,7 +86,7 @@ $(call gb_Output_announce,$(2),$(true),PCH,1)
 $(call gb_Helper_abbreviate_dirs,\
 	mkdir -p $(dir $(1)) $(dir $(call gb_PrecompiledHeader_get_dep_target,$(2),$(7))) && \
 	unset INCLUDE && \
-	$(gb_CXX) \
+	$(call gb_CObject__compiler,$(4) $(5),$(3)) \
 		$(if $(WARNINGS_DISABLED),$(call gb_Helper_disable_warnings,$(4) $(5)),$(4) $(5)) \
 		-Fd$(PDBFILE) \
 		$(if $(EXTERNAL_CODE),$(if $(COM_IS_CLANG),-Wno-undef),$(gb_DEFS_INTERNAL)) \
commit a3ef7309e5ddc4159ae93eee08ba873a62c3b1ba
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Oct 3 12:29:18 2019 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Fri Oct 4 01:25:54 2019 +0200

    do not abort build on PCH CXXFLAGS mismatch if set explicitly
    
    All the various gb_CppunitTest_add_cxxobjects variants actually
    allow passing additional CXXFLAGS. However, currently that would
    abort the build if PCH is used, because PCH requires the same
    CXXFLAGS. But if those extra CXXFLAGS are set explicitly, just
    skip using the PCH for that one file, as the mismatch is intentional.
    
    Change-Id: Iec4eed6d5f94c3e97ee461241203a84d21e8113c

diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index 0fb38de3399a..9404c00cd4ec 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -266,21 +266,24 @@ gb_CxxObject_get_source = $(1)/$(2).cxx
 # should never be overridden on an object -- they should be the same as for the
 # whole linktarget. In general it should be cleaner to use a static library
 # compiled with different flags and link that in rather than mixing different
-# flags in one linktarget.
+# flags in one linktarget. If OBJECT_HAS_EXTRA_CXXFLAGS is set, the object
+# has explicitly set additional CXXFLAGS, so in that case avoid using the PCH.
 define gb_CxxObject__set_pchflags
 ifneq ($(gb_ENABLE_PCH),)
 ifneq ($(strip $$(PCH_NAME)),)
-ifeq ($$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_EXCEPTIONFLAGS)),$$(sort $$(T_CXXFLAGS) $$(T_CXXFLAGS_APPEND) $$(DEFS)))
+ifeq ($(OBJECT_HAS_EXTRA_CXXFLAGS),)
+ifeq ($$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS)),$$(sort $$(T_CXXFLAGS) $$(T_CXXFLAGS_APPEND) $$(DEFS)))
 $$@ : PCHFLAGS := $$(call gb_PrecompiledHeader_get_enableflags,$$(PCH_NAME),$$(PCH_LINKTARGETMAKEFILENAME))
 else
 $$(warning No precompiled header available for $$*.cxx .)
-$$(info precompiled header flags : $$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_EXCEPTIONFLAGS)))
+$$(info precompiled header flags : $$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS)))
 $$(info .           object flags : $$(sort $$(T_CXXFLAGS) $$(T_CXXFLAGS_APPEND) $$(DEFS)))
 $$(error   Incorrect precompiled header setup or internal gbuild error.)
 $$@ : PCHFLAGS :=
 endif
 endif
 endif
+endif
 endef
 
 ifneq ($(COMPILER_EXTERNAL_TOOL)$(COMPILER_PLUGIN_TOOL),)
@@ -762,6 +765,7 @@ $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS_APPEND :=
 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS_APPEND :=
 $(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
+$(call gb_LinkTarget_get_target,$(1)) : OBJECT_HAS_EXTRA_CXXFLAGS :=
 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS_APPEND :=
 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS := $$(gb_LinkTarget_OBJCFLAGS)
@@ -1112,15 +1116,20 @@ endif
 
 endef
 
-# call gb_LinkTarget_add_cxxobject,linktarget,sourcefile,cxxflags,linktargetmakefilename
-define gb_LinkTarget_add_cxxobject
+# call gb_LinkTarget_add_cxxobject_internal,linktarget,sourcefile,cxxflags,linktargetmakefilename,exceptionflags
+# The purpose of the exceptionflags extra argument is to differentiate between usage that just needs
+# exception flags and usage that adds other flags. Using a PCH requires the same cxxflags as the ones used
+# to create the PCH, so non-empty cxxflags here mean the object cannot use the PCH, and the add_exception_cxxobject
+# variant passes the necessary flags by setting the extra argument.
+define gb_LinkTarget_add_cxxobject_internal
 $(if $(wildcard $(call gb_CxxObject_get_source,$(SRCDIR),$(2))),,$(eval $(call gb_Output_error,No such source file $(call gb_CxxObject_get_source,$(SRCDIR),$(2)))))
 $(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS += $(2)
 $(call gb_LinkTarget_get_clean_target,$(1)) : CXXOBJECTS += $(2)
 
 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_CxxObject_get_target,$(2))
 $(call gb_CxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
-$(call gb_CxxObject_get_target,$(2)) : T_CXXFLAGS += $(call gb_LinkTarget__get_cxxflags,$(4)) $(3)
+$(call gb_CxxObject_get_target,$(2)) : T_CXXFLAGS += $(call gb_LinkTarget__get_cxxflags,$(4)) $(3) $(5)
+$(call gb_CxxObject_get_target,$(2)) : OBJECT_HAS_EXTRA_CXXFLAGS := $(if $(strip $(3)),1)
 $(call gb_CxxObject_get_target,$(2)) : \
 	OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
 ifneq ($(gb_ENABLE_PCH),)
@@ -1136,6 +1145,11 @@ endif
 
 endef
 
+# call gb_LinkTarget_add_cxxobject,linktarget,sourcefile,cxxflags,linktargetmakefilename
+define gb_LinkTarget_add_cxxobject
+$(call gb_LinkTarget_add_cxxobject_internal,$(1),$(2),$(3),$(4))
+endef
+
 # call gb_LinkTarget_add_objcobject,linktarget,sourcefile,objcflags,linktargetmakefilename
 define gb_LinkTarget_add_objcobject
 $(if $(wildcard $(call gb_ObjCObject_get_source,$(SRCDIR),$(2))),,$(eval $(call gb_Output_error,No such source file $(call gb_ObjCObject_get_source,$(SRCDIR),$(2)))))
@@ -1244,8 +1258,8 @@ endif
 
 endef
 
-# call gb_LinkTarget_add_generated_cxx_object,linktarget,sourcefile,cxxflags,linktargetmakefilename
-define gb_LinkTarget_add_generated_cxx_object
+# call gb_LinkTarget_add_generated_cxx_object_internal,linktarget,sourcefile,cxxflags,linktargetmakefilename,exceptionflags
+define gb_LinkTarget_add_generated_cxx_object_internal
 $(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS += $(2)
 $(call gb_LinkTarget_get_clean_target,$(1)) : GENCXXOBJECTS += $(2)
 
@@ -1256,7 +1270,8 @@ $(call gb_GenCxxObject_get_target,$(2)) : $(call gb_GenCxxObject_get_source,$(2)
 $(call gb_GenCxxObject_get_source,$(2),$(1)) : | $(gb_Helper_MISCDUMMY)
 $(call gb_GenCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
 $(call gb_GenCxxObject_get_target,$(2)) : WARNINGS_NOT_ERRORS := $(true)
-$(call gb_GenCxxObject_get_target,$(2)) : T_CXXFLAGS += $(call gb_LinkTarget__get_cxxflags,$(4)) $(3)
+$(call gb_GenCxxObject_get_target,$(2)) : T_CXXFLAGS += $(call gb_LinkTarget__get_cxxflags,$(4)) $(3) $(5)
+$(call gb_GenCxxObject_get_target,$(2)) : OBJECT_HAS_EXTRA_CXXFLAGS := $(if $(strip $(3)),1)
 $(call gb_GenCxxObject_get_target,$(2)) : \
 	OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
 $(call gb_GenCxxObject_get_target,$(2)) : GEN_CXX_SOURCE := $(call gb_GenCxxObject_get_source,$(2),$(1))
@@ -1273,6 +1288,11 @@ endif
 
 endef
 
+# call gb_LinkTarget_add_generated_cxx_object,linktarget,sourcefile,cxxflags,linktargetmakefilename
+define gb_LinkTarget_add_generated_cxx_object
+$(call gb_LinkTarget_add_generated_cxx_object_internal,$(1),$(2),$(3),$(4))
+endef
+
 # call gb_LinkTarget_add_generated_cxxclrobject,linktarget,sourcefile,cxxclrflags,linktargetmakefilename
 define gb_LinkTarget_add_generated_cxxclrobject
 $(call gb_LinkTarget_get_target,$(1)) : GENCXXCLROBJECTS += $(2)
@@ -1331,7 +1351,7 @@ endef
 
 # call gb_LinkTarget_add_exception_object,linktarget,sourcefile,cxxflags,linktargetmakefilename
 define gb_LinkTarget_add_exception_object
-$(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(3),$(4))
+$(call gb_LinkTarget_add_cxxobject_internal,$(1),$(2),$(3),$(4),$(gb_LinkTarget_EXCEPTIONFLAGS))
 endef
 
 # call gb_LinkTarget__use_linktarget_objects,linktarget,linktargets
@@ -1416,7 +1436,7 @@ endef
 
 # call gb_LinkTarget_add_generated_exception_object,linktarget,sourcefile,cxxflags,linktargetmakefilename
 define gb_LinkTarget_add_generated_exception_object
-$(call gb_LinkTarget_add_generated_cxx_object,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(3),$(4))
+$(call gb_LinkTarget_add_generated_cxx_object_internal,$(1),$(2),$(3),$(4),$(gb_LinkTarget_EXCEPTIONFLAGS))
 endef
 
 # call gb_LinkTarget_add_generated_exception_objects,linktarget,sourcefile,cxxflags,linktargetmakefilename
@@ -1516,7 +1536,7 @@ $(call gb_LinkTarget_get_target,$(1)) : PCHOBJEX = $(call gb_PrecompiledHeader_g
 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJS = $$(PCHOBJEX)
 
 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS := $$(DEFS)
-$(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $$(T_CXXFLAGS) $(call gb_LinkTarget__get_cxxflags,$(4))
+$(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $$(T_CXXFLAGS) $(call gb_LinkTarget__get_cxxflags,$(4)) $(gb_LinkTarget_EXCEPTIONFLAGS)
 
 $(call gb_LinkTarget_get_target,$(1)) : DEFS += -DPCH_LEVEL=$(gb_ENABLE_PCH)
 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS += -DPCH_LEVEL=$(gb_ENABLE_PCH)
diff --git a/solenv/gbuild/extensions/post_GbuildToJson.mk b/solenv/gbuild/extensions/post_GbuildToJson.mk
index a14f6a9145e3..7f05392e1179 100644
--- a/solenv/gbuild/extensions/post_GbuildToJson.mk
+++ b/solenv/gbuild/extensions/post_GbuildToJson.mk
@@ -103,7 +103,7 @@ define gb_LinkTarget_add_cobject
 $(call gb_LinkTarget_get_target,$(1)) : COBJECTS += $(2)
 
 endef
-define gb_LinkTarget_add_cxxobject
+define gb_LinkTarget_add_cxxobject_internal
 $(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS += $(2)
 
 endef
@@ -111,7 +111,7 @@ define gb_LinkTarget_add_generated_c_object
 $(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS += $(2)
 
 endef
-define gb_LinkTarget_add_generated_cxx_object
+define gb_LinkTarget_add_generated_cxx_object_internal
 $(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS += $(2)
 
 endef


More information about the Libreoffice-commits mailing list