summaryrefslogtreecommitdiff
path: root/chromium/components/subresource_filter/tools/BUILD.gn
blob: 557e6b293859c6d487315c36e12e8f1cfd90a8d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Copyright 2018 The Chromium Authors. All rights reserved.
# 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")

static_library("tools_lib") {
  sources = [
    "filter_tool.cc",
    "filter_tool.h",
    "indexing_tool.cc",
    "indexing_tool.h",
  ]
  deps = [
    "../core/browser",
    "../core/common",
    "//base",
    "//components/url_pattern_index:util",
    "//url",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "filter_tool_unittest.cc",
    "indexing_tool_unittest.cc",
  ]

  deps = [
    ":tools_lib",
    "../core/common",
    "../core/common:test_support",
    "rule_parser:unit_tests",
    "ruleset_converter:unit_tests",
    "//base",
    "//base/test:test_support",
    "//components/url_pattern_index:test_support",
    "//testing/gtest",
    "//third_party/protobuf:protobuf_lite",
    "//url",
  ]
}

if (!is_ios) {
  executable("subresource_filter_tool") {
    # Production code should not depend on this.
    testonly = true
    sources = [
      "filter_tool_main.cc",
    ]
    deps = [
      ":tools_lib",
      "//base",
      "//build/config:exe_and_shlib_deps",
    ]
  }

  executable("subresource_indexing_tool") {
    # Production code should not depend on this.
    testonly = true
    sources = [
      "indexing_tool_main.cc",
    ]
    deps = [
      ":tools_lib",
      "//base",
      "//build/config:exe_and_shlib_deps",
    ]
  }

  executable("ruleset_converter") {
    sources = [
      "ruleset_converter/main.cc",
    ]
    deps = [
      "ruleset_converter:support",
      "//base",
      "//build/config:exe_and_shlib_deps",
      "//third_party/protobuf:protobuf_lite",
    ]
  }

  group("subresource_filter_tools") {
    # Production code should not depend on this.
    testonly = true
    deps = [
      ":ruleset_converter",
      ":subresource_filter_tool",
      ":subresource_indexing_tool",
    ]
  }

  # This action compiles the indexing tool using the host's toolchain, and
  # generates an indexed ruleset using the existing unindexed ruleset in the
  # source tree.
  compiled_action("index_ruleset") {
    testonly = true
    tool = ":subresource_indexing_tool"

    outputs = [
      "$target_gen_dir/GeneratedRulesetData",
    ]

    inputs = [
      # Make sure the inputs are system-absolute, as base::File cannot open files with ".." components.
      rebase_path(
          "//components/subresource_filter/core/common/perftests/data/UnindexedRules_7.54",
          "",
          "/"),
    ]
    deps = [
      ":subresource_indexing_tool",
    ]

    args = [
      inputs[0],
      rebase_path("$target_gen_dir/GeneratedRulesetData", root_build_dir),
    ]
  }
}