summaryrefslogtreecommitdiff
path: root/chromium/third_party/qcms/BUILD.gn
blob: 81963b17ce0b65ed3c533f5ef58178d4289263c0 (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
# Copyright 2014 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("//testing/libfuzzer/fuzzer_test.gni")

config("qcms_config") {
  include_dirs = [ "src" ]
}

disable_qcms = false

static_library("qcms") {
  if (disable_qcms) {
    sources = [ "src/empty.c" ]
  } else {
    sources = [
      "src/chain.c",
      "src/chain.h",
      "src/iccread.c",
      "src/matrix.c",
      "src/matrix.h",
      "src/qcms.h",
      "src/qcms_util.c",
      "src/qcmsint.h",
      "src/qcmstypes.h",
      "src/transform.c",
      "src/transform_util.c",
      "src/transform_util.h",
    ]

    defines = []

    if (current_cpu == "x86" || current_cpu == "x64") {
      defines += [ "SSE2_ENABLE" ]
      sources += [ "src/transform-sse2.c" ]
    }

    if (use_fuzzing_engine) {
      defines += [ "USE_LIBFUZZER" ]
    }
  }

  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  public_configs = [ ":qcms_config" ]

  if (is_win) {
    cflags = [
      "/wd4018",  # Signed/unsigned mismatch in comparison.
      "/wd4056",  # Overflow in floating-point constant arithmetic (INFINITY).
      "/wd4756",  # Overflow in constant arithmetic (INFINITY).
    ]
  }
}

# fuzzers BUILD depends on this target. Needed for package discovery
group("fuzzers") {
}

fuzzer_test("qcms_color_space_fuzzer") {
  sources = [
    "//testing/libfuzzer/fuzzers/color_space_data.h",
    "qcms_color_space_fuzzer.cc",
  ]
  deps = [
    ":qcms",
    "//base",
  ]
  dict = "//testing/libfuzzer/fuzzers/dicts/icc.dict"
  libfuzzer_options = [ "max_len=4194304" ]
}

if (!disable_qcms) {
  executable("qcms_tests") {
    if (current_cpu == "x86" || current_cpu == "x64") {
      defines = [ "SSE2_ENABLE" ]
    }
    sources = [
      "src/tests/qcms_test_internal_srgb.c",
      "src/tests/qcms_test_main.c",
      "src/tests/qcms_test_munsell.c",
      "src/tests/qcms_test_ntsc_gamut.c",
      "src/tests/qcms_test_output_trc.c",
      "src/tests/qcms_test_tetra_clut_rgba.c",
      "src/tests/qcms_test_util.c",
    ]

    deps = [
      "//build/win:default_exe_manifest",
      "//third_party/qcms",
    ]

    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    public_configs = [ ":qcms_config" ]
  }
}