Make core/ pass gn check.

Use allow_circular_includes_from as a crutch for now.

Change-Id: Ia7a29a268e67b1fe21bed5cdd629e06fb5cc7bfb
Reviewed-on: https://pdfium-review.googlesource.com/c/43992
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/.gn b/.gn
index 818bf58..5f7540a 100644
--- a/.gn
+++ b/.gn
@@ -18,7 +18,7 @@
 
 check_targets = [
   ":pdfium",
-  "//core/fxcrt/*",
+  "//core/*",
   "//fpdfsdk/*",
   "//fxbarcode/*",
   "//fxjs/*",
@@ -27,7 +27,4 @@
   "//testing/fuzzers/*",
   "//testing/image_diff/*",
   "//xfa/*",
-
-  # TODO(thestig): Work on these.
-  #"//core/*",
 ]
diff --git a/core/fpdfapi/BUILD.gn b/core/fpdfapi/BUILD.gn
index 347e66e..465b1af 100644
--- a/core/fpdfapi/BUILD.gn
+++ b/core/fpdfapi/BUILD.gn
@@ -14,7 +14,10 @@
   ]
   configs += [ "../../:pdfium_core_config" ]
   deps = [
+    "../fpdfdoc",
+    "../fxcodec",
     "../fxcrt",
+    "../fxge",
     "cmaps",
     "edit",
     "font",
@@ -22,5 +25,12 @@
     "parser",
     "render",
   ]
+  allow_circular_includes_from = [
+    "parser",
+    "cmaps",
+    "font",
+    "page",
+    "render",
+  ]
   visibility = [ "../../*" ]
 }
diff --git a/core/fpdfapi/edit/BUILD.gn b/core/fpdfapi/edit/BUILD.gn
index 1bcce79..de1a404 100644
--- a/core/fpdfapi/edit/BUILD.gn
+++ b/core/fpdfapi/edit/BUILD.gn
@@ -22,7 +22,12 @@
   ]
   configs += [ "../../../:pdfium_core_config" ]
   deps = [
+    "../../../third_party:skia_shared",
     "../../fxcrt",
+    "../font",
+    "../page",
+    "../parser",
   ]
+  allow_circular_includes_from = [ "../parser" ]
   visibility = [ "../../../*" ]
 }
diff --git a/core/fpdfapi/font/BUILD.gn b/core/fpdfapi/font/BUILD.gn
index e00bea7..a8f8619 100644
--- a/core/fpdfapi/font/BUILD.gn
+++ b/core/fpdfapi/font/BUILD.gn
@@ -43,6 +43,14 @@
   configs += [ "../../../:pdfium_core_config" ]
   deps = [
     "../../fxcrt",
+    "../../fxge",
+    "../cmaps",
+    "../parser",
+  ]
+  allow_circular_includes_from = [
+    "../../fxge",
+    "../cmaps",
+    "../parser",
   ]
   visibility = [ "../../../*" ]
 }
diff --git a/core/fpdfapi/page/BUILD.gn b/core/fpdfapi/page/BUILD.gn
index 573ee60..5df39f2 100644
--- a/core/fpdfapi/page/BUILD.gn
+++ b/core/fpdfapi/page/BUILD.gn
@@ -92,7 +92,22 @@
   ]
   configs += [ "../../../:pdfium_core_config" ]
   deps = [
+    "../../fdrm",
+    "../../fxcodec",
     "../../fxcrt",
+    "../../fxge",
+    "../cmaps",
+    "../font",
+    "../parser",
   ]
+  allow_circular_includes_from = [
+    "../cmaps",
+    "../font",
+    "../parser",
+    "../../fxcodec",
+  ]
+  if (pdf_use_skia || pdf_use_skia_paths) {
+    allow_circular_includes_from += [ "../../fxge" ]
+  }
   visibility = [ "../../../*" ]
 }
diff --git a/core/fpdfapi/parser/BUILD.gn b/core/fpdfapi/parser/BUILD.gn
index 0a8958f..64306df 100644
--- a/core/fpdfapi/parser/BUILD.gn
+++ b/core/fpdfapi/parser/BUILD.gn
@@ -72,7 +72,14 @@
   ]
   configs += [ "../../../:pdfium_core_config" ]
   deps = [
+    "../../fdrm",
+    "../../fxcodec",
     "../../fxcrt",
+    "../../fxge",
+  ]
+  allow_circular_includes_from = [
+    "../../fxge",
+    "../../fxcodec",
   ]
   visibility = [ "../../../*" ]
 }
diff --git a/core/fpdfapi/render/BUILD.gn b/core/fpdfapi/render/BUILD.gn
index 02b3b4f..042f04d 100644
--- a/core/fpdfapi/render/BUILD.gn
+++ b/core/fpdfapi/render/BUILD.gn
@@ -48,7 +48,16 @@
   ]
   configs += [ "../../../:pdfium_core_config" ]
   deps = [
+    "../../fxcodec",
     "../../fxcrt",
+    "../../fxge",
+    "../font",
+    "../page",
+    "../parser",
+  ]
+  allow_circular_includes_from = [
+    "../parser",
+    "../page",
   ]
   visibility = [ "../../../*" ]
 }
diff --git a/core/fpdfdoc/BUILD.gn b/core/fpdfdoc/BUILD.gn
index f7d9d71..411d26a 100644
--- a/core/fpdfdoc/BUILD.gn
+++ b/core/fpdfdoc/BUILD.gn
@@ -84,7 +84,18 @@
   ]
   configs += [ "../../:pdfium_core_config" ]
   deps = [
+    "../fpdfapi/font",
+    "../fpdfapi/page",
+    "../fpdfapi/parser",
+    "../fpdfapi/render",
     "../fxcrt",
+    "../fxge",
+  ]
+  allow_circular_includes_from = [
+    "../fxge",
+    "../fpdfapi/parser",
+    "../fpdfapi/page",
+    "../fpdfapi/render",
   ]
   visibility = [ "../../*" ]
 }
diff --git a/core/fpdftext/BUILD.gn b/core/fpdftext/BUILD.gn
index f477451..1319c62 100644
--- a/core/fpdftext/BUILD.gn
+++ b/core/fpdftext/BUILD.gn
@@ -18,6 +18,9 @@
   ]
   configs += [ "../../:pdfium_core_config" ]
   deps = [
+    "../fpdfapi/font",
+    "../fpdfapi/page",
+    "../fpdfapi/parser",
     "../fxcrt",
   ]
   visibility = [ "../../*" ]
diff --git a/core/fxcodec/BUILD.gn b/core/fxcodec/BUILD.gn
index 442a058..4c06d55 100644
--- a/core/fxcodec/BUILD.gn
+++ b/core/fxcodec/BUILD.gn
@@ -73,8 +73,10 @@
     "../../third_party:lcms2",
     "../../third_party:zlib",
     "../fxcrt",
+    "../fxge",
     "//third_party:jpeg",
   ]
+  allow_circular_includes_from = [ "../fxge" ]
 
   if (pdf_enable_xfa) {
     sources += [