Export defines to dependents of the "pdfium" target. Use GN's public_configs feature to do this. PDFium embedders no longer need to manually define PDF_ENABLE_V8 or PDF_ENABLE_XFA, for example. Remove redundant defines in samples/ and testing/fuzzers/. Change-Id: I2472316cf2e7e6af84e8e03f4f478db8ad27f5ce Reviewed-on: https://pdfium-review.googlesource.com/c/46110 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn index e9a87e0..e5f2066 100644 --- a/BUILD.gn +++ b/BUILD.gn
@@ -25,14 +25,31 @@ "PNG_USE_READ_MACROS", ] - if (pdf_enable_v8) { - defines += [ "PDF_ENABLE_V8" ] - } - if (pdf_enable_click_logging) { defines += [ "PDF_ENABLE_CLICK_LOGGING" ] } + if (pdf_use_skia) { + defines += [ "_SKIA_SUPPORT_" ] + } + + if (pdf_use_skia_paths) { + defines += [ "_SKIA_SUPPORT_PATHS_" ] + } + + if (is_win) { + # Assume UTF-8 by default to avoid code page dependencies. + cflags += [ "/utf-8" ] + } +} + +config("pdfium_public_config") { + defines = [] + + if (pdf_enable_v8) { + defines += [ "PDF_ENABLE_V8" ] + } + if (pdf_enable_xfa) { defines += [ "PDF_ENABLE_XFA" ] if (pdf_enable_xfa_bmp) { @@ -49,27 +66,17 @@ } } - if (pdf_use_skia) { - defines += [ "_SKIA_SUPPORT_" ] - } - - if (pdf_use_skia_paths) { - defines += [ "_SKIA_SUPPORT_PATHS_" ] - } - if (pdf_use_win32_gdi) { defines += [ "PDFIUM_PRINT_TEXT_WITH_GDI" ] } - - if (is_win) { - # Assume UTF-8 by default to avoid code page dependencies. - cflags += [ "/utf-8" ] - } } config("pdfium_core_config") { cflags = [] - configs = [ ":pdfium_common_config" ] + configs = [ + ":pdfium_common_config", + ":pdfium_public_config", + ] defines = [ "V8_DEPRECATION_WARNINGS" ] if (is_clang) { cflags += [ "-Wshadow" ] @@ -115,6 +122,8 @@ "public/fpdf_transformpage.h", "public/fpdfview.h", ] + + public_configs = [ ":pdfium_public_config" ] } jumbo_static_library("pdfium") {
diff --git a/samples/BUILD.gn b/samples/BUILD.gn index 01aff41..f2c8014 100644 --- a/samples/BUILD.gn +++ b/samples/BUILD.gn
@@ -20,12 +20,6 @@ "PNG_USE_READ_MACROS", ] include_dirs = [ ".." ] - if (pdf_enable_v8) { - defines += [ "PDF_ENABLE_V8" ] - } - if (pdf_enable_xfa) { - defines += [ "PDF_ENABLE_XFA" ] - } if (pdf_use_skia) { defines += [ "PDF_ENABLE_SKIA" ] }
diff --git a/testing/fuzzers/BUILD.gn b/testing/fuzzers/BUILD.gn index 1451467..e20fe12 100644 --- a/testing/fuzzers/BUILD.gn +++ b/testing/fuzzers/BUILD.gn
@@ -13,12 +13,6 @@ "PNG_USE_READ_MACROS", ] include_dirs = [ "../.." ] - if (pdf_enable_v8) { - defines += [ "PDF_ENABLE_V8" ] - } - if (pdf_enable_xfa) { - defines += [ "PDF_ENABLE_XFA" ] - } } group("fuzzers") {
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn index c803f5d..5fa8207 100644 --- a/third_party/BUILD.gn +++ b/third_party/BUILD.gn
@@ -19,7 +19,10 @@ } config("pdfium_third_party_config") { - configs = [ "..:pdfium_common_config" ] + configs = [ + "..:pdfium_common_config", + "..:pdfium_public_config", + ] } if (pdf_enable_xfa) {