910e62b5创建于 1月15日历史提交
# Copyright 2019 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//ios/web/public/js_messaging/compile_ts.gni")
import("//ios/web/public/js_messaging/optimize_js.gni")
import("//ios/web/public/js_messaging/optimize_ts.gni")

source_set("js_messaging") {
  deps = [
    "//ios/web/public/",
    "//url",
  ]

  public_deps = [ "//base" ]

  frameworks = [ "Foundation.framework" ]

  sources = [
    "java_script_feature.h",
    "java_script_feature_util.h",
    "script_message.h",
    "web_frame.h",
    "web_frame_user_data.h",
    "web_frames_manager.h",
    "web_frames_manager_observer_bridge.h",
  ]
}

source_set("web_view_js_utils") {
  frameworks = [ "Foundation.framework" ]

  sources = [ "web_view_js_utils.h" ]
}

source_set("content_world_header") {
  sources = [ "content_world.h" ]
}

compile_ts("gcrweb_error") {
  sources = [ "resources/gcrweb_error.ts" ]
}

compile_ts("util_scripts") {
  sources = [ "resources/utils.ts" ]
}

compile_ts("error_reporting") {
  sources = [ "resources/error_reporting.ts" ]

  deps = [ ":util_scripts" ]
}

# `compile_ts` and `optimize_js` targets are defined separately here instead of
# combined using `optimize_ts` because it allows `gcrweb` target's
# compiled TypeScript to be used as a dependency by other TypeScript targets.
compile_ts("gcrweb") {
  sources = [ "resources/gcrweb.ts" ]

  deps = [
    ":error_reporting",
    ":gcrweb_error",
    ":util_scripts",
  ]
}

optimize_js("gcrweb_js") {
  _script = filter_include(get_target_outputs(":gcrweb"), [ "*gcrweb.js" ])
  primary_script = _script[0]
  sources = _script
  output_name = "gcrweb"

  deps = [ ":gcrweb" ]
}

source_set("unittests") {
  testonly = true

  deps = [
    ":gcrweb_test_api",
    ":util_test_api",
    "//base",
    "//base/test:test_support",
    "//ios/web/public/test:javascript_test",
    "//ios/web/public/test:util",
    "//testing/gtest",
    "//url",
  ]

  sources = [
    "gcrweb_javascript_test.mm",
    "utils_javascript_test.mm",
  ]
}

optimize_ts("util_test_api") {
  testonly = true

  sources = [ "resources/utils_test_api.ts" ]

  deps = [
    ":gcrweb",
    ":util_scripts",
  ]
}

optimize_ts("gcrweb_test_api") {
  testonly = true

  sources = [ "resources/gcrweb_test_api.ts" ]

  deps = [ ":gcrweb" ]
}