chromium/components/url_formatter/spoof_checks/top_domains/BUILD.gn

# Copyright 2017 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/compiled_action.gni")

if (!is_ios && !is_android) {
  executable("make_top_domain_skeletons") {
    sources = [ "make_top_domain_skeletons.cc" ]

    deps = [
      "//base",
      "//base:i18n",
      "//components/lookalikes/core",
      "//components/url_formatter:skeleton_generator",
      "//third_party/icu",
    ]
  }
}

executable("top_domain_generator") {
  sources = [
    "top_domain_generator.cc",
    "top_domain_state_generator.cc",
    "top_domain_state_generator.h",
    "trie_entry.cc",
    "trie_entry.h",
  ]
  deps = [
    "//base",
    "//base:i18n",
    "//net/tools/huffman_trie:huffman_trie_generator_sources",
    "//url:url",
  ]
  if (is_ios) {
    frameworks = [ "UIKit.framework" ]
  }
}

compiled_action("generate_top_domains_trie") {
  tool = ":top_domain_generator"

  # Inputs in order expected by the command line of the tool.
  inputs = [
    "//components/url_formatter/spoof_checks/top_domains/domains.skeletons",
    "//components/url_formatter/spoof_checks/top_domains/top_domains_trie.template",
  ]
  outputs = [ "$target_gen_dir/domains-trie-inc.cc" ]
  args =
      rebase_path(inputs, root_build_dir) + rebase_path(outputs, root_build_dir)
}

# TODO(crbug.com/41432246): Combine this and the previous one into a
# compiled_action_foreach target.
compiled_action("generate_idn_top_domains_test_trie") {
  tool = ":top_domain_generator"

  # Inputs in order expected by the command line of the tool.
  inputs = [
    "//components/url_formatter/spoof_checks/top_domains/idn_test_domains.skeletons",
    "//components/url_formatter/spoof_checks/top_domains/top_domains_trie.template",
  ]
  outputs = [ "$target_gen_dir/idn_test_domains-trie-inc.cc" ]

  args =
      rebase_path(inputs, root_build_dir) + rebase_path(outputs, root_build_dir)
}

# TODO(crbug.com/41432246): Combine this and the previous one into a
# compiled_action_foreach target.
compiled_action("generate_top_domains_test_trie") {
  tool = ":top_domain_generator"

  # Inputs in order expected by the command line of the tool.
  inputs = [
    "//components/url_formatter/spoof_checks/top_domains/test_domains.skeletons",
    "//components/url_formatter/spoof_checks/top_domains/top_domains_trie.template",
  ]
  outputs = [ "$target_gen_dir/test_domains-trie-inc.cc" ]

  args =
      rebase_path(inputs, root_build_dir) + rebase_path(outputs, root_build_dir)
}

executable("make_top_domain_list_variables") {
  sources = [ "make_top_domain_list_variables.cc" ]
  deps = [
    ":common",
    "//base",
    "//base:i18n",
    "//components/url_formatter/spoof_checks/common_words:common",
    "//third_party/icu",
  ]
  if (is_ios) {
    frameworks = [ "UIKit.framework" ]
  }
}

source_set("common") {
  sources = [
    "top_domain_util.cc",
    "top_domain_util.h",
  ]

  deps = [
    "//base",
    "//net",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [ "top_domain_util_unittest.cc" ]
  deps = [
    ":common",
    "//testing/gtest",
  ]
}

# TODO(crbug.com/41432246): Combine this and the previous one into a
# compiled_action_foreach target.
compiled_action("generate_top_domain_list_variables_file") {
  tool = ":make_top_domain_list_variables"

  # Inputs in order expected by the command line of the tool.
  inputs =
      [ "//components/url_formatter/spoof_checks/top_domains/domains.list" ]
  outputs = [ "$target_gen_dir/top-bucket-domains-inc.cc" ]
  args = rebase_path(inputs, root_build_dir) + [ "top_bucket_domains" ] +
         rebase_path(outputs, root_build_dir)
}

# TODO(crbug.com/41432246): Combine this and the previous one into a
# compiled_action_foreach target.
compiled_action("generate_test_top_domain_list_variables_file") {
  tool = ":make_top_domain_list_variables"

  # Inputs in order expected by the command line of the tool.
  inputs = [
    "//components/url_formatter/spoof_checks/top_domains/test_domains.list",
  ]
  outputs = [ "$target_gen_dir/test-top-bucket-domains-inc.cc" ]
  args = rebase_path(inputs, root_build_dir) + [ "test_top_bucket_domains" ] +
         rebase_path(outputs, root_build_dir)
}

# top_bucket_domains and top_bucket_domains_header are intentionally separated to remove
# serialized build dependency from some targets to
# generate_top_domain_list_variables action target.
source_set("top_bucket_domains") {
  # This empty public is intentional to remove unnecessary build dependency.
  public = []

  sources = [ "$target_gen_dir/top-bucket-domains-inc.cc" ]

  deps = [
    ":generate_top_domain_list_variables_file",
    ":top_bucket_domains_header",
  ]
}

source_set("top_bucket_domains_header") {
  sources = [ "top_bucket_domains.h" ]
}

source_set("test_top_bucket_domains") {
  # This empty public is intentional to remove unnecessary build dependency.
  public = []

  sources = [ "$target_gen_dir/test-top-bucket-domains-inc.cc" ]

  deps = [
    ":generate_test_top_domain_list_variables_file",
    ":test_top_bucket_domains_header",
  ]
}

source_set("test_top_bucket_domains_header") {
  sources = [ "test_top_bucket_domains.h" ]
}