Add use_system_libtiff build option Let embedders use the system libtiff instead of the bundled one if desired. Bug: chromium:1429647 Change-Id: I76fd11c4cc9829938066b2928844a5f88811d443 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/105650 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nigi <nigi@chromium.org>
diff --git a/core/fxcodec/BUILD.gn b/core/fxcodec/BUILD.gn index c0539b8..28f9915 100644 --- a/core/fxcodec/BUILD.gn +++ b/core/fxcodec/BUILD.gn
@@ -130,7 +130,7 @@ "tiff/tiff_decoder.cpp", "tiff/tiff_decoder.h", ] - deps += [ "../../third_party:fx_tiff" ] + deps += [ "../../third_party:tiff" ] } }
diff --git a/pdfium.gni b/pdfium.gni index d8a8955..9c6ae8d 100644 --- a/pdfium.gni +++ b/pdfium.gni
@@ -58,9 +58,6 @@ # Enable callgrind for performance profiling enable_callgrind = false - # Don't build against bundled zlib. - use_system_zlib = false - # Don't build against bundled lcms2. use_system_lcms2 = false @@ -70,6 +67,12 @@ # Don't build against bundled libpng. use_system_libpng = false + # Don't build against bundled libtiff. + use_system_libtiff = false + + # Don't build against bundled zlib. + use_system_zlib = false + # Enable SSE2 for MSVC builds. Ignored if it's not a MSVC build. msvc_use_sse2 = true }
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn index 1c6c3d2..534b3b8 100644 --- a/third_party/BUILD.gn +++ b/third_party/BUILD.gn
@@ -452,60 +452,74 @@ } if (pdf_enable_xfa_tiff) { - source_set("fx_tiff") { - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - "//build/config/compiler:no_chromium_code", - ":pdfium_third_party_config", - ] - if (is_win) { - # Need to undefine the macro since it is redefined in tif_jpeg.c. - configs -= [ "//build/config/win:lean_and_mean" ] + if (use_system_libtiff) { + config("system_tiff_config") { + libs = [ "tiff" ] } - deps = [ - ":zlib", - "../core/fxcrt", - "//third_party:jpeg", - ] - sources = [ - "libtiff/tif_aux.c", - "libtiff/tif_close.c", - "libtiff/tif_codec.c", - "libtiff/tif_color.c", - "libtiff/tif_compress.c", - "libtiff/tif_dir.c", - "libtiff/tif_dirinfo.c", - "libtiff/tif_dirread.c", - "libtiff/tif_dirwrite.c", - "libtiff/tif_dumpmode.c", - "libtiff/tif_error.c", - "libtiff/tif_extension.c", - "libtiff/tif_fax3.c", - "libtiff/tif_fax3sm.c", - "libtiff/tif_flush.c", - "libtiff/tif_getimage.c", - "libtiff/tif_hash_set.c", - "libtiff/tif_hash_set.h", - "libtiff/tif_jpeg.c", - "libtiff/tif_luv.c", - "libtiff/tif_lzw.c", - "libtiff/tif_next.c", - "libtiff/tif_open.c", - "libtiff/tif_packbits.c", - "libtiff/tif_pixarlog.c", - "libtiff/tif_predict.c", - "libtiff/tif_print.c", - "libtiff/tif_read.c", - "libtiff/tif_strip.c", - "libtiff/tif_swab.c", - "libtiff/tif_thunder.c", - "libtiff/tif_tile.c", - "libtiff/tif_version.c", - "libtiff/tif_warning.c", - "libtiff/tif_write.c", - "libtiff/tiffiop.h", - "libtiff/tiffvers.h", - ] + } else { + source_set("fx_tiff") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ + "//build/config/compiler:no_chromium_code", + ":pdfium_third_party_config", + ] + if (is_win) { + # Need to undefine the macro since it is redefined in tif_jpeg.c. + configs -= [ "//build/config/win:lean_and_mean" ] + } + deps = [ + ":zlib", + "../core/fxcrt", + "//third_party:jpeg", + ] + sources = [ + "libtiff/tif_aux.c", + "libtiff/tif_close.c", + "libtiff/tif_codec.c", + "libtiff/tif_color.c", + "libtiff/tif_compress.c", + "libtiff/tif_dir.c", + "libtiff/tif_dirinfo.c", + "libtiff/tif_dirread.c", + "libtiff/tif_dirwrite.c", + "libtiff/tif_dumpmode.c", + "libtiff/tif_error.c", + "libtiff/tif_extension.c", + "libtiff/tif_fax3.c", + "libtiff/tif_fax3sm.c", + "libtiff/tif_flush.c", + "libtiff/tif_getimage.c", + "libtiff/tif_hash_set.c", + "libtiff/tif_hash_set.h", + "libtiff/tif_jpeg.c", + "libtiff/tif_luv.c", + "libtiff/tif_lzw.c", + "libtiff/tif_next.c", + "libtiff/tif_open.c", + "libtiff/tif_packbits.c", + "libtiff/tif_pixarlog.c", + "libtiff/tif_predict.c", + "libtiff/tif_print.c", + "libtiff/tif_read.c", + "libtiff/tif_strip.c", + "libtiff/tif_swab.c", + "libtiff/tif_thunder.c", + "libtiff/tif_tile.c", + "libtiff/tif_version.c", + "libtiff/tif_warning.c", + "libtiff/tif_write.c", + "libtiff/tiffiop.h", + "libtiff/tiffvers.h", + ] + } + } + + group("tiff") { + if (use_system_libtiff) { + public_configs = [ ":system_tiff_config" ] + } else { + public_deps = [ ":fx_tiff" ] + } } }