Switch pdfium target from a static library to a component
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: I03cfcac6206a42729139de8e93249c906b63d9a7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/53290
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/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/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..d19dbfc 100644
--- a/testing/fuzzers/BUILD.gn
+++ b/testing/fuzzers/BUILD.gn
@@ -143,6 +143,7 @@
"pdf_fx_date_helpers_fuzzer.cc",
]
deps = [
+ "../../fpdfsdk",
"../../fxjs",
]
}
@@ -345,6 +346,7 @@
]
deps = [
":utils",
+ "../../core/fpdfapi",
"../../core/fpdfapi/parser",
"../../core/fxcodec",
"../../core/fxge",
@@ -408,6 +410,9 @@
sources = [
"pdf_xml_fuzzer.cc",
]
+ deps = [
+ "../../core/fxcrt",
+ ]
}
pdfium_public_fuzzer("pdfium_fuzzer_src") {