Split fpdfsdk build rules into various BUILD.gn files in fpdfsdk.

Change-Id: I3500ab9a9bbf0ec983e02dd4b739c9b199d71e21
Reviewed-on: https://pdfium-review.googlesource.com/c/43943
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 5227fcb..aa676b7 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -94,43 +94,6 @@
 
 jumbo_static_library("pdfium") {
   sources = [
-    "fpdfsdk/cfx_systemhandler.cpp",
-    "fpdfsdk/cfx_systemhandler.h",
-    "fpdfsdk/cpdf_annotcontext.cpp",
-    "fpdfsdk/cpdf_annotcontext.h",
-    "fpdfsdk/cpdfsdk_actionhandler.cpp",
-    "fpdfsdk/cpdfsdk_actionhandler.h",
-    "fpdfsdk/cpdfsdk_annot.cpp",
-    "fpdfsdk/cpdfsdk_annot.h",
-    "fpdfsdk/cpdfsdk_annothandlermgr.cpp",
-    "fpdfsdk/cpdfsdk_annothandlermgr.h",
-    "fpdfsdk/cpdfsdk_annotiteration.cpp",
-    "fpdfsdk/cpdfsdk_annotiteration.h",
-    "fpdfsdk/cpdfsdk_annotiterator.cpp",
-    "fpdfsdk/cpdfsdk_annotiterator.h",
-    "fpdfsdk/cpdfsdk_baannot.cpp",
-    "fpdfsdk/cpdfsdk_baannot.h",
-    "fpdfsdk/cpdfsdk_baannothandler.cpp",
-    "fpdfsdk/cpdfsdk_baannothandler.h",
-    "fpdfsdk/cpdfsdk_common.h",
-    "fpdfsdk/cpdfsdk_customaccess.cpp",
-    "fpdfsdk/cpdfsdk_customaccess.h",
-    "fpdfsdk/cpdfsdk_fieldaction.cpp",
-    "fpdfsdk/cpdfsdk_fieldaction.h",
-    "fpdfsdk/cpdfsdk_filewriteadapter.cpp",
-    "fpdfsdk/cpdfsdk_filewriteadapter.h",
-    "fpdfsdk/cpdfsdk_formfillenvironment.cpp",
-    "fpdfsdk/cpdfsdk_formfillenvironment.h",
-    "fpdfsdk/cpdfsdk_helpers.cpp",
-    "fpdfsdk/cpdfsdk_helpers.h",
-    "fpdfsdk/cpdfsdk_interactiveform.cpp",
-    "fpdfsdk/cpdfsdk_interactiveform.h",
-    "fpdfsdk/cpdfsdk_pageview.cpp",
-    "fpdfsdk/cpdfsdk_pageview.h",
-    "fpdfsdk/cpdfsdk_widget.cpp",
-    "fpdfsdk/cpdfsdk_widget.h",
-    "fpdfsdk/cpdfsdk_widgethandler.cpp",
-    "fpdfsdk/cpdfsdk_widgethandler.h",
     "fpdfsdk/fpdf_annot.cpp",
     "fpdfsdk/fpdf_attachment.cpp",
     "fpdfsdk/fpdf_catalog.cpp",
@@ -152,9 +115,6 @@
     "fpdfsdk/fpdf_text.cpp",
     "fpdfsdk/fpdf_transformpage.cpp",
     "fpdfsdk/fpdf_view.cpp",
-    "fpdfsdk/ipdfsdk_annothandler.h",
-    "fpdfsdk/ipdfsdk_pauseadapter.cpp",
-    "fpdfsdk/ipdfsdk_pauseadapter.h",
     "public/cpp/fpdf_deleters.h",
     "public/cpp/fpdf_scopers.h",
     "public/fpdf_annot.h",
@@ -184,14 +144,15 @@
   deps = [
     ":constants",
     ":fdrm",
-    ":formfiller",
     ":fpdfapi",
     ":fpdfdoc",
     ":fpdftext",
     ":fxcodec",
     ":fxcrt",
     ":fxge",
-    ":pwl",
+    "fpdfsdk",
+    "fpdfsdk/formfiller",
+    "fpdfsdk/pwl",
     "fxjs",
     "third_party:pdfium_base",
     "third_party:skia_shared",
@@ -200,16 +161,6 @@
   public_deps = [
     ":fxcrt",
   ]
-  if (pdf_enable_xfa) {
-    sources += [
-      "fpdfsdk/cpdfsdk_xfawidget.cpp",
-      "fpdfsdk/cpdfsdk_xfawidget.h",
-      "fpdfsdk/cpdfsdk_xfawidgethandler.cpp",
-      "fpdfsdk/cpdfsdk_xfawidgethandler.h",
-    ]
-
-    deps += [ ":fpdfxfa" ]
-  }
 
   if (is_win) {
     libs += [
@@ -918,6 +869,7 @@
   configs += [ ":pdfium_core_config" ]
   visibility += [
     "fxbarcode:*",
+    "fpdfsdk/*",
     "fxjs:*",
     "xfa/*",
     "third_party:*",
@@ -1157,99 +1109,6 @@
   }
 }
 
-jumbo_source_set("pwl") {
-  sources = [
-    "fpdfsdk/pwl/cpwl_appstream.cpp",
-    "fpdfsdk/pwl/cpwl_appstream.h",
-    "fpdfsdk/pwl/cpwl_button.cpp",
-    "fpdfsdk/pwl/cpwl_button.h",
-    "fpdfsdk/pwl/cpwl_caret.cpp",
-    "fpdfsdk/pwl/cpwl_caret.h",
-    "fpdfsdk/pwl/cpwl_combo_box.cpp",
-    "fpdfsdk/pwl/cpwl_combo_box.h",
-    "fpdfsdk/pwl/cpwl_edit.cpp",
-    "fpdfsdk/pwl/cpwl_edit.h",
-    "fpdfsdk/pwl/cpwl_edit_ctrl.cpp",
-    "fpdfsdk/pwl/cpwl_edit_ctrl.h",
-    "fpdfsdk/pwl/cpwl_edit_impl.cpp",
-    "fpdfsdk/pwl/cpwl_edit_impl.h",
-    "fpdfsdk/pwl/cpwl_font_map.cpp",
-    "fpdfsdk/pwl/cpwl_font_map.h",
-    "fpdfsdk/pwl/cpwl_icon.cpp",
-    "fpdfsdk/pwl/cpwl_icon.h",
-    "fpdfsdk/pwl/cpwl_list_box.cpp",
-    "fpdfsdk/pwl/cpwl_list_box.h",
-    "fpdfsdk/pwl/cpwl_list_impl.cpp",
-    "fpdfsdk/pwl/cpwl_list_impl.h",
-    "fpdfsdk/pwl/cpwl_scroll_bar.cpp",
-    "fpdfsdk/pwl/cpwl_scroll_bar.h",
-    "fpdfsdk/pwl/cpwl_special_button.cpp",
-    "fpdfsdk/pwl/cpwl_special_button.h",
-    "fpdfsdk/pwl/cpwl_timer.cpp",
-    "fpdfsdk/pwl/cpwl_timer.h",
-    "fpdfsdk/pwl/cpwl_timer_handler.cpp",
-    "fpdfsdk/pwl/cpwl_timer_handler.h",
-    "fpdfsdk/pwl/cpwl_wnd.cpp",
-    "fpdfsdk/pwl/cpwl_wnd.h",
-  ]
-  configs += [ ":pdfium_core_config" ]
-  deps = [
-    ":fxcrt",
-  ]
-}
-
-jumbo_source_set("formfiller") {
-  sources = [
-    "fpdfsdk/formfiller/cba_fontmap.cpp",
-    "fpdfsdk/formfiller/cba_fontmap.h",
-    "fpdfsdk/formfiller/cffl_button.cpp",
-    "fpdfsdk/formfiller/cffl_button.h",
-    "fpdfsdk/formfiller/cffl_checkbox.cpp",
-    "fpdfsdk/formfiller/cffl_checkbox.h",
-    "fpdfsdk/formfiller/cffl_combobox.cpp",
-    "fpdfsdk/formfiller/cffl_combobox.h",
-    "fpdfsdk/formfiller/cffl_formfiller.cpp",
-    "fpdfsdk/formfiller/cffl_formfiller.h",
-    "fpdfsdk/formfiller/cffl_interactiveformfiller.cpp",
-    "fpdfsdk/formfiller/cffl_interactiveformfiller.h",
-    "fpdfsdk/formfiller/cffl_listbox.cpp",
-    "fpdfsdk/formfiller/cffl_listbox.h",
-    "fpdfsdk/formfiller/cffl_pushbutton.cpp",
-    "fpdfsdk/formfiller/cffl_pushbutton.h",
-    "fpdfsdk/formfiller/cffl_radiobutton.cpp",
-    "fpdfsdk/formfiller/cffl_radiobutton.h",
-    "fpdfsdk/formfiller/cffl_textfield.cpp",
-    "fpdfsdk/formfiller/cffl_textfield.h",
-    "fpdfsdk/formfiller/cffl_textobject.cpp",
-    "fpdfsdk/formfiller/cffl_textobject.h",
-  ]
-  configs += [ ":pdfium_core_config" ]
-  deps = [
-    ":fxcrt",
-  ]
-}
-
-if (pdf_enable_xfa) {
-  jumbo_source_set("fpdfxfa") {
-    sources = [
-      "fpdfsdk/fpdfxfa/cpdfxfa_context.cpp",
-      "fpdfsdk/fpdfxfa/cpdfxfa_context.h",
-      "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp",
-      "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h",
-      "fpdfsdk/fpdfxfa/cpdfxfa_page.cpp",
-      "fpdfsdk/fpdfxfa/cpdfxfa_page.h",
-      "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.cpp",
-      "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h",
-    ]
-    deps = [
-      ":fxcrt",
-      "fxjs",
-      "xfa",
-    ]
-    configs += [ ":pdfium_core_config" ]
-  }
-}
-
 test("pdfium_unittests") {
   testonly = true
   sources = [
diff --git a/fpdfsdk/BUILD.gn b/fpdfsdk/BUILD.gn
new file mode 100644
index 0000000..2fc658e
--- /dev/null
+++ b/fpdfsdk/BUILD.gn
@@ -0,0 +1,68 @@
+# Copyright 2018 The PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/jumbo.gni")
+import("../pdfium.gni")
+
+jumbo_source_set("fpdfsdk") {
+  sources = [
+    "cfx_systemhandler.cpp",
+    "cfx_systemhandler.h",
+    "cpdf_annotcontext.cpp",
+    "cpdf_annotcontext.h",
+    "cpdfsdk_actionhandler.cpp",
+    "cpdfsdk_actionhandler.h",
+    "cpdfsdk_annot.cpp",
+    "cpdfsdk_annot.h",
+    "cpdfsdk_annothandlermgr.cpp",
+    "cpdfsdk_annothandlermgr.h",
+    "cpdfsdk_annotiteration.cpp",
+    "cpdfsdk_annotiteration.h",
+    "cpdfsdk_annotiterator.cpp",
+    "cpdfsdk_annotiterator.h",
+    "cpdfsdk_baannot.cpp",
+    "cpdfsdk_baannot.h",
+    "cpdfsdk_baannothandler.cpp",
+    "cpdfsdk_baannothandler.h",
+    "cpdfsdk_common.h",
+    "cpdfsdk_customaccess.cpp",
+    "cpdfsdk_customaccess.h",
+    "cpdfsdk_fieldaction.cpp",
+    "cpdfsdk_fieldaction.h",
+    "cpdfsdk_filewriteadapter.cpp",
+    "cpdfsdk_filewriteadapter.h",
+    "cpdfsdk_formfillenvironment.cpp",
+    "cpdfsdk_formfillenvironment.h",
+    "cpdfsdk_helpers.cpp",
+    "cpdfsdk_helpers.h",
+    "cpdfsdk_interactiveform.cpp",
+    "cpdfsdk_interactiveform.h",
+    "cpdfsdk_pageview.cpp",
+    "cpdfsdk_pageview.h",
+    "cpdfsdk_widget.cpp",
+    "cpdfsdk_widget.h",
+    "cpdfsdk_widgethandler.cpp",
+    "cpdfsdk_widgethandler.h",
+    "ipdfsdk_annothandler.h",
+    "ipdfsdk_pauseadapter.cpp",
+    "ipdfsdk_pauseadapter.h",
+  ]
+
+  configs += [ "../:pdfium_core_config" ]
+  deps = [
+    "../:fxcrt",
+  ]
+  visibility = [ "../*" ]
+
+  if (pdf_enable_xfa) {
+    sources += [
+      "cpdfsdk_xfawidget.cpp",
+      "cpdfsdk_xfawidget.h",
+      "cpdfsdk_xfawidgethandler.cpp",
+      "cpdfsdk_xfawidgethandler.h",
+    ]
+
+    deps += [ "fpdfxfa" ]
+  }
+}
diff --git a/fpdfsdk/formfiller/BUILD.gn b/fpdfsdk/formfiller/BUILD.gn
new file mode 100644
index 0000000..fe5ba5e
--- /dev/null
+++ b/fpdfsdk/formfiller/BUILD.gn
@@ -0,0 +1,38 @@
+# Copyright 2018 The PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/jumbo.gni")
+import("../../pdfium.gni")
+
+jumbo_source_set("formfiller") {
+  sources = [
+    "cba_fontmap.cpp",
+    "cba_fontmap.h",
+    "cffl_button.cpp",
+    "cffl_button.h",
+    "cffl_checkbox.cpp",
+    "cffl_checkbox.h",
+    "cffl_combobox.cpp",
+    "cffl_combobox.h",
+    "cffl_formfiller.cpp",
+    "cffl_formfiller.h",
+    "cffl_interactiveformfiller.cpp",
+    "cffl_interactiveformfiller.h",
+    "cffl_listbox.cpp",
+    "cffl_listbox.h",
+    "cffl_pushbutton.cpp",
+    "cffl_pushbutton.h",
+    "cffl_radiobutton.cpp",
+    "cffl_radiobutton.h",
+    "cffl_textfield.cpp",
+    "cffl_textfield.h",
+    "cffl_textobject.cpp",
+    "cffl_textobject.h",
+  ]
+  configs += [ "../../:pdfium_core_config" ]
+  deps = [
+    "../../:fxcrt",
+  ]
+  visibility = [ "../../*" ]
+}
diff --git a/fpdfsdk/fpdfxfa/BUILD.gn b/fpdfsdk/fpdfxfa/BUILD.gn
new file mode 100644
index 0000000..14a8281
--- /dev/null
+++ b/fpdfsdk/fpdfxfa/BUILD.gn
@@ -0,0 +1,28 @@
+# Copyright 2018 The PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/jumbo.gni")
+import("../../pdfium.gni")
+
+assert(pdf_enable_xfa)
+
+jumbo_source_set("fpdfxfa") {
+  sources = [
+    "cpdfxfa_context.cpp",
+    "cpdfxfa_context.h",
+    "cpdfxfa_docenvironment.cpp",
+    "cpdfxfa_docenvironment.h",
+    "cpdfxfa_page.cpp",
+    "cpdfxfa_page.h",
+    "cxfa_fwladaptertimermgr.cpp",
+    "cxfa_fwladaptertimermgr.h",
+  ]
+  deps = [
+    "../../:fxcrt",
+    "../../fxjs",
+    "../../xfa",
+  ]
+  configs += [ "../../:pdfium_core_config" ]
+  visibility = [ "../../*" ]
+}
diff --git a/fpdfsdk/pwl/BUILD.gn b/fpdfsdk/pwl/BUILD.gn
new file mode 100644
index 0000000..47cfce7
--- /dev/null
+++ b/fpdfsdk/pwl/BUILD.gn
@@ -0,0 +1,48 @@
+# Copyright 2018 The PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/jumbo.gni")
+import("../../pdfium.gni")
+
+jumbo_source_set("pwl") {
+  sources = [
+    "cpwl_appstream.cpp",
+    "cpwl_appstream.h",
+    "cpwl_button.cpp",
+    "cpwl_button.h",
+    "cpwl_caret.cpp",
+    "cpwl_caret.h",
+    "cpwl_combo_box.cpp",
+    "cpwl_combo_box.h",
+    "cpwl_edit.cpp",
+    "cpwl_edit.h",
+    "cpwl_edit_ctrl.cpp",
+    "cpwl_edit_ctrl.h",
+    "cpwl_edit_impl.cpp",
+    "cpwl_edit_impl.h",
+    "cpwl_font_map.cpp",
+    "cpwl_font_map.h",
+    "cpwl_icon.cpp",
+    "cpwl_icon.h",
+    "cpwl_list_box.cpp",
+    "cpwl_list_box.h",
+    "cpwl_list_impl.cpp",
+    "cpwl_list_impl.h",
+    "cpwl_scroll_bar.cpp",
+    "cpwl_scroll_bar.h",
+    "cpwl_special_button.cpp",
+    "cpwl_special_button.h",
+    "cpwl_timer.cpp",
+    "cpwl_timer.h",
+    "cpwl_timer_handler.cpp",
+    "cpwl_timer_handler.h",
+    "cpwl_wnd.cpp",
+    "cpwl_wnd.h",
+  ]
+  configs += [ "../../:pdfium_core_config" ]
+  deps = [
+    "../../:fxcrt",
+  ]
+  visibility = [ "../../*" ]
+}