Use Redis for Windows (#7364)

This commit is contained in:
mehrdadn 2020-02-28 10:18:56 -08:00 committed by GitHub
parent 3f8b1d2756
commit 0efaa9b310
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 11 deletions

View file

@ -1201,6 +1201,16 @@ filegroup(
genrule(
name = "redis",
srcs = [
] + select({
# Windows is not supported yet, so make stubs for it
"@bazel_tools//src/conditions:windows": [
"@win-redis-bin//file",
],
"//conditions:default": [
"@redis-src//file",
],
}),
outs = [
"redis-server",
"redis-cli",
@ -1208,18 +1218,13 @@ genrule(
cmd = select({
# Windows is not supported yet, so make stubs for it
"@bazel_tools//src/conditions:windows": """
set -eu
for f in $(OUTS); do
{
echo '#!/usr/bin/env bash'
echo 'echo "$${0##*/} is unsupported on this platform" 1>&2 && false'
} > "$$f"
chmod +x "$$f"
done
unzip -q -o -- $(location @win-redis-bin//file) redis-server.exe redis-cli.exe &&
mv -f -- redis-server.exe $(location redis-server) &&
mv -f -- redis-cli.exe $(location redis-cli)
""",
"//conditions:default": """
set -x &&
curl -sL \"https://github.com/antirez/redis/archive/5.0.3.tar.gz\" | tar -xzf - --strip-components=1 -C . &&
tar -xzf $(location @redis-src//file) --strip-components=1 -C . &&
make &&
mv ./src/redis-server $(location redis-server) &&
chmod +x $(location redis-server) &&

View file

@ -1,5 +1,5 @@
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
def github_repository(*, name=None, remote=None, commit=None, tag=None,
branch=None, build_file=None, build_file_content=None,
@ -87,6 +87,18 @@ def ray_deps_setup():
],
)
http_file(
name = "win-redis-bin",
sha256 = "6fac443543244c803311de5883b714a7ae3c4fa0594cad51d75b24c4ef45b353",
urls = ["https://github.com/tporadowski/redis/releases/download/v4.0.14.2/Redis-x64-4.0.14.2.zip"],
)
http_file(
name = "redis-src",
sha256 = "7084e8bd9e5dedf2dbb2a1e1d862d0c46e66cc0872654bdc677f4470d28d84c5",
urls = ["https://github.com/antirez/redis/archive/5.0.3.tar.gz"],
)
github_repository(
name = "rules_jvm_external",
tag = "2.10",

View file

@ -977,6 +977,9 @@ extern "C" {
/// This function must be present on each Redis module. It is used in order to
/// register the commands into the Redis server.
#ifdef _WIN32
__declspec(dllexport)
#endif
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);