Skip to content

Commit ca2a523

Browse files
committed
Merge branch 'release/v0.1.1'
2 parents bec64f4 + 1ab05aa commit ca2a523

File tree

5 files changed

+42
-13
lines changed

5 files changed

+42
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
bin/*
22
*.o
3+
lib*

Makefile

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,68 @@ LOGFILE = test_server.log
1111

1212
# binaries and folders
1313
BINDIR = bin
14+
LIBDIR = lib
1415
TEST = $(BINDIR)/test
16+
LIBNAME = librestclient-cpp.so
17+
LIB = $(LIBDIR)/$(LIBNAME)
18+
STATIC = $(LIBDIR)/librestclient-cpp.a
1519

1620
# set library and include paths
1721
INCLUDE = -I. -I/usr/local/include
1822
TESTLIBS = -lgtest -lcurl
1923
LIBS = -lcurl
2024

2125
# set compiler and linker flags
22-
CCFLAGS = -O3 -W -Wall
26+
CCFLAGS = -fPIC -O3 -W -Wall
2327
LDFLAGS = -W -Wall -L/usr/local/lib
2428

2529
# source files
2630
SRCS = source/restclient.cpp
27-
SRCS += $(wildcard test/test*.cpp)
31+
32+
# test source files
33+
TESTSRCS = $(SRCS)
34+
TESTSRCS += $(wildcard test/test*.cpp)
2835

2936
# dependencies
3037
# object files
3138
OBJS = $(SRCS:.cpp=.o)
39+
TESTOBJS = $(TESTSRCS:.cpp=.o)
3240

3341
# linking rule
34-
$(TEST): $(OBJS) $(BINDIR)
35-
$(LD) $(LDFLAGS) $(OBJS) -o $(TEST) $(TESTLIBS)
42+
$(TEST): $(TESTOBJS) $(BINDIR)
43+
$(LD) $(LDFLAGS) $(TESTOBJS) -o $(TEST) $(TESTLIBS)
44+
45+
# dynamic lib rule
46+
$(LIB): $(OBJS) $(LIBDIR)
47+
$(LD) $(LDFLAGS) -shared -soname,$(LIBNAME) -o $(LIB) $(OBJS) $(LIBS)
48+
49+
# static lib rule
50+
$(STATIC): $(OBJS) $(LIBDIR)
51+
ar rcs $(STATIC) $(OBJS)
3652

3753
# compile rule
3854
.cpp.o:
3955
$(CC) $(CCFLAGS) $(INCLUDE) -c $< -o $@
4056

41-
4257
$(BINDIR):
4358
@mkdir -p $(BINDIR)
4459

60+
$(LIBDIR):
61+
@mkdir -p $(LIBDIR)
62+
4563
# tasks
46-
.PHONY: clean all
64+
.PHONY: clean
4765

4866
clean:
4967
@rm -rf test/*.o
5068
@rm -rf source/*.o
5169
@rm -rf bin
70+
@rm -rf lib
5271

53-
all: $(TEST)
72+
test: $(TEST)
5473
@echo Running tests...
5574
@./bin/test
75+
76+
dynamiclibrary: $(LIB)
77+
78+
staticlibrary: $(STATIC)

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# REST client for C++
22

33
## About
4-
This is a simple REST client for C++. It wraps libcurl for HTTP requests
5-
and uses jsoncpp for parsing JSON responses.
4+
This is a simple REST client for C++. It wraps libcurl for HTTP requests.
65

76
## Usage
87
I tried to keep usage close to the [ruby rest-client][]. So the basic usage is:
@@ -18,11 +17,17 @@ Examples:
1817
RestClient::put("http://url.com/put", "text/json", "{"foo": "bla"}")
1918
RestClient::del("http://url.com/delete")
2019

20+
The response is of type RestClient::response and has two attributes:
21+
22+
RestClient::response.code // HTTP response code
23+
RestClient::response.body // HTTP response body
24+
25+
2126
## Dependencies
2227
- [libcurl][]
23-
- [jsoncpp][]
28+
- [gtest][] for development
2429

2530

2631
[libcurl]: http://curl.haxx.se/libcurl/
27-
[jsoncpp]: http://jsoncpp.sourceforge.net/
2832
[ruby rest-client]: http://github.com/archiloque/rest-client
33+
[gtest]: http://code.google.com/p/googletest/

include/meta.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define INCLUDE_META_H_
99

1010
// version string normally set from makefile
11-
#define VERSION "0.1.0"
11+
#define VERSION "0.1.1"
1212

1313
#endif // INCLUDE_META_H_
1414

include/restclient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include <curl/curl.h>
1313
#include <string>
14-
#include "include/meta.h"
14+
#include "meta.h"
1515

1616
class RestClient
1717
{

0 commit comments

Comments
 (0)