Use system FreeType on Linux.
[pdfium.git] / BUILD.gn
index 86839fa..9c58b03 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2,15 +2,19 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+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"
-  ]
   defines = [
-    "FT2_BUILD_LIBRARY",
     "_FPDFSDK_LIB",
     "_NO_GDIPLUS_",  # workaround text rendering issues on Windows
     "OPJ_STATIC",
@@ -38,6 +42,13 @@ config("pdfium_config") {
       "/wd4345",
     ]
   }
+
+  if (bundle_freetype) {
+    include_dirs = [ "third_party/freetype/include" ]
+    defines += [ "FT2_BUILD_LIBRARY" ]
+  } else {
+    include_dirs = [ "/usr/include/freetype2" ]
+  }
 }
 
 static_library("pdfium") {
@@ -90,7 +101,6 @@ static_library("pdfium") {
 
   deps = [
     "third_party:bigint",
-    "third_party:freetype",
     "third_party:safemath",
     ":fdrm",
     ":formfiller",
@@ -113,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.
@@ -795,6 +811,7 @@ static_library("formfiller") {
 test("pdfium_unittests") {
   sources = [
     "core/src/fxcrt/fx_basic_bstring_unittest.cpp",
+    "core/src/fxcrt/fx_basic_wstring_unittest.cpp",
     "testing/fx_string_testhelpers.cpp",
     "testing/fx_string_testhelpers.h",
   ]
@@ -807,3 +824,23 @@ test("pdfium_unittests") {
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [ ":pdfium_config", "//build/config/compiler:no_chromium_code" ]
 }
+
+test("pdfium_embeddertests") {
+  sources = [
+    "fpdfsdk/src/fpdf_dataavail_embeddertest.cpp",
+    "fpdfsdk/src/fpdfdoc_embeddertest.cpp",
+    "fpdfsdk/src/fpdftext_embeddertest.cpp",
+    "fpdfsdk/src/fpdfview_embeddertest.cpp",
+    "testing/embedder_test.cpp",
+    "testing/embedder_test.h",
+    "testing/fx_string_testhelpers.cpp",
+    "testing/fx_string_testhelpers.h",
+  ]
+  deps = [
+    "//testing/gtest",
+    ":pdfium"
+  ]
+  include_dirs = [ "." ]
+  configs -= [ "//build/config/compiler:chromium_code" ]
+  configs += [ ":pdfium_config", "//build/config/compiler:no_chromium_code" ]
+}