From d87b20e1ae765cb65281c5bd7c12fc41e8a86780 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 2 Mar 2016 16:55:26 -0800 Subject: Rename png_ functions conflicting with chrome. Part of the work required to ship XFA with chrome. BUG=pdfium:396 R=dsinclair@chromium.org Review URL: https://codereview.chromium.org/1763493002 . --- BUILD.gn | 1 - pdfium.gyp | 1 - samples/BUILD.gn | 7 +++---- samples/samples.gyp | 1 - testing/libfuzzer/BUILD.gn | 1 - testing/libfuzzer/fuzzers.gyp | 1 - third_party/BUILD.gn | 9 ++++++--- third_party/libpng16/README.pdfium | 1 + third_party/libpng16/pngprefix.h | 17 +++++++++++++++++ third_party/third_party.gyp | 2 +- 10 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 third_party/libpng16/pngprefix.h diff --git a/BUILD.gn b/BUILD.gn index 831fe2dc45..3f99c28f0a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,7 +16,6 @@ config("pdfium_config") { defines = [ "OPJ_STATIC", "PNG_PREFIX", - "PNGPREFIX_H", "PNG_USE_READ_MACROS", "V8_DEPRECATION_WARNINGS", "_CRT_SECURE_NO_WARNINGS", diff --git a/pdfium.gyp b/pdfium.gyp index 6bc8709a17..14d18e1499 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -22,7 +22,6 @@ 'defines' : [ 'OPJ_STATIC', 'PNG_PREFIX', - 'PNGPREFIX_H', 'PNG_USE_READ_MACROS', 'V8_DEPRECATION_WARNINGS', '_CRT_SECURE_NO_WARNINGS', diff --git a/samples/BUILD.gn b/samples/BUILD.gn index e3652086e4..9ff1bea4c1 100644 --- a/samples/BUILD.gn +++ b/samples/BUILD.gn @@ -17,24 +17,23 @@ group("samples") { config("pdfium_samples_config") { defines = [ "PNG_PREFIX", - "PNGPREFIX_H", "PNG_USE_READ_MACROS", ] include_dirs = [ ".." ] if (pdf_enable_v8) { - defines += [ "PDF_ENABLE_V8", ] + defines += [ "PDF_ENABLE_V8" ] } if (pdf_enable_xfa) { - defines += [ "PDF_ENABLE_XFA", ] + defines += [ "PDF_ENABLE_XFA" ] } } executable("pdfium_test") { testonly = true sources = [ - "pdfium_test.cc", "image_diff_png.cc", "image_diff_png.h", + "pdfium_test.cc", ] deps = [ "//build/config/sanitizers:deps", diff --git a/samples/samples.gyp b/samples/samples.gyp index da9ce74b0a..6f262d5a04 100644 --- a/samples/samples.gyp +++ b/samples/samples.gyp @@ -10,7 +10,6 @@ 'target_defaults': { 'defines' : [ 'PNG_PREFIX', - 'PNGPREFIX_H', 'PNG_USE_READ_MACROS', ], 'include_dirs': [ diff --git a/testing/libfuzzer/BUILD.gn b/testing/libfuzzer/BUILD.gn index 46cf0589d3..d5ccb7f40f 100644 --- a/testing/libfuzzer/BUILD.gn +++ b/testing/libfuzzer/BUILD.gn @@ -7,7 +7,6 @@ import("../../pdfium.gni") config("libfuzzer_config") { defines = [ "PNG_PREFIX", - "PNGPREFIX_H", "PNG_USE_READ_MACROS", ] include_dirs = [ "../.." ] diff --git a/testing/libfuzzer/fuzzers.gyp b/testing/libfuzzer/fuzzers.gyp index a65fe1b993..bdd9086592 100644 --- a/testing/libfuzzer/fuzzers.gyp +++ b/testing/libfuzzer/fuzzers.gyp @@ -10,7 +10,6 @@ 'target_defaults': { 'defines' : [ 'PNG_PREFIX', - 'PNGPREFIX_H', 'PNG_USE_READ_MACROS', ], 'include_dirs': [ diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn index 92fbcaa9fb..ec6f8cb7f8 100644 --- a/third_party/BUILD.gn +++ b/third_party/BUILD.gn @@ -298,6 +298,7 @@ source_set("fx_lpng") { "libpng16/pnglibconf.h", "libpng16/pngmem.c", "libpng16/pngpread.c", + "libpng16/pngprefix.h", "libpng16/pngpriv.h", "libpng16/pngread.c", "libpng16/pngrio.c", @@ -320,10 +321,10 @@ if (pdf_enable_xfa) { "//build/config/compiler:no_chromium_code", "//third_party/pdfium:pdfium_config", ] - deps = [ "//third_party:jpeg" ] + deps = [ + "//third_party:jpeg", + ] sources = [ - "libtiff/tiffiop.h", - "libtiff/tiffvers.h", "libtiff/tif_aux.c", "libtiff/tif_close.c", "libtiff/tif_codec.c", @@ -359,6 +360,8 @@ if (pdf_enable_xfa) { "libtiff/tif_warning.c", "libtiff/tif_write.c", "libtiff/tif_zip.c", + "libtiff/tiffiop.h", + "libtiff/tiffvers.h", ] } } diff --git a/third_party/libpng16/README.pdfium b/third_party/libpng16/README.pdfium index d60bc6f428..b0e6805537 100644 --- a/third_party/libpng16/README.pdfium +++ b/third_party/libpng16/README.pdfium @@ -10,6 +10,7 @@ PNG library. Local Modifications: pnglibconf.h: a copy of libpng's scripts/pnglibconf.h.prebuilt. +pngprefix.h: manually-created redefinitions to avoid conflicts with chome. 0000-build-config.patch: Local build configuration changes. 0001-disable-arm-neon.diff: Disable ARM NEON optimizations. 0002-static-png-gt.patch: Unconditionally use static png_gt() in png.c to avoid compilation warning. diff --git a/third_party/libpng16/pngprefix.h b/third_party/libpng16/pngprefix.h new file mode 100644 index 0000000000..8eab668297 --- /dev/null +++ b/third_party/libpng16/pngprefix.h @@ -0,0 +1,17 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PNGPREFIX_H +#define PNGPREFIX_H + +// The purpose of this file is to rename conflicting functions +// when this version of libpng and chromium's version of it are +// both simultaneously present. + +#define png_get_uint_32 PDFIUM_png_get_uint_32 +#define png_get_uint_16 PDFIUM_png_get_uint_16 +#define png_get_int_32 PDFIUM_png_get_int_32 +#define png_get_int_16 PDFIUM_png_get_int_16 + +#endif // PNGPREFIX_H diff --git a/third_party/third_party.gyp b/third_party/third_party.gyp index 6746230f1d..d58c9a71d0 100644 --- a/third_party/third_party.gyp +++ b/third_party/third_party.gyp @@ -10,7 +10,6 @@ 'defines': [ 'OPJ_STATIC', 'PNG_PREFIX', - 'PNGPREFIX_H', 'PNG_USE_READ_MACROS', '_CRT_SECURE_NO_WARNINGS', ], @@ -280,6 +279,7 @@ 'libpng16/pnglibconf.h', 'libpng16/pngmem.c', 'libpng16/pngpread.c', + 'libpng16/pngprefix.h', 'libpng16/pngpriv.h', 'libpng16/pngread.c', 'libpng16/pngrio.c', -- cgit v1.2.3