blob: 6e1f810e4943334e993f41274fa29fae7e27d5fe [file] [log] [blame]
# 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.
if (!is_starboard) {
import("//testing/libfuzzer/fuzzer_test.gni")
}
if (is_win) {
import("//build/config/win/visual_studio_version.gni")
}
config("includes") {
if (is_starboard) {
include_dirs = [ "c/include" ]
} else {
include_dirs = [ "include" ]
}
}
source_set("headers") {
if (is_starboard) {
sources = [
"c/include/brotli/decode.h",
"c/include/brotli/encode.h",
"c/include/brotli/port.h",
"c/include/brotli/types.h",
]
} else {
sources = [
"include/brotli/decode.h",
"include/brotli/encode.h",
"include/brotli/port.h",
"include/brotli/types.h",
]
}
}
if (is_starboard) {
common_sources = [
"c/common/constants.h",
"c/common/dictionary.c",
"c/common/dictionary.h",
"c/common/platform.h",
"c/common/version.h",
]
} else {
common_sources = [
"common/constants.c",
"common/constants.h",
"common/context.c",
"common/context.h",
"common/dictionary.c",
"common/dictionary.h",
"common/platform.c",
"common/platform.h",
"common/transform.c",
"common/transform.h",
"common/version.h",
]
}
static_library("common") {
sources = common_sources
public_configs = [ ":includes" ]
deps = [ ":headers" ]
}
static_library("common_no_dictionary_data") {
sources = common_sources
public_configs = [ ":includes" ]
deps = [ ":headers" ]
defines = [ "BROTLI_EXTERNAL_DICTIONARY_DATA" ]
}
if (is_starboard) {
dec_sources = [
"c/dec/bit_reader.c",
"c/dec/bit_reader.h",
"c/dec/context.h",
"c/dec/decode.c",
"c/dec/huffman.c",
"c/dec/huffman.h",
"c/dec/prefix.h",
"c/dec/state.c",
"c/dec/state.h",
"c/dec/transform.h",
]
} else {
dec_sources = [
"dec/bit_reader.c",
"dec/bit_reader.h",
"dec/decode.c",
"dec/huffman.c",
"dec/huffman.h",
"dec/prefix.h",
"dec/state.c",
"dec/state.h",
]
enc_sources = [
"enc/backward_references_hq.c",
"enc/backward_references_hq.h",
"enc/backward_references_inc.h",
"enc/backward_references.c",
"enc/backward_references.h",
"enc/bit_cost_inc.h",
"enc/bit_cost.c",
"enc/bit_cost.h",
"enc/block_encoder_inc.h",
"enc/block_splitter_inc.h",
"enc/block_splitter.c",
"enc/block_splitter.h",
"enc/brotli_bit_stream.c",
"enc/brotli_bit_stream.h",
"enc/cluster_inc.h",
"enc/cluster.c",
"enc/cluster.h",
"enc/command.c",
"enc/command.h",
"enc/compress_fragment_two_pass.c",
"enc/compress_fragment_two_pass.h",
"enc/compress_fragment.c",
"enc/compress_fragment.h",
"enc/dictionary_hash.c",
"enc/dictionary_hash.h",
"enc/encode.c",
"enc/encoder_dict.c",
"enc/encoder_dict.h",
"enc/entropy_encode_static.h",
"enc/entropy_encode.c",
"enc/entropy_encode.h",
"enc/fast_log.c",
"enc/fast_log.h",
"enc/find_match_length.h",
"enc/hash_composite_inc.h",
"enc/hash_forgetful_chain_inc.h",
"enc/hash_longest_match_inc.h",
"enc/hash_longest_match_quickly_inc.h",
"enc/hash_longest_match64_inc.h",
"enc/hash_rolling_inc.h",
"enc/hash_to_binary_tree_inc.h",
"enc/hash.h",
"enc/histogram_inc.h",
"enc/histogram.c",
"enc/histogram.h",
"enc/literal_cost.c",
"enc/literal_cost.h",
"enc/memory.c",
"enc/memory.h",
"enc/metablock_inc.h",
"enc/metablock.c",
"enc/metablock.h",
"enc/params.h",
"enc/prefix.h",
"enc/quality.h",
"enc/ringbuffer.h",
"enc/static_dict_lut.h",
"enc/static_dict.c",
"enc/static_dict.h",
"enc/utf8_util.c",
"enc/utf8_util.h",
"enc/write_bits.h",
]
}
static_library("dec") {
sources = dec_sources
public_configs = [ ":includes" ]
public_deps = [ ":headers" ]
deps = [ ":common" ]
if (is_starboard) {
configs -= [ "//starboard/build/config:size" ]
configs += [ "//starboard/build/config:speed" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
} else {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
# Since we never debug brotli, freeze the optimizations to -O2.
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_max" ]
}
}
static_library("dec_no_dictionary_data") {
sources = dec_sources
public_configs = [ ":includes" ]
public_deps = [ ":headers" ]
deps = [ ":common_no_dictionary_data" ]
if (is_starboard) {
configs -= [ "//starboard/build/config:size" ]
configs += [ "//starboard/build/config:speed" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
} else {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
# Since we never debug brotli, freeze the optimizations to -O2.
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_max" ]
}
}
if (!is_starboard) {
static_library("enc") {
sources = enc_sources
public_configs = [ ":includes" ]
public_deps = [ ":headers" ]
deps = [ ":common" ]
if (is_starboard) {
configs -= [ "//starboard/build/config:size" ]
configs += [ "//starboard/build/config:speed" ]
} else {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
# Since we never debug brotli, freeze the optimizations to -O2.
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_max" ]
}
}
if (current_toolchain == host_toolchain) {
executable("brotli") {
sources = [ "tools/brotli.c" ]
public_configs = [ ":includes" ]
deps = [
":common",
":dec",
":enc",
":headers",
"//build/win:default_exe_manifest",
]
if (is_win && visual_studio_version == "2015") {
# Disabling "result of 32-bit shift implicitly converted to 64 bits",
# caused by code like: foo |= (1 << i); // warning 4334
cflags = [ "/wd4334" ]
}
# Always build release since this is a build tool.
if (is_debug) {
configs -= [ "//build/config:debug" ]
configs += [ "//build/config:release" ]
}
}
}
fuzzer_test("brotli_fuzzer") {
sources = [ "fuzz/decode_fuzzer.cc" ]
deps = [ ":dec" ]
libfuzzer_options = [ "max_len=1280" ]
}
}