Move pdf_enable_xfa build rules inside pdf_enable_v8 blocks.

V8 is required for XFA. This avoids the possibility of XFA on, V8 off.

Change-Id: I0ed89f6afe6f69e67f9005876bc1bb73b0d77dd5
Reviewed-on: https://pdfium-review.googlesource.com/c/46131
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index e5f2066..990733e 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -48,21 +48,21 @@
 
   if (pdf_enable_v8) {
     defines += [ "PDF_ENABLE_V8" ]
-  }
 
-  if (pdf_enable_xfa) {
-    defines += [ "PDF_ENABLE_XFA" ]
-    if (pdf_enable_xfa_bmp) {
-      defines += [ "PDF_ENABLE_XFA_BMP" ]
-    }
-    if (pdf_enable_xfa_gif) {
-      defines += [ "PDF_ENABLE_XFA_GIF" ]
-    }
-    if (pdf_enable_xfa_png) {
-      defines += [ "PDF_ENABLE_XFA_PNG" ]
-    }
-    if (pdf_enable_xfa_tiff) {
-      defines += [ "PDF_ENABLE_XFA_TIFF" ]
+    if (pdf_enable_xfa) {
+      defines += [ "PDF_ENABLE_XFA" ]
+      if (pdf_enable_xfa_bmp) {
+        defines += [ "PDF_ENABLE_XFA_BMP" ]
+      }
+      if (pdf_enable_xfa_gif) {
+        defines += [ "PDF_ENABLE_XFA_GIF" ]
+      }
+      if (pdf_enable_xfa_png) {
+        defines += [ "PDF_ENABLE_XFA_PNG" ]
+      }
+      if (pdf_enable_xfa_tiff) {
+        defines += [ "PDF_ENABLE_XFA_TIFF" ]
+      }
     }
   }
 
diff --git a/testing/BUILD.gn b/testing/BUILD.gn
index 8494fc3..0fed059 100644
--- a/testing/BUILD.gn
+++ b/testing/BUILD.gn
@@ -71,18 +71,18 @@
       "js_embedder_test.h",
     ]
     deps += [ "../fxjs" ]
-  }
 
-  if (pdf_enable_xfa) {
-    sources += [
-      "xfa_js_embedder_test.cpp",
-      "xfa_js_embedder_test.h",
-    ]
-    deps += [
-      "../fpdfsdk",
-      "../fpdfsdk/fpdfxfa",
-      "../xfa/fxfa",
-      "../xfa/fxfa/parser",
-    ]
+    if (pdf_enable_xfa) {
+      sources += [
+        "xfa_js_embedder_test.cpp",
+        "xfa_js_embedder_test.h",
+      ]
+      deps += [
+        "../fpdfsdk",
+        "../fpdfsdk/fpdfxfa",
+        "../xfa/fxfa",
+        "../xfa/fxfa/parser",
+      ]
+    }
   }
 }
diff --git a/testing/fuzzers/BUILD.gn b/testing/fuzzers/BUILD.gn
index e20fe12..0e91ac2 100644
--- a/testing/fuzzers/BUILD.gn
+++ b/testing/fuzzers/BUILD.gn
@@ -37,31 +37,32 @@
       ":pdf_cjs_util_fuzzer_src",
       ":pdf_fx_date_helpers_fuzzer_src",
     ]
-  }
-  if (pdf_enable_xfa) {
-    deps += [
-      ":pdf_bidi_fuzzer_src",
-      ":pdf_cfx_barcode_fuzzer_src",
-      ":pdf_codec_jpeg_fuzzer_src",
-      ":pdf_css_fuzzer_src",
-      ":pdf_fm2js_fuzzer_src",
-      ":pdf_formcalc_fuzzer_src",
-      ":pdfium_xfa_fuzzer_src",
-    ]
-    if (pdf_enable_xfa_bmp) {
-      deps += [ ":pdf_codec_bmp_fuzzer_src" ]
-    }
-    if (pdf_enable_xfa_gif) {
+
+    if (pdf_enable_xfa) {
       deps += [
-        ":pdf_codec_gif_fuzzer_src",
-        ":pdf_lzw_fuzzer_src",
+        ":pdf_bidi_fuzzer_src",
+        ":pdf_cfx_barcode_fuzzer_src",
+        ":pdf_codec_jpeg_fuzzer_src",
+        ":pdf_css_fuzzer_src",
+        ":pdf_fm2js_fuzzer_src",
+        ":pdf_formcalc_fuzzer_src",
+        ":pdfium_xfa_fuzzer_src",
       ]
-    }
-    if (pdf_enable_xfa_png) {
-      deps += [ ":pdf_codec_png_fuzzer_src" ]
-    }
-    if (pdf_enable_xfa_tiff) {
-      deps += [ ":pdf_codec_tiff_fuzzer_src" ]
+      if (pdf_enable_xfa_bmp) {
+        deps += [ ":pdf_codec_bmp_fuzzer_src" ]
+      }
+      if (pdf_enable_xfa_gif) {
+        deps += [
+          ":pdf_codec_gif_fuzzer_src",
+          ":pdf_lzw_fuzzer_src",
+        ]
+      }
+      if (pdf_enable_xfa_png) {
+        deps += [ ":pdf_codec_png_fuzzer_src" ]
+      }
+      if (pdf_enable_xfa_tiff) {
+        deps += [ ":pdf_codec_tiff_fuzzer_src" ]
+      }
     }
   }
 }
@@ -133,45 +134,66 @@
       "../../fxjs",
     ]
   }
-}
 
-if (pdf_enable_xfa) {
-  pdfium_fuzzer("pdf_bidi_fuzzer_src") {
-    sources = [
-      "pdf_bidi_fuzzer.cc",
-    ]
-    deps = [
-      "../../xfa/fgas",
-    ]
-  }
-
-  pdfium_fuzzer("pdf_cfx_barcode_fuzzer_src") {
-    sources = [
-      "pdf_cfx_barcode_fuzzer.cc",
-    ]
-    deps = [
-      "../../xfa/fwl",
-    ]
-  }
-
-  if (pdf_enable_xfa_bmp) {
-    pdfium_fuzzer("pdf_codec_bmp_fuzzer_src") {
+  if (pdf_enable_xfa) {
+    pdfium_fuzzer("pdf_bidi_fuzzer_src") {
       sources = [
-        "pdf_codec_bmp_fuzzer.cc",
-        "xfa_codec_fuzzer.h",
+        "pdf_bidi_fuzzer.cc",
       ]
       deps = [
-        "../:test_support",
-        "../../core/fxcodec",
-        "../../core/fxge",
+        "../../xfa/fgas",
       ]
     }
-  }
 
-  if (pdf_enable_xfa_gif) {
-    pdfium_fuzzer("pdf_codec_gif_fuzzer_src") {
+    pdfium_fuzzer("pdf_cfx_barcode_fuzzer_src") {
       sources = [
-        "pdf_codec_gif_fuzzer.cc",
+        "pdf_cfx_barcode_fuzzer.cc",
+      ]
+      deps = [
+        "../../xfa/fwl",
+      ]
+    }
+
+    if (pdf_enable_xfa_bmp) {
+      pdfium_fuzzer("pdf_codec_bmp_fuzzer_src") {
+        sources = [
+          "pdf_codec_bmp_fuzzer.cc",
+          "xfa_codec_fuzzer.h",
+        ]
+        deps = [
+          "../:test_support",
+          "../../core/fxcodec",
+          "../../core/fxge",
+        ]
+      }
+    }
+
+    if (pdf_enable_xfa_gif) {
+      pdfium_fuzzer("pdf_codec_gif_fuzzer_src") {
+        sources = [
+          "pdf_codec_gif_fuzzer.cc",
+          "xfa_codec_fuzzer.h",
+        ]
+        deps = [
+          "../:test_support",
+          "../../core/fxcodec",
+          "../../core/fxge",
+        ]
+      }
+
+      pdfium_fuzzer("pdf_lzw_fuzzer_src") {
+        sources = [
+          "pdf_lzw_fuzzer.cc",
+        ]
+        deps = [
+          "../../core/fxcodec",
+        ]
+      }
+    }
+
+    pdfium_fuzzer("pdf_codec_jpeg_fuzzer_src") {
+      sources = [
+        "pdf_codec_jpeg_fuzzer.cc",
         "xfa_codec_fuzzer.h",
       ]
       deps = [
@@ -181,87 +203,66 @@
       ]
     }
 
-    pdfium_fuzzer("pdf_lzw_fuzzer_src") {
+    if (pdf_enable_xfa_png) {
+      pdfium_fuzzer("pdf_codec_png_fuzzer_src") {
+        sources = [
+          "pdf_codec_png_fuzzer.cc",
+          "xfa_codec_fuzzer.h",
+        ]
+        deps = [
+          "../:test_support",
+          "../../core/fxcodec",
+          "../../core/fxge",
+        ]
+      }
+    }
+
+    if (pdf_enable_xfa_tiff) {
+      pdfium_fuzzer("pdf_codec_tiff_fuzzer_src") {
+        sources = [
+          "pdf_codec_tiff_fuzzer.cc",
+          "xfa_codec_fuzzer.h",
+        ]
+        deps = [
+          "../:test_support",
+          "../../core/fxcodec",
+          "../../core/fxge",
+        ]
+      }
+    }
+
+    pdfium_fuzzer("pdf_css_fuzzer_src") {
       sources = [
-        "pdf_lzw_fuzzer.cc",
+        "pdf_css_fuzzer.cc",
       ]
       deps = [
-        "../../core/fxcodec",
+        "../../core/fxcrt/css",
       ]
     }
-  }
 
-  pdfium_fuzzer("pdf_codec_jpeg_fuzzer_src") {
-    sources = [
-      "pdf_codec_jpeg_fuzzer.cc",
-      "xfa_codec_fuzzer.h",
-    ]
-    deps = [
-      "../:test_support",
-      "../../core/fxcodec",
-      "../../core/fxge",
-    ]
-  }
-
-  if (pdf_enable_xfa_png) {
-    pdfium_fuzzer("pdf_codec_png_fuzzer_src") {
+    pdfium_fuzzer("pdf_fm2js_fuzzer_src") {
       sources = [
-        "pdf_codec_png_fuzzer.cc",
-        "xfa_codec_fuzzer.h",
+        "pdf_fm2js_fuzzer.cc",
       ]
       deps = [
-        "../:test_support",
-        "../../core/fxcodec",
-        "../../core/fxge",
+        "../../fxjs",
       ]
     }
-  }
 
-  if (pdf_enable_xfa_tiff) {
-    pdfium_fuzzer("pdf_codec_tiff_fuzzer_src") {
+    pdfium_fuzzer("pdf_formcalc_fuzzer_src") {
       sources = [
-        "pdf_codec_tiff_fuzzer.cc",
-        "xfa_codec_fuzzer.h",
+        "pdf_formcalc_fuzzer.cc",
       ]
       deps = [
-        "../:test_support",
-        "../../core/fxcodec",
-        "../../core/fxge",
+        "../../xfa/fxfa/fm2js",
       ]
     }
-  }
 
-  pdfium_fuzzer("pdf_css_fuzzer_src") {
-    sources = [
-      "pdf_css_fuzzer.cc",
-    ]
-    deps = [
-      "../../core/fxcrt/css",
-    ]
-  }
-
-  pdfium_fuzzer("pdf_fm2js_fuzzer_src") {
-    sources = [
-      "pdf_fm2js_fuzzer.cc",
-    ]
-    deps = [
-      "../../fxjs",
-    ]
-  }
-
-  pdfium_fuzzer("pdf_formcalc_fuzzer_src") {
-    sources = [
-      "pdf_formcalc_fuzzer.cc",
-    ]
-    deps = [
-      "../../xfa/fxfa/fm2js",
-    ]
-  }
-
-  pdfium_public_fuzzer("pdfium_xfa_fuzzer_src") {
-    sources = [
-      "pdfium_xfa_fuzzer.cc",
-    ]
+    pdfium_public_fuzzer("pdfium_xfa_fuzzer_src") {
+      sources = [
+        "pdfium_xfa_fuzzer.cc",
+      ]
+    }
   }
 }