From 0efaa9b310abafdbf08d58874f76ece8ae22665a Mon Sep 17 00:00:00 2001 From: mehrdadn Date: Fri, 28 Feb 2020 10:18:56 -0800 Subject: [PATCH] Use Redis for Windows (#7364) --- BUILD.bazel | 23 ++++++++++++-------- bazel/ray_deps_setup.bzl | 14 +++++++++++- src/ray/gcs/redis_module/ray_redis_module.cc | 5 ++++- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index d85a2d904..cc26c438d 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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) && diff --git a/bazel/ray_deps_setup.bzl b/bazel/ray_deps_setup.bzl index 7a9f7d199..e3941c154 100644 --- a/bazel/ray_deps_setup.bzl +++ b/bazel/ray_deps_setup.bzl @@ -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", diff --git a/src/ray/gcs/redis_module/ray_redis_module.cc b/src/ray/gcs/redis_module/ray_redis_module.cc index 4d92c3b6c..46b430ede 100644 --- a/src/ray/gcs/redis_module/ray_redis_module.cc +++ b/src/ray/gcs/redis_module/ray_redis_module.cc @@ -977,7 +977,10 @@ extern "C" { /// This function must be present on each Redis module. It is used in order to /// register the commands into the Redis server. -int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +#ifdef _WIN32 +__declspec(dllexport) +#endif + int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc);