chromium/ui/chromeos/styles/BUILD.gn

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

import("//chrome/common/features.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/style_variable_generator/style_variable_generator.gni")
import("//ui/webui/resources/tools/generate_grd.gni")

style_variable_generator("cros_styles") {
  # If you change the sources, also change the paths in presubmit_support.py
  sources = [
    "cros_colors.json5",
    "cros_gm3_shadows.json5",
    "cros_palette.json5",
    "cros_shadows.json5",
    "cros_typography.json5",
  ]

  gen_css = true

  # TODO(b/252365403): Delete this when the old usages are removed.
  gen_views = true
  cpp_namespace = "cros_styles"
}

style_variable_generator("cros_typography") {
  # If you change the sources, also change the paths in presubmit_support.py
  sources = [ "cros_gm3_typography.json5" ]
  gen_css = true
  gen_views = false
}

style_variable_generator("cros_tokens") {
  # If you change the sources, also change the paths in presubmit_support.py
  sources = [
    "cros_colors.json5",
    "cros_palette.json5",
    "cros_ref_colors.json5",
    "cros_sys_colors.json5",
  ]

  cpp_namespace = "cros_tokens"
  color_id_start_value = "0x4000"
}

style_variable_generator("color_internals_tokens") {
  # If you change the sources, also change the paths in presubmit_support.py
  sources = [
    "cros_ref_colors.json5",
    "cros_sys_colors.json5",
  ]
  cpp_namespace = "color_internals_tokens"
}

grit("cros_styles_resources") {
  # Required since the .grd file is generated at build time.
  enable_input_discovery_for_gn_analyze = false

  source = "$target_gen_dir/cros_typography_resources.grd"
  defines = chrome_grit_defines
  outputs = [
    "grit/cros_styles_resources.h",
    "grit/cros_styles_resources_map.cc",
    "grit/cros_styles_resources_map.h",
    "cros_styles_resources.pak",
  ]

  deps = [ ":build_grd" ]

  output_dir = "$root_gen_dir/chrome"
}

generate_grd("build_grd") {
  grd_prefix = "cros_styles"
  out_grd = "$target_gen_dir/cros_typography_resources.grd"
  public_deps = [ "//ui/chromeos/styles:cros_typography_css" ]
  input_files_base_dir = rebase_path("$root_gen_dir/", root_build_dir)
  input_files = [ "ui/chromeos/styles/cros_typography.css" ]
  resource_path_rewrites = [ "ui/chromeos/styles/cros_typography.css|chromeos/colors/cros_typography.css" ]
}