• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package(default_visibility = ["//visibility:public"])
2
3licenses(["notice"])  # BSD 3-Clause
4
5exports_files(["COPYING"])
6
7cc_library(
8    name = "snappy",
9    srcs = [
10        "config.h",
11        "snappy.cc",
12        "snappy.h",
13        "snappy-internal.h",
14        "snappy-sinksource.cc",
15        "snappy-sinksource.h",
16        "snappy-stubs-internal.cc",
17        "snappy-stubs-internal.h",
18        "snappy-stubs-public.h",
19    ],
20    hdrs = ["snappy.h"],
21    copts = ["-DHAVE_CONFIG_H"] + select({
22        "@org_tensorflow//tensorflow:windows": [],
23        "//conditions:default": [
24            "-fno-exceptions",
25            "-Wno-sign-compare",
26            "-Wno-shift-negative-value",
27            "-Wno-implicit-function-declaration",
28        ],
29    }),
30    defines = select({
31        "@org_tensorflow//tensorflow:windows": [],
32        "//conditions:default": ["HAVE_SYS_UIO_H"],
33    }),
34)
35
36genrule(
37    name = "config_h",
38    outs = ["config.h"],
39    cmd = "\n".join([
40        "cat <<'EOF' >$@",
41        "#define HAVE_STDDEF_H 1",
42        "#define HAVE_STDINT_H 1",
43        "",
44        "#ifdef __has_builtin",
45        "#  if !defined(HAVE_BUILTIN_EXPECT) && __has_builtin(__builtin_expect)",
46        "#    define HAVE_BUILTIN_EXPECT 1",
47        "#  endif",
48        "#  if !defined(HAVE_BUILTIN_CTZ) && __has_builtin(__builtin_ctzll)",
49        "#    define HAVE_BUILTIN_CTZ 1",
50        "#  endif",
51        "#elif defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)",
52        "#  ifndef HAVE_BUILTIN_EXPECT",
53        "#    define HAVE_BUILTIN_EXPECT 1",
54        "#  endif",
55        "#  ifndef HAVE_BUILTIN_CTZ",
56        "#    define HAVE_BUILTIN_CTZ 1",
57        "#  endif",
58        "#endif",
59        "",
60        "#ifdef __has_include",
61        "#  if !defined(HAVE_BYTESWAP_H) && __has_include(<byteswap.h>)",
62        "#    define HAVE_BYTESWAP_H 1",
63        "#  endif",
64        "#  if !defined(HAVE_UNISTD_H) && __has_include(<unistd.h>)",
65        "#    define HAVE_UNISTD_H 1",
66        "#  endif",
67        "#  if !defined(HAVE_SYS_ENDIAN_H) && __has_include(<sys/endian.h>)",
68        "#    define HAVE_SYS_ENDIAN_H 1",
69        "#  endif",
70        "#  if !defined(HAVE_SYS_MMAN_H) && __has_include(<sys/mman.h>)",
71        "#    define HAVE_SYS_MMAN_H 1",
72        "#  endif",
73        "#  if !defined(HAVE_SYS_UIO_H) && __has_include(<sys/uio.h>)",
74        "#    define HAVE_SYS_UIO_H 1",
75        "#  endif",
76        "#endif",
77        "",
78        "#ifndef SNAPPY_IS_BIG_ENDIAN",
79        "#  ifdef __s390x__",
80        "#    define SNAPPY_IS_BIG_ENDIAN 1",
81        "#  elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__",
82        "#    define SNAPPY_IS_BIG_ENDIAN 1",
83        "#  endif",
84        "#endif",
85        "EOF",
86    ]),
87)
88
89genrule(
90    name = "snappy_stubs_public_h",
91    srcs = ["snappy-stubs-public.h.in"],
92    outs = ["snappy-stubs-public.h"],
93    cmd = ("sed " +
94           "-e 's/$${\\(.*\\)_01}/\\1/g' " +
95           "-e 's/$${SNAPPY_MAJOR}/1/g' " +
96           "-e 's/$${SNAPPY_MINOR}/1/g' " +
97           "-e 's/$${SNAPPY_PATCHLEVEL}/4/g' " +
98           "$< >$@"),
99)
100