rugged-redis 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/rugged/redis/extconf.rb +90 -0
- data/ext/rugged/redis/rugged_redis.c +16 -0
- data/ext/rugged/redis/rugged_redis.h +4 -0
- data/ext/rugged/redis/rugged_redis_backend.c +113 -0
- data/lib/rugged/redis/version.rb +5 -0
- data/lib/rugged/redis.rb +8 -0
- data/lib/rugged-redis.rb +1 -0
- data/vendor/hiredis/Makefile +217 -0
- data/vendor/hiredis/async.c +687 -0
- data/vendor/hiredis/async.h +129 -0
- data/vendor/hiredis/dict.c +338 -0
- data/vendor/hiredis/dict.h +126 -0
- data/vendor/hiredis/fmacros.h +25 -0
- data/vendor/hiredis/hiredis.c +1021 -0
- data/vendor/hiredis/hiredis.h +223 -0
- data/vendor/hiredis/net.c +477 -0
- data/vendor/hiredis/net.h +53 -0
- data/vendor/hiredis/read.c +525 -0
- data/vendor/hiredis/read.h +111 -0
- data/vendor/hiredis/sds.c +1272 -0
- data/vendor/hiredis/sds.h +273 -0
- data/vendor/hiredis/sdsalloc.h +42 -0
- data/vendor/hiredis/test.c +823 -0
- data/vendor/hiredis/win32.h +42 -0
- data/vendor/libgit2-backends/CMake/FindHiredis.cmake +32 -0
- data/vendor/libgit2-backends/CMake/FindLibgit2.cmake +33 -0
- data/vendor/libgit2-backends/CMake/FindLibmemcached.cmake +37 -0
- data/vendor/libgit2-backends/CMake/FindLibmysql.cmake +37 -0
- data/vendor/libgit2-backends/CMake/FindSQLite3.cmake +56 -0
- data/vendor/libgit2-backends/redis/CMakeLists.txt +25 -0
- data/vendor/libgit2-backends/redis/hiredis.c +598 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 995769de20494fbfcb572fb6803d78cfcb163353
|
4
|
+
data.tar.gz: 0d385978edb79cf73bedaf1b3ee4e222d152c489
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f59d84087f6267f07ea66f043bc6e3a1e0601954fe5231f147d507070f62291348033a37705071889557dda301a7eae4a479f3e3e8c0cbf84b7e92c3e0df3b95
|
7
|
+
data.tar.gz: b507b739747181e3a55d66963eca8fd3e1255d0a6c2ed270304490702e6b086348e254062575edbefccc18e5ac96860901de84435beb328bfe17e42a87f09049
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rugged'
|
4
|
+
|
5
|
+
$CFLAGS << " #{ENV["CFLAGS"]}"
|
6
|
+
$CFLAGS << " -g"
|
7
|
+
$CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
|
8
|
+
$CFLAGS << " -Wall -Wno-comment"
|
9
|
+
|
10
|
+
def sys(cmd)
|
11
|
+
puts " -- #{cmd}"
|
12
|
+
unless ret = xsystem(cmd)
|
13
|
+
raise "ERROR: '#{cmd}' failed"
|
14
|
+
end
|
15
|
+
ret
|
16
|
+
end
|
17
|
+
|
18
|
+
if !find_executable('cmake')
|
19
|
+
abort "ERROR: CMake is required to build Rugged."
|
20
|
+
end
|
21
|
+
|
22
|
+
if !(MAKE = find_executable('gmake') || find_executable('make'))
|
23
|
+
abort "ERROR: GNU make is required to build Rugged."
|
24
|
+
end
|
25
|
+
|
26
|
+
CWD = File.expand_path(File.dirname(__FILE__))
|
27
|
+
ROOT_DIR = File.expand_path(File.join(CWD, '..', '..', '..'))
|
28
|
+
|
29
|
+
REDIS_BACKEND_DIR = File.join(ROOT_DIR, 'vendor', 'libgit2-backends', 'redis')
|
30
|
+
|
31
|
+
rugged_spec = Gem::Specification.find {|s| s.name == 'rugged' }
|
32
|
+
rugged_root = rugged_spec.gem_dir
|
33
|
+
RUGGED_EXT_DIR = File.join(rugged_root, 'ext', 'rugged')
|
34
|
+
puts "Found rugged at #{RUGGED_EXT_DIR}"
|
35
|
+
LIBGIT2_DIR = File.join(rugged_root, 'vendor', 'libgit2')
|
36
|
+
|
37
|
+
# Build hiredis
|
38
|
+
HIREDIS_DIR = File.join(ROOT_DIR, 'vendor') # because hiredis headers are included as hiredis/hiredis.h
|
39
|
+
unless File.directory?(File.join(HIREDIS_DIR, 'hiredis'))
|
40
|
+
STDERR.puts "vendor/hiredis missing, please checkout its submodule..."
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
|
44
|
+
system("cd #{HIREDIS_DIR}/hiredis && make static")
|
45
|
+
|
46
|
+
puts("Using hiredis from #{HIREDIS_DIR}/hiredis\n")
|
47
|
+
dir_config('hiredis', HIREDIS_DIR, File.join(HIREDIS_DIR, "hiredis"))
|
48
|
+
unless have_library('hiredis', 'redisConnect')
|
49
|
+
abort "ERROR: Failed to build hiredis library"
|
50
|
+
end
|
51
|
+
|
52
|
+
# Build Redis backend
|
53
|
+
|
54
|
+
Dir.chdir(REDIS_BACKEND_DIR) do
|
55
|
+
Dir.mkdir("build") if !Dir.exists?("build")
|
56
|
+
|
57
|
+
Dir.chdir("build") do
|
58
|
+
flags = [
|
59
|
+
"-DBUILD_SHARED_LIBS=OFF",
|
60
|
+
"-DBUILD_TESTS=OFF",
|
61
|
+
"-DCMAKE_C_FLAGS=-fPIC",
|
62
|
+
"-DPC_LIBGIT2_LIBRARY_DIRS=#{LIBGIT2_DIR}/build",
|
63
|
+
"-DPC_LIBGIT2_INCLUDE_DIRS=#{LIBGIT2_DIR}/include",
|
64
|
+
"-DPC_LIBHIREDIS_LIBRARY_DIRS=#{HIREDIS_DIR}/hiredis",
|
65
|
+
"-DPC_LIBHIREDIS_INCLUDE_DIRS=#{HIREDIS_DIR}"
|
66
|
+
]
|
67
|
+
sys("cmake .. #{flags.join(" ")}")
|
68
|
+
sys(MAKE)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
puts "Using libgit2-redis from #{REDIS_BACKEND_DIR}/build\n"
|
73
|
+
$LIBPATH.unshift "#{REDIS_BACKEND_DIR}/build"
|
74
|
+
|
75
|
+
# Include rugged's header for the backend interface definition
|
76
|
+
|
77
|
+
puts "Using rugged headers from #{RUGGED_EXT_DIR}\n"
|
78
|
+
$CFLAGS << " -I#{RUGGED_EXT_DIR}"
|
79
|
+
|
80
|
+
# Link against rugged's libgit2
|
81
|
+
|
82
|
+
puts "Using libgit2 from #{LIBGIT2_DIR}/include and #{LIBGIT2_DIR}/build (rugged bundled)\n"
|
83
|
+
$CFLAGS << " -I#{LIBGIT2_DIR}/include"
|
84
|
+
$LIBPATH.unshift "#{LIBGIT2_DIR}/build"
|
85
|
+
|
86
|
+
unless have_library 'git2-redis'
|
87
|
+
abort "ERROR: Failed to build libgit2 redis backend"
|
88
|
+
end
|
89
|
+
|
90
|
+
create_makefile("rugged/redis/rugged_redis")
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#include "rugged_redis.h"
|
2
|
+
|
3
|
+
VALUE rb_mRugged;
|
4
|
+
VALUE rb_cRuggedBackend;
|
5
|
+
|
6
|
+
VALUE rb_mRuggedRedis;
|
7
|
+
|
8
|
+
void Init_rugged_redis(void)
|
9
|
+
{
|
10
|
+
rb_mRugged = rb_const_get(rb_cObject, rb_intern("Rugged"));
|
11
|
+
rb_cRuggedBackend = rb_const_get(rb_mRugged, rb_intern("Backend"));
|
12
|
+
|
13
|
+
rb_mRuggedRedis = rb_const_get(rb_mRugged, rb_intern("Redis"));
|
14
|
+
|
15
|
+
Init_rugged_redis_backend();
|
16
|
+
}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
#include <git2/sys/odb_backend.h>
|
2
|
+
#include <git2/sys/refdb_backend.h>
|
3
|
+
#include <rugged.h>
|
4
|
+
|
5
|
+
#include "rugged_redis.h"
|
6
|
+
|
7
|
+
extern VALUE rb_mRuggedRedis;
|
8
|
+
extern VALUE rb_cRuggedBackend;
|
9
|
+
|
10
|
+
VALUE rb_cRuggedRedisBackend;
|
11
|
+
|
12
|
+
typedef struct {
|
13
|
+
rugged_backend backend;
|
14
|
+
|
15
|
+
char *host;
|
16
|
+
int port;
|
17
|
+
char *password;
|
18
|
+
} rugged_redis_backend;
|
19
|
+
|
20
|
+
// libgit2-redis interface
|
21
|
+
|
22
|
+
int git_refdb_backend_hiredis(git_refdb_backend **backend_out, const char* prefix, const char* path, const char *host, int port, char* password);
|
23
|
+
int git_odb_backend_hiredis(git_odb_backend **backend_out, const char* prefix, const char* path, const char *host, int port, char* password);
|
24
|
+
|
25
|
+
static void rb_rugged_redis_backend__free(rugged_redis_backend *backend)
|
26
|
+
{
|
27
|
+
free(backend->host);
|
28
|
+
if (backend->password != NULL)
|
29
|
+
free(backend->password);
|
30
|
+
|
31
|
+
// libgit will free the backends eventually
|
32
|
+
|
33
|
+
free(backend);
|
34
|
+
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Redis backend factory functions
|
39
|
+
|
40
|
+
static int rugged_redis_odb_backend(git_odb_backend **backend_out, rugged_backend *backend, const char* path)
|
41
|
+
{
|
42
|
+
rugged_redis_backend *rugged_backend = (rugged_redis_backend *) backend;
|
43
|
+
return git_odb_backend_hiredis(backend_out, "rugged", path, rugged_backend->host, rugged_backend->port, rugged_backend->password);
|
44
|
+
}
|
45
|
+
|
46
|
+
static int rugged_redis_refdb_backend(git_refdb_backend **backend_out, rugged_backend *backend, const char* path)
|
47
|
+
{
|
48
|
+
rugged_redis_backend *rugged_backend = (rugged_redis_backend *) backend;
|
49
|
+
return git_refdb_backend_hiredis(backend_out, "rugged", path, rugged_backend->host, rugged_backend->port, rugged_backend->password);
|
50
|
+
}
|
51
|
+
|
52
|
+
// Redis backend initializer
|
53
|
+
|
54
|
+
static rugged_redis_backend *rugged_redis_backend_new(char* host, int port, char* password)
|
55
|
+
{
|
56
|
+
rugged_redis_backend *redis_backend = malloc(sizeof(rugged_redis_backend));
|
57
|
+
|
58
|
+
redis_backend->backend.odb_backend = rugged_redis_odb_backend;
|
59
|
+
redis_backend->backend.refdb_backend = rugged_redis_refdb_backend;
|
60
|
+
|
61
|
+
redis_backend->host = strdup(host);
|
62
|
+
redis_backend->port = port;
|
63
|
+
|
64
|
+
if (password != NULL)
|
65
|
+
redis_backend->password = strdup(password);
|
66
|
+
else
|
67
|
+
redis_backend->password = NULL;
|
68
|
+
|
69
|
+
return redis_backend;
|
70
|
+
}
|
71
|
+
|
72
|
+
/*
|
73
|
+
Public: Initialize a redis backend.
|
74
|
+
|
75
|
+
opts - hash containing the connection options.
|
76
|
+
:host - string, host to connect to
|
77
|
+
:port - integer, port number
|
78
|
+
:password - (optional) string, redis server password
|
79
|
+
|
80
|
+
*/
|
81
|
+
static VALUE rb_rugged_redis_backend_new(VALUE klass, VALUE rb_opts)
|
82
|
+
{
|
83
|
+
VALUE val;
|
84
|
+
|
85
|
+
char *host;
|
86
|
+
char *password = NULL;
|
87
|
+
int port;
|
88
|
+
|
89
|
+
Check_Type(rb_opts, T_HASH);
|
90
|
+
|
91
|
+
val = rb_hash_aref(rb_opts, ID2SYM(rb_intern("host")));
|
92
|
+
Check_Type(val, T_STRING);
|
93
|
+
host = StringValueCStr(val);
|
94
|
+
|
95
|
+
val = rb_hash_aref(rb_opts, ID2SYM(rb_intern("port")));
|
96
|
+
Check_Type(val, T_FIXNUM);
|
97
|
+
port = NUM2INT(val);
|
98
|
+
|
99
|
+
if ((val = rb_hash_aref(rb_opts, ID2SYM(rb_intern("password")))) != Qnil) {
|
100
|
+
Check_Type(val, T_STRING);
|
101
|
+
password = StringValueCStr(val);
|
102
|
+
}
|
103
|
+
|
104
|
+
return Data_Wrap_Struct(klass, NULL, rb_rugged_redis_backend__free, rugged_redis_backend_new(host, port, password));
|
105
|
+
}
|
106
|
+
|
107
|
+
void Init_rugged_redis_backend(void)
|
108
|
+
{
|
109
|
+
rb_cRuggedRedisBackend = rb_define_class_under(rb_mRuggedRedis, "Backend", rb_cRuggedBackend);
|
110
|
+
|
111
|
+
rb_define_singleton_method(rb_cRuggedRedisBackend, "new", rb_rugged_redis_backend_new, 1);
|
112
|
+
}
|
113
|
+
|
data/lib/rugged/redis.rb
ADDED
data/lib/rugged-redis.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rugged/redis'
|
@@ -0,0 +1,217 @@
|
|
1
|
+
# Hiredis Makefile
|
2
|
+
# Copyright (C) 2010-2011 Salvatore Sanfilippo <antirez at gmail dot com>
|
3
|
+
# Copyright (C) 2010-2011 Pieter Noordhuis <pcnoordhuis at gmail dot com>
|
4
|
+
# This file is released under the BSD license, see the COPYING file
|
5
|
+
|
6
|
+
OBJ=net.o hiredis.o sds.o async.o read.o
|
7
|
+
EXAMPLES=hiredis-example hiredis-example-libevent hiredis-example-libev hiredis-example-glib
|
8
|
+
TESTS=hiredis-test
|
9
|
+
LIBNAME=libhiredis
|
10
|
+
PKGCONFNAME=hiredis.pc
|
11
|
+
|
12
|
+
HIREDIS_MAJOR=$(shell grep HIREDIS_MAJOR hiredis.h | awk '{print $$3}')
|
13
|
+
HIREDIS_MINOR=$(shell grep HIREDIS_MINOR hiredis.h | awk '{print $$3}')
|
14
|
+
HIREDIS_PATCH=$(shell grep HIREDIS_PATCH hiredis.h | awk '{print $$3}')
|
15
|
+
HIREDIS_SONAME=$(shell grep HIREDIS_SONAME hiredis.h | awk '{print $$3}')
|
16
|
+
|
17
|
+
# Installation related variables and target
|
18
|
+
PREFIX?=/usr/local
|
19
|
+
INCLUDE_PATH?=include/hiredis
|
20
|
+
LIBRARY_PATH?=lib
|
21
|
+
PKGCONF_PATH?=pkgconfig
|
22
|
+
INSTALL_INCLUDE_PATH= $(DESTDIR)$(PREFIX)/$(INCLUDE_PATH)
|
23
|
+
INSTALL_LIBRARY_PATH= $(DESTDIR)$(PREFIX)/$(LIBRARY_PATH)
|
24
|
+
INSTALL_PKGCONF_PATH= $(INSTALL_LIBRARY_PATH)/$(PKGCONF_PATH)
|
25
|
+
|
26
|
+
# redis-server configuration used for testing
|
27
|
+
REDIS_PORT=56379
|
28
|
+
REDIS_SERVER=redis-server
|
29
|
+
define REDIS_TEST_CONFIG
|
30
|
+
daemonize yes
|
31
|
+
pidfile /tmp/hiredis-test-redis.pid
|
32
|
+
port $(REDIS_PORT)
|
33
|
+
bind 127.0.0.1
|
34
|
+
unixsocket /tmp/hiredis-test-redis.sock
|
35
|
+
endef
|
36
|
+
export REDIS_TEST_CONFIG
|
37
|
+
|
38
|
+
# Fallback to gcc when $CC is not in $PATH.
|
39
|
+
CC:=$(shell sh -c 'type $(CC) >/dev/null 2>/dev/null && echo $(CC) || echo gcc')
|
40
|
+
CXX:=$(shell sh -c 'type $(CXX) >/dev/null 2>/dev/null && echo $(CXX) || echo g++')
|
41
|
+
OPTIMIZATION?=-O3
|
42
|
+
WARNINGS=-Wall -W -Wstrict-prototypes -Wwrite-strings
|
43
|
+
DEBUG_FLAGS?= -g -ggdb
|
44
|
+
REAL_CFLAGS=$(OPTIMIZATION) -fPIC $(CFLAGS) $(WARNINGS) $(DEBUG_FLAGS) $(ARCH)
|
45
|
+
REAL_LDFLAGS=$(LDFLAGS) $(ARCH)
|
46
|
+
|
47
|
+
DYLIBSUFFIX=so
|
48
|
+
STLIBSUFFIX=a
|
49
|
+
DYLIB_MINOR_NAME=$(LIBNAME).$(DYLIBSUFFIX).$(HIREDIS_SONAME)
|
50
|
+
DYLIB_MAJOR_NAME=$(LIBNAME).$(DYLIBSUFFIX).$(HIREDIS_MAJOR)
|
51
|
+
DYLIBNAME=$(LIBNAME).$(DYLIBSUFFIX)
|
52
|
+
DYLIB_MAKE_CMD=$(CC) -shared -Wl,-soname,$(DYLIB_MINOR_NAME) -o $(DYLIBNAME) $(LDFLAGS)
|
53
|
+
STLIBNAME=$(LIBNAME).$(STLIBSUFFIX)
|
54
|
+
STLIB_MAKE_CMD=ar rcs $(STLIBNAME)
|
55
|
+
|
56
|
+
# Platform-specific overrides
|
57
|
+
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
|
58
|
+
ifeq ($(uname_S),SunOS)
|
59
|
+
REAL_LDFLAGS+= -ldl -lnsl -lsocket
|
60
|
+
DYLIB_MAKE_CMD=$(CC) -G -o $(DYLIBNAME) -h $(DYLIB_MINOR_NAME) $(LDFLAGS)
|
61
|
+
INSTALL= cp -r
|
62
|
+
endif
|
63
|
+
ifeq ($(uname_S),Darwin)
|
64
|
+
DYLIBSUFFIX=dylib
|
65
|
+
DYLIB_MINOR_NAME=$(LIBNAME).$(HIREDIS_SONAME).$(DYLIBSUFFIX)
|
66
|
+
DYLIB_MAKE_CMD=$(CC) -shared -Wl,-install_name,$(DYLIB_MINOR_NAME) -o $(DYLIBNAME) $(LDFLAGS)
|
67
|
+
endif
|
68
|
+
|
69
|
+
all: $(DYLIBNAME) $(STLIBNAME) hiredis-test $(PKGCONFNAME)
|
70
|
+
|
71
|
+
# Deps (use make dep to generate this)
|
72
|
+
async.o: async.c fmacros.h async.h hiredis.h read.h sds.h net.h dict.c dict.h
|
73
|
+
dict.o: dict.c fmacros.h dict.h
|
74
|
+
hiredis.o: hiredis.c fmacros.h hiredis.h read.h sds.h net.h
|
75
|
+
net.o: net.c fmacros.h net.h hiredis.h read.h sds.h
|
76
|
+
read.o: read.c fmacros.h read.h sds.h
|
77
|
+
sds.o: sds.c sds.h
|
78
|
+
test.o: test.c fmacros.h hiredis.h read.h sds.h
|
79
|
+
|
80
|
+
$(DYLIBNAME): $(OBJ)
|
81
|
+
$(DYLIB_MAKE_CMD) $(OBJ)
|
82
|
+
|
83
|
+
$(STLIBNAME): $(OBJ)
|
84
|
+
$(STLIB_MAKE_CMD) $(OBJ)
|
85
|
+
|
86
|
+
dynamic: $(DYLIBNAME)
|
87
|
+
static: $(STLIBNAME)
|
88
|
+
|
89
|
+
# Binaries:
|
90
|
+
hiredis-example-libevent: examples/example-libevent.c adapters/libevent.h $(STLIBNAME)
|
91
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I. $< -levent $(STLIBNAME)
|
92
|
+
|
93
|
+
hiredis-example-libev: examples/example-libev.c adapters/libev.h $(STLIBNAME)
|
94
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I. $< -lev $(STLIBNAME)
|
95
|
+
|
96
|
+
hiredis-example-glib: examples/example-glib.c adapters/glib.h $(STLIBNAME)
|
97
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I. $< $(shell pkg-config --cflags --libs glib-2.0) $(STLIBNAME)
|
98
|
+
|
99
|
+
hiredis-example-ivykis: examples/example-ivykis.c adapters/ivykis.h $(STLIBNAME)
|
100
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I. $< -livykis $(STLIBNAME)
|
101
|
+
|
102
|
+
hiredis-example-macosx: examples/example-macosx.c adapters/macosx.h $(STLIBNAME)
|
103
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I. $< -framework CoreFoundation $(STLIBNAME)
|
104
|
+
|
105
|
+
ifndef AE_DIR
|
106
|
+
hiredis-example-ae:
|
107
|
+
@echo "Please specify AE_DIR (e.g. <redis repository>/src)"
|
108
|
+
@false
|
109
|
+
else
|
110
|
+
hiredis-example-ae: examples/example-ae.c adapters/ae.h $(STLIBNAME)
|
111
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I. -I$(AE_DIR) $< $(AE_DIR)/ae.o $(AE_DIR)/zmalloc.o $(AE_DIR)/../deps/jemalloc/lib/libjemalloc.a -pthread $(STLIBNAME)
|
112
|
+
endif
|
113
|
+
|
114
|
+
ifndef LIBUV_DIR
|
115
|
+
hiredis-example-libuv:
|
116
|
+
@echo "Please specify LIBUV_DIR (e.g. ../libuv/)"
|
117
|
+
@false
|
118
|
+
else
|
119
|
+
hiredis-example-libuv: examples/example-libuv.c adapters/libuv.h $(STLIBNAME)
|
120
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I. -I$(LIBUV_DIR)/include $< $(LIBUV_DIR)/.libs/libuv.a -lpthread -lrt $(STLIBNAME)
|
121
|
+
endif
|
122
|
+
|
123
|
+
ifeq ($(and $(QT_MOC),$(QT_INCLUDE_DIR),$(QT_LIBRARY_DIR)),)
|
124
|
+
hiredis-example-qt:
|
125
|
+
@echo "Please specify QT_MOC, QT_INCLUDE_DIR AND QT_LIBRARY_DIR"
|
126
|
+
@false
|
127
|
+
else
|
128
|
+
hiredis-example-qt: examples/example-qt.cpp adapters/qt.h $(STLIBNAME)
|
129
|
+
$(QT_MOC) adapters/qt.h -I. -I$(QT_INCLUDE_DIR) -I$(QT_INCLUDE_DIR)/QtCore | \
|
130
|
+
$(CXX) -x c++ -o qt-adapter-moc.o -c - $(REAL_CFLAGS) -I. -I$(QT_INCLUDE_DIR) -I$(QT_INCLUDE_DIR)/QtCore
|
131
|
+
$(QT_MOC) examples/example-qt.h -I. -I$(QT_INCLUDE_DIR) -I$(QT_INCLUDE_DIR)/QtCore | \
|
132
|
+
$(CXX) -x c++ -o qt-example-moc.o -c - $(REAL_CFLAGS) -I. -I$(QT_INCLUDE_DIR) -I$(QT_INCLUDE_DIR)/QtCore
|
133
|
+
$(CXX) -o examples/$@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I. -I$(QT_INCLUDE_DIR) -I$(QT_INCLUDE_DIR)/QtCore -L$(QT_LIBRARY_DIR) qt-adapter-moc.o qt-example-moc.o $< -pthread $(STLIBNAME) -lQtCore
|
134
|
+
endif
|
135
|
+
|
136
|
+
hiredis-example: examples/example.c $(STLIBNAME)
|
137
|
+
$(CC) -o examples/$@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I. $< $(STLIBNAME)
|
138
|
+
|
139
|
+
examples: $(EXAMPLES)
|
140
|
+
|
141
|
+
hiredis-test: test.o $(STLIBNAME)
|
142
|
+
|
143
|
+
hiredis-%: %.o $(STLIBNAME)
|
144
|
+
$(CC) $(REAL_CFLAGS) -o $@ $(REAL_LDFLAGS) $< $(STLIBNAME)
|
145
|
+
|
146
|
+
test: hiredis-test
|
147
|
+
./hiredis-test
|
148
|
+
|
149
|
+
check: hiredis-test
|
150
|
+
@echo "$$REDIS_TEST_CONFIG" | $(REDIS_SERVER) -
|
151
|
+
$(PRE) ./hiredis-test -h 127.0.0.1 -p $(REDIS_PORT) -s /tmp/hiredis-test-redis.sock || \
|
152
|
+
( kill `cat /tmp/hiredis-test-redis.pid` && false )
|
153
|
+
kill `cat /tmp/hiredis-test-redis.pid`
|
154
|
+
|
155
|
+
.c.o:
|
156
|
+
$(CC) -std=c99 -pedantic -c $(REAL_CFLAGS) $<
|
157
|
+
|
158
|
+
clean:
|
159
|
+
rm -rf $(DYLIBNAME) $(STLIBNAME) $(TESTS) $(PKGCONFNAME) examples/hiredis-example* *.o *.gcda *.gcno *.gcov
|
160
|
+
|
161
|
+
dep:
|
162
|
+
$(CC) -MM *.c
|
163
|
+
|
164
|
+
ifeq ($(uname_S),SunOS)
|
165
|
+
INSTALL?= cp -r
|
166
|
+
endif
|
167
|
+
|
168
|
+
INSTALL?= cp -a
|
169
|
+
|
170
|
+
$(PKGCONFNAME): hiredis.h
|
171
|
+
@echo "Generating $@ for pkgconfig..."
|
172
|
+
@echo prefix=$(PREFIX) > $@
|
173
|
+
@echo exec_prefix=\$${prefix} >> $@
|
174
|
+
@echo libdir=$(PREFIX)/$(LIBRARY_PATH) >> $@
|
175
|
+
@echo includedir=$(PREFIX)/$(INCLUDE_PATH) >> $@
|
176
|
+
@echo >> $@
|
177
|
+
@echo Name: hiredis >> $@
|
178
|
+
@echo Description: Minimalistic C client library for Redis. >> $@
|
179
|
+
@echo Version: $(HIREDIS_MAJOR).$(HIREDIS_MINOR).$(HIREDIS_PATCH) >> $@
|
180
|
+
@echo Libs: -L\$${libdir} -lhiredis >> $@
|
181
|
+
@echo Cflags: -I\$${includedir} -D_FILE_OFFSET_BITS=64 >> $@
|
182
|
+
|
183
|
+
install: $(DYLIBNAME) $(STLIBNAME) $(PKGCONFNAME)
|
184
|
+
mkdir -p $(INSTALL_INCLUDE_PATH) $(INSTALL_LIBRARY_PATH)
|
185
|
+
$(INSTALL) hiredis.h async.h read.h sds.h adapters $(INSTALL_INCLUDE_PATH)
|
186
|
+
$(INSTALL) $(DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(DYLIB_MINOR_NAME)
|
187
|
+
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(DYLIB_MINOR_NAME) $(DYLIBNAME)
|
188
|
+
$(INSTALL) $(STLIBNAME) $(INSTALL_LIBRARY_PATH)
|
189
|
+
mkdir -p $(INSTALL_PKGCONF_PATH)
|
190
|
+
$(INSTALL) $(PKGCONFNAME) $(INSTALL_PKGCONF_PATH)
|
191
|
+
|
192
|
+
32bit:
|
193
|
+
@echo ""
|
194
|
+
@echo "WARNING: if this fails under Linux you probably need to install libc6-dev-i386"
|
195
|
+
@echo ""
|
196
|
+
$(MAKE) CFLAGS="-m32" LDFLAGS="-m32"
|
197
|
+
|
198
|
+
32bit-vars:
|
199
|
+
$(eval CFLAGS=-m32)
|
200
|
+
$(eval LDFLAGS=-m32)
|
201
|
+
|
202
|
+
gprof:
|
203
|
+
$(MAKE) CFLAGS="-pg" LDFLAGS="-pg"
|
204
|
+
|
205
|
+
gcov:
|
206
|
+
$(MAKE) CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS="-fprofile-arcs"
|
207
|
+
|
208
|
+
coverage: gcov
|
209
|
+
make check
|
210
|
+
mkdir -p tmp/lcov
|
211
|
+
lcov -d . -c -o tmp/lcov/hiredis.info
|
212
|
+
genhtml --legend -o tmp/lcov/report tmp/lcov/hiredis.info
|
213
|
+
|
214
|
+
noopt:
|
215
|
+
$(MAKE) OPTIMIZATION=""
|
216
|
+
|
217
|
+
.PHONY: all test check clean dep install 32bit 32bit-vars gprof gcov noopt
|