Integrating external libraries (libpq and jsoncpp) into waf
refs #2631
Change-Id: I420421fba0f53e78ddd4908792df2ce380117ea3
diff --git a/README.md b/README.md
index e6c2de5..528369e 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,17 @@
+ndn-atmos
+=========
This software is designed to support ongoing climate model research at Colorado State University,
Berkeley and other institutes.
This software provides API interface to publish, query and retrieve Climate datasets using NDN.
+
+Dependencies
+============
+
+ The ndn-atmos is built based on several libraries:
+ 1. ndn-cxx-0.3.0 (https://github.com/named-data/ndn-cxx.git)
+ 2. ChronoSync v0.2 (https://github.com/named-data/ChronoSync.git)
+ 3. boost (Minimum required boost version is 1.48.0)
+ 4. jsoncpp 1.6.0 (https://github.com/open-source-parsers/jsoncpp.git)
+ 5. postgresql 9.4.1 (http://www.postgresql.org)
diff --git a/catalog/src/main.cpp b/catalog/src/main.cpp
index 78e3ccf..d5f89ee 100644
--- a/catalog/src/main.cpp
+++ b/catalog/src/main.cpp
@@ -21,13 +21,25 @@
#include <ChronoSync/socket.hpp>
#include <ndn-cxx/face.hpp>
+#include <json/value.h>
+#include <libpq-fe.h>
using namespace std;
using namespace ndn;
int main()
{
- Face face;
- shared_ptr<chronosync::Socket> socket;
+ Face face; // use ndn-cxx
+ shared_ptr<chronosync::Socket> socket; // use ChronoSync
+
+ Json::Value root; // use jsoncpp
+ PGconn *conn; // use libpq
+ // Make a connection to the database
+ conn = PQconnectdb("dbname=bedrock sslmode=disable");
+ if (PQstatus(conn) != CONNECTION_OK) {
+ cout << "Connection to database failed: "
+ << PQerrorMessage(conn) << endl;
+ }
+
return 0;
}
diff --git a/catalog/tests/unit-tests/simple.cpp b/catalog/tests/unit-tests/simple.cpp
index c6b4fbb..01ae66a 100644
--- a/catalog/tests/unit-tests/simple.cpp
+++ b/catalog/tests/unit-tests/simple.cpp
@@ -20,6 +20,11 @@
*/
#include <boost/test/unit_test.hpp>
+#include <libpq-fe.h>
+#include <json/value.h>
+#include <json/writer.h>
+#include <json/reader.h>
+#include <iostream>
namespace NdnAtmos {
namespace test {
@@ -31,6 +36,30 @@
BOOST_CHECK(0==0);
}
+BOOST_AUTO_TEST_CASE(DBTest)
+{
+ PGconn *conn;
+ conn = PQconnectdb("dbname=test sslmode=disable");
+ BOOST_CHECK_EQUAL(PQstatus(conn) != CONNECTION_OK, true);
+}
+
+BOOST_AUTO_TEST_CASE(JsonTest)
+{
+ Json::Value original;
+ original["command"] = "test";
+
+ Json::FastWriter fastWriter;
+ std::string jsonMessage = fastWriter.write(original);
+
+ Json::Value parsedFromString;
+ Json::Reader reader;
+ bool result;
+ BOOST_CHECK_EQUAL(result = reader.parse(jsonMessage, parsedFromString), true);
+ if (result) {
+ BOOST_CHECK_EQUAL(original, parsedFromString);
+ }
+}
+
BOOST_AUTO_TEST_SUITE_END()
} //namespace test
diff --git a/catalog/tests/wscript b/catalog/tests/wscript
index 21e0b09..0f29974 100644
--- a/catalog/tests/wscript
+++ b/catalog/tests/wscript
@@ -26,11 +26,11 @@
def build(bld):
# unit test objects
unit_tests_objects = bld(
- target="unit-test-objects",
- name="unit-test-objects",
+ target='unit-test-objects',
+ name='unit-test-objects',
features="cxx",
source=bld.path.ant_glob(['unit-tests/**/*.cpp']),
- use='ndn-cxx BOOST',
+ use='NDN_CXX BOOST ndn_atmos_objects',
includes='.',
install_path=None)
@@ -39,6 +39,6 @@
target='../unit-tests',
name='unit-tests-main-unit',
source="main.cpp",
- use='ndn-cxx unit-test-objects BOOST',
+ use='unit-test-objects',
install_path=None)
diff --git a/wscript b/wscript
index efbb69f..df0b84c 100644
--- a/wscript
+++ b/wscript
@@ -54,8 +54,14 @@
conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
uselib_store='NDN_CXX', mandatory=True)
- conf.check_cfg (package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'],
- uselib_store='SYNC', mandatory=True)
+ conf.check_cfg(package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'],
+ uselib_store='SYNC', mandatory=True)
+
+ conf.check_cfg(package='jsoncpp', args=['--cflags', '--libs'],
+ uselib_store='JSON', mandatory=True)
+
+ conf.check_cfg(package='libpq', args=['--cflags', '--libs'],
+ uselib_store='SQL_PQ', mandatory=True)
boost_libs = 'system random thread filesystem'
@@ -74,12 +80,22 @@
conf.write_config_header('config.h')
def build (bld):
+ ndn_atmos_objects = bld(
+ target='ndn_atmos_objects',
+ name='ndn_atmos_objects',
+ features='cxx',
+ source=bld.path.ant_glob(['catalog/src/*.cpp'],
+ excl=['catalog/src/main.cpp']),
+ use='NDN_CXX BOOST SYNC JSON SQL_PQ',
+ includes='catalog/src .',
+ export_includes='catalog/src .'
+ )
+
bld(
- target="bin/ndn-atmos",
- features=['cxx', 'cxxprogram'],
- source=bld.path.ant_glob(['catalog/src/*.cpp']),
- includes="catalog/src .",
- use="ndn-cxx BOOST SYNC"
+ target='bin/ndn-atmos',
+ features='cxx cxxprogram',
+ source='catalog/src/main.cpp',
+ use='ndn_atmos_objects'
)
# Catalog unit tests