xref: /aosp_15_r20/external/cronet/third_party/ced/BUILD.gn (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright 2016 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//testing/libfuzzer/fuzzer_test.gni")
6import("//testing/test.gni")
7
8config("ced_config") {
9  include_dirs = [ "src" ]
10}
11
12config("ced_config_private") {
13  # This cannot be set directly on the "ced" and "ced_unittests" target because
14  # the target cflags property is added to the command-line before the cflags
15  # property from its config. For configs, the cflags property are set in the
16  # order public_configs, configs thus it is correctly set after the flag that
17  # enable the error.
18  if (is_clang) {
19    cflags = [ "-Wno-unused-function" ]
20  }
21}
22
23static_library("ced") {
24  sources = [
25    # find src -maxdepth 3 ! -type d | egrep '\.(h|cc)$' | grep -v test.cc |\
26    # LC_COLLATE=c sort | sed 's/^\(.*\)$/    "\1",/'
27    "src/compact_enc_det/compact_enc_det.cc",
28    "src/compact_enc_det/compact_enc_det_generated_tables.h",
29    "src/compact_enc_det/compact_enc_det_generated_tables2.h",
30    "src/compact_enc_det/compact_enc_det_hint_code.cc",
31    "src/compact_enc_det/compact_enc_det_hint_code.h",
32    "src/util/basictypes.h",
33    "src/util/case_insensitive_hash.h",
34    "src/util/commandlineflags.h",
35    "src/util/encodings/encodings.cc",
36    "src/util/encodings/encodings.h",
37    "src/util/encodings/encodings.pb.h",
38    "src/util/languages/languages.cc",
39    "src/util/languages/languages.h",
40    "src/util/languages/languages.pb.h",
41    "src/util/logging.h",
42    "src/util/port.h",
43    "src/util/string_util.h",
44    "src/util/varsetter.h",
45  ]
46  configs -= [ "//build/config/compiler:chromium_code" ]
47  configs += [
48    "//build/config/compiler:no_chromium_code",
49    ":ced_config_private",
50  ]
51
52  public_configs = [ ":ced_config" ]
53
54  if (is_win) {
55    defines = [ "COMPILER_MSVC" ]
56    cflags = [
57      "/wd4005",  # Macro defined twice.
58      "/wd4006",  # #undef expected an identifier.
59      "/wd4018",  # '<': signed/unsigned mismatch
60      "/wd4309",  # Truncation of constant value.
61    ]
62  } else {
63    defines = [ "COMPILER_GCC" ]
64  }
65
66  defines += [ "HTML5_MODE" ]
67}
68
69test("ced_unittests") {
70  sources = [
71    "src/compact_enc_det/compact_enc_det_fuzz_test.cc",
72    "src/compact_enc_det/compact_enc_det_unittest.cc",
73    "src/compact_enc_det/detail_head_string.inc",
74    "src/util/encodings/encodings_unittest.cc",
75  ]
76
77  configs += [ ":ced_config_private" ]
78
79  if (is_win) {
80    defines = [ "COMPILER_MSVC" ]
81    cflags = [
82      "/wd4310",  # Truncation of constant value.
83      "/wd4267",  # size_t -> int
84    ]
85  } else {
86    defines = [ "COMPILER_GCC" ]
87  }
88
89  defines += [ "HTML5_MODE" ]
90
91  deps = [
92    ":ced",
93    "//testing/gtest",
94    "//testing/gtest:gtest_main",
95  ]
96}
97
98fuzzer_test("compact_enc_det_fuzzer") {
99  sources = [ "compact_enc_det_fuzzer.cc" ]
100  deps = [
101    ":ced",
102    "//base/test:test_support",
103  ]
104  seed_corpus = "compact_enc_det_corpus"
105}
106