chromium/components/strings/BUILD.gn

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

import("//build/config/features.gni")
import("//build/config/locales.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//pdf/features.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//printing/buildflags/buildflags.gni")
import("//services/screen_ai/buildflags/features.gni")
import("//tools/grit/grit_rule.gni")

if (is_android) {
  import("//build/config/android/rules.gni")
  android_components_strings_java_resources =
      [ "java/res/values/components_strings.xml" ] +
      process_file_template(
          android_bundle_locales_as_resources,
          [ "java/res/values-{{source_name_part}}/components_strings.xml" ])
}

group("strings") {
  public_deps = [
    ":components_branded_strings",
    ":components_locale_settings",
    ":components_strings",
    ":privacy_sandbox_strings",
    ":search_engine_descriptions_strings",
  ]
}

grit("components_strings") {
  source = "../components_strings.grd"
  defines = [
    "enable_arcore=$enable_arcore",
    "enable_cardboard=$enable_cardboard",
    "enable_pdf=$enable_pdf",
    "enable_pdf_ink2=$enable_pdf_ink2",
    "enable_plugins=$enable_plugins",
    "enable_print_preview=$enable_print_preview",
    "enable_screen_ai_service=$enable_screen_ai_service",
    "enable_vr=$enable_vr",
    "use_blink=$use_blink",
  ]

  outputs = [ "grit/components_strings.h" ]
  foreach(locale, all_chrome_locales) {
    outputs += [ "components_strings_$locale.pak" ]
  }

  if (is_android) {
    outputs += android_components_strings_java_resources
  }
}

if (is_android) {
  java_strings_grd_prebuilt("components_strings_grd") {
    grit_output_dir = "$root_gen_dir/components/strings/java/res"
    generated_files =
        rebase_path(android_components_strings_java_resources, "java/res", ".")
    deps = [ ":components_strings" ]
  }
}

grit("components_branded_strings") {
  source = "../components_${branding_path_product}_strings.grd"
  outputs = [ "grit/components_branded_strings.h" ]
  foreach(locale, all_chrome_locales) {
    outputs += [ "components_${branding_path_product}_strings_$locale.pak" ]
  }
}

if (is_android) {
  android_components_locale_settings_java_resources =
      [ "java/res/values/components_locale_settings.xml" ]
  android_components_locale_settings_java_resources += process_file_template(
          android_bundle_locales_as_resources,
          [ "java/res/values-{{source_name_part}}/components_locale_settings.xml" ])
}

grit("components_locale_settings") {
  source = "../components_locale_settings.grd"
  outputs = [ "grit/components_locale_settings.h" ]
  foreach(locale, all_chrome_locales) {
    outputs += [ "components_locale_settings_$locale.pak" ]
  }

  if (is_android) {
    outputs += android_components_locale_settings_java_resources
  }
}

grit("search_engine_descriptions_strings") {
  source = "../search_engine_descriptions_strings.grd"
  outputs = [ "grit/search_engine_descriptions_strings.h" ]
  foreach(locale, all_chrome_locales) {
    outputs += [ "search_engine_descriptions_strings_$locale.pak" ]
  }
}

if (is_android) {
  java_strings_grd_prebuilt("components_locale_settings_grd") {
    grit_output_dir = "$root_gen_dir/components/strings/java/res"
    generated_files =
        rebase_path(android_components_locale_settings_java_resources,
                    "java/res",
                    ".")
    deps = [ ":components_locale_settings" ]
  }
}

if (is_android) {
  android_privacy_sandbox_strings_java_resources =
      [ "java/res/values/privacy_sandbox_strings.xml" ]
  android_privacy_sandbox_strings_java_resources += process_file_template(
          android_bundle_locales_as_resources,
          [ "java/res/values-{{source_name_part}}/privacy_sandbox_strings.xml" ])
}

grit("privacy_sandbox_strings") {
  source = "../privacy_sandbox_strings.grd"
  outputs = [ "grit/privacy_sandbox_strings.h" ]
  foreach(locale, all_chrome_locales) {
    outputs += [ "privacy_sandbox_strings_$locale.pak" ]
  }

  if (is_android) {
    outputs += android_privacy_sandbox_strings_java_resources
  }
}

if (is_android) {
  java_strings_grd_prebuilt("privacy_sandbox_strings_grd") {
    grit_output_dir = "$root_gen_dir/components/strings/java/res"
    generated_files =
        rebase_path(android_privacy_sandbox_strings_java_resources,
                    "java/res",
                    ".")
    deps = [ ":privacy_sandbox_strings" ]
  }
}