summaryrefslogtreecommitdiff
path: root/chromium/components/schema_org/BUILD.gn
blob: 9d3f9a7757b39d0f40b8b10d4aa6e29f5a579340 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Copyright 2020 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")
import("//build/config/python.gni")
import("//testing/libfuzzer/fuzzer_test.gni")

source_set("unit_tests") {
  testonly = true
  sources = [
    "extractor_unittest.cc",
    "generate_schema_org_code_unittest.cc",
    "validator_unittest.cc",
  ]

  deps = [
    ":extractor",
    ":generate_schema_org_code",
    ":schema_org",
    ":schema_org_properties",
    "//base",
    "//base/test:test_support",
    "//components/schema_org/common:improved_mojom",
    "//services/data_decoder/public/cpp:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]
}

executable("schema_org_name_generator") {
  sources = [ "schema_org_name_generator.cc" ]
  deps = [
    "//base",
    "//url",
  ]
}

compiled_action("schema_org_name_data") {
  tool = ":schema_org_name_generator"

  args = [
    rebase_path("//third_party/schema_org/schema.jsonld", root_build_dir),
    rebase_path("//third_party/schema_org/overrides.jsonld", root_build_dir),
    rebase_path("$target_gen_dir/schema_org_name_data.json", root_build_dir),
  ]

  inputs = [
    "//third_party/schema_org/schema.jsonld",
    "//third_party/schema_org/overrides.jsonld",
  ]

  outputs = [ "$target_gen_dir/schema_org_name_data.json" ]
}

# TODO(crbug.com/1112471): Get this to run cleanly under Python 3.
python2_action("generate_schema_org_code") {
  script = "//components/schema_org/generate_schema_org_code.py"

  sources = [
    "templates/schema_org_entity_names.cc.tmpl",
    "templates/schema_org_entity_names.h.tmpl",
    "templates/schema_org_enums.cc.tmpl",
    "templates/schema_org_enums.h.tmpl",
    "templates/schema_org_property_configurations.cc.tmpl",
    "templates/schema_org_property_configurations.h.tmpl",
    "templates/schema_org_property_names.cc.tmpl",
    "templates/schema_org_property_names.h.tmpl",
  ]

  args =
      [
        "--schema-file",
        rebase_path("//third_party/schema_org/schema.jsonld", root_build_dir),
        "--overrides-file",
        rebase_path("//third_party/schema_org/overrides.jsonld",
                    root_build_dir),
        "--name-file",
        rebase_path("$target_gen_dir/schema_org_name_data.json",
                    root_build_dir),
        "--output-dir",
        rebase_path("$target_gen_dir", root_build_dir),
        "--templates",
      ] + sources

  inputs = [
    "//third_party/schema_org/schema.jsonld",
    "//third_party/schema_org/overrides.jsonld",
  ]

  outputs = [
    "$target_gen_dir/schema_org_entity_names.h",
    "$target_gen_dir/schema_org_entity_names.cc",
    "$target_gen_dir/schema_org_property_configurations.h",
    "$target_gen_dir/schema_org_property_configurations.cc",
    "$target_gen_dir/schema_org_property_names.h",
    "$target_gen_dir/schema_org_property_names.cc",
    "$target_gen_dir/schema_org_enums.h",
    "$target_gen_dir/schema_org_enums.cc",
  ]

  deps = [ ":schema_org_name_data" ]
}

static_library("schema_org_properties") {
  sources = [
    "$target_gen_dir/schema_org_entity_names.cc",
    "$target_gen_dir/schema_org_entity_names.h",
    "$target_gen_dir/schema_org_enums.cc",
    "$target_gen_dir/schema_org_enums.h",
    "$target_gen_dir/schema_org_property_configurations.cc",
    "$target_gen_dir/schema_org_property_configurations.h",
    "$target_gen_dir/schema_org_property_names.cc",
    "$target_gen_dir/schema_org_property_names.h",
  ]

  deps = [
    ":generate_schema_org_code",
    "//base",
  ]
}

static_library("extractor") {
  sources = [
    "extractor.cc",
    "extractor.h",
  ]

  deps = [
    "//base",
    "//components/schema_org:generate_schema_org_code",
    "//components/schema_org:schema_org",
    "//components/schema_org:schema_org_properties",
    "//components/schema_org/common",
    "//components/schema_org/common:improved_mojom",
    "//services/data_decoder/public/cpp",
  ]
}

static_library("schema_org") {
  sources = [
    "validator.cc",
    "validator.h",
  ]

  deps = [
    "//base",
    "//components/schema_org:generate_schema_org_code",
    "//components/schema_org:schema_org_properties",
    "//components/schema_org/common:improved_mojom",
  ]
}

fuzzer_test("extractor_fuzzer") {
  sources = [ "extractor_fuzzer.cc" ]
  deps = [
    ":extractor",
    ":schema_org_properties",
    "//base",
    "//base/test:test_support",
    "//components/schema_org/common:improved_mojom",
    "//services/data_decoder/public/cpp:test_support",
  ]
}