1 # Description: 2 # Brotli is a generic-purpose lossless compression algorithm. 3 4 package( 5 default_visibility = ["//visibility:public"], 6 ) 7 8 licenses(["notice"]) # MIT 9 10 exports_files(["LICENSE"]) 11 12 # >>> JNI headers 13 14 config_setting( 15 name = "darwin", 16 values = {"cpu": "darwin"}, 17 visibility = ["//visibility:public"], 18 ) 19 20 config_setting( 21 name = "darwin_x86_64", 22 values = {"cpu": "darwin_x86_64"}, 23 visibility = ["//visibility:public"], 24 ) 25 26 genrule( 27 name = "copy_link_jni_header", 28 srcs = ["@openjdk_linux//:jni_h"], 29 outs = ["jni/jni.h"], 30 cmd = "cp -f $< $@", 31 ) 32 33 genrule( 34 name = "copy_link_jni_md_header", 35 srcs = select({ 36 ":darwin": ["@openjdk_macos//:jni_md_h"], 37 ":darwin_x86_64": ["@openjdk_macos//:jni_md_h"], 38 "//conditions:default": ["@openjdk_linux//:jni_md_h"], 39 }), 40 outs = ["jni/jni_md.h"], 41 cmd = "cp -f $< $@", 42 ) 43 44 cc_library( 45 name = "jni_inc", 46 hdrs = [ 47 ":jni/jni.h", 48 ":jni/jni_md.h", 49 ], 50 includes = ["jni"], 51 ) 52 53 # <<< JNI headers 54 55 STRICT_C_OPTIONS = [ 56 "--pedantic-errors", 57 "-Wall", 58 "-Wconversion", 59 "-Werror", 60 "-Wextra", 61 "-Wlong-long", 62 "-Wmissing-declarations", 63 "-Wmissing-prototypes", 64 "-Wno-strict-aliasing", 65 "-Wshadow", 66 "-Wsign-compare", 67 ] 68 69 filegroup( 70 name = "public_headers", 71 srcs = glob(["c/include/brotli/*.h"]), 72 ) 73 74 filegroup( 75 name = "common_headers", 76 srcs = glob(["c/common/*.h"]), 77 ) 78 79 filegroup( 80 name = "common_sources", 81 srcs = glob(["c/common/*.c"]), 82 ) 83 84 filegroup( 85 name = "dec_headers", 86 srcs = glob(["c/dec/*.h"]), 87 ) 88 89 filegroup( 90 name = "dec_sources", 91 srcs = glob(["c/dec/*.c"]), 92 ) 93 94 filegroup( 95 name = "enc_headers", 96 srcs = glob(["c/enc/*.h"]), 97 ) 98 99 filegroup( 100 name = "enc_sources", 101 srcs = glob(["c/enc/*.c"]), 102 ) 103 104 cc_library( 105 name = "brotli_inc", 106 hdrs = [":public_headers"], 107 copts = STRICT_C_OPTIONS, 108 includes = ["c/include"], 109 ) 110 111 cc_library( 112 name = "brotlicommon", 113 srcs = [":common_sources"], 114 hdrs = [":common_headers"], 115 copts = STRICT_C_OPTIONS, 116 deps = [":brotli_inc"], 117 ) 118 119 cc_library( 120 name = "brotlidec", 121 srcs = [":dec_sources"], 122 hdrs = [":dec_headers"], 123 copts = STRICT_C_OPTIONS, 124 deps = [":brotlicommon"], 125 ) 126 127 cc_library( 128 name = "brotlienc", 129 srcs = [":enc_sources"], 130 hdrs = [":enc_headers"], 131 copts = STRICT_C_OPTIONS, 132 linkopts = ["-lm"], 133 deps = [":brotlicommon"], 134 ) 135 136 cc_binary( 137 name = "brotli", 138 srcs = ["c/tools/brotli.c"], 139 copts = STRICT_C_OPTIONS, 140 linkstatic = 1, 141 deps = [ 142 ":brotlidec", 143 ":brotlienc", 144 ], 145 ) 146 147 ######################################################## 148 # WARNING: do not (transitively) depend on this target! 149 ######################################################## 150 cc_library( 151 name = "jni", 152 srcs = [ 153 ":common_sources", 154 ":dec_sources", 155 ":enc_sources", 156 "//java/org/brotli/wrapper/common:jni_src", 157 "//java/org/brotli/wrapper/dec:jni_src", 158 "//java/org/brotli/wrapper/enc:jni_src", 159 ], 160 hdrs = [ 161 ":common_headers", 162 ":dec_headers", 163 ":enc_headers", 164 ], 165 deps = [ 166 ":brotli_inc", 167 ":jni_inc", 168 ], 169 alwayslink = 1, 170 ) 171 172 ######################################################## 173 # WARNING: do not (transitively) depend on this target! 174 ######################################################## 175 cc_library( 176 name = "jni_no_dictionary_data", 177 srcs = [ 178 ":common_sources", 179 ":dec_sources", 180 ":enc_sources", 181 "//java/org/brotli/wrapper/common:jni_src", 182 "//java/org/brotli/wrapper/dec:jni_src", 183 "//java/org/brotli/wrapper/enc:jni_src", 184 ], 185 hdrs = [ 186 ":common_headers", 187 ":dec_headers", 188 ":enc_headers", 189 ], 190 defines = [ 191 "BROTLI_EXTERNAL_DICTIONARY_DATA=", 192 ], 193 deps = [ 194 ":brotli_inc", 195 ":jni_inc", 196 ], 197 alwayslink = 1, 198 ) 199 200 filegroup( 201 name = "dictionary", 202 srcs = ["c/common/dictionary.bin"], 203 ) 204 205 load("@io_bazel_rules_go//go:def.bzl", "go_prefix") 206 207 go_prefix("github.com/google/brotli") 208