Hash :
1045ab52
        
        Author :
  
        
        Date :
2024-01-04T03:32:33
        
      
Fix/simplify/improve Bazel build PiperOrigin-RevId: 595656443
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
# Description:
#   Brotli is a generic-purpose lossless compression algorithm.
package(
    default_visibility = ["//visibility:public"],
)
licenses(["notice"])  # MIT
exports_files(["LICENSE"])
config_setting(
    name = "clang-cl",
    flag_values = {
        "@bazel_tools//tools/cpp:compiler": "clang-cl",
    },
    visibility = ["//visibility:public"],
)
config_setting(
    name = "msvc",
    flag_values = {
        "@bazel_tools//tools/cpp:compiler": "msvc-cl",
    },
    visibility = ["//visibility:public"],
)
STRICT_C_OPTIONS = select({
    ":msvc": [],
    ":clang-cl": [
        "/W4",
        "-Wconversion",
        "-Wlong-long",
        "-Wmissing-declarations",
        "-Wmissing-prototypes",
        "-Wno-strict-aliasing",
        "-Wshadow",
        "-Wsign-compare",
        "-Wno-sign-conversion",
    ],
    "//conditions:default": [
        "--pedantic-errors",
        "-Wall",
        "-Wconversion",
        "-Werror",
        "-Wextra",
        "-Wlong-long",
        "-Wmissing-declarations",
        "-Wmissing-prototypes",
        "-Wno-strict-aliasing",
        "-Wshadow",
        "-Wsign-compare",
    ],
})
filegroup(
    name = "public_headers",
    srcs = glob(["c/include/brotli/*.h"]),
)
filegroup(
    name = "common_headers",
    srcs = glob(["c/common/*.h"]),
)
filegroup(
    name = "common_sources",
    srcs = glob(["c/common/*.c"]),
)
filegroup(
    name = "dec_headers",
    srcs = glob(["c/dec/*.h"]),
)
filegroup(
    name = "dec_sources",
    srcs = glob(["c/dec/*.c"]),
)
filegroup(
    name = "enc_headers",
    srcs = glob(["c/enc/*.h"]),
)
filegroup(
    name = "enc_sources",
    srcs = glob(["c/enc/*.c"]),
)
cc_library(
    name = "brotli_inc",
    hdrs = [":public_headers"],
    copts = STRICT_C_OPTIONS,
    strip_include_prefix = "c/include",
)
cc_library(
    name = "brotlicommon",
    srcs = [":common_sources"],
    hdrs = [":common_headers"],
    copts = STRICT_C_OPTIONS,
    deps = [":brotli_inc"],
)
cc_library(
    name = "brotlidec",
    srcs = [":dec_sources"],
    hdrs = [":dec_headers"],
    copts = STRICT_C_OPTIONS,
    deps = [":brotlicommon"],
)
cc_library(
    name = "brotlienc",
    srcs = [":enc_sources"],
    hdrs = [":enc_headers"],
    copts = STRICT_C_OPTIONS,
    linkopts = select({
        ":clang-cl": [],
        ":msvc": [],
        "//conditions:default": ["-lm"],
    }),
    deps = [":brotlicommon"],
)
cc_binary(
    name = "brotli",
    srcs = ["c/tools/brotli.c"],
    copts = STRICT_C_OPTIONS,
    linkstatic = 1,
    deps = [
        ":brotlidec",
        ":brotlienc",
    ],
)
filegroup(
    name = "dictionary",
    srcs = ["c/common/dictionary.bin"],
)