From 46b0d40da9b5f9051e3022033e499b892276d680 Mon Sep 17 00:00:00 2001 From: Bram Veldhoen Date: Wed, 3 Jun 2015 16:43:03 +0200 Subject: [PATCH] Enable creation of rpm. --- CMakeLists.txt | 19 ++++++++++++++++--- README.md | 50 +++++++++++++++++++++++++++++--------------------- 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99efae9..973c8cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,16 +168,29 @@ install(FILES ${INC_REDOX_WRAPPER} DESTINATION include) # Create system package (make package) # --------------------------------------------------------- -# build a CPack driven installer package +# Determine build architecture +execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE) +message("Building for ${ARCHITECTURE}") + +# build CPack driven installer packages include(InstallRequiredSystemLibraries) set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C++11 client for Redis") set(CPACK_PACKAGE_VENDOR "Hayk Martirosyan") -set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Hayk Martirosyan ") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") #set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libgcc1 (>= 1:3.4.2-12)") set(CPACK_PACKAGE_VERSION_MAJOR "${REDOX_VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "${REDOX_VERSION_MINOR}") set(CPACK_PACKAGE_VERSION_PATCH "${REDOX_VERSION_PATCH}") -set(CPACK_GENERATOR "DEB") +set(CPACK_PACKAGE_VERSION_RELEASE "1") # Increase this if a failed build was published +set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CPACK_PACKAGE_VERSION_RELEASE}") +set(CPACK_SYSTEM_NAME "${ARCHITECTURE}") +set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}.${ARCHITECTURE}") +# Debian specific fields +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Hayk Martirosyan ") +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${ARCHITECTURE}") +# RPM specific fields +set(CPACK_RPM_PACKAGE_ARCHITECTURE "${ARCHITECTURE}") +# Select CPack generators +set(CPACK_GENERATOR "DEB" "RPM") include(CPack) diff --git a/README.md b/README.md index 01f5969..5e31b5c 100644 --- a/README.md +++ b/README.md @@ -51,18 +51,18 @@ Here is the simplest possible redox program: #include #include - + using namespace std; using namespace redox; - + int main(int argc, char* argv[]) { - + Redox rdx; if(!rdx.connect("localhost", 6379)) return 1; - + rdx.set("hello", "world!"); cout << "Hello, " << rdx.get("hello") << endl; - + rdx.disconnect(); return 0; } @@ -74,7 +74,7 @@ Compile and run: Hello, world! This example is synchronous, in the sense that the commands don't return until -a reply is received from the server. +a reply is received from the server. #### Asynchronous commands In a high-performance application, we don't want to wait for a reply, but instead @@ -110,20 +110,20 @@ the callback returns. Here is a simple example of running `GET hello` asynchronously ten times: Redox rdx; - + // Block until connected, localhost by default if(!rdx.connect()) return 1; - + auto got_reply = [](Command& c) { if(!c.ok()) return; cout << c.cmd() << ": " << c.reply() << endl; }; - + for(int i = 0; i < 10; i++) rdx.command({"GET", "hello"}, got_reply); - + // Do useful work this_thread::sleep_for(chrono::milliseconds(10)); - + rdx.disconnect(); // Block until disconnected The `.command()` method returns immediately, so this program doesn't wait for a reply @@ -132,7 +132,7 @@ shut down after we get all replies, we could do something like this: Redox rdx; if(!rdx.connect()) return 1; - + int total = 10; // Number of commands to run atomic_int count(0); // Number of replies expected auto got_reply = [&](Command& c) { @@ -140,11 +140,11 @@ shut down after we get all replies, we could do something like this: if(c.ok()) cout << c.cmd() << " #" << count << ": " << c.reply() << endl; if(count == total) rdx.stop(); // Signal to shut down }; - + for(int i = 0; i < total; i++) rdx.command({"GET", "hello"}, got_reply); - + // Do useful work - + rdx.wait(); // Block until shut down complete This example tracks of how how many replies are received and signals the Redox @@ -152,7 +152,7 @@ instance to stop once they all process. We use an `std::atomic_int` to be safe because the callback is invoked from a separate thread. The `stop()` method signals Redox to shut down its event loop and disconnect from Redis. The `wait()` method blocks until `stop()` has been called and everything is brought down. -The `disconnect()` method used earlier is just a call to `stop()` and then a +The `disconnect()` method used earlier is just a call to `stop()` and then a call to `wait()`. #### Synchronous commands @@ -181,7 +181,7 @@ calls `c.free()`. Command& cmd = rdx.commandLoop({"GET", "hello"}, [](Command& c) { if(c.ok()) cout << c.cmd() << ": " << c.reply() << endl; }, 0.1); - + this_thread::sleep_for(chrono::seconds(1)); cmd.free(); rdx.disconnect(); @@ -212,16 +212,16 @@ receives messages and provides subscribe/unsubscribe and psubscribe/punsubscribe Redox rdx; Subscriber sub; if(!rdx.connect() || !sub.connect()) return 1; - + sub.subscribe("hello", [](const string& topic, const string& msg) { cout << topic << ": " << msg << endl; }); - + for(int i = 0; i < 10; i++) { rdx.publish("hello", "this is a pubsub message"); this_thread::sleep_for(chrono::milliseconds(500)); } - + sub.disconnect(); rdx.disconnect(); #### strToVec and vecToStr @@ -251,7 +251,7 @@ a `WRONG_TYPE` or `NIL_REPLY` status. * `>`: Arrays of Simple Strings or Bulk Strings (in received order) * `>`: Arrays of Simple Strings or Bulk Strings (in sorted order) * `>`: Arrays of Simple Strings or Bulk Strings (in no order) - + ## Installation Instructions provided are for Ubuntu, but all components are platform-independent. @@ -293,6 +293,14 @@ Redox documentation is generated using [doxygen](http://doxygen.org). The documentation can then be viewed in a browser at `docs/html/index.html`. +#### Build RPM and DEB packages +Basic support to build RPMs and DEBs is in the build system. To build them, issue +the following commands: + + mkdir release && cd release + cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. + make package + ## Contributing Redox is in its early stages and I am looking for feedback and contributors to make it easier, faster, and more robust. Open issues on GitHub or message me directly. -- libgit2 0.21.4