allow tmakatos (a binary) emitter to be statically compiled

It is trivial to implement static compilation of the rest of the 3rd party
emitters.
This commit is contained in:
Thanos Makatos 2016-04-06 14:15:07 +03:00
parent 35cfc3b90a
commit 431f2ab50a
2 changed files with 35 additions and 1 deletions

View File

@ -92,7 +92,6 @@ SOURCE=\
thin-provisioning/restore_emitter.cc \
thin-provisioning/rmap_visitor.cc \
thin-provisioning/superblock.cc \
thin-provisioning/shared_library_emitter.cc \
thin-provisioning/thin_check.cc \
thin-provisioning/thin_delta.cc \
thin-provisioning/thin_dump.cc \
@ -119,10 +118,23 @@ ifeq ("@DEVTOOLS@", "yes")
SOURCE+=$(DEVTOOLS_SOURCE)
endif
ifeq ("@STATIC@", "yes")
SOURCE += thin-provisioning/static_library_emitter.cc
else
SOURCE += thin-provisioning/shared_library_emitter.cc
endif
CC:=@CC@
CXX:=@CXX@
STRIP:=@STRIP@
OBJECTS:=$(subst .cc,.o,$(SOURCE))
# FIXME OBJECTS += $(PLUGIN_LIBS) doesn't work, probably because it's empty at
# the time of use?
ifeq ("@STATIC@", "yes")
OBJECTS += contrib/*.a
endif
TOP_DIR:=@top_srcdir@
TOP_BUILDDIR:=@top_builddir@
CFLAGS+=-g -Wall -O3 -fPIC

View File

@ -0,0 +1,22 @@
#include "thin-provisioning/shared_library_emitter.h"
#include <stdexcept>
#include "contrib/tmakatos_emitter.h"
using namespace std;
using namespace thin_provisioning;
//----------------------------------------------------------------
emitter::ptr
thin_provisioning::create_custom_emitter(string const &shared_lib, ostream &out)
{
if (shared_lib != "tmakatos_emitter.so")
throw runtime_error(shared_lib + ": no such emitter");
cout << "XXX creating tmakatos_emitter" << endl;
cout << flush;
return emitter::ptr(new tmakatos_emitter::binary_emitter(out));
}
//----------------------------------------------------------------