From 7cf035d1bd19932d9deb48ded215830e611d7265 Mon Sep 17 00:00:00 2001 From: Dvir Volk Date: Tue, 14 Nov 2017 17:18:59 +0200 Subject: [PATCH] proper packaging and version 0.99 --- .gitignore | 2 ++ src/Makefile | 28 +++++++++++++++++++++------- src/print_version | Bin 0 -> 8432 bytes src/print_version.c | 12 ++++++++++++ src/ramp.yml | 23 +++++++++++++++++++++++ src/rejson.c | 6 +++--- src/rejson.h | 13 +------------ src/version.h | 21 +++++++++++++++++++++ 8 files changed, 83 insertions(+), 22 deletions(-) create mode 100755 src/print_version create mode 100644 src/print_version.c create mode 100644 src/ramp.yml create mode 100644 src/version.h diff --git a/.gitignore b/.gitignore index ddd5c8bb1..a6b87d5e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*.rdb +*.d # Object files *.o *.ko diff --git a/src/Makefile b/src/Makefile index 8165ba963..55355fd37 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 @@ -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) @@ -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" \ No newline at end of file +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 diff --git a/src/print_version b/src/print_version new file mode 100755 index 0000000000000000000000000000000000000000..98fc2505c28a87d1ac1b0de1621b6547e2871e4d GIT binary patch literal 8432 zcmeHMO>0v@6uq&nmRfDH5x;pBBicnjK*WvGl!m5S`e7@mP{yWBO(022@`4R06pD*1 zDqXnn2e@#f)Ro1pLhVLf`U6xdw9uu97|(fcUh+OS+yI)2T|MELH*YX@?Mc$9t;f*Uyb$; zdVAQanItuj* zV?Fiz{pF`t-TR;`55l5KTA^Kqe6A~^v;&<+pN2RV!RvK`+;zpx+9gLNFU$R|uMQ0*K2j~DZHBGcK|iE*UjPLP~| zVSl$Rm%nowlOH370mFb{z%XDKFbo(53Og3Xc=@`(_1Y#2#+U-4|u>>!+>GH zFkl!k3>XFs1BL;^fMLKeU>GnA7zX|e214z@F-|1Z%ga9JGF-)RKa9)kv7D?(E*R=n z^SFSvXMrFAh5PtDDw9-+g~W8hPT;P4is7d+Q>mvKMA5JnB;uYv_3ph80&iTS2 q2fJq#Ja6C`25jZ%f%l4j?52fNq?ct2H^jTgpqw#y +#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 \ No newline at end of file diff --git a/src/ramp.yml b/src/ramp.yml new file mode 100644 index 000000000..7fa8f8692 --- /dev/null +++ b/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 + diff --git a/src/rejson.c b/src/rejson.c index 8521198af..6619f5798 100644 --- a/src/rejson.c +++ b/src/rejson.c @@ -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 @@ -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; } diff --git a/src/rejson.h b/src/rejson.h index 8ba872fc2..2e2d272fb 100644 --- a/src/rejson.h +++ b/src/rejson.h @@ -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" diff --git a/src/version.h b/src/version.h new file mode 100644 index 000000000..0119da843 --- /dev/null +++ b/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