(Reland) Switch builds to clang by default for Linux and OS X.
[pdfium.git] / BUILD.gn
index 4ba901e..e563e87 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -3,14 +3,7 @@
 # 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.
-  pdfium_bundle_freetype = !is_linux
-}
+import("pdfium.gni")
 
 config("pdfium_config") {
   cflags = []
@@ -25,6 +18,10 @@ config("pdfium_config") {
     defines += [ "_SKIA_SUPPORT_" ]
   }
 
+  if (pdf_enable_v8) {
+    defines += [ "PDF_ENABLE_V8" ]
+  }
+
   if (is_linux) {
     if (current_cpu == "x64") {
       defines += [ "_FX_CPU_=_FX_X64_" ]
@@ -111,7 +108,6 @@ static_library("pdfium") {
     ":fxedit",
     ":fxge",
     ":javascript",
-    ":jsapi",
     ":pdfwindow",
   ]
 
@@ -137,6 +133,39 @@ static_library("pdfium") {
   }
 }
 
+source_set("test_support") {
+  testonly = true
+  sources = [
+    "testing/fx_string_testhelpers.cpp",
+    "testing/fx_string_testhelpers.h",
+    "testing/test_support.cpp",
+    "testing/test_support.h",
+  ]
+  deps = [
+    "//testing/gmock",
+    "//testing/gtest",
+    ":pdfium",
+  ]
+  include_dirs = [
+    "."
+  ]
+  if (pdf_enable_v8) {
+    deps += [
+      "//v8",
+      "//v8:v8_libplatform",
+    ]
+    include_dirs += [
+      "//v8",
+      "//v8/include",
+    ]
+  }
+  configs -= [ "//build/config/compiler:chromium_code" ]
+  configs += [
+    ":pdfium_config",
+    "//build/config/compiler:no_chromium_code",
+  ]
+}
+
 # Targets below this are only visible within this file (and to the
 # top-level gn_visibility target used to help gn_all build everything).
 visibility = [
@@ -321,6 +350,7 @@ static_library("fpdftext") {
     "core/src/fpdftext/txtproc.h",
     "core/src/fpdftext/unicodenormalization.cpp",
     "core/src/fpdftext/unicodenormalizationdata.cpp",
+    "core/src/fpdftext/unicodenormalizationdata.h",
   ]
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
@@ -350,16 +380,23 @@ static_library("fxcodec") {
     "core/src/fxcodec/codec/fx_codec_jbig_enc.cpp",
     "core/src/fxcodec/codec/fx_codec_jpeg.cpp",
     "core/src/fxcodec/codec/fx_codec_jpx_opj.cpp",
+    "core/src/fxcodec/jbig2/JBig2_ArithDecoder.cpp",
     "core/src/fxcodec/jbig2/JBig2_ArithDecoder.h",
     "core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp",
     "core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.h",
-    "core/src/fxcodec/jbig2/JBig2_ArithQe.h",
+    "core/src/fxcodec/jbig2/JBig2_BitStream.cpp",
     "core/src/fxcodec/jbig2/JBig2_BitStream.h",
     "core/src/fxcodec/jbig2/JBig2_Context.cpp",
     "core/src/fxcodec/jbig2/JBig2_Context.h",
     "core/src/fxcodec/jbig2/JBig2_Define.h",
-    "core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp",
-    "core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h",
+    "core/src/fxcodec/jbig2/JBig2_GrdProc.cpp",
+    "core/src/fxcodec/jbig2/JBig2_GrdProc.h",
+    "core/src/fxcodec/jbig2/JBig2_GrrdProc.cpp",
+    "core/src/fxcodec/jbig2/JBig2_GrrdProc.h",
+    "core/src/fxcodec/jbig2/JBig2_GsidProc.cpp",
+    "core/src/fxcodec/jbig2/JBig2_GsidProc.h",
+    "core/src/fxcodec/jbig2/JBig2_HtrdProc.cpp",
+    "core/src/fxcodec/jbig2/JBig2_HtrdProc.h",
     "core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp",
     "core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.h",
     "core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp",
@@ -368,16 +405,19 @@ static_library("fxcodec") {
     "core/src/fxcodec/jbig2/JBig2_Image.cpp",
     "core/src/fxcodec/jbig2/JBig2_Image.h",
     "core/src/fxcodec/jbig2/JBig2_List.h",
-    "core/src/fxcodec/jbig2/JBig2_Module.h",
-    "core/src/fxcodec/jbig2/JBig2_Object.cpp",
-    "core/src/fxcodec/jbig2/JBig2_Object.h",
     "core/src/fxcodec/jbig2/JBig2_Page.h",
     "core/src/fxcodec/jbig2/JBig2_PatternDict.cpp",
     "core/src/fxcodec/jbig2/JBig2_PatternDict.h",
+    "core/src/fxcodec/jbig2/JBig2_PddProc.cpp",
+    "core/src/fxcodec/jbig2/JBig2_PddProc.h",
+    "core/src/fxcodec/jbig2/JBig2_SddProc.cpp",
+    "core/src/fxcodec/jbig2/JBig2_SddProc.h",
     "core/src/fxcodec/jbig2/JBig2_Segment.cpp",
     "core/src/fxcodec/jbig2/JBig2_Segment.h",
     "core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp",
     "core/src/fxcodec/jbig2/JBig2_SymbolDict.h",
+    "core/src/fxcodec/jbig2/JBig2_TrdProc.cpp",
+    "core/src/fxcodec/jbig2/JBig2_TrdProc.h",
   ]
   configs -= [ "//build/config/compiler:chromium_code" ]
 
@@ -392,6 +432,15 @@ static_library("fxcodec") {
   ]
 }
 
+config("fxge_warnings") {
+  if (is_clang) {
+    cflags = [
+      # http://code.google.com/p/pdfium/issues/detail?id=188
+      "-Wno-switch",
+    ]
+  }
+}
+
 static_library("fxcrt") {
   sources = [
     "core/include/fxcrt/fx_basic.h",
@@ -474,6 +523,7 @@ static_library("fxge") {
     "core/src/fxge/dib/fx_dib_engine.cpp",
     "core/src/fxge/dib/fx_dib_main.cpp",
     "core/src/fxge/dib/fx_dib_transform.cpp",
+    "core/src/fxge/fontdata/chromefontdata/chromefontdata.h",
     "core/src/fxge/fontdata/chromefontdata/FoxitDingbats.c",
     "core/src/fxge/fontdata/chromefontdata/FoxitFixed.c",
     "core/src/fxge/fontdata/chromefontdata/FoxitFixedBold.c",
@@ -502,14 +552,6 @@ static_library("fxge") {
     "core/src/fxge/ge/text_int.h",
   ]
 
-  config("fxge_warnings") {
-    if (is_clang) {
-      cflags = [
-        # http://code.google.com/p/pdfium/issues/detail?id=188
-        "-Wno-switch",
-      ]
-    }
-  }
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
     ":pdfium_config",
@@ -618,83 +660,67 @@ static_library("pdfwindow") {
 
 static_library("javascript") {
   sources = [
-    "fpdfsdk/include/javascript/Consts.h",
-    "fpdfsdk/include/javascript/Document.h",
-    "fpdfsdk/include/javascript/Field.h",
     "fpdfsdk/include/javascript/IJavaScript.h",
-    "fpdfsdk/include/javascript/Icon.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_Object.h",
-    "fpdfsdk/include/javascript/JS_Runtime.h",
-    "fpdfsdk/include/javascript/JS_Value.h",
-    "fpdfsdk/include/javascript/JavaScript.h",
-    "fpdfsdk/include/javascript/PublicMethods.h",
-    "fpdfsdk/include/javascript/app.h",
-    "fpdfsdk/include/javascript/color.h",
-    "fpdfsdk/include/javascript/console.h",
-    "fpdfsdk/include/javascript/event.h",
-    "fpdfsdk/include/javascript/global.h",
-    "fpdfsdk/include/javascript/report.h",
-    "fpdfsdk/include/javascript/resource.h",
-    "fpdfsdk/include/javascript/util.h",
-    "fpdfsdk/src/javascript/Consts.cpp",
-    "fpdfsdk/src/javascript/Document.cpp",
-    "fpdfsdk/src/javascript/Field.cpp",
-    "fpdfsdk/src/javascript/Icon.cpp",
-    "fpdfsdk/src/javascript/JS_Context.cpp",
-    "fpdfsdk/src/javascript/JS_EventHandler.cpp",
-    "fpdfsdk/src/javascript/JS_GlobalData.cpp",
-    "fpdfsdk/src/javascript/JS_Object.cpp",
-    "fpdfsdk/src/javascript/JS_Runtime.cpp",
-    "fpdfsdk/src/javascript/JS_Value.cpp",
-    "fpdfsdk/src/javascript/PublicMethods.cpp",
-    "fpdfsdk/src/javascript/app.cpp",
-    "fpdfsdk/src/javascript/color.cpp",
-    "fpdfsdk/src/javascript/console.cpp",
-    "fpdfsdk/src/javascript/event.cpp",
-    "fpdfsdk/src/javascript/global.cpp",
-    "fpdfsdk/src/javascript/report.cpp",
-    "fpdfsdk/src/javascript/resource.cpp",
-    "fpdfsdk/src/javascript/util.cpp",
-  ]
-
-  configs -= [ "//build/config/compiler:chromium_code" ]
-  configs += [
-    ":pdfium_config",
-    "//build/config/compiler:no_chromium_code",
-  ]
-  include_dirs = [
-    "//v8",
-    "//v8/include",
-  ]
-
-  public_deps = [
-    "//v8",
   ]
-}
-
-static_library("jsapi") {
-  sources = [
-    "fpdfsdk/include/jsapi/fxjs_v8.h",
-    "fpdfsdk/src/jsapi/fxjs_v8.cpp",
-  ]
-
+  if (pdf_enable_v8) {
+    sources += [
+      "fpdfsdk/src/javascript/Consts.cpp",
+      "fpdfsdk/src/javascript/Consts.h",
+      "fpdfsdk/src/javascript/Document.cpp",
+      "fpdfsdk/src/javascript/Document.h",
+      "fpdfsdk/src/javascript/Field.cpp",
+      "fpdfsdk/src/javascript/Field.h",
+      "fpdfsdk/src/javascript/Icon.cpp",
+      "fpdfsdk/src/javascript/Icon.h",
+      "fpdfsdk/src/javascript/JS_Context.cpp",
+      "fpdfsdk/src/javascript/JS_Context.h",
+      "fpdfsdk/src/javascript/JS_Define.h",
+      "fpdfsdk/src/javascript/JS_EventHandler.cpp",
+      "fpdfsdk/src/javascript/JS_EventHandler.h",
+      "fpdfsdk/src/javascript/JS_GlobalData.cpp",
+      "fpdfsdk/src/javascript/JS_GlobalData.h",
+      "fpdfsdk/src/javascript/JS_Object.cpp",
+      "fpdfsdk/src/javascript/JS_Object.h",
+      "fpdfsdk/src/javascript/JS_Runtime.cpp",
+      "fpdfsdk/src/javascript/JS_Runtime.h",
+      "fpdfsdk/src/javascript/JS_Value.cpp",
+      "fpdfsdk/src/javascript/JS_Value.h",
+      "fpdfsdk/src/javascript/PublicMethods.cpp",
+      "fpdfsdk/src/javascript/PublicMethods.h",
+      "fpdfsdk/src/javascript/app.cpp",
+      "fpdfsdk/src/javascript/app.h",
+      "fpdfsdk/src/javascript/color.cpp",
+      "fpdfsdk/src/javascript/color.h",
+      "fpdfsdk/src/javascript/console.cpp",
+      "fpdfsdk/src/javascript/console.h",
+      "fpdfsdk/src/javascript/event.cpp",
+      "fpdfsdk/src/javascript/event.h",
+      "fpdfsdk/src/javascript/global.cpp",
+      "fpdfsdk/src/javascript/global.h",
+      "fpdfsdk/src/javascript/report.cpp",
+      "fpdfsdk/src/javascript/report.h",
+      "fpdfsdk/src/javascript/resource.cpp",
+      "fpdfsdk/src/javascript/resource.h",
+      "fpdfsdk/src/javascript/util.cpp",
+      "fpdfsdk/src/javascript/util.h",
+      "fpdfsdk/include/jsapi/fxjs_v8.h",
+      "fpdfsdk/src/jsapi/fxjs_v8.cpp",
+    ]
+    include_dirs = [
+      "//v8",
+      "//v8/include",
+    ]
+    public_deps = [
+      "//v8",
+    ]
+  } else {
+    sources += [ "fpdfsdk/src/javascript/JS_Runtime_Stub.cpp" ]
+  }
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
     ":pdfium_config",
     "//build/config/compiler:no_chromium_code",
   ]
-  include_dirs = [
-    "//v8",
-    "//v8/include",
-  ]
-
-  public_deps = [
-    "//v8",
-  ]
 }
 
 static_library("formfiller") {
@@ -705,11 +731,9 @@ static_library("formfiller") {
     "fpdfsdk/include/formfiller/FFL_FormFiller.h",
     "fpdfsdk/include/formfiller/FFL_IFormFiller.h",
     "fpdfsdk/include/formfiller/FFL_ListBox.h",
-    "fpdfsdk/include/formfiller/FFL_Notify.h",
     "fpdfsdk/include/formfiller/FFL_PushButton.h",
     "fpdfsdk/include/formfiller/FFL_RadioButton.h",
     "fpdfsdk/include/formfiller/FFL_TextField.h",
-    "fpdfsdk/include/formfiller/FFL_Utils.h",
     "fpdfsdk/include/formfiller/FormFiller.h",
     "fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp",
     "fpdfsdk/src/formfiller/FFL_CheckBox.cpp",
@@ -717,11 +741,9 @@ static_library("formfiller") {
     "fpdfsdk/src/formfiller/FFL_FormFiller.cpp",
     "fpdfsdk/src/formfiller/FFL_IFormFiller.cpp",
     "fpdfsdk/src/formfiller/FFL_ListBox.cpp",
-    "fpdfsdk/src/formfiller/FFL_Notify.cpp",
     "fpdfsdk/src/formfiller/FFL_PushButton.cpp",
     "fpdfsdk/src/formfiller/FFL_RadioButton.cpp",
     "fpdfsdk/src/formfiller/FFL_TextField.cpp",
-    "fpdfsdk/src/formfiller/FFL_Utils.cpp",
   ]
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
@@ -738,13 +760,13 @@ test("pdfium_unittests") {
     "core/src/fxcrt/fx_basic_wstring_unittest.cpp",
     "core/src/fxcrt/fx_bidi_unittest.cpp",
     "core/src/fxcrt/fx_system_unittest.cpp",
-    "testing/fx_string_testhelpers.cpp",
-    "testing/fx_string_testhelpers.h",
+    "third_party/base/nonstd_unique_ptr_unittest.cpp",
   ]
   deps = [
     "//testing/gtest",
     "//testing/gtest:gtest_main",
     ":pdfium",
+    ":test_support",
   ]
   include_dirs = [ "." ]
   configs -= [ "//build/config/compiler:chromium_code" ]
@@ -769,20 +791,29 @@ test("pdfium_embeddertests") {
     "testing/embedder_test.h",
     "testing/embedder_test_mock_delegate.h",
     "testing/embedder_test_timer_handling_delegate.h",
-    "testing/fx_string_testhelpers.cpp",
-    "testing/fx_string_testhelpers.h",
   ]
   deps = [
     "//testing/gmock",
     "//testing/gtest",
-    "//v8:v8_libplatform",
     ":pdfium",
+    ":test_support",
   ]
   include_dirs = [
-    "//v8",
-    "//v8/include",
     "."
   ]
+  if (pdf_enable_v8) {
+    sources += [
+     "fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp"
+    ]
+    deps += [
+      "//v8",
+      "//v8:v8_libplatform",
+    ]
+    include_dirs += [
+      "//v8",
+      "//v8/include",
+    ]
+  }
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
     ":pdfium_config",