BUILD.gn 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. # Copyright 2014 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import("//testing/libfuzzer/fuzzer_test.gni")
  5. if (is_win) {
  6. import("//build/config/win/visual_studio_version.gni")
  7. }
  8. config("includes") {
  9. include_dirs = [ "include" ]
  10. }
  11. source_set("headers") {
  12. sources = [
  13. "include/brotli/decode.h",
  14. "include/brotli/encode.h",
  15. "include/brotli/port.h",
  16. "include/brotli/types.h",
  17. ]
  18. }
  19. common_sources = [
  20. "common/constants.c",
  21. "common/constants.h",
  22. "common/context.c",
  23. "common/context.h",
  24. "common/dictionary.c",
  25. "common/dictionary.h",
  26. "common/platform.c",
  27. "common/platform.h",
  28. "common/transform.c",
  29. "common/transform.h",
  30. "common/version.h",
  31. ]
  32. static_library("common") {
  33. sources = common_sources
  34. public_configs = [ ":includes" ]
  35. deps = [ ":headers" ]
  36. }
  37. static_library("common_no_dictionary_data") {
  38. sources = common_sources
  39. public_configs = [ ":includes" ]
  40. deps = [ ":headers" ]
  41. defines = [ "BROTLI_EXTERNAL_DICTIONARY_DATA" ]
  42. }
  43. dec_sources = [
  44. "dec/bit_reader.c",
  45. "dec/bit_reader.h",
  46. "dec/decode.c",
  47. "dec/huffman.c",
  48. "dec/huffman.h",
  49. "dec/prefix.h",
  50. "dec/state.c",
  51. "dec/state.h",
  52. ]
  53. enc_sources = [
  54. "enc/backward_references_hq.c",
  55. "enc/backward_references_hq.h",
  56. "enc/backward_references_inc.h",
  57. "enc/backward_references.c",
  58. "enc/backward_references.h",
  59. "enc/bit_cost_inc.h",
  60. "enc/bit_cost.c",
  61. "enc/bit_cost.h",
  62. "enc/block_encoder_inc.h",
  63. "enc/block_splitter_inc.h",
  64. "enc/block_splitter.c",
  65. "enc/block_splitter.h",
  66. "enc/brotli_bit_stream.c",
  67. "enc/brotli_bit_stream.h",
  68. "enc/cluster_inc.h",
  69. "enc/cluster.c",
  70. "enc/cluster.h",
  71. "enc/command.c",
  72. "enc/command.h",
  73. "enc/compress_fragment_two_pass.c",
  74. "enc/compress_fragment_two_pass.h",
  75. "enc/compress_fragment.c",
  76. "enc/compress_fragment.h",
  77. "enc/dictionary_hash.c",
  78. "enc/dictionary_hash.h",
  79. "enc/encode.c",
  80. "enc/encoder_dict.c",
  81. "enc/encoder_dict.h",
  82. "enc/entropy_encode_static.h",
  83. "enc/entropy_encode.c",
  84. "enc/entropy_encode.h",
  85. "enc/fast_log.c",
  86. "enc/fast_log.h",
  87. "enc/find_match_length.h",
  88. "enc/hash_composite_inc.h",
  89. "enc/hash_forgetful_chain_inc.h",
  90. "enc/hash_longest_match_inc.h",
  91. "enc/hash_longest_match_quickly_inc.h",
  92. "enc/hash_longest_match64_inc.h",
  93. "enc/hash_rolling_inc.h",
  94. "enc/hash_to_binary_tree_inc.h",
  95. "enc/hash.h",
  96. "enc/histogram_inc.h",
  97. "enc/histogram.c",
  98. "enc/histogram.h",
  99. "enc/literal_cost.c",
  100. "enc/literal_cost.h",
  101. "enc/memory.c",
  102. "enc/memory.h",
  103. "enc/metablock_inc.h",
  104. "enc/metablock.c",
  105. "enc/metablock.h",
  106. "enc/params.h",
  107. "enc/prefix.h",
  108. "enc/quality.h",
  109. "enc/ringbuffer.h",
  110. "enc/static_dict_lut.h",
  111. "enc/static_dict.c",
  112. "enc/static_dict.h",
  113. "enc/utf8_util.c",
  114. "enc/utf8_util.h",
  115. "enc/write_bits.h",
  116. ]
  117. static_library("dec") {
  118. sources = dec_sources
  119. public_configs = [ ":includes" ]
  120. public_deps = [ ":headers" ]
  121. deps = [ ":common" ]
  122. configs -= [ "//build/config/compiler:chromium_code" ]
  123. configs += [ "//build/config/compiler:no_chromium_code" ]
  124. # Since we never debug brotli, freeze the optimizations to -O2.
  125. configs -= [ "//build/config/compiler:default_optimization" ]
  126. configs += [ "//build/config/compiler:optimize_max" ]
  127. }
  128. static_library("dec_no_dictionary_data") {
  129. sources = dec_sources
  130. public_configs = [ ":includes" ]
  131. public_deps = [ ":headers" ]
  132. deps = [ ":common_no_dictionary_data" ]
  133. configs -= [ "//build/config/compiler:chromium_code" ]
  134. configs += [ "//build/config/compiler:no_chromium_code" ]
  135. # Since we never debug brotli, freeze the optimizations to -O2.
  136. configs -= [ "//build/config/compiler:default_optimization" ]
  137. configs += [ "//build/config/compiler:optimize_max" ]
  138. }
  139. static_library("enc") {
  140. sources = enc_sources
  141. public_configs = [ ":includes" ]
  142. public_deps = [ ":headers" ]
  143. deps = [ ":common" ]
  144. configs -= [ "//build/config/compiler:chromium_code" ]
  145. configs += [ "//build/config/compiler:no_chromium_code" ]
  146. # Since we never debug brotli, freeze the optimizations to -O2.
  147. configs -= [ "//build/config/compiler:default_optimization" ]
  148. configs += [ "//build/config/compiler:optimize_max" ]
  149. }
  150. if (current_toolchain == host_toolchain) {
  151. executable("brotli") {
  152. sources = [ "tools/brotli.c" ]
  153. public_configs = [ ":includes" ]
  154. deps = [
  155. ":common",
  156. ":dec",
  157. ":enc",
  158. ":headers",
  159. "//build/win:default_exe_manifest",
  160. ]
  161. if (is_win && visual_studio_version == "2015") {
  162. # Disabling "result of 32-bit shift implicitly converted to 64 bits",
  163. # caused by code like: foo |= (1 << i); // warning 4334
  164. cflags = [ "/wd4334" ]
  165. }
  166. # Always build release since this is a build tool.
  167. if (is_debug) {
  168. configs -= [ "//build/config:debug" ]
  169. configs += [ "//build/config:release" ]
  170. }
  171. }
  172. }
  173. fuzzer_test("brotli_fuzzer") {
  174. sources = [ "fuzz/decode_fuzzer.cc" ]
  175. deps = [ ":dec" ]
  176. libfuzzer_options = [ "max_len=1280" ]
  177. }