Split core/fpdfapi build rules into various sub-directories.

Change-Id: I98e2e913f11ff63e70cb841de00a4f56b06ca03b
Reviewed-on: https://pdfium-review.googlesource.com/c/43974
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/BUILD.gn b/core/fpdfapi/BUILD.gn
index a5b86a5..347e66e 100644
--- a/core/fpdfapi/BUILD.gn
+++ b/core/fpdfapi/BUILD.gn
@@ -7,304 +7,20 @@
 
 jumbo_source_set("fpdfapi") {
   sources = [
-    "cmaps/CNS1/Adobe-CNS1-UCS2_5.cpp",
-    "cmaps/CNS1/B5pc-H_0.cpp",
-    "cmaps/CNS1/B5pc-V_0.cpp",
-    "cmaps/CNS1/CNS-EUC-H_0.cpp",
-    "cmaps/CNS1/CNS-EUC-V_0.cpp",
-    "cmaps/CNS1/ETen-B5-H_0.cpp",
-    "cmaps/CNS1/ETen-B5-V_0.cpp",
-    "cmaps/CNS1/ETenms-B5-H_0.cpp",
-    "cmaps/CNS1/ETenms-B5-V_0.cpp",
-    "cmaps/CNS1/HKscs-B5-H_5.cpp",
-    "cmaps/CNS1/HKscs-B5-V_5.cpp",
-    "cmaps/CNS1/UniCNS-UCS2-H_3.cpp",
-    "cmaps/CNS1/UniCNS-UCS2-V_3.cpp",
-    "cmaps/CNS1/UniCNS-UTF16-H_0.cpp",
-    "cmaps/CNS1/cmaps_cns1.cpp",
-    "cmaps/GB1/Adobe-GB1-UCS2_5.cpp",
-    "cmaps/GB1/GB-EUC-H_0.cpp",
-    "cmaps/GB1/GB-EUC-V_0.cpp",
-    "cmaps/GB1/GBK-EUC-H_2.cpp",
-    "cmaps/GB1/GBK-EUC-V_2.cpp",
-    "cmaps/GB1/GBK2K-H_5.cpp",
-    "cmaps/GB1/GBK2K-V_5.cpp",
-    "cmaps/GB1/GBKp-EUC-H_2.cpp",
-    "cmaps/GB1/GBKp-EUC-V_2.cpp",
-    "cmaps/GB1/GBpc-EUC-H_0.cpp",
-    "cmaps/GB1/GBpc-EUC-V_0.cpp",
-    "cmaps/GB1/UniGB-UCS2-H_4.cpp",
-    "cmaps/GB1/UniGB-UCS2-V_4.cpp",
-    "cmaps/GB1/cmaps_gb1.cpp",
-    "cmaps/Japan1/83pv-RKSJ-H_1.cpp",
-    "cmaps/Japan1/90ms-RKSJ-H_2.cpp",
-    "cmaps/Japan1/90ms-RKSJ-V_2.cpp",
-    "cmaps/Japan1/90msp-RKSJ-H_2.cpp",
-    "cmaps/Japan1/90msp-RKSJ-V_2.cpp",
-    "cmaps/Japan1/90pv-RKSJ-H_1.cpp",
-    "cmaps/Japan1/Add-RKSJ-H_1.cpp",
-    "cmaps/Japan1/Add-RKSJ-V_1.cpp",
-    "cmaps/Japan1/Adobe-Japan1-UCS2_4.cpp",
-    "cmaps/Japan1/EUC-H_1.cpp",
-    "cmaps/Japan1/EUC-V_1.cpp",
-    "cmaps/Japan1/Ext-RKSJ-H_2.cpp",
-    "cmaps/Japan1/Ext-RKSJ-V_2.cpp",
-    "cmaps/Japan1/H_1.cpp",
-    "cmaps/Japan1/UniJIS-UCS2-HW-H_4.cpp",
-    "cmaps/Japan1/UniJIS-UCS2-HW-V_4.cpp",
-    "cmaps/Japan1/UniJIS-UCS2-H_4.cpp",
-    "cmaps/Japan1/UniJIS-UCS2-V_4.cpp",
-    "cmaps/Japan1/V_1.cpp",
-    "cmaps/Japan1/cmaps_japan1.cpp",
-    "cmaps/Korea1/Adobe-Korea1-UCS2_2.cpp",
-    "cmaps/Korea1/KSC-EUC-H_0.cpp",
-    "cmaps/Korea1/KSC-EUC-V_0.cpp",
-    "cmaps/Korea1/KSCms-UHC-HW-H_1.cpp",
-    "cmaps/Korea1/KSCms-UHC-HW-V_1.cpp",
-    "cmaps/Korea1/KSCms-UHC-H_1.cpp",
-    "cmaps/Korea1/KSCms-UHC-V_1.cpp",
-    "cmaps/Korea1/KSCpc-EUC-H_0.cpp",
-    "cmaps/Korea1/UniKS-UCS2-H_1.cpp",
-    "cmaps/Korea1/UniKS-UCS2-V_1.cpp",
-    "cmaps/Korea1/UniKS-UTF16-H_0.cpp",
-    "cmaps/Korea1/cmaps_korea1.cpp",
-    "cmaps/cmap_int.h",
-    "cmaps/fpdf_cmaps.cpp",
     "cpdf_modulemgr.cpp",
     "cpdf_modulemgr.h",
     "cpdf_pagerendercontext.cpp",
     "cpdf_pagerendercontext.h",
-    "edit/cpdf_creator.cpp",
-    "edit/cpdf_creator.h",
-    "edit/cpdf_encryptor.cpp",
-    "edit/cpdf_encryptor.h",
-    "edit/cpdf_flateencoder.cpp",
-    "edit/cpdf_flateencoder.h",
-    "edit/cpdf_pagecontentgenerator.cpp",
-    "edit/cpdf_pagecontentgenerator.h",
-    "edit/cpdf_pagecontentmanager.cpp",
-    "edit/cpdf_pagecontentmanager.h",
-    "edit/cpdf_stringarchivestream.cpp",
-    "edit/cpdf_stringarchivestream.h",
-    "font/cfx_cttgsubtable.cpp",
-    "font/cfx_cttgsubtable.h",
-    "font/cfx_stockfontarray.cpp",
-    "font/cfx_stockfontarray.h",
-    "font/cpdf_cid2unicodemap.cpp",
-    "font/cpdf_cid2unicodemap.h",
-    "font/cpdf_cidfont.cpp",
-    "font/cpdf_cidfont.h",
-    "font/cpdf_cmap.cpp",
-    "font/cpdf_cmap.h",
-    "font/cpdf_cmapmanager.cpp",
-    "font/cpdf_cmapmanager.h",
-    "font/cpdf_cmapparser.cpp",
-    "font/cpdf_cmapparser.h",
-    "font/cpdf_font.cpp",
-    "font/cpdf_font.h",
-    "font/cpdf_fontencoding.cpp",
-    "font/cpdf_fontencoding.h",
-    "font/cpdf_fontglobals.cpp",
-    "font/cpdf_fontglobals.h",
-    "font/cpdf_simplefont.cpp",
-    "font/cpdf_simplefont.h",
-    "font/cpdf_tounicodemap.cpp",
-    "font/cpdf_tounicodemap.h",
-    "font/cpdf_truetypefont.cpp",
-    "font/cpdf_truetypefont.h",
-    "font/cpdf_type1font.cpp",
-    "font/cpdf_type1font.h",
-    "font/cpdf_type3char.cpp",
-    "font/cpdf_type3char.h",
-    "font/cpdf_type3font.cpp",
-    "font/cpdf_type3font.h",
-    "page/cpdf_allstates.cpp",
-    "page/cpdf_allstates.h",
-    "page/cpdf_clippath.cpp",
-    "page/cpdf_clippath.h",
-    "page/cpdf_color.cpp",
-    "page/cpdf_color.h",
-    "page/cpdf_colorspace.cpp",
-    "page/cpdf_colorspace.h",
-    "page/cpdf_colorstate.cpp",
-    "page/cpdf_colorstate.h",
-    "page/cpdf_contentmarkitem.cpp",
-    "page/cpdf_contentmarkitem.h",
-    "page/cpdf_contentmarks.cpp",
-    "page/cpdf_contentmarks.h",
-    "page/cpdf_contentparser.cpp",
-    "page/cpdf_contentparser.h",
-    "page/cpdf_countedobject.h",
-    "page/cpdf_devicecs.cpp",
-    "page/cpdf_devicecs.h",
-    "page/cpdf_docpagedata.cpp",
-    "page/cpdf_docpagedata.h",
-    "page/cpdf_expintfunc.cpp",
-    "page/cpdf_expintfunc.h",
-    "page/cpdf_form.cpp",
-    "page/cpdf_form.h",
-    "page/cpdf_formobject.cpp",
-    "page/cpdf_formobject.h",
-    "page/cpdf_function.cpp",
-    "page/cpdf_function.h",
-    "page/cpdf_generalstate.cpp",
-    "page/cpdf_generalstate.h",
-    "page/cpdf_graphicstates.cpp",
-    "page/cpdf_graphicstates.h",
-    "page/cpdf_iccprofile.cpp",
-    "page/cpdf_iccprofile.h",
-    "page/cpdf_image.cpp",
-    "page/cpdf_image.h",
-    "page/cpdf_imageobject.cpp",
-    "page/cpdf_imageobject.h",
-    "page/cpdf_meshstream.cpp",
-    "page/cpdf_meshstream.h",
-    "page/cpdf_page.cpp",
-    "page/cpdf_page.h",
-    "page/cpdf_pagemodule.cpp",
-    "page/cpdf_pagemodule.h",
-    "page/cpdf_pageobject.cpp",
-    "page/cpdf_pageobject.h",
-    "page/cpdf_pageobjectholder.cpp",
-    "page/cpdf_pageobjectholder.h",
-    "page/cpdf_pageobjectlist.cpp",
-    "page/cpdf_pageobjectlist.h",
-    "page/cpdf_path.cpp",
-    "page/cpdf_path.h",
-    "page/cpdf_pathobject.cpp",
-    "page/cpdf_pathobject.h",
-    "page/cpdf_pattern.cpp",
-    "page/cpdf_pattern.h",
-    "page/cpdf_patterncs.cpp",
-    "page/cpdf_patterncs.h",
-    "page/cpdf_psengine.cpp",
-    "page/cpdf_psengine.h",
-    "page/cpdf_psfunc.cpp",
-    "page/cpdf_psfunc.h",
-    "page/cpdf_sampledfunc.cpp",
-    "page/cpdf_sampledfunc.h",
-    "page/cpdf_shadingobject.cpp",
-    "page/cpdf_shadingobject.h",
-    "page/cpdf_shadingpattern.cpp",
-    "page/cpdf_shadingpattern.h",
-    "page/cpdf_stitchfunc.cpp",
-    "page/cpdf_stitchfunc.h",
-    "page/cpdf_streamcontentparser.cpp",
-    "page/cpdf_streamcontentparser.h",
-    "page/cpdf_streamparser.cpp",
-    "page/cpdf_streamparser.h",
-    "page/cpdf_textobject.cpp",
-    "page/cpdf_textobject.h",
-    "page/cpdf_textstate.cpp",
-    "page/cpdf_textstate.h",
-    "page/cpdf_tilingpattern.cpp",
-    "page/cpdf_tilingpattern.h",
-    "page/ipdf_page.h",
-    "parser/cfdf_document.cpp",
-    "parser/cfdf_document.h",
-    "parser/cpdf_array.cpp",
-    "parser/cpdf_array.h",
-    "parser/cpdf_boolean.cpp",
-    "parser/cpdf_boolean.h",
-    "parser/cpdf_cross_ref_avail.cpp",
-    "parser/cpdf_cross_ref_avail.h",
-    "parser/cpdf_cross_ref_table.cpp",
-    "parser/cpdf_cross_ref_table.h",
-    "parser/cpdf_crypto_handler.cpp",
-    "parser/cpdf_crypto_handler.h",
-    "parser/cpdf_data_avail.cpp",
-    "parser/cpdf_data_avail.h",
-    "parser/cpdf_dictionary.cpp",
-    "parser/cpdf_dictionary.h",
-    "parser/cpdf_document.cpp",
-    "parser/cpdf_document.h",
-    "parser/cpdf_hint_tables.cpp",
-    "parser/cpdf_hint_tables.h",
-    "parser/cpdf_indirect_object_holder.cpp",
-    "parser/cpdf_indirect_object_holder.h",
-    "parser/cpdf_linearized_header.cpp",
-    "parser/cpdf_linearized_header.h",
-    "parser/cpdf_name.cpp",
-    "parser/cpdf_name.h",
-    "parser/cpdf_null.cpp",
-    "parser/cpdf_null.h",
-    "parser/cpdf_number.cpp",
-    "parser/cpdf_number.h",
-    "parser/cpdf_object.cpp",
-    "parser/cpdf_object.h",
-    "parser/cpdf_object_avail.cpp",
-    "parser/cpdf_object_avail.h",
-    "parser/cpdf_object_stream.cpp",
-    "parser/cpdf_object_stream.h",
-    "parser/cpdf_object_walker.cpp",
-    "parser/cpdf_object_walker.h",
-    "parser/cpdf_page_object_avail.cpp",
-    "parser/cpdf_page_object_avail.h",
-    "parser/cpdf_parser.cpp",
-    "parser/cpdf_parser.h",
-    "parser/cpdf_read_validator.cpp",
-    "parser/cpdf_read_validator.h",
-    "parser/cpdf_reference.cpp",
-    "parser/cpdf_reference.h",
-    "parser/cpdf_security_handler.cpp",
-    "parser/cpdf_security_handler.h",
-    "parser/cpdf_simple_parser.cpp",
-    "parser/cpdf_simple_parser.h",
-    "parser/cpdf_stream.cpp",
-    "parser/cpdf_stream.h",
-    "parser/cpdf_stream_acc.cpp",
-    "parser/cpdf_stream_acc.h",
-    "parser/cpdf_string.cpp",
-    "parser/cpdf_string.h",
-    "parser/cpdf_syntax_parser.cpp",
-    "parser/cpdf_syntax_parser.h",
-    "parser/fpdf_parser_decode.cpp",
-    "parser/fpdf_parser_decode.h",
-    "parser/fpdf_parser_utility.cpp",
-    "parser/fpdf_parser_utility.h",
-    "render/cpdf_charposlist.cpp",
-    "render/cpdf_charposlist.h",
-    "render/cpdf_devicebuffer.cpp",
-    "render/cpdf_devicebuffer.h",
-    "render/cpdf_dibbase.cpp",
-    "render/cpdf_dibbase.h",
-    "render/cpdf_dibtransferfunc.cpp",
-    "render/cpdf_dibtransferfunc.h",
-    "render/cpdf_docrenderdata.cpp",
-    "render/cpdf_docrenderdata.h",
-    "render/cpdf_imagecacheentry.cpp",
-    "render/cpdf_imagecacheentry.h",
-    "render/cpdf_imageloader.cpp",
-    "render/cpdf_imageloader.h",
-    "render/cpdf_imagerenderer.cpp",
-    "render/cpdf_imagerenderer.h",
-    "render/cpdf_pagerendercache.cpp",
-    "render/cpdf_pagerendercache.h",
-    "render/cpdf_progressiverenderer.cpp",
-    "render/cpdf_progressiverenderer.h",
-    "render/cpdf_rendercontext.cpp",
-    "render/cpdf_rendercontext.h",
-    "render/cpdf_renderoptions.cpp",
-    "render/cpdf_renderoptions.h",
-    "render/cpdf_renderstatus.cpp",
-    "render/cpdf_renderstatus.h",
-    "render/cpdf_scaledrenderbuffer.cpp",
-    "render/cpdf_scaledrenderbuffer.h",
-    "render/cpdf_textrenderer.cpp",
-    "render/cpdf_textrenderer.h",
-    "render/cpdf_transferfunc.cpp",
-    "render/cpdf_transferfunc.h",
-    "render/cpdf_transparency.cpp",
-    "render/cpdf_transparency.h",
-    "render/cpdf_type3cache.cpp",
-    "render/cpdf_type3cache.h",
-    "render/cpdf_type3glyphs.cpp",
-    "render/cpdf_type3glyphs.h",
   ]
   configs += [ "../../:pdfium_core_config" ]
   deps = [
-    "../../third_party:lcms2",
     "../fxcrt",
+    "cmaps",
+    "edit",
+    "font",
+    "page",
+    "parser",
+    "render",
   ]
   visibility = [ "../../*" ]
 }
diff --git a/core/fpdfapi/cmaps/BUILD.gn b/core/fpdfapi/cmaps/BUILD.gn
new file mode 100644
index 0000000..b8e01dd
--- /dev/null
+++ b/core/fpdfapi/cmaps/BUILD.gn
@@ -0,0 +1,79 @@
+# 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("cmaps") {
+  sources = [
+    "CNS1/Adobe-CNS1-UCS2_5.cpp",
+    "CNS1/B5pc-H_0.cpp",
+    "CNS1/B5pc-V_0.cpp",
+    "CNS1/CNS-EUC-H_0.cpp",
+    "CNS1/CNS-EUC-V_0.cpp",
+    "CNS1/ETen-B5-H_0.cpp",
+    "CNS1/ETen-B5-V_0.cpp",
+    "CNS1/ETenms-B5-H_0.cpp",
+    "CNS1/ETenms-B5-V_0.cpp",
+    "CNS1/HKscs-B5-H_5.cpp",
+    "CNS1/HKscs-B5-V_5.cpp",
+    "CNS1/UniCNS-UCS2-H_3.cpp",
+    "CNS1/UniCNS-UCS2-V_3.cpp",
+    "CNS1/UniCNS-UTF16-H_0.cpp",
+    "CNS1/cmaps_cns1.cpp",
+    "GB1/Adobe-GB1-UCS2_5.cpp",
+    "GB1/GB-EUC-H_0.cpp",
+    "GB1/GB-EUC-V_0.cpp",
+    "GB1/GBK-EUC-H_2.cpp",
+    "GB1/GBK-EUC-V_2.cpp",
+    "GB1/GBK2K-H_5.cpp",
+    "GB1/GBK2K-V_5.cpp",
+    "GB1/GBKp-EUC-H_2.cpp",
+    "GB1/GBKp-EUC-V_2.cpp",
+    "GB1/GBpc-EUC-H_0.cpp",
+    "GB1/GBpc-EUC-V_0.cpp",
+    "GB1/UniGB-UCS2-H_4.cpp",
+    "GB1/UniGB-UCS2-V_4.cpp",
+    "GB1/cmaps_gb1.cpp",
+    "Japan1/83pv-RKSJ-H_1.cpp",
+    "Japan1/90ms-RKSJ-H_2.cpp",
+    "Japan1/90ms-RKSJ-V_2.cpp",
+    "Japan1/90msp-RKSJ-H_2.cpp",
+    "Japan1/90msp-RKSJ-V_2.cpp",
+    "Japan1/90pv-RKSJ-H_1.cpp",
+    "Japan1/Add-RKSJ-H_1.cpp",
+    "Japan1/Add-RKSJ-V_1.cpp",
+    "Japan1/Adobe-Japan1-UCS2_4.cpp",
+    "Japan1/EUC-H_1.cpp",
+    "Japan1/EUC-V_1.cpp",
+    "Japan1/Ext-RKSJ-H_2.cpp",
+    "Japan1/Ext-RKSJ-V_2.cpp",
+    "Japan1/H_1.cpp",
+    "Japan1/UniJIS-UCS2-HW-H_4.cpp",
+    "Japan1/UniJIS-UCS2-HW-V_4.cpp",
+    "Japan1/UniJIS-UCS2-H_4.cpp",
+    "Japan1/UniJIS-UCS2-V_4.cpp",
+    "Japan1/V_1.cpp",
+    "Japan1/cmaps_japan1.cpp",
+    "Korea1/Adobe-Korea1-UCS2_2.cpp",
+    "Korea1/KSC-EUC-H_0.cpp",
+    "Korea1/KSC-EUC-V_0.cpp",
+    "Korea1/KSCms-UHC-HW-H_1.cpp",
+    "Korea1/KSCms-UHC-HW-V_1.cpp",
+    "Korea1/KSCms-UHC-H_1.cpp",
+    "Korea1/KSCms-UHC-V_1.cpp",
+    "Korea1/KSCpc-EUC-H_0.cpp",
+    "Korea1/UniKS-UCS2-H_1.cpp",
+    "Korea1/UniKS-UCS2-V_1.cpp",
+    "Korea1/UniKS-UTF16-H_0.cpp",
+    "Korea1/cmaps_korea1.cpp",
+    "cmap_int.h",
+    "fpdf_cmaps.cpp",
+  ]
+  configs += [ "../../../:pdfium_core_config" ]
+  deps = [
+    "../../fxcrt",
+  ]
+  visibility = [ "../../../*" ]
+}
diff --git a/core/fpdfapi/edit/BUILD.gn b/core/fpdfapi/edit/BUILD.gn
new file mode 100644
index 0000000..1bcce79
--- /dev/null
+++ b/core/fpdfapi/edit/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")
+
+jumbo_source_set("edit") {
+  sources = [
+    "cpdf_creator.cpp",
+    "cpdf_creator.h",
+    "cpdf_encryptor.cpp",
+    "cpdf_encryptor.h",
+    "cpdf_flateencoder.cpp",
+    "cpdf_flateencoder.h",
+    "cpdf_pagecontentgenerator.cpp",
+    "cpdf_pagecontentgenerator.h",
+    "cpdf_pagecontentmanager.cpp",
+    "cpdf_pagecontentmanager.h",
+    "cpdf_stringarchivestream.cpp",
+    "cpdf_stringarchivestream.h",
+  ]
+  configs += [ "../../../:pdfium_core_config" ]
+  deps = [
+    "../../fxcrt",
+  ]
+  visibility = [ "../../../*" ]
+}
diff --git a/core/fpdfapi/font/BUILD.gn b/core/fpdfapi/font/BUILD.gn
new file mode 100644
index 0000000..e00bea7
--- /dev/null
+++ b/core/fpdfapi/font/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("font") {
+  sources = [
+    "cfx_cttgsubtable.cpp",
+    "cfx_cttgsubtable.h",
+    "cfx_stockfontarray.cpp",
+    "cfx_stockfontarray.h",
+    "cpdf_cid2unicodemap.cpp",
+    "cpdf_cid2unicodemap.h",
+    "cpdf_cidfont.cpp",
+    "cpdf_cidfont.h",
+    "cpdf_cmap.cpp",
+    "cpdf_cmap.h",
+    "cpdf_cmapmanager.cpp",
+    "cpdf_cmapmanager.h",
+    "cpdf_cmapparser.cpp",
+    "cpdf_cmapparser.h",
+    "cpdf_font.cpp",
+    "cpdf_font.h",
+    "cpdf_fontencoding.cpp",
+    "cpdf_fontencoding.h",
+    "cpdf_fontglobals.cpp",
+    "cpdf_fontglobals.h",
+    "cpdf_simplefont.cpp",
+    "cpdf_simplefont.h",
+    "cpdf_tounicodemap.cpp",
+    "cpdf_tounicodemap.h",
+    "cpdf_truetypefont.cpp",
+    "cpdf_truetypefont.h",
+    "cpdf_type1font.cpp",
+    "cpdf_type1font.h",
+    "cpdf_type3char.cpp",
+    "cpdf_type3char.h",
+    "cpdf_type3font.cpp",
+    "cpdf_type3font.h",
+  ]
+  configs += [ "../../../:pdfium_core_config" ]
+  deps = [
+    "../../fxcrt",
+  ]
+  visibility = [ "../../../*" ]
+}
diff --git a/core/fpdfapi/page/BUILD.gn b/core/fpdfapi/page/BUILD.gn
new file mode 100644
index 0000000..573ee60
--- /dev/null
+++ b/core/fpdfapi/page/BUILD.gn
@@ -0,0 +1,98 @@
+# 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("page") {
+  sources = [
+    "cpdf_allstates.cpp",
+    "cpdf_allstates.h",
+    "cpdf_clippath.cpp",
+    "cpdf_clippath.h",
+    "cpdf_color.cpp",
+    "cpdf_color.h",
+    "cpdf_colorspace.cpp",
+    "cpdf_colorspace.h",
+    "cpdf_colorstate.cpp",
+    "cpdf_colorstate.h",
+    "cpdf_contentmarkitem.cpp",
+    "cpdf_contentmarkitem.h",
+    "cpdf_contentmarks.cpp",
+    "cpdf_contentmarks.h",
+    "cpdf_contentparser.cpp",
+    "cpdf_contentparser.h",
+    "cpdf_countedobject.h",
+    "cpdf_devicecs.cpp",
+    "cpdf_devicecs.h",
+    "cpdf_docpagedata.cpp",
+    "cpdf_docpagedata.h",
+    "cpdf_expintfunc.cpp",
+    "cpdf_expintfunc.h",
+    "cpdf_form.cpp",
+    "cpdf_form.h",
+    "cpdf_formobject.cpp",
+    "cpdf_formobject.h",
+    "cpdf_function.cpp",
+    "cpdf_function.h",
+    "cpdf_generalstate.cpp",
+    "cpdf_generalstate.h",
+    "cpdf_graphicstates.cpp",
+    "cpdf_graphicstates.h",
+    "cpdf_iccprofile.cpp",
+    "cpdf_iccprofile.h",
+    "cpdf_image.cpp",
+    "cpdf_image.h",
+    "cpdf_imageobject.cpp",
+    "cpdf_imageobject.h",
+    "cpdf_meshstream.cpp",
+    "cpdf_meshstream.h",
+    "cpdf_page.cpp",
+    "cpdf_page.h",
+    "cpdf_pagemodule.cpp",
+    "cpdf_pagemodule.h",
+    "cpdf_pageobject.cpp",
+    "cpdf_pageobject.h",
+    "cpdf_pageobjectholder.cpp",
+    "cpdf_pageobjectholder.h",
+    "cpdf_pageobjectlist.cpp",
+    "cpdf_pageobjectlist.h",
+    "cpdf_path.cpp",
+    "cpdf_path.h",
+    "cpdf_pathobject.cpp",
+    "cpdf_pathobject.h",
+    "cpdf_pattern.cpp",
+    "cpdf_pattern.h",
+    "cpdf_patterncs.cpp",
+    "cpdf_patterncs.h",
+    "cpdf_psengine.cpp",
+    "cpdf_psengine.h",
+    "cpdf_psfunc.cpp",
+    "cpdf_psfunc.h",
+    "cpdf_sampledfunc.cpp",
+    "cpdf_sampledfunc.h",
+    "cpdf_shadingobject.cpp",
+    "cpdf_shadingobject.h",
+    "cpdf_shadingpattern.cpp",
+    "cpdf_shadingpattern.h",
+    "cpdf_stitchfunc.cpp",
+    "cpdf_stitchfunc.h",
+    "cpdf_streamcontentparser.cpp",
+    "cpdf_streamcontentparser.h",
+    "cpdf_streamparser.cpp",
+    "cpdf_streamparser.h",
+    "cpdf_textobject.cpp",
+    "cpdf_textobject.h",
+    "cpdf_textstate.cpp",
+    "cpdf_textstate.h",
+    "cpdf_tilingpattern.cpp",
+    "cpdf_tilingpattern.h",
+    "ipdf_page.h",
+  ]
+  configs += [ "../../../:pdfium_core_config" ]
+  deps = [
+    "../../fxcrt",
+  ]
+  visibility = [ "../../../*" ]
+}
diff --git a/core/fpdfapi/parser/BUILD.gn b/core/fpdfapi/parser/BUILD.gn
new file mode 100644
index 0000000..0a8958f
--- /dev/null
+++ b/core/fpdfapi/parser/BUILD.gn
@@ -0,0 +1,78 @@
+# 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("parser") {
+  sources = [
+    "cfdf_document.cpp",
+    "cfdf_document.h",
+    "cpdf_array.cpp",
+    "cpdf_array.h",
+    "cpdf_boolean.cpp",
+    "cpdf_boolean.h",
+    "cpdf_cross_ref_avail.cpp",
+    "cpdf_cross_ref_avail.h",
+    "cpdf_cross_ref_table.cpp",
+    "cpdf_cross_ref_table.h",
+    "cpdf_crypto_handler.cpp",
+    "cpdf_crypto_handler.h",
+    "cpdf_data_avail.cpp",
+    "cpdf_data_avail.h",
+    "cpdf_dictionary.cpp",
+    "cpdf_dictionary.h",
+    "cpdf_document.cpp",
+    "cpdf_document.h",
+    "cpdf_hint_tables.cpp",
+    "cpdf_hint_tables.h",
+    "cpdf_indirect_object_holder.cpp",
+    "cpdf_indirect_object_holder.h",
+    "cpdf_linearized_header.cpp",
+    "cpdf_linearized_header.h",
+    "cpdf_name.cpp",
+    "cpdf_name.h",
+    "cpdf_null.cpp",
+    "cpdf_null.h",
+    "cpdf_number.cpp",
+    "cpdf_number.h",
+    "cpdf_object.cpp",
+    "cpdf_object.h",
+    "cpdf_object_avail.cpp",
+    "cpdf_object_avail.h",
+    "cpdf_object_stream.cpp",
+    "cpdf_object_stream.h",
+    "cpdf_object_walker.cpp",
+    "cpdf_object_walker.h",
+    "cpdf_page_object_avail.cpp",
+    "cpdf_page_object_avail.h",
+    "cpdf_parser.cpp",
+    "cpdf_parser.h",
+    "cpdf_read_validator.cpp",
+    "cpdf_read_validator.h",
+    "cpdf_reference.cpp",
+    "cpdf_reference.h",
+    "cpdf_security_handler.cpp",
+    "cpdf_security_handler.h",
+    "cpdf_simple_parser.cpp",
+    "cpdf_simple_parser.h",
+    "cpdf_stream.cpp",
+    "cpdf_stream.h",
+    "cpdf_stream_acc.cpp",
+    "cpdf_stream_acc.h",
+    "cpdf_string.cpp",
+    "cpdf_string.h",
+    "cpdf_syntax_parser.cpp",
+    "cpdf_syntax_parser.h",
+    "fpdf_parser_decode.cpp",
+    "fpdf_parser_decode.h",
+    "fpdf_parser_utility.cpp",
+    "fpdf_parser_utility.h",
+  ]
+  configs += [ "../../../:pdfium_core_config" ]
+  deps = [
+    "../../fxcrt",
+  ]
+  visibility = [ "../../../*" ]
+}
diff --git a/core/fpdfapi/render/BUILD.gn b/core/fpdfapi/render/BUILD.gn
new file mode 100644
index 0000000..02b3b4f
--- /dev/null
+++ b/core/fpdfapi/render/BUILD.gn
@@ -0,0 +1,54 @@
+# 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("render") {
+  sources = [
+    "cpdf_charposlist.cpp",
+    "cpdf_charposlist.h",
+    "cpdf_devicebuffer.cpp",
+    "cpdf_devicebuffer.h",
+    "cpdf_dibbase.cpp",
+    "cpdf_dibbase.h",
+    "cpdf_dibtransferfunc.cpp",
+    "cpdf_dibtransferfunc.h",
+    "cpdf_docrenderdata.cpp",
+    "cpdf_docrenderdata.h",
+    "cpdf_imagecacheentry.cpp",
+    "cpdf_imagecacheentry.h",
+    "cpdf_imageloader.cpp",
+    "cpdf_imageloader.h",
+    "cpdf_imagerenderer.cpp",
+    "cpdf_imagerenderer.h",
+    "cpdf_pagerendercache.cpp",
+    "cpdf_pagerendercache.h",
+    "cpdf_progressiverenderer.cpp",
+    "cpdf_progressiverenderer.h",
+    "cpdf_rendercontext.cpp",
+    "cpdf_rendercontext.h",
+    "cpdf_renderoptions.cpp",
+    "cpdf_renderoptions.h",
+    "cpdf_renderstatus.cpp",
+    "cpdf_renderstatus.h",
+    "cpdf_scaledrenderbuffer.cpp",
+    "cpdf_scaledrenderbuffer.h",
+    "cpdf_textrenderer.cpp",
+    "cpdf_textrenderer.h",
+    "cpdf_transferfunc.cpp",
+    "cpdf_transferfunc.h",
+    "cpdf_transparency.cpp",
+    "cpdf_transparency.h",
+    "cpdf_type3cache.cpp",
+    "cpdf_type3cache.h",
+    "cpdf_type3glyphs.cpp",
+    "cpdf_type3glyphs.h",
+  ]
+  configs += [ "../../../:pdfium_core_config" ]
+  deps = [
+    "../../fxcrt",
+  ]
+  visibility = [ "../../../*" ]
+}
diff --git a/core/fxcrt/BUILD.gn b/core/fxcrt/BUILD.gn
index 4de938b..1fd82f0 100644
--- a/core/fxcrt/BUILD.gn
+++ b/core/fxcrt/BUILD.gn
@@ -133,7 +133,7 @@
     ]
     deps = [
       ":fxcrt",
-      "../fpdfapi",
+      "../fpdfapi/parser",
     ]
     visibility = [ "../../*" ]
   }