diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2012-08-07 11:56:16 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2012-08-07 11:56:16 +0200 |
commit | 9dfe4aa8f2fe2fc93479e4b806aafc0cdd76f650 (patch) | |
tree | 70930568daa261300e31baca29e08a75955a7076 | |
parent | d61420eab67f2acab8ea6e3b51a4e763a3259569 (diff) | |
download | crawler-9dfe4aa8f2fe2fc93479e4b806aafc0cdd76f650.tar.gz crawler-9dfe4aa8f2fe2fc93479e4b806aafc0cdd76f650.tar.bz2 |
allow modules to be linked as static libraries, mainly to be able to
use valgrind for leak-checking
-rw-r--r-- | src/ModuleRegistry.hpp | 8 | ||||
-rw-r--r-- | src/modules/urlnormalizer/googleurl/GNUmakefile | 3 | ||||
-rw-r--r-- | src/modules/urlnormalizer/simpleurl/GNUmakefile | 3 | ||||
-rw-r--r-- | src/modules/urlnormalizer/simpleurl/SimpleURLNormalizer.cpp | 2 | ||||
-rw-r--r-- | src/modules/urlnormalizer/simpleurl/SimpleURLNormalizer.hpp | 2 | ||||
-rw-r--r-- | tests/url/GNUmakefile | 10 | ||||
-rw-r--r-- | tests/url/test1.cpp | 26 |
7 files changed, 46 insertions, 8 deletions
diff --git a/src/ModuleRegistry.hpp b/src/ModuleRegistry.hpp index 4f62872..403bb22 100644 --- a/src/ModuleRegistry.hpp +++ b/src/ModuleRegistry.hpp @@ -18,9 +18,14 @@ struct ModuleRegistry { } }; +#ifdef SHARED #define DECLARE_MODULE( baseClass ) \ extern "C" ModuleRegistry<baseClass> registry; +#else +#define DECLARE_MODULE( baseClass ) +#endif +#ifdef SHARED #define REGISTER_MODULE( name, baseClass, subClass ) \ static baseClass *create( ) \ { \ @@ -33,5 +38,8 @@ static void destroy( baseClass *obj ) \ } \ \ ModuleRegistry<baseClass> registry( name, &create, &destroy ); +#else +#define REGISTER_MODULE( name, baseClass, subClass ) +#endif #endif diff --git a/src/modules/urlnormalizer/googleurl/GNUmakefile b/src/modules/urlnormalizer/googleurl/GNUmakefile index 6c5283f..9b86a52 100644 --- a/src/modules/urlnormalizer/googleurl/GNUmakefile +++ b/src/modules/urlnormalizer/googleurl/GNUmakefile @@ -20,6 +20,9 @@ INCLUDE_LIBS = \ DYNAMIC_MODULE = \ mod_urlnormalizer_googleurl.so +STATIC_LIB = \ + libgoogleurlnormalizer.a + CPP_OBJS = \ GoogleURLNormalizer.o diff --git a/src/modules/urlnormalizer/simpleurl/GNUmakefile b/src/modules/urlnormalizer/simpleurl/GNUmakefile index 46f0e27..d91d94d 100644 --- a/src/modules/urlnormalizer/simpleurl/GNUmakefile +++ b/src/modules/urlnormalizer/simpleurl/GNUmakefile @@ -17,6 +17,9 @@ INCLUDE_LIBS = \ DYNAMIC_MODULE = \ mod_urlnormalizer_simple.so +STATIC_LIB = \ + libsimpleurlnormalizer.a + CPP_OBJS = \ SimpleURLNormalizer.o diff --git a/src/modules/urlnormalizer/simpleurl/SimpleURLNormalizer.cpp b/src/modules/urlnormalizer/simpleurl/SimpleURLNormalizer.cpp index 7e7d1ac..414adf1 100644 --- a/src/modules/urlnormalizer/simpleurl/SimpleURLNormalizer.cpp +++ b/src/modules/urlnormalizer/simpleurl/SimpleURLNormalizer.cpp @@ -7,12 +7,10 @@ using namespace std; SimpleURLNormalizer::SimpleURLNormalizer( ) { - test = malloc(10); } SimpleURLNormalizer::~SimpleURLNormalizer( ) { - free( test ); } URL SimpleURLNormalizer::parseUrl( const string s ) diff --git a/src/modules/urlnormalizer/simpleurl/SimpleURLNormalizer.hpp b/src/modules/urlnormalizer/simpleurl/SimpleURLNormalizer.hpp index 1b1de60..5bd454c 100644 --- a/src/modules/urlnormalizer/simpleurl/SimpleURLNormalizer.hpp +++ b/src/modules/urlnormalizer/simpleurl/SimpleURLNormalizer.hpp @@ -16,8 +16,6 @@ class SimpleURLNormalizer : public URLNormalizer { private: void normalizePath( std::string &path ); - - void *test; }; DECLARE_MODULE( URLNormalizer ) diff --git a/tests/url/GNUmakefile b/tests/url/GNUmakefile index df37f62..8ce49bd 100644 --- a/tests/url/GNUmakefile +++ b/tests/url/GNUmakefile @@ -3,12 +3,18 @@ TOPDIR = ../.. SUBDIRS = INCLUDE_DIRS = \ - -I$(TOPDIR)/src + -I$(TOPDIR)/src \ + -I$(TOPDIR)/src/modules/urlnormalizer/simpleurl \ + -I$(TOPDIR)/src/modules/urlnormalizer/googleurl INCLUDE_LDFLAGS = INCLUDE_LIBS = \ - $(TOPDIR)/src/libcrawlingwolf.a + $(TOPDIR)/src/libcrawlingwolf.a \ + $(TOPDIR)/src/modules/urlnormalizer/simpleurl/libsimpleurlnormalizer.a \ + $(TOPDIR)/src/modules/urlnormalizer/googleurl/libgoogleurlnormalizer.a \ + $(TOPDIR)/googleurl/libgoogleurl.a \ + -licui18n -licuuc TEST_CPP_BINS = \ test1$(EXE) diff --git a/tests/url/test1.cpp b/tests/url/test1.cpp index 9c0faa6..b2ee90e 100644 --- a/tests/url/test1.cpp +++ b/tests/url/test1.cpp @@ -1,6 +1,11 @@ #include "URL.hpp" +#ifdef USE_MODULELOADER #include "URLNormalizer.hpp" #include "ModuleLoader.hpp" +#else +#include "SimpleURLNormalizer.hpp" +#include "GoogleURLNormalizer.hpp" +#endif #include <vector> #include <iostream> @@ -21,12 +26,25 @@ int main( int argc, char *argv[] ) char *baseUrlString = argv[3]; char *partialUrlString = argv[4]; +#ifdef USE_MODULELOADER vector<string> modules; modules.push_back( "../../src/modules/urlnormalizer/simpleurl/mod_urlnormalizer_simple.so" ); modules.push_back( "../../src/modules/urlnormalizer/googleurl/mod_urlnormalizer_googleurl.so" ); ModuleLoader<URLNormalizer> urlNormalizers( modules ); - + URLNormalizer *normalizer = urlNormalizers.create( method ); +#else + URLNormalizer *normalizer; + if( strcmp( method, "simple" ) == 0 ) { + normalizer = new SimpleURLNormalizer( ); + } else if( strcmp( method, "google" ) == 0 ) { + normalizer = new GoogleURLNormalizer( ); + } else { + cerr << "Unknown normalization method '" << method << "'" << endl; + return 1; + } +#endif + URL url; @@ -58,7 +76,11 @@ int main( int argc, char *argv[] ) cout << "URL: " << url << endl; +#ifdef USE_MODULELOADER urlNormalizers.destroy( normalizer ); - +#else + delete normalizer; +#endif + return 0; } |