Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
moved from cmake to makefile (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
swilly22 committed Oct 8, 2017
1 parent 44d55a0 commit bbda85f
Show file tree
Hide file tree
Showing 19 changed files with 141 additions and 5,669 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -32,7 +32,6 @@
CMakeFiles/

# Files
Makefile
CMakeCache.txt
DartConfiguration.tcl

Expand All @@ -46,3 +45,4 @@ DartConfiguration.tcl
*.make
*.xml
*.iml
*.d
16 changes: 3 additions & 13 deletions .travis.yml
Expand Up @@ -2,17 +2,9 @@ language: c
compiler: gcc
dist: xenial

addons:
apt:
sources:
- george-edison55-precise-backports # cmake 3.2.3 / doxygen 1.8.3
packages:
- cmake
- cmake-data

env:
- MODULE_NAME=redisgraph
- REDIS_MODULE_PATH=$TRAVIS_BUILD_DIR/src/libmodule.so
- REDIS_MODULE_PATH=$TRAVIS_BUILD_DIR/src/redisgraph.so
- REDIS_PATH=$TRAVIS_BUILD_DIR/redis/src/redis-server

before_script:
Expand All @@ -23,13 +15,11 @@ before_script:
- cd ..

script:
- cmake --version
- cmake .
- make clean
- make module
- make
- cd src
- mkdir -p ../build
- module_packer -v -o "../build/redisgraph.{os}-{architecture}.latest.zip" "`pwd`/libmodule.so"
- module_packer -v -o "../build/redisgraph.{os}-{architecture}.latest.zip" "`pwd`/redisgraph.so"
- cd ..
# - make test

Expand Down
14 changes: 0 additions & 14 deletions CMakeLists.txt

This file was deleted.

6 changes: 3 additions & 3 deletions Dockerfile
@@ -1,15 +1,15 @@
FROM ubuntu

RUN apt-get -y update && apt-get install -y build-essential
RUN apt-get install -y wget cmake
RUN apt-get install -y wget
RUN cd /tmp
RUN wget https://github.com/antirez/redis/archive/4.0-rc2.tar.gz
RUN tar xvzf 4.0-rc2.tar.gz
RUN cd redis-4.0-rc2 && make
RUN cd redis-4.0-rc2 && make install
COPY . /redis-graph
RUN cd /redis-graph && cmake . && make module
RUN cd /redis-graph && make

EXPOSE 6379

CMD ["/usr/local/bin/redis-server", "--bind", "0.0.0.0", "--loadmodule", "/redis-graph/src/libmodule.so"]
CMD ["/usr/local/bin/redis-server", "--bind", "0.0.0.0", "--loadmodule", "/redis-graph/src/redisgraph.so"]
24 changes: 24 additions & 0 deletions Makefile
@@ -0,0 +1,24 @@
all:
$(MAKE) -C ./src all

clean:
$(MAKE) -C ./src $@

package: all
$(MAKE) -C ./src package
.PHONY: package

docker:
docker build . -t redislabs/redisgraph

docker_push: docker
docker push redislabs/redisgraph:latest

builddocs:
mkdocs build

localdocs: builddocs
mkdocs serve

deploydocs: builddocs
mkdocs gh-deploy
2 changes: 1 addition & 1 deletion demo/README.md
Expand Up @@ -2,7 +2,7 @@

1. Set the following environment variables:

- REDIS_MODULE_PATH - Relative path to compiled libmodule.so
- REDIS_MODULE_PATH - Relative path to compiled redisgraph.so

```sh
export REDIS_MODULE_PATH=<ABSOLUTE_PATH_TO_MODULE.SO>
Expand Down
2 changes: 1 addition & 1 deletion demo/utils.py
Expand Up @@ -23,7 +23,7 @@ def _redis():

if module_path is None:
print("Undeclared environment variable {}".format(REDIS_MODULE_PATH_ENVVAR))
print("run: export {}=../../src/libmodule.so".format(REDIS_MODULE_PATH_ENVVAR))
print("run: export {}=../../src/redisgraph.so".format(REDIS_MODULE_PATH_ENVVAR))
return None

if redis_path is None:
Expand Down
18 changes: 7 additions & 11 deletions docs/index.md
Expand Up @@ -26,15 +26,11 @@ To see Redis Graph in action see [Demos](https://github.com/RedisLabsModules/red
Requirements:

* The Redis Graph repository: `git clone https://github.com/RedisLabsModules/redis-module-graph.git`
* The build-essential and cmake packages: `apt-get install build-essential cmake`
* The build-essential package: `apt-get install build-essential`

To build the module, run the following in the project's directory:
To build the module, run `make` in the project's directory:

```sh
cmake . && make module
```

Congratulations! You can find the compiled module library at `src/libmodule.so`.
Congratulations! You can find the compiled module library at `src/redisgraph.so`.

## Loading the module to Redis

Expand All @@ -45,13 +41,13 @@ Requirements:
We recommend you have Redis load the module during startup by adding the following to your redis.conf file:

```
loadmodule /path/to/module/libmodule.so
loadmodule /path/to/module/redisgraph.so
```

In the line above replace `/path/to/module/libmodule.so` with the actual path to the module's library. Alternatively, you can have Redis load the module using the following command line argument syntax:
In the line above replace `/path/to/module/redisgraph.so` with the actual path to the module's library. Alternatively, you can have Redis load the module using the following command line argument syntax:

```sh
~/$ redis-server --loadmodule /path/to/module/libmodule.so
~/$ redis-server --loadmodule /path/to/module/redisgraph.so
```

Lastly, you can also use the [`MODULE LOAD`](http://redis.io/commands/module-load) command. Note, however, that `MODULE LOAD` is a dangerous command and may be blocked/deprecated in the future due to security considerations.
Expand All @@ -60,7 +56,7 @@ Once the module has been loaded successfully, the Redis log should have lines si

```
...
30707:M 20 Jun 02:08:12.314 * Module 'graph' loaded from <redacted>/src/libmodule.so
30707:M 20 Jun 02:08:12.314 * Module 'graph' loaded from <redacted>/src/redisgraph.so
...
```

Expand Down
94 changes: 0 additions & 94 deletions src/CMakeLists.txt

This file was deleted.

92 changes: 92 additions & 0 deletions src/Makefile
@@ -0,0 +1,92 @@
# find the OS
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')

CC=gcc
export CC

# if DEBUG env var is set, we compile with "debug" cflags
DEBUGFLAGS = -g -ggdb -O3
ifeq ($(DEBUG), 1)
DEBUGFLAGS = -g -ggdb -O0
endif

# Default CFLAGS
CFLAGS = -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-result -fPIC \
-D_GNU_SOURCE -std=gnu99 -I"$(shell pwd)" -DREDIS_MODULE_TARGET \
-DREDISMODULE_EXPERIMENTAL_API
CFLAGS += $(DEBUGFLAGS)

# Compile flags for linux / osx
ifeq ($(uname_S),Linux)
SHOBJ_LDFLAGS ?= -shared -Bsymbolic -Bsymbolic-functions -ldl -lpthread
else
CFLAGS += -mmacosx-version-min=10.6
SHOBJ_LDFLAGS ?= -macosx_version_min 10.6 -exported_symbol _RedisModule_OnLoad -bundle -undefined dynamic_lookup -ldl -lpthread
endif
export CFLAGS

# Sources
SOURCEDIR=$(shell pwd -P)
CC_SOURCES = $(wildcard $(SOURCEDIR)/*.c)
CC_SOURCES += $(wildcard $(SOURCEDIR)/aggregate/*.c)
CC_SOURCES += $(wildcard $(SOURCEDIR)/execution_plan/*.c)
CC_SOURCES += $(wildcard $(SOURCEDIR)/execution_plan/ops/*.c)
CC_SOURCES += $(wildcard $(SOURCEDIR)/filter_tree/*.c)
CC_SOURCES += $(wildcard $(SOURCEDIR)/graph/*.c)
CC_SOURCES += $(wildcard $(SOURCEDIR)/grouping/*.c)
CC_SOURCES += $(wildcard $(SOURCEDIR)/hexastore/*.c)
CC_SOURCES += $(SOURCEDIR)/parser/ast.c
CC_SOURCES += $(SOURCEDIR)/parser/lex.yy.c
CC_SOURCES += $(SOURCEDIR)/parser/grammar.c
CC_SOURCES += $(wildcard $(SOURCEDIR)/resultset/*.c)
CC_SOURCES += $(wildcard $(SOURCEDIR)/stores/*.c)
CC_SOURCES += $(wildcard $(SOURCEDIR)/util/*.c)

# Convert all sources to .o files
CC_OBJECTS = $(patsubst %.c, %.o, $(CC_SOURCES) )

# .d files for each c file. These make sure that changing a header file
# will also change the dependent .c files of it
CC_DEPS = $(patsubst %.c, %.d, $(CC_SOURCES) )

# Library dependencies
LIBRMUTIL=rmutil/librmutil.a
LIBTRIEMAP=util/triemap/libtriemap.a

# Compilation deps for the module
LIBS=$(LIBTRIEMAP) $(LIBRMUTIL)
MODULE=$(CC_OBJECTS) $(LIBS)

%.c: %.y

# Compile C file while generating a .d file for it
%.o: %.c
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@ -MMD -MF $(@:.o=.d)

all: redisgraph.so

# Include all dependency files for C files
-include $(CC_DEPS)

# Library compile rules
$(LIBRMUTIL):
$(MAKE) -C rmutil
.PHONY: $(LIBRMUTIL)

$(LIBTRIEMAP):
$(MAKE) -C util/triemap
.PHONY: $(LIBTRIEMAP)

# Compile query parse.
# This is not included in the usual make target!
parser:
$(MAKE) -C $@
.PHONY: parser

# Build the module...
redisgraph.so: $(MODULE)
$(LD) -o $@ $(MODULE) $(SHOBJ_LDFLAGS) -lc -lm

clean:
find . -name '*.[oad]' -type f -delete
1 change: 1 addition & 0 deletions src/graph/graph_entity.c
@@ -1,4 +1,5 @@
#include "graph.h"
#include "graph_entity.h"

SIValue *PROPERTY_NOTFOUND = NULL;

Expand Down
2 changes: 0 additions & 2 deletions src/graph/node.c
Expand Up @@ -5,8 +5,6 @@
#include "assert.h"
#include "graph_entity.h"

// SIValue* NODE_PROPERTY_NOTFOUND = &SI_StringValC("NOT FOUND");

Node* NewNode(long int id, const char *label) {
Node* node = (Node*)calloc(1, sizeof(Node));

Expand Down
1 change: 0 additions & 1 deletion src/module.c
Expand Up @@ -14,7 +14,6 @@

#include "util/prng.h"
#include "util/snowflake.h"
#include "util/triemap/triemap_type.h"

#include "rmutil/util.h"
#include "rmutil/vector.h"
Expand Down
8 changes: 6 additions & 2 deletions src/parser/Makefile
@@ -1,3 +1,7 @@
g++ -o grammar grammar.c AST_Node.c
%.c: %.y
parser:
lex -i lexer.l;\
./lemon -s grammar.y

cc -o grammar lex.yy.c grammar.c ast.c ../value.c ../rmutil/vector.c
.PHONY: parser
all: parser

0 comments on commit bbda85f

Please sign in to comment.