Skip to content

Commit ac72ba7

Browse files
committed
cleanup version gen to be driven by git tags
this removes the static meta.h header file which included only version information and replaces it with a version.h file. This file is generated on build time from the m4/version.h.m4 template and includes the version string as generated from `git describe --tags --always --dirty`. This makes sure that the version of any builds always corresponds to an existing revision in git (and also marks it as dirty if the build comes from uncommited changes).
1 parent 7333581 commit ac72ba7

11 files changed

Lines changed: 22 additions & 30 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ usr
4343

4444
# generated files
4545
docs
46+
include/restclient-cpp/version.h

Makefile.am

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
ACLOCAL_AMFLAGS=-I m4
2-
CPPFLAGS=-Iinclude -Ivendor/gtest-1.7.0/include -Ivendor/jsoncpp-0.10.5/dist
2+
CPPFLAGS=-Iinclude
33
check_PROGRAMS = test-program
4-
pkginclude_HEADERS = include/restclient-cpp/restclient.h include/restclient-cpp/meta.h
4+
pkginclude_HEADERS = include/restclient-cpp/restclient.h include/restclient-cpp/version.h
5+
BUILT_SOURCES = include/restclient-cpp/version.h
56

67
test_program_SOURCES = vendor/jsoncpp-0.10.5/dist/jsoncpp.cpp test/test_restclient_delete.cpp test/test_restclient_get.cpp test/test_restclient_post.cpp test/test_restclient_put.cpp test/tests.cpp
78
test_program_LDADD = .libs/librestclient-cpp.a
89
test_program_LDFLAGS=-Lvendor/gtest-1.7.0/lib/.libs -lgtest
10+
test_program_CPPFLAGS=-Iinclude -Ivendor/gtest-1.7.0/include -Ivendor/jsoncpp-0.10.5/dist
911

1012
lib_LTLIBRARIES=librestclient-cpp.la
1113
librestclient_cpp_la_SOURCES=source/restclient.cpp
1214
librestclient_cpp_la_CXXFLAGS=-fPIC
1315
librestclient_cpp_la_LDFLAGS=-version-info 1:0:1
1416

15-
.PHONY: test check clean-coverage-files coverage-html docs clean-docs deploy-docs doxygen jekyll packages rpm deb
17+
.PHONY: test check clean-coverage-files coverage-html docs clean-docs deploy-docs doxygen jekyll packages rpm deb include/restclient-cpp/version.h
1618

1719
test: check
1820
./test-program
@@ -45,8 +47,8 @@ deb:
4547

4648
packages: local-install rpm deb
4749

48-
include/snyder/version.h:
49-
m4 -I m4 --define=M4_SNYDER_VERSION=$(VERSION) version.h.m4 > $@
50+
include/restclient-cpp/version.h:
51+
m4 -I m4 --define=M4_RESTCLIENT_VERSION=$(VERSION) version.h.m4 > $@
5052

5153

5254
GAUGES_CODE="539c6c8de32bb442640005f3"
@@ -61,7 +63,7 @@ jekyll:
6163
echo "markdown: redcarpet" >> docs/_config.yml
6264
echo "---" > docs/index.md
6365
echo "layout: project" >> docs/index.md
64-
echo "title: restclient-cpp" >> docs/index.md
66+
echo "title: $(NAME)" >> docs/index.md
6567
echo "---" >> docs/index.md
6668
cat README.md >> docs/index.md
6769

configure.ac

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ AC_PREREQ([2.52])
55
AC_INIT([restclient-cpp], [0.1.2], [[email protected]])
66
AM_INIT_AUTOMAKE([0.1.2 foreign subdir-objects])
77
LT_INIT
8-
AC_CONFIG_SRCDIR([include/restclient-cpp/meta.h])
98
AC_CONFIG_HEADERS([config.h])
109
AC_CONFIG_MACRO_DIR([m4])
1110

include/restclient-cpp/meta.h

Lines changed: 0 additions & 13 deletions
This file was deleted.

include/restclient-cpp/restclient.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <cstdlib>
1515
#include <algorithm>
1616

17+
#include "restclient-cpp/version.h"
18+
1719
class RestClient
1820
{
1921
public:

m4/version.h.m4

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
changecom(`@@')dnl
2+
#ifndef RESTCLIENT_VERSION
3+
#define RESTCLIENT_VERSION "M4_RESTCLIENT_VERSION"
4+
#endif
5+
changecom(`#')dnl

source/restclient.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
INCLUDES
99
========================*/
1010
#include "restclient-cpp/restclient.h"
11-
#include "restclient-cpp/meta.h"
11+
#include "restclient-cpp/version.h"
1212

1313
#include <curl/curl.h>
1414
#include <cstring>
@@ -17,7 +17,7 @@
1717
#include <map>
1818

1919
/** initialize user agent string */
20-
const char* RestClient::user_agent = "restclient-cpp/" VERSION;
20+
const char* RestClient::user_agent = "restclient-cpp/" RESTCLIENT_VERSION;
2121
/** initialize authentication variable */
2222
std::string RestClient::user_pass = std::string();
2323
/** Authentication Methods implementation */

test/test_restclient_delete.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "restclient-cpp/restclient.h"
2-
#include "restclient-cpp/meta.h"
32
#include <gtest/gtest.h>
43
#include <json/json.h>
54
#include <string>
@@ -47,7 +46,7 @@ TEST_F(RestClientDeleteTest, TestRestClientDeleteBody)
4746
str >> root;
4847

4948
EXPECT_EQ("http://httpbin.org/delete", root.get("url", "no url set").asString());
50-
EXPECT_EQ("restclient-cpp/" VERSION, root["headers"].get("User-Agent", "no url set").asString());
49+
EXPECT_EQ("restclient-cpp/" RESTCLIENT_VERSION, root["headers"].get("User-Agent", "no url set").asString());
5150
}
5251
// check for failure
5352
TEST_F(RestClientDeleteTest, TestRestClientFailureCode)

test/test_restclient_get.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "restclient-cpp/restclient.h"
2-
#include "restclient-cpp/meta.h"
32
#include <gtest/gtest.h>
43
#include <json/json.h>
54
#include <string>
@@ -47,7 +46,7 @@ TEST_F(RestClientGetTest, TestRestClientGETBodyCode)
4746
str >> root;
4847

4948
EXPECT_EQ("http://httpbin.org/get", root.get("url", "no url set").asString());
50-
EXPECT_EQ("restclient-cpp/" VERSION, root["headers"].get("User-Agent", "no url set").asString());
49+
EXPECT_EQ("restclient-cpp/" RESTCLIENT_VERSION, root["headers"].get("User-Agent", "no url set").asString());
5150
}
5251
//check if additional http headers were sent
5352
TEST_F(RestClientGetTest, TestRestClientGETAdditionalHeaders)

test/test_restclient_post.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "restclient-cpp/restclient.h"
2-
#include "restclient-cpp/meta.h"
32
#include <gtest/gtest.h>
43
#include <json/json.h>
54
#include <string>
@@ -47,7 +46,7 @@ TEST_F(RestClientPostTest, TestRestClientPostBody)
4746
str >> root;
4847

4948
EXPECT_EQ("http://httpbin.org/post", root.get("url", "no url set").asString());
50-
EXPECT_EQ("restclient-cpp/" VERSION, root["headers"].get("User-Agent", "no url set").asString());
49+
EXPECT_EQ("restclient-cpp/" RESTCLIENT_VERSION, root["headers"].get("User-Agent", "no url set").asString());
5150
}
5251
// check for failure
5352
TEST_F(RestClientPostTest, TestRestClientFailureCode)

0 commit comments

Comments
 (0)