chromium/ios/web/public/js_messaging/BUILD.gn

# 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")

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("frame_id") {
  sources = [ "resources/frame_id.ts" ]

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

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

  deps = [ ":gcrweb" ]
}

# `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" ]
}

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

  deps = [ ":gcrweb" ]
}