Merge to XFA: Restore checked strlen conversions.
[pdfium.git] / BUILD.gn
index 87f360d..43a8644 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -6,15 +6,22 @@ import("//testing/test.gni")
 
 pdf_use_skia = false
 
+declare_args() {
+  # On Android there's no system FreeType. On Windows and Mac, only a few
+  # methods are used from it.
+  bundle_freetype = !is_linux
+}
+
 config("pdfium_config") {
   cflags = []
-  include_dirs = [
-    "third_party/freetype/include"
-  ]
+  include_dirs = [ "third_party/freetype/include" ]
   defines = [
-    "FT2_BUILD_LIBRARY",
     "_FPDFSDK_LIB",
     "_NO_GDIPLUS_",  # workaround text rendering issues on Windows
+    "OPJ_STATIC",
+    "PNG_PREFIX",
+    "PNGPREFIX_H",
+    "PNG_USE_READ_MACROS",
   ]
 
   if (pdf_use_skia) {
@@ -43,18 +50,6 @@ config("pdfium_config") {
 
 static_library("pdfium") {
   sources = [
-    "fpdfsdk/include/fpdfdoc.h",
-    "fpdfsdk/include/fpdfedit.h",
-    "fpdfsdk/include/fpdfformfill.h",
-    "fpdfsdk/include/fpdftext.h",
-    "fpdfsdk/include/fpdfview.h",
-    "fpdfsdk/include/fpdf_dataavail.h",
-    "fpdfsdk/include/fpdf_flatten.h",
-    "fpdfsdk/include/fpdf_progressive.h",
-    "fpdfsdk/include/fpdf_searchex.h",
-    "fpdfsdk/include/fpdf_sysfontinfo.h",
-    "fpdfsdk/include/fpdf_ext.h",
-    "fpdfsdk/include/fpdf_sysfontinfo.h",
     "fpdfsdk/include/fsdk_actionhandler.h",
     "fpdfsdk/include/fsdk_annothandler.h",
     "fpdfsdk/include/fsdk_baseannot.h",
@@ -81,8 +76,21 @@ static_library("pdfium") {
     "fpdfsdk/src/fsdk_rendercontext.cpp",
     "fpdfsdk/src/fpdfsdkdll.rc",
     "fpdfsdk/src/resource.h",
-    "fpdfsdk/include/fpdf_transformpage.h",
-    "fpdfsdk/src/fpdf_transformpage.cpp",
+    "public/fpdf_dataavail.h",
+    "public/fpdf_doc.h",
+    "public/fpdf_edit.h",
+    "public/fpdf_ext.h",
+    "public/fpdf_flatten.h",
+    "public/fpdf_formfill.h",
+    "public/fpdf_fwlevent.h",
+    "public/fpdf_ppo.h",
+    "public/fpdf_progressive.h",
+    "public/fpdf_save.h",
+    "public/fpdf_searchex.h",
+    "public/fpdf_sysfontinfo.h",
+    "public/fpdf_text.h",
+    "public/fpdf_transformpage.h",
+    "public/fpdfview.h",
   ]
 
   libs = []
@@ -91,8 +99,7 @@ static_library("pdfium") {
 
   deps = [
     "third_party:bigint",
-    "third_party:freetype",
-    "third_party:safemath",
+    "third_party:pdfium_base",
     ":fdrm",
     ":formfiller",
     ":fpdfapi",
@@ -116,6 +123,12 @@ static_library("pdfium") {
   if (is_mac) {
     libs += [ "AppKit.framework", "CoreFoundation.framework" ]
   }
+
+  if (bundle_freetype) {
+    deps += [ "third_party:freetype" ]
+  } else {
+    libs += [ "freetype" ]
+  }
 }
 
 # Targets below this are only visible within this file.
@@ -151,6 +164,7 @@ static_library("fpdfdoc") {
     "core/src/fpdfdoc/doc_ocg.cpp",
     "core/src/fpdfdoc/doc_tagged.cpp",
     "core/src/fpdfdoc/doc_utils.cpp",
+    "core/src/fpdfdoc/doc_utils.h",
     "core/src/fpdfdoc/doc_viewerPreferences.cpp",
     "core/src/fpdfdoc/doc_vt.cpp",
     "core/src/fpdfdoc/doc_vtmodule.cpp",
@@ -249,7 +263,6 @@ static_library("fpdfapi") {
     "core/src/fpdfapi/fpdf_font/fpdf_font.cpp",
     "core/src/fpdfapi/fpdf_font/fpdf_font_charset.cpp",
     "core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp",
-    "core/src/fpdfapi/fpdf_font/fpdf_font_utility.cpp",
     "core/src/fpdfapi/fpdf_font/ttgsubtable.cpp",
     "core/src/fpdfapi/fpdf_font/ttgsubtable.h",
     "core/src/fpdfapi/fpdf_page/fpdf_page.cpp",
@@ -338,7 +351,6 @@ static_library("fxcodec") {
     "core/src/fxcodec/fx_libopenjpeg/src/fx_pi.c",
     "core/src/fxcodec/fx_libopenjpeg/src/fx_raw.c",
     "core/src/fxcodec/fx_libopenjpeg/src/fx_t1.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_t1_generate_luts.c",
     "core/src/fxcodec/fx_libopenjpeg/src/fx_t2.c",
     "core/src/fxcodec/fx_libopenjpeg/src/fx_tcd.c",
     "core/src/fxcodec/fx_libopenjpeg/src/fx_tgt.c",
@@ -545,6 +557,7 @@ static_library("fxcrt") {
     "core/include/fxcrt/fx_ucd.h",
     "core/include/fxcrt/fx_xml.h",
     "core/src/fxcrt/extension.h",
+    "core/src/fxcrt/fx_safe_types.h",
     "core/src/fxcrt/fxcrt_platforms.cpp",
     "core/src/fxcrt/fxcrt_platforms.h",
     "core/src/fxcrt/fxcrt_posix.cpp",
@@ -761,12 +774,10 @@ static_library("javascript") {
     "fpdfsdk/include/javascript/Icon.h",
     "fpdfsdk/include/javascript/IJavaScript.h",
     "fpdfsdk/include/javascript/JavaScript.h",
-    "fpdfsdk/include/javascript/JS_Console.h",
     "fpdfsdk/include/javascript/JS_Context.h",
     "fpdfsdk/include/javascript/JS_Define.h",
     "fpdfsdk/include/javascript/JS_EventHandler.h",
     "fpdfsdk/include/javascript/JS_GlobalData.h",
-    "fpdfsdk/include/javascript/JS_Module.h",
     "fpdfsdk/include/javascript/JS_Object.h",
     "fpdfsdk/include/javascript/JS_Runtime.h",
     "fpdfsdk/include/javascript/JS_Value.h",
@@ -791,6 +802,7 @@ static_library("javascript") {
     "fpdfsdk/src/javascript/JS_Value.cpp",
     "fpdfsdk/src/javascript/PublicMethods.cpp",
     "fpdfsdk/src/javascript/report.cpp",
+    "fpdfsdk/src/javascript/resource.cpp",
     "fpdfsdk/src/javascript/util.cpp",
   ]
 
@@ -804,9 +816,6 @@ static_library("javascript") {
   public_deps = [
     "//v8",
   ]
-  deps = [
-    "//v8:v8_libplatform",
-  ]
 }
 
 static_library("jsapi") {
@@ -1545,6 +1554,7 @@ static_library("xfa") {
 
 test("pdfium_unittests") {
   sources = [
+    "core/src/fxcodec/codec/fx_codec_jpx_unittest.cpp",
     "core/src/fxcrt/fx_basic_bstring_unittest.cpp",
     "core/src/fxcrt/fx_basic_wstring_unittest.cpp",
     "testing/fx_string_testhelpers.cpp",
@@ -1563,18 +1573,30 @@ test("pdfium_unittests") {
 
 test("pdfium_embeddertests") {
   sources = [
+    "core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp",
+    "core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_embeddertest.cpp",
+    "fpdfsdk/src/fpdf_dataavail_embeddertest.cpp",
     "fpdfsdk/src/fpdfdoc_embeddertest.cpp",
+    "fpdfsdk/src/fpdfformfill_embeddertest.cpp",
+    "fpdfsdk/src/fpdftext_embeddertest.cpp",
     "fpdfsdk/src/fpdfview_embeddertest.cpp",
     "testing/embedder_test.cpp",
     "testing/embedder_test.h",
+    "testing/embedder_test_mock_delegate.h",
     "testing/fx_string_testhelpers.cpp",
     "testing/fx_string_testhelpers.h",
   ]
   deps = [
+    "//testing/gmock",
     "//testing/gtest",
+    "//v8:v8_libplatform",
     ":pdfium"
   ]
-  include_dirs = [ "." ]
+  include_dirs = [
+    ".",
+    "//v8",
+    "//v8/include",
+  ]
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [ ":pdfium_config", "//build/config/compiler:no_chromium_code" ]
 }