chromium/tools/code_coverage/js_source_maps/create_js_source_maps/create_js_source_maps.gni

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

# NOTE: The "create_js_source_maps" build rule must come after the
# "preprocess_if_expr" build rule(s) in the BUILD.gn file. If you are getting
# "Target not found in this context" errors, check that the deps
# names are correct and that they are defined earlier in the same BUILD.gn file.

import("//ui/webui/webui_features.gni")

template("create_js_source_maps") {
  assert(enable_webui_inline_sourcemaps)

  action(target_name) {
    forward_variables_from(invoker,
                           [
                             "sources",
                             "outputs",
                             "deps",
                           ])
    script = "//tools/code_coverage/js_source_maps/create_js_source_maps/create_js_source_maps.py"
    args = [ "--originals" ] + rebase_path(invoker.originals, root_out_dir) +
           [ "--sources" ] + rebase_path(invoker.sources, root_out_dir) +
           [ "--outputs" ] + rebase_path(invoker.outputs, root_out_dir)
    inputs = [ "//tools/code_coverage/js_source_maps/create_js_source_maps/create_js_source_maps.js" ]
    if (defined(invoker.inline_sourcemaps) && invoker.inline_sourcemaps) {
      args += [ "--inline-sourcemaps" ]
    }
  }
}