# Copyright 2018 The PDFium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("../pdfium.gni")
import("../testing/test.gni")

source_set("fxjs") {
  sources = [
    "cjs_event_context_stub.cpp",
    "cjs_event_context_stub.h",
    "cjs_runtimestub.cpp",
    "cjs_runtimestub.h",
    "ijs_event_context.h",
    "ijs_runtime.cpp",
    "ijs_runtime.h",
  ]
  configs += [ "../:pdfium_strict_config" ]
  deps = [ "../core/fxcrt" ]
  public_deps = []
  visibility = [ "../*" ]

  if (pdf_enable_v8) {
    sources += [
      "cfx_globaldata.cpp",
      "cfx_globaldata.h",
      "cfx_keyvalue.cpp",
      "cfx_keyvalue.h",
      "cfx_v8.cpp",
      "cfx_v8.h",
      "cfx_v8_array_buffer_allocator.cpp",
      "cfx_v8_array_buffer_allocator.h",
      "cfxjs_engine.cpp",
      "cfxjs_engine.h",
      "cjs_annot.cpp",
      "cjs_annot.h",
      "cjs_app.cpp",
      "cjs_app.h",
      "cjs_border.cpp",
      "cjs_border.h",
      "cjs_color.cpp",
      "cjs_color.h",
      "cjs_console.cpp",
      "cjs_console.h",
      "cjs_delaydata.cpp",
      "cjs_delaydata.h",
      "cjs_display.cpp",
      "cjs_display.h",
      "cjs_document.cpp",
      "cjs_document.h",
      "cjs_event.cpp",
      "cjs_event.h",
      "cjs_event_context.cpp",
      "cjs_event_context.h",
      "cjs_field.cpp",
      "cjs_field.h",
      "cjs_font.cpp",
      "cjs_font.h",
      "cjs_global.cpp",
      "cjs_global.h",
      "cjs_globalarrays.cpp",
      "cjs_globalarrays.h",
      "cjs_globalconsts.cpp",
      "cjs_globalconsts.h",
      "cjs_highlight.cpp",
      "cjs_highlight.h",
      "cjs_icon.cpp",
      "cjs_icon.h",
      "cjs_object.cpp",
      "cjs_object.h",
      "cjs_position.cpp",
      "cjs_position.h",
      "cjs_publicmethods.cpp",
      "cjs_publicmethods.h",
      "cjs_result.cpp",
      "cjs_result.h",
      "cjs_runtime.cpp",
      "cjs_runtime.h",
      "cjs_scalehow.cpp",
      "cjs_scalehow.h",
      "cjs_scalewhen.cpp",
      "cjs_scalewhen.h",
      "cjs_style.cpp",
      "cjs_style.h",
      "cjs_timerobj.cpp",
      "cjs_timerobj.h",
      "cjs_util.cpp",
      "cjs_util.h",
      "cjs_zoomtype.cpp",
      "cjs_zoomtype.h",
      "fx_date_helpers.cpp",
      "fx_date_helpers.h",
      "fxv8.cpp",
      "fxv8.h",
      "global_timer.cpp",
      "global_timer.h",
      "js_define.cpp",
      "js_define.h",
      "js_resources.cpp",
      "js_resources.h",
    ]
    deps += [
      "../constants",
      "../core/fdrm",
      "../core/fpdfapi/page",
      "../core/fpdfapi/parser",
      "../core/fpdfapi/render",
      "../core/fpdfdoc",
      "../core/fxge",
      "//v8",
      "//v8:v8_libplatform",
    ]
    configs += [ "//v8:external_startup_data" ]
    public_deps += [
      "../core/fxcrt",
      "//v8",
    ]

    if (pdf_enable_xfa) {
      sources += [
        "xfa/cfxjse_class.cpp",
        "xfa/cfxjse_class.h",
        "xfa/cfxjse_context.cpp",
        "xfa/cfxjse_context.h",
        "xfa/cfxjse_engine.cpp",
        "xfa/cfxjse_engine.h",
        "xfa/cfxjse_formcalc_context.cpp",
        "xfa/cfxjse_formcalc_context.h",
        "xfa/cfxjse_isolatetracker.cpp",
        "xfa/cfxjse_isolatetracker.h",
        "xfa/cfxjse_mapmodule.cpp",
        "xfa/cfxjse_mapmodule.h",
        "xfa/cfxjse_nodehelper.cpp",
        "xfa/cfxjse_nodehelper.h",
        "xfa/cfxjse_resolveprocessor.cpp",
        "xfa/cfxjse_resolveprocessor.h",
        "xfa/cfxjse_runtimedata.cpp",
        "xfa/cfxjse_runtimedata.h",
        "xfa/cfxjse_value.cpp",
        "xfa/cfxjse_value.h",
        "xfa/cjx_boolean.cpp",
        "xfa/cjx_boolean.h",
        "xfa/cjx_container.cpp",
        "xfa/cjx_container.h",
        "xfa/cjx_datawindow.cpp",
        "xfa/cjx_datawindow.h",
        "xfa/cjx_delta.cpp",
        "xfa/cjx_delta.h",
        "xfa/cjx_desc.cpp",
        "xfa/cjx_desc.h",
        "xfa/cjx_draw.cpp",
        "xfa/cjx_draw.h",
        "xfa/cjx_encrypt.cpp",
        "xfa/cjx_encrypt.h",
        "xfa/cjx_eventpseudomodel.cpp",
        "xfa/cjx_eventpseudomodel.h",
        "xfa/cjx_exclgroup.cpp",
        "xfa/cjx_exclgroup.h",
        "xfa/cjx_extras.cpp",
        "xfa/cjx_extras.h",
        "xfa/cjx_field.cpp",
        "xfa/cjx_field.h",
        "xfa/cjx_form.cpp",
        "xfa/cjx_form.h",
        "xfa/cjx_handler.cpp",
        "xfa/cjx_handler.h",
        "xfa/cjx_hostpseudomodel.cpp",
        "xfa/cjx_hostpseudomodel.h",
        "xfa/cjx_instancemanager.cpp",
        "xfa/cjx_instancemanager.h",
        "xfa/cjx_layoutpseudomodel.cpp",
        "xfa/cjx_layoutpseudomodel.h",
        "xfa/cjx_list.cpp",
        "xfa/cjx_list.h",
        "xfa/cjx_logpseudomodel.cpp",
        "xfa/cjx_logpseudomodel.h",
        "xfa/cjx_manifest.cpp",
        "xfa/cjx_manifest.h",
        "xfa/cjx_model.cpp",
        "xfa/cjx_model.h",
        "xfa/cjx_node.cpp",
        "xfa/cjx_node.h",
        "xfa/cjx_object.cpp",
        "xfa/cjx_object.h",
        "xfa/cjx_occur.cpp",
        "xfa/cjx_occur.h",
        "xfa/cjx_packet.cpp",
        "xfa/cjx_packet.h",
        "xfa/cjx_script.cpp",
        "xfa/cjx_script.h",
        "xfa/cjx_signaturepseudomodel.cpp",
        "xfa/cjx_signaturepseudomodel.h",
        "xfa/cjx_source.cpp",
        "xfa/cjx_source.h",
        "xfa/cjx_subform.cpp",
        "xfa/cjx_subform.h",
        "xfa/cjx_template.cpp",
        "xfa/cjx_template.h",
        "xfa/cjx_textnode.cpp",
        "xfa/cjx_textnode.h",
        "xfa/cjx_tree.cpp",
        "xfa/cjx_tree.h",
        "xfa/cjx_treelist.cpp",
        "xfa/cjx_treelist.h",
        "xfa/cjx_wsdlconnection.cpp",
        "xfa/cjx_wsdlconnection.h",
        "xfa/cjx_xfa.cpp",
        "xfa/cjx_xfa.h",
        "xfa/fxjse.cpp",
        "xfa/fxjse.h",
        "xfa/jse_define.h",
      ]
      deps += [
        ":gc",
        "../xfa/fgas/crt",
        "../xfa/fgas/graphics",
        "../xfa/fxfa/formcalc",
      ]
    }
  }
}

if (pdf_enable_v8) {
  if (pdf_enable_xfa) {
    source_set("gc") {
      sources = [
        "gc/container_trace.h",
        "gc/gced_tree_node.h",
        "gc/gced_tree_node_mixin.h",
        "gc/heap.cpp",
        "gc/heap.h",
      ]
      configs += [ "../:pdfium_strict_config" ]
      deps = [
        "../core/fxcrt",
        "//v8:v8_libplatform",
      ]
      public_deps = [ "//v8:cppgc" ]
    }
  }
}

if (pdf_enable_v8) {
  pdfium_unittest_source_set("unittests") {
    sources = [
      "cfx_globaldata_unittest.cpp",
      "cfx_v8_unittest.cpp",
      "cfxjs_engine_unittest.cpp",
      "cjs_publicmethods_unittest.cpp",
      "cjs_util_unittest.cpp",
      "fx_date_helpers_unittest.cpp",
    ]
    configs = [ "//v8:external_startup_data" ]
    deps = [
      ":fxjs",
      "../core/fxcrt:unit_test_support",
    ]
    pdfium_root_dir = "../"
    if (pdf_enable_xfa) {
      sources += [
        "gc/container_trace_unittest.cpp",
        "gc/gced_tree_node_mixin_unittest.cpp",
        "gc/gced_tree_node_unittest.cpp",
        "gc/heap_unittest.cpp",
        "gc/move_unittest.cpp",
        "xfa/cfxjse_formcalc_context_unittest.cpp",
        "xfa/cfxjse_mapmodule_unittest.cpp",
      ]
      deps += [
        ":gc",
        "../xfa/fxfa/parser",
      ]
    }
  }

  pdfium_embeddertest_source_set("embeddertests") {
    sources = [
      "cfxjs_engine_embeddertest.cpp",
      "cjs_publicmethods_embeddertest.cpp",
    ]
    configs = [ "//v8:external_startup_data" ]
    deps = [
      ":fxjs",
      "../fpdfsdk",
    ]
    pdfium_root_dir = "../"
    if (pdf_enable_xfa) {
      sources += [
        "xfa/cfxjse_app_embeddertest.cpp",
        "xfa/cfxjse_formcalc_context_embeddertest.cpp",
        "xfa/cfxjse_value_embeddertest.cpp",
        "xfa/cjx_hostpseudomodel_embeddertest.cpp",
        "xfa/cjx_list_embeddertest.cpp",
        "xfa/cjx_object_embeddertest.cpp",
      ]
      deps += [
        ":gc",
        "../xfa/fxfa",
      ]
    }
  }
}
