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 15licenses(["notice"]) 16 17cc_library( 18 name = "footprint", 19 srcs = ["footprint.cc"], 20 hdrs = ["footprint.h"], 21 deps = [ 22 "//:api", 23 "//src/base", 24 ], 25) 26 27cc_library( 28 name = "astc_utils", 29 srcs = [ 30 "astc_file.cc", 31 "endpoint_codec.cc", 32 "integer_sequence_codec.cc", 33 "intermediate_astc_block.cc", 34 "logical_astc_block.cc", 35 "partition.cc", 36 "physical_astc_block.cc", 37 "quantization.cc", 38 "weight_infill.cc", 39 ], 40 hdrs = [ 41 "astc_file.h", 42 "endpoint_codec.h", 43 "integer_sequence_codec.h", 44 "intermediate_astc_block.h", 45 "logical_astc_block.h", 46 "partition.h", 47 "physical_astc_block.h", 48 "quantization.h", 49 "types.h", 50 "weight_infill.h", 51 ], 52 copts = [ 53 "-Wno-unused-variable", 54 "-O3", 55 ], 56 deps = [ 57 ":footprint", 58 "//src/base", 59 ], 60) 61 62cc_library( 63 name = "codec", 64 srcs = ["codec.cc"], 65 hdrs = ["codec.h"], 66 visibility = ["//:__pkg__"], 67 deps = [ 68 ":astc_utils", 69 ":footprint", 70 "//src/base", 71 ], 72) 73 74cc_binary( 75 name = "astc_inspector_cli", 76 srcs = ["tools/astc_inspector_cli.cc"], 77 deps = [ 78 ":astc_utils", 79 "//src/base", 80 ], 81) 82 83################################################################################ 84## 85## Testing 86## 87################################################################################ 88 89cc_library( 90 name = "test", 91 testonly = 1, 92 hdrs = ["test/image_utils.h"], 93 deps = ["@gtest//:gtest"], 94) 95 96cc_test( 97 name = "physical_astc_block_test", 98 size = "small", 99 srcs = ["test/physical_astc_block_test.cc"], 100 deps = [ 101 ":astc_utils", 102 "@gtest//:gtest_main", 103 "//src/base", 104 ], 105) 106 107cc_test( 108 name = "partition_test", 109 size = "medium", 110 srcs = ["test/partition_test.cc"], 111 deps = [ 112 ":astc_utils", 113 "@gtest//:gtest_main", 114 ], 115) 116 117cc_test( 118 name = "integer_sequence_codec_test", 119 size = "small", 120 srcs = ["test/integer_sequence_codec_test.cc"], 121 deps = [ 122 ":astc_utils", 123 "@gtest//:gtest_main", 124 "//src/base", 125 ], 126) 127 128cc_test( 129 name = "intermediate_astc_block_test", 130 size = "small", 131 srcs = ["test/intermediate_astc_block_test.cc"], 132 data = glob([ 133 "testdata/checkered_*.astc", 134 ]), 135 deps = [ 136 ":astc_utils", 137 ":test", 138 "@gtest//:gtest_main", 139 ], 140) 141 142cc_test( 143 name = "quantization_test", 144 size = "medium", 145 srcs = ["test/quantization_test.cc"], 146 deps = [ 147 ":astc_utils", 148 "@gtest//:gtest_main", 149 ], 150) 151 152cc_test( 153 name = "weight_infill_test", 154 size = "small", 155 srcs = ["test/weight_infill_test.cc"], 156 deps = [ 157 ":astc_utils", 158 ":footprint", 159 "@gtest//:gtest_main", 160 ], 161) 162 163cc_test( 164 name = "endpoint_codec_test", 165 size = "small", 166 srcs = ["test/endpoint_codec_test.cc"], 167 data = [ 168 ":testdata/checkerboard.astc", 169 ], 170 deps = [ 171 ":astc_utils", 172 ":test", 173 "@gtest//:gtest_main", 174 ], 175) 176 177cc_test( 178 name = "logical_astc_block_test", 179 size = "large", 180 srcs = ["test/logical_astc_block_test.cc"], 181 data = glob([ 182 "testdata/atlas_small_*.astc", 183 "testdata/atlas_small_*.bmp", 184 "testdata/footprint_*.astc", 185 "testdata/footprint_*.bmp", 186 "testdata/rgb_*.astc", 187 "testdata/rgb_*.bmp", 188 ]), 189 deps = [ 190 ":astc_utils", 191 ":test", 192 "@gtest//:gtest_main", 193 ], 194) 195 196cc_test( 197 name = "codec_test", 198 size = "large", 199 srcs = ["test/codec_test.cc"], 200 data = glob([ 201 "testdata/atlas_small_*.astc", 202 "testdata/atlas_small_*.bmp", 203 ]), 204 deps = [ 205 ":codec", 206 ":test", 207 "@gtest//:gtest_main", 208 "//:api", 209 ], 210) 211 212cc_test( 213 name = "footprint_test", 214 size = "small", 215 srcs = ["test/footprint_test.cc"], 216 deps = [ 217 ":footprint", 218 "@gtest//:gtest_main", 219 ], 220) 221 222cc_test( 223 name = "astc_fuzzer", 224 srcs = ["test/astc_fuzzer.cc"], 225 copts = select({ 226 # Clang-only flags. TODO: Find a better way to detect GCC/clang. 227 "@bazel_tools//src/conditions:darwin_x86_64": [ 228 "-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp", 229 "-fsanitize-coverage=bb", 230 ], 231 "@bazel_tools//src/conditions:darwin": [ 232 "-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp", 233 "-fsanitize-coverage=bb", 234 ], 235 # GCC-only flags. 236 "//conditions:default": [ 237 "-finstrument-functions" 238 ], 239 }), 240 deps = [ 241 ":codec", 242 "@honggfuzz//:honggfuzz", 243 "@benchmark//:benchmark", 244 ], 245 linkstatic = 1, 246) 247