[Reland] Switch pdfium target from a static library to a component
Reland fixes linker failures, verified by Chromium's CQ:
https://chromium-review.googlesource.com/c/chromium/src/+/1590226
Reduces size of build directory by 206 MiB (-1.0%) when building "all"
with gn args "use_goma=true is_component_build=true is_debug=false
enable_nacl=false symbol_level=1". Build time also reduced from
426.111s to 405.252s, though I only took one sample.
Also added some missing dependencies that were causing linker failures
in component builds.
BUG=chromium:941663
R=thestig
Change-Id: Ie5d71a50741e0c4f57554b29816e89cf43fffdc6
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/53731
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 83fc631..65a8597 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -129,7 +129,7 @@
public_configs = [ ":pdfium_public_config" ]
}
-jumbo_static_library("pdfium") {
+jumbo_component("pdfium") {
sources = [
"fpdfsdk/fpdf_annot.cpp",
"fpdfsdk/fpdf_attachment.cpp",
@@ -184,6 +184,8 @@
"core/fxcrt",
]
+ defines = [ "FPDF_IMPLEMENTATION" ]
+
if (pdf_enable_xfa) {
deps += [
"fpdfsdk/fpdfxfa",
@@ -359,6 +361,7 @@
]
deps = [
":pdfium",
+ "core/fxcrt",
"testing/image_diff",
"//build/win:default_exe_manifest",
]
diff --git a/core/fpdfapi/font/BUILD.gn b/core/fpdfapi/font/BUILD.gn
index 1e8c76e..c5ce882 100644
--- a/core/fpdfapi/font/BUILD.gn
+++ b/core/fpdfapi/font/BUILD.gn
@@ -48,6 +48,9 @@
"../cmaps",
"../parser",
]
+ if (is_mac) {
+ libs = [ "CoreFoundation.framework" ]
+ }
allow_circular_includes_from = [
"../../fxge",
"../cmaps",
diff --git a/core/fxcrt/BUILD.gn b/core/fxcrt/BUILD.gn
index 88337ff..fd21666 100644
--- a/core/fxcrt/BUILD.gn
+++ b/core/fxcrt/BUILD.gn
@@ -88,6 +88,7 @@
"../../fpdfsdk/*",
"../../fxbarcode:*",
"../../fxjs:*",
+ "../../testing/fuzzers:*",
"../../third_party:fx_agg",
"../../third_party:fx_lcms2",
"../../third_party:fx_tiff",
diff --git a/core/fxge/BUILD.gn b/core/fxge/BUILD.gn
index 6c9ed9a..83374cc 100644
--- a/core/fxge/BUILD.gn
+++ b/core/fxge/BUILD.gn
@@ -168,6 +168,7 @@
"apple/fx_mac_imp.cpp",
"apple/fx_quartz_device.cpp",
]
+ libs = [ "CoreGraphics.framework" ]
}
if (is_win) {
diff --git a/public/fpdfview.h b/public/fpdfview.h
index 8892da5..601ac54 100644
--- a/public/fpdfview.h
+++ b/public/fpdfview.h
@@ -154,12 +154,27 @@
// Dictionary value types.
typedef int FPDF_OBJECT_TYPE;
-#if defined(_WIN32) && defined(FPDFSDK_EXPORTS)
-// On Windows system, functions are exported in a DLL
+#if defined(COMPONENT_BUILD)
+#if defined(WIN32)
+#if defined(FPDF_IMPLEMENTATION)
#define FPDF_EXPORT __declspec(dllexport)
-#define FPDF_CALLCONV __stdcall
+#else
+#define FPDF_EXPORT __declspec(dllimport)
+#endif // defined(FPDF_IMPLEMENTATION)
+#else
+#if defined(FPDF_IMPLEMENTATION)
+#define FPDF_EXPORT __attribute__((visibility("default")))
#else
#define FPDF_EXPORT
+#endif // defined(FPDF_IMPLEMENTATION)
+#endif // defined(WIN32)
+#else
+#define FPDF_EXPORT
+#endif // defined(COMPONENT_BUILD)
+
+#if defined(WIN32) && defined(FPDFSDK_EXPORTS)
+#define FPDF_CALLCONV __stdcall
+#else
#define FPDF_CALLCONV
#endif
diff --git a/testing/fuzzers/BUILD.gn b/testing/fuzzers/BUILD.gn
index 0dbbccc..fd47b88 100644
--- a/testing/fuzzers/BUILD.gn
+++ b/testing/fuzzers/BUILD.gn
@@ -135,6 +135,7 @@
"pdf_cjs_util_fuzzer.cc",
]
deps = [
+ "../../fpdfsdk",
"../../fxjs",
]
}
@@ -143,6 +144,7 @@
"pdf_fx_date_helpers_fuzzer.cc",
]
deps = [
+ "../../fpdfsdk",
"../../fxjs",
]
}
@@ -153,6 +155,7 @@
"pdf_bidi_fuzzer.cc",
]
deps = [
+ "../../core/fpdfapi",
"../../core/fxge",
"../../xfa/fgas",
"../../xfa/fgas/layout",
@@ -164,6 +167,7 @@
"pdf_cfgas_stringformatter_fuzzer.cc",
]
deps = [
+ "../../fpdfsdk",
"../../xfa/fgas",
"../../xfa/fxfa/parser",
]
@@ -174,6 +178,7 @@
"pdf_cfx_barcode_fuzzer.cc",
]
deps = [
+ "../../fpdfsdk",
"../../xfa/fwl",
]
}
@@ -260,6 +265,7 @@
"pdf_css_fuzzer.cc",
]
deps = [
+ "../../core/fxcodec",
"../../core/fxcrt/css",
]
}
@@ -269,6 +275,7 @@
"pdf_fm2js_fuzzer.cc",
]
deps = [
+ "../../fpdfsdk",
"../../fxjs",
]
}
@@ -278,6 +285,7 @@
"pdf_formcalc_context_fuzzer.cc",
]
deps = [
+ "../../fpdfsdk",
"../../fpdfsdk/fpdfxfa",
"../../fxjs",
"../../xfa/fxfa",
@@ -306,6 +314,7 @@
"pdf_cmap_fuzzer.cc",
]
deps = [
+ "../../core/fpdfapi",
"../../core/fpdfapi/font",
]
}
@@ -315,6 +324,7 @@
"pdf_codec_a85_fuzzer.cc",
]
deps = [
+ "../../core/fpdfapi",
"../../core/fxcodec",
]
}
@@ -325,6 +335,7 @@
]
deps = [
":utils",
+ "../../core/fpdfapi",
"../../core/fxcodec",
]
}
@@ -334,6 +345,7 @@
"pdf_codec_icc_fuzzer.cc",
]
deps = [
+ "../../core/fpdfapi",
"../../core/fxcodec",
"../../third_party/:lcms2",
]
@@ -345,6 +357,7 @@
]
deps = [
":utils",
+ "../../core/fpdfapi",
"../../core/fpdfapi/parser",
"../../core/fxcodec",
"../../core/fxge",
@@ -356,6 +369,7 @@
"pdf_codec_rle_fuzzer.cc",
]
deps = [
+ "../../core/fpdfapi",
"../../core/fxcodec",
]
}
@@ -371,6 +385,7 @@
"pdf_hint_table_fuzzer.cc",
]
deps = [
+ "../../core/fpdfapi",
"../../core/fpdfapi/parser",
]
}
@@ -380,6 +395,7 @@
"pdf_jpx_fuzzer.cc",
]
deps = [
+ "../../core/fpdfapi",
"../../core/fxcodec",
"../../core/fxge",
]
@@ -390,6 +406,7 @@
"pdf_psengine_fuzzer.cc",
]
deps = [
+ "../../core/fpdfapi",
"../../core/fpdfapi/page",
]
}
@@ -399,6 +416,7 @@
"pdf_streamparser_fuzzer.cc",
]
deps = [
+ "../../core/fpdfapi",
"../../core/fpdfapi/page",
"../../core/fpdfapi/parser",
]
@@ -408,6 +426,9 @@
sources = [
"pdf_xml_fuzzer.cc",
]
+ deps = [
+ "../../core/fxcrt",
+ ]
}
pdfium_public_fuzzer("pdfium_fuzzer_src") {