import("//tools/grit/repack.gni")
import("//build/config/locales.gni")
import("//chrome/chrome_repack_locales.gni")
import("//extensions/buildflags/buildflags.gni")

group("qtwebengine_resources") {
  deps = [
      "//chrome/app:generated_resources",
      "//chrome/browser:resources",
      "//chrome/browser/resources:component_extension_resources",
      "//chrome/common:resources",
      "//components/resources:components_resources",
      ":qtwebengine_repack_resources",
      ":qtwebengine_repack_resources_100",
      ":qtwebengine_repack_resources_200",
      ":qtwebengine_repack_resources_devtools",
      ":qtwebengine_repack_locales_pack"
   ]
}

repack("qtwebengine_repack_resources") {
  sources = [
    "$root_gen_dir/qtwebengine/qt_webengine_resources.pak",
    "$root_gen_dir/chrome/common_resources.pak",
    "$root_gen_dir/chrome/net_internals_resources.pak",
    "$root_gen_dir/chrome/quota_internals_resources.pak",
    "$root_gen_dir/components/components_resources.pak",
    "$root_gen_dir/components/dev_ui_components_resources.pak",
    "$root_gen_dir/content/browser/resources/media/media_internals_resources.pak",
    "$root_gen_dir/content/browser/tracing/tracing_resources.pak",
    "$root_gen_dir/content/content_resources.pak",
    "$root_gen_dir/content/dev_ui_content_resources.pak",
    "$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak",
    "$root_gen_dir/net/net_resources.pak",
    "$root_gen_dir/third_party/blink/public/resources/blink_resources.pak",
    "$root_gen_dir/ui/resources/webui_resources.pak",
  ]
  output = "$root_out_dir/qtwebengine_resources.pak"
  deps = [
     "//qtwebengine/browser:qt_webengine_resources",
     "//chrome/browser/resources/net_internals:net_internals_resources",
     "//chrome/browser/resources/quota_internals:quota_internals_resources",
     "//chrome/common:resources_grit",
     "//components/resources:components_resources_grit",
     "//components/resources:dev_ui_components_resources_grit",
     "//content/browser/resources/media:media_internals_resources",
     "//content/browser/tracing:resources",
     "//content:content_resources_grit",
     "//content:dev_ui_content_resources_grit",
     "//mojo/public/js:resources",
     "//net:net_resources_grit",
     "//third_party/blink/public:resources_grit",
     "//ui/resources:webui_resources_grd_grit",
  ]

  if (enable_extensions) {
    sources += [
      "$root_gen_dir/chrome/component_extension_resources.pak",
      "$root_gen_dir/extensions/extensions_renderer_resources.pak",
      "$root_gen_dir/extensions/extensions_resources.pak",
    ]
    deps += [
      "//chrome/browser/resources:component_extension_resources_grit",
      "//extensions:extensions_renderer_resources_grit",
      "//extensions:extensions_resources_grd_grit",
    ]
  }

  if (enable_webrtc) {
    sources += [
      "$root_gen_dir/content/browser/webrtc/resources/webrtc_internals_resources.pak",
    ]
    deps += [
      "//content/browser/webrtc/resources",
    ]
  }

  if (enable_webrtc && enable_extensions) {
    sources += [
      "$root_gen_dir/chrome/webrtc_logs_resources.pak",
    ]
    deps += [
      "//chrome/browser/resources/media:webrtc_logs_resources",
    ]
  }
}

repack("qtwebengine_repack_resources_100") {
  sources = [
    "$root_gen_dir/chrome/renderer_resources_100_percent.pak",
    "$root_gen_dir/components/components_resources_100_percent.pak",
    "$root_gen_dir/content/app/resources/content_resources_100_percent.pak",
    "$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_100_percent.pak",
    "$root_gen_dir/ui/resources/ui_resources_100_percent.pak",
  ]
  output = "$root_out_dir/qtwebengine_resources_100p.pak"
  deps = [
    "//chrome/renderer:resources_grit",
    "//components/resources:components_scaled_resources_grit",
    "//content/app/resources:resources_grit",
    "//third_party/blink/public:scaled_resources_100_percent",
    "//ui/resources:ui_resources_grd_grit"
  ]
  if (enable_extensions) {
    sources += [
      "$root_gen_dir/extensions/extensions_browser_resources_100_percent.pak"
    ]
    deps += [
      "//extensions:extensions_browser_resources_grit"
    ]
  }
}

repack("qtwebengine_repack_resources_200") {
  sources = [
    "$root_gen_dir/chrome/renderer_resources_200_percent.pak",
    "$root_gen_dir/components/components_resources_200_percent.pak",
    "$root_gen_dir/content/app/resources/content_resources_200_percent.pak",
    "$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_200_percent.pak",
    "$root_gen_dir/ui/resources/ui_resources_200_percent.pak",
  ]
  output = "$root_out_dir/qtwebengine_resources_200p.pak"
  deps = [
    "//chrome/renderer:resources_grit",
    "//components/resources:components_scaled_resources_grit",
    "//content/app/resources:resources_grit",
    "//third_party/blink/public:scaled_resources_200_percent",
    "//ui/resources:ui_resources_grd_grit"
  ]
  if (enable_extensions) {
    sources += [
      "$root_gen_dir/extensions/extensions_browser_resources_200_percent.pak"
    ]
    deps += [
      "//extensions:extensions_browser_resources_grit"
    ]
  }
}

repack("qtwebengine_repack_resources_devtools") {
  sources = [
    "$root_gen_dir/content/browser/devtools/devtools_resources.pak",
    "$root_gen_dir/third_party/blink/public/resources/inspector_overlay_resources.pak",
  ]
  output = "$root_out_dir/qtwebengine_devtools_resources.pak"
  deps = [
    "//content/browser/devtools:devtools_resources_grit",
    "//third_party/blink/public:devtools_inspector_resources",
  ]
}

chrome_repack_locales("qtwebengine_repack_locales_pack") {
  input_locales = locales
  output_dir = "$root_out_dir/qtwebengine_locales"
  output_locales = locales
}

