1# Copyright 2018 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15cc_library( 16 name = "footprint", 17 srcs = ["footprint.cc"], 18 hdrs = ["footprint.h"], 19 deps = [ 20 "//:api", 21 "//src/base", 22 ], 23) 24 25cc_library( 26 name = "astc_utils", 27 srcs = [ 28 "astc_file.cc", 29 "endpoint_codec.cc", 30 "integer_sequence_codec.cc", 31 "intermediate_astc_block.cc", 32 "logical_astc_block.cc", 33 "partition.cc", 34 "physical_astc_block.cc", 35 "quantization.cc", 36 "weight_infill.cc", 37 ], 38 hdrs = [ 39 "astc_file.h", 40 "endpoint_codec.h", 41 "integer_sequence_codec.h", 42 "intermediate_astc_block.h", 43 "logical_astc_block.h", 44 "partition.h", 45 "physical_astc_block.h", 46 "quantization.h", 47 "types.h", 48 "weight_infill.h", 49 ], 50 deps = [ 51 ":footprint", 52 "//src/base", 53 ], 54) 55 56cc_library( 57 name = "codec", 58 srcs = ["codec.cc"], 59 hdrs = ["codec.h"], 60 deps = [ 61 ":astc_utils", 62 ":footprint", 63 "//src/base", 64 ], 65 visibility = ["//:__pkg__"], 66) 67 68cc_binary( 69 name = "astc_inspector_cli", 70 srcs = ["tools/astc_inspector_cli.cc"], 71 deps = [ 72 ":astc_utils", 73 "//src/base", 74 ], 75) 76 77################################################################################ 78## 79## Testing 80## 81################################################################################ 82 83cc_library( 84 name = "test", 85 hdrs = ["test/image_utils.h"], 86 deps = [ 87 "@gtest//:gtest_main", 88 ], 89) 90 91cc_test( 92 name = "physical_astc_block_test", 93 size = "small", 94 srcs = ["test/physical_astc_block_test.cc"], 95 deps = [ 96 ":astc_utils", 97 "@gtest//:gtest_main", 98 ], 99) 100 101cc_test( 102 name = "partition_test", 103 size = "small", 104 srcs = ["test/partition_test.cc"], 105 deps = [ 106 ":astc_utils", 107 "@gtest//:gtest_main", 108 ], 109) 110 111cc_test( 112 name = "integer_sequence_codec_test", 113 size = "small", 114 srcs = ["test/integer_sequence_codec_test.cc"], 115 deps = [ 116 ":astc_utils", 117 "@gtest//:gtest_main", 118 ], 119) 120 121cc_test( 122 name = "intermediate_astc_block_test", 123 size = "small", 124 srcs = ["test/intermediate_astc_block_test.cc"], 125 data = glob([ 126 "testdata/checkered_*.astc", 127 ]), 128 deps = [ 129 ":astc_utils", 130 ":test", 131 "@gtest//:gtest_main", 132 ], 133) 134 135cc_test( 136 name = "quantization_test", 137 size = "medium", 138 srcs = ["test/quantization_test.cc"], 139 deps = [ 140 ":astc_utils", 141 "@gtest//:gtest_main", 142 ], 143) 144 145cc_test( 146 name = "weight_infill_test", 147 size = "small", 148 srcs = ["test/weight_infill_test.cc"], 149 deps = [ 150 ":astc_utils", 151 ":footprint", 152 "@gtest//:gtest_main", 153 ], 154) 155 156cc_test( 157 name = "endpoint_codec_test", 158 size = "small", 159 srcs = ["test/endpoint_codec_test.cc"], 160 data = [ 161 ":testdata/checkerboard.astc", 162 ], 163 deps = [ 164 ":astc_utils", 165 ":test", 166 "@gtest//:gtest_main", 167 ], 168) 169 170cc_test( 171 name = "logical_astc_block_test", 172 size = "large", 173 srcs = ["test/logical_astc_block_test.cc"], 174 data = glob([ 175 "testdata/atlas_small_*.astc", 176 "testdata/atlas_small_*.bmp", 177 "testdata/footprint_*.astc", 178 "testdata/footprint_*.bmp", 179 "testdata/rgb_*.astc", 180 "testdata/rgb_*.bmp", 181 ]), 182 deps = [ 183 ":test", 184 ":astc_utils", 185 "@gtest//:gtest_main", 186 ], 187) 188 189cc_test( 190 name = "codec_test", 191 size = "large", 192 srcs = ["test/codec_test.cc"], 193 data = glob([ 194 "testdata/atlas_small_*.astc", 195 "testdata/atlas_small_*.bmp", 196 ]), 197 deps = [ 198 ":test", 199 ":codec", 200 "@gtest//:gtest_main", 201 ], 202) 203 204cc_test( 205 name = "footprint_test", 206 size = "small", 207 srcs = ["test/footprint_test.cc"], 208 deps = [ 209 ":footprint", 210 "@gtest//:gtest_main", 211 ], 212) 213 214cc_test( 215 name = "astc_fuzzer", 216 srcs = ["test/astc_fuzzer.cc"], 217 copts = select({ 218 # Clang-only flags. TODO: Find a better way to detect GCC/clang. 219 "@bazel_tools//src/conditions:darwin_x86_64": [ 220 "-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp", 221 "-fsanitize-coverage=bb", 222 ], 223 "@bazel_tools//src/conditions:darwin": [ 224 "-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp", 225 "-fsanitize-coverage=bb", 226 ], 227 # GCC-only flags. 228 "//conditions:default": [ 229 "-finstrument-functions" 230 ], 231 }), 232 deps = [ 233 ":codec", 234 "@honggfuzz//:honggfuzz", 235 "@benchmark//:benchmark", 236 ], 237 linkstatic = 1, 238) 239