Skip to content

Commit

Permalink
proper packaging and version 0.99
Browse files Browse the repository at this point in the history
  • Loading branch information
dvirsky committed Nov 14, 2017
1 parent 60de11f commit 7cf035d
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
*.rdb
*.d
# Object files
*.o
*.ko
Expand Down
28 changes: 21 additions & 7 deletions src/Makefile
Expand Up @@ -36,8 +36,9 @@ SOURCEDIR=$(shell pwd -P)
CC_SOURCES = $(wildcard $(SOURCEDIR)/*.c) $(wildcard $(SOURCEDIR)/dep/*.c)
CC_OBJECTS = $(patsubst $(SOURCEDIR)/%.c, $(SOURCEDIR)/%.o, $(CC_SOURCES))
LIBS = $(DEPS_DIR)/jsonsl/jsonsl.o $(DEPS_DIR)/RedisModuleSDK/rmutil/librmutil.a
MODULE=rejson.so

all: rejson.so librejson.a
all: $(MODULE) librejson.a

jsonsl:
$(MAKE) -C $(DEPS_DIR)/jsonsl static
Expand All @@ -48,7 +49,7 @@ rmutil:

.PHONY: rmutil

rejson.so: jsonsl rmutil $(CC_OBJECTS)
$(MODULE): jsonsl rmutil $(CC_OBJECTS)
$(LD) -o $@ $(CC_OBJECTS) $(LIBS) $(SHOBJ_LDFLAGS) -lc -lm

librejson.a: jsonsl rmutil $(CC_OBJECTS)
Expand All @@ -61,8 +62,21 @@ deepclean:
find ./ -name "*.[oa]" -exec rm {} \; -print
find ./ -name "*.so" -exec rm {} \; -print

package: rejson.so
mkdir -p ../build
module_packer -v \
-o "../build/rejson.{os}-{architecture}.latest.zip" \
"`pwd`/rejson.so"
RAMP_COMMAND=ramp-packer -v -m ramp.yml
PACKAGE_NAME=rejson
## Package the module into a RAMP package on master builds and version tag builds
package: $(MODULE)
@mkdir -p ../build
@# On release tags (v1.2.3) - package with the version, and package the latest-stable
@set -e; if (expr "$$TRAVIS_TAG" : "^v[0-9]"); then\
$(RAMP_COMMAND) --output "../build/$(PACKAGE_NAME).{os}-{architecture}.`./print_version`.zip" "`pwd`/$(MODULE)";\
$(RAMP_COMMAND) --output "../build/$(PACKAGE_NAME).{os}-{architecture}.latest.zip" "`pwd`/$(MODULE)";\
fi

@# On master builds - package the master latest
@set -e; if [ "$$TRAVIS_BRANCH" = "master" ]; then\
$(RAMP_COMMAND) --output "../build/$(PACKAGE_NAME).{os}-{architecture}.master.zip" "`pwd`/$(MODULE)";\
fi
# Compile an executable that prints the current version
print_version: version.h print_version.c
@$(CC) -o $@ -DPRINT_VERSION_TARGET $@.c
Binary file added src/print_version
Binary file not shown.
12 changes: 12 additions & 0 deletions src/print_version.c
@@ -0,0 +1,12 @@
#ifdef PRINT_VERSION_TARGET
#include <stdio.h>
#include "version.h"

/* This is a utility that prints the current semantic version string, to be used in make files */

int main(int argc, char **argv) {
printf("%d.%d.%d\n", REJSON_VERSION_MAJOR, REJSON_VERSION_MINOR,
REJSON_VERSION_PATCH);
return 0;
}
#endif
23 changes: 23 additions & 0 deletions src/ramp.yml
@@ -0,0 +1,23 @@
display_name: ReJSON
author: Redis Labs
email: redismodules@redislabs.com
description: Native JSON Data Type for Redis
homepage: http://rejson.io
license: AGPLv3
command_line_args: ""
min_redis_version: "4.0"
min_redis_pack_version: "5.0"
capabilities:
- types
- no_multi_key
- replica_of
- eviction_expiry
- failover_migrate
- flash
- backup_restore
- reshard_rebalance
- persistence_aof
- persistence_rdb
- hash_policy
- clustering

6 changes: 3 additions & 3 deletions src/rejson.c
Expand Up @@ -1826,7 +1826,7 @@ int Module_CreateCommands(RedisModuleCtx *ctx) {

int RedisModule_OnLoad(RedisModuleCtx *ctx) {
// Register the module
if (RedisModule_Init(ctx, RLMODULE_NAME, 1, REDISMODULE_APIVER_1) == REDISMODULE_ERR)
if (RedisModule_Init(ctx, RLMODULE_NAME, REJSON_MODULE_VERSION, REDISMODULE_APIVER_1) == REDISMODULE_ERR)
return REDISMODULE_ERR;

// Register the JSON data type
Expand All @@ -1847,8 +1847,8 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx) {
if (REDISMODULE_ERR == Module_CreateCommands(ctx))
return REDISMODULE_ERR;

RM_LOG_WARNING(ctx, "%s v%d.%d.%d [encver %d]", RLMODULE_DESC, PROJECT_VERSION_MAJOR,
PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH, JSONTYPE_ENCODING_VERSION);
RM_LOG_WARNING(ctx, "%s v%d.%d.%d [encver %d]", RLMODULE_DESC, REJSON_VERSION_MAJOR,
REJSON_VERSION_MINOR, REJSON_VERSION_PATCH, JSONTYPE_ENCODING_VERSION);

return REDISMODULE_OK;
}
13 changes: 1 addition & 12 deletions src/rejson.h
Expand Up @@ -27,22 +27,11 @@
#include "object.h"
#include "json_type.h"
#include "redismodule.h"
#include "version.h"

#define RLMODULE_NAME "ReJSON"
#define RLMODULE_DESC "JSON data type for Redis"

#ifndef PROJECT_VERSION_MAJOR
#define PROJECT_VERSION_MAJOR 999
#endif

#ifndef PROJECT_VERSION_MINOR
#define PROJECT_VERSION_MINOR 999
#endif

#ifndef PROJECT_VERSION_PATCH
#define PROJECT_VERSION_PATCH 999
#endif

#define RM_ERRORMSG_SYNTAX "ERR syntax error"

#define REJSON_ERROR_EMPTY_STRING "ERR the empty string is not a valid JSON value"
Expand Down
21 changes: 21 additions & 0 deletions src/version.h
@@ -0,0 +1,21 @@
#ifndef REJSON_VERSION_H_
// This is where the modules build/version is declared.
// If declared with -D in compile time, this file is ignored


#ifndef REJSON_VERSION_MAJOR
#define REJSON_VERSION_MAJOR 0
#endif

#ifndef REJSON_VERSION_MINOR
#define REJSON_VERSION_MINOR 99
#endif

#ifndef REJSON_VERSION_PATCH
#define REJSON_VERSION_PATCH 0
#endif

#define REJSON_MODULE_VERSION \
(REJSON_VERSION_MAJOR * 10000 + REJSON_VERSION_MINOR * 100 + REJSON_VERSION_PATCH)

#endif

0 comments on commit 7cf035d

Please sign in to comment.