Make fpdfsdk/ pass gn check.

Use allow_circular_includes_from as a crutch for now.

Change-Id: I58e90da4b71a22dd54fd59e8d644b6eef740d4cd
Reviewed-on: https://pdfium-review.googlesource.com/c/43988
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/.gn b/.gn
index 1d4f5fc..764e08c 100644
--- a/.gn
+++ b/.gn
@@ -18,6 +18,7 @@
 
 check_targets = [
   "//core/fxcrt/*",
+  "//fpdfsdk/*",
   "//fxbarcode/*",
   "//samples/*",
   "//testing/:*",
@@ -27,6 +28,5 @@
 
   # TODO(thestig): Work on these.
   #"//core/*",
-  #"//fpdfsdk/*",
   #"//fxjs/*",
 ]
diff --git a/BUILD.gn b/BUILD.gn
index 3faf5cd..c9cd7b0 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -156,11 +156,25 @@
     "third_party:pdfium_base",
     "third_party:skia_shared",
   ]
+  allow_circular_includes_from = [
+    "fpdfsdk",
+    "fpdfsdk/formfiller",
+    "fpdfsdk/pwl",
+  ]
 
   public_deps = [
     "core/fxcrt",
   ]
 
+  if (pdf_enable_xfa) {
+    deps += [
+      "fpdfsdk/fpdfxfa",
+      "xfa/fxfa",
+      "xfa/fxfa/parser",
+    ]
+    allow_circular_includes_from += [ "fpdfsdk/fpdfxfa" ]
+  }
+
   if (is_win) {
     libs += [
       "advapi32.lib",
diff --git a/fpdfsdk/BUILD.gn b/fpdfsdk/BUILD.gn
index f4df1d5..cf1fdbf 100644
--- a/fpdfsdk/BUILD.gn
+++ b/fpdfsdk/BUILD.gn
@@ -51,7 +51,20 @@
 
   configs += [ "../:pdfium_core_config" ]
   deps = [
+    "../core/fpdfapi",
+    "../core/fpdfapi/page",
+    "../core/fpdfapi/parser",
+    "../core/fpdfapi/render",
+    "../core/fpdfdoc",
     "../core/fxcrt",
+    "../core/fxge",
+    "../fxjs",
+    "formfiller",
+    "pwl",
+  ]
+  allow_circular_includes_from = [
+    "formfiller",
+    "pwl",
   ]
   visibility = [ "../*" ]
 
@@ -63,6 +76,13 @@
       "cpdfsdk_xfawidgethandler.h",
     ]
 
-    deps += [ "fpdfxfa" ]
+    deps += [
+      "../xfa/fwl",
+      "../xfa/fxfa",
+      "../xfa/fxfa/parser",
+      "../xfa/fxgraphics",
+      "fpdfxfa",
+    ]
+    allow_circular_includes_from += [ "fpdfxfa" ]
   }
 }
diff --git a/fpdfsdk/formfiller/BUILD.gn b/fpdfsdk/formfiller/BUILD.gn
index a9994ee..434e580 100644
--- a/fpdfsdk/formfiller/BUILD.gn
+++ b/fpdfsdk/formfiller/BUILD.gn
@@ -32,7 +32,14 @@
   ]
   configs += [ "../../:pdfium_core_config" ]
   deps = [
+    "../../core/fpdfapi/font",
+    "../../core/fpdfapi/page",
+    "../../core/fpdfapi/parser",
+    "../../core/fpdfdoc",
     "../../core/fxcrt",
+    "../../core/fxge",
+    "../pwl",
   ]
+  allow_circular_includes_from = [ "../pwl" ]
   visibility = [ "../../*" ]
 }
diff --git a/fpdfsdk/fpdfxfa/BUILD.gn b/fpdfsdk/fpdfxfa/BUILD.gn
index bca6f67..baa615d 100644
--- a/fpdfsdk/fpdfxfa/BUILD.gn
+++ b/fpdfsdk/fpdfxfa/BUILD.gn
@@ -19,9 +19,14 @@
     "cxfa_fwladaptertimermgr.h",
   ]
   deps = [
+    "../../core/fpdfapi/page",
+    "../../core/fpdfapi/parser",
     "../../core/fxcrt",
     "../../fxjs",
-    "../../xfa",
+    "../../xfa/fgas",
+    "../../xfa/fwl",
+    "../../xfa/fxfa",
+    "../../xfa/fxfa/parser",
   ]
   configs += [ "../../:pdfium_core_config" ]
   visibility = [ "../../*" ]
diff --git a/fpdfsdk/pwl/BUILD.gn b/fpdfsdk/pwl/BUILD.gn
index 7c33196..c5e0268 100644
--- a/fpdfsdk/pwl/BUILD.gn
+++ b/fpdfsdk/pwl/BUILD.gn
@@ -42,7 +42,14 @@
   ]
   configs += [ "../../:pdfium_core_config" ]
   deps = [
+    "../../core/fpdfapi",
+    "../../core/fpdfapi/font",
+    "../../core/fpdfapi/page",
+    "../../core/fpdfapi/parser",
+    "../../core/fpdfapi/render",
+    "../../core/fpdfdoc",
     "../../core/fxcrt",
+    "../../core/fxge",
   ]
   visibility = [ "../../*" ]
 }
diff --git a/fxjs/BUILD.gn b/fxjs/BUILD.gn
index 96c3c6d..a197d78 100644
--- a/fxjs/BUILD.gn
+++ b/fxjs/BUILD.gn
@@ -435,6 +435,7 @@
         "xfa/cjx_xsdconnection.cpp",
         "xfa/cjx_xsdconnection.h",
       ]
+      deps += [ "../xfa/fxfa/fm2js" ]
     }
   }
 }
diff --git a/xfa/BUILD.gn b/xfa/BUILD.gn
index 3453a40..df29737 100644
--- a/xfa/BUILD.gn
+++ b/xfa/BUILD.gn
@@ -12,16 +12,3 @@
     cflags = [ "-Wno-strict-overflow" ]
   }
 }
-
-group("xfa") {
-  deps = [
-    "fde",
-    "fgas",
-    "fwl",
-    "fxfa",
-    "fxfa/fm2js",
-    "fxfa/parser",
-    "fxgraphics",
-  ]
-  visibility = [ "../*" ]
-}