Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,20 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

exports_files([
"COPYING",
"COPYING.notestdata",
])

SNAPPY_VERSION = (1, 2, 2)

config_setting(
Expand Down Expand Up @@ -133,10 +143,10 @@ cc_test(
)

# Generate a config.h similar to what cmake would produce.
genrule(
write_file(
name = "config_h",
outs = ["config.h"],
cmd = """cat <<EOF >$@
out = "config.h",
content = """\
#define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1
#ifdef __has_builtin
Expand Down Expand Up @@ -193,19 +203,17 @@ genrule(
# define SNAPPY_IS_BIG_ENDIAN 1
# endif
#endif
EOF
""",
""".splitlines(),
)

genrule(
expand_template(
name = "snappy_stubs_public_h",
srcs = ["snappy-stubs-public.h.in"],
outs = ["snappy-stubs-public.h"],
# Assume sys/uio.h is available on non-Windows.
# Set the version numbers.
cmd = ("""sed -e 's/$${HAVE_SYS_UIO_H_01}/!_WIN32/g' \
-e 's/$${PROJECT_VERSION_MAJOR}/%d/g' \
-e 's/$${PROJECT_VERSION_MINOR}/%d/g' \
-e 's/$${PROJECT_VERSION_PATCH}/%d/g' \
$< >$@""" % SNAPPY_VERSION),
out = "snappy-stubs-public.h",
substitutions = {
"${HAVE_SYS_UIO_H_01}": "!_WIN32",
"${PROJECT_VERSION_MAJOR}": str(SNAPPY_VERSION[0]),
"${PROJECT_VERSION_MINOR}": str(SNAPPY_VERSION[1]),
"${PROJECT_VERSION_PATCH}": str(SNAPPY_VERSION[2]),
},
template = "snappy-stubs-public.h.in",
)
9 changes: 6 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ module(
compatibility_level = 1,
)

bazel_dep(name = "rules_cc", version = "0.2.4")
bazel_dep(name = "bazel_skylib", version = "1.8.2")

bazel_dep(
name = "googletest",
version = "1.14.0.bcr.1",
version = "1.17.0.bcr.2",
dev_dependency = True,
repo_name = "com_google_googletest",
)
bazel_dep(
name = "google_benchmark",
version = "1.9.0",
version = "1.9.5",
dev_dependency = True,
repo_name = "com_google_benchmark",
)

bazel_dep(
name = "platforms",
version = "0.0.9",
version = "1.0.0",
)