diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-04-09 11:38:48 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-04-09 11:38:48 +0200 |
commit | 2f42619303627db401e469e2fd65123cd794a378 (patch) | |
tree | fb9944f9838b9d19be3e2ce39e6be6b71f9c469c /plugins/weblog | |
parent | f5e2c43abe9477fba6255c734faf2822e7f2f9c5 (diff) |
Load only configured plugins, add plugins
Diffstat (limited to 'plugins/weblog')
-rw-r--r-- | plugins/weblog/Makefile | 130 | ||||
-rw-r--r-- | plugins/weblog/weblog.cpp | 26 | ||||
-rw-r--r-- | plugins/weblog/weblog.h | 15 |
3 files changed, 171 insertions, 0 deletions
diff --git a/plugins/weblog/Makefile b/plugins/weblog/Makefile new file mode 100644 index 0000000..27b68fc --- /dev/null +++ b/plugins/weblog/Makefile @@ -0,0 +1,130 @@ +DISTROS=debian10 +VERSION=$(shell dpkg-parsechangelog --show-field Version) +PROJECTNAME=weblog + +CXX=clang++-10 + +ifeq ($(shell which $(CXX)),) +CXX=clang++ +endif + +ifeq ($(shell which $(CXX)),) +CXX=g++-9 +endif + +ifeq ($(CXXFLAGS),) +#CXXFLAGS=-O2 -DNDEBUG +CXXFLAGS=-O0 -g -D_DEBUG +endif +# -fprofile-instr-generate -fcoverage-mapping +# gcc:--coverage + +CXXFLAGS+= -Wall -I. + +CXXFLAGS+= -pthread -fvisibility=hidden -fPIC +ifeq ($(CXX),clang++-10) +CXXFLAGS+=-std=c++20 #-stdlib=libc++ +else +CXXFLAGS+=-std=c++2a +endif + +CXXTESTFLAGS=-Igoogletest/include -Igooglemock/include/ -Igoogletest -Igooglemock + +LIBS=\ +-lboost_context \ +-lboost_coroutine \ +-lboost_program_options \ +-lboost_system \ +-lboost_thread \ +-lboost_filesystem \ +-lboost_regex \ +-lpthread \ +-lssl -lcrypto \ +-ldl + +ifeq ($(CXX),clang++-10) +LIBS+= \ +-fuse-ld=lld-10 \ +-lstdc++ +#-lc++ \ +#-lc++abi +#-lc++fs +#-lstdc++fs +else +LIBS+= \ +-lstdc++ +#-lstdc++fs +endif + +PROGSRC=\ + weblog.cpp + +TESTSRC=\ + test-webserver.cpp \ + googlemock/src/gmock-all.cpp \ + googletest/src/gtest-all.cpp \ + $(PROGSRC) + +SRC=$(PROGSRC) + +all: $(PROJECTNAME).so + +# testsuite ---------------------------------------------- +test-$(PROJECTNAME): $(TESTSRC:.cpp=.o) + $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@ + +$(PROJECTNAME).so: $(SRC:.cpp=.o) + $(CXX) -shared $(CXXFLAGS) $^ $(LIBS) -o $@ + +dep: $(TESTSRC:.cpp=.d) + +%.d: %.cpp + $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $< + +%.o: %.cpp %.d + $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ + +googletest/src/%.o: googletest/src/%.cc + $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@ + +# dependencies + +ADD_DEP=Makefile + +install: + mkdir -p $(DESTDIR)/usr/bin + cp webserver $(DESTDIR)/usr/bin + + mkdir -p $(DESTDIR)/usr/lib/webserver/plugins + mkdir -p $(DESTDIR)/usr/local/lib/webserver/plugins + + mkdir -p $(DESTDIR)/etc + cp webserver.conf $(DESTDIR)/etc/webserver.conf + +# misc --------------------------------------------------- +deb: + # build binary deb package + dpkg-buildpackage -us -uc -rfakeroot + +deb-src: + dpkg-source -b . + +$(DISTROS): deb-src + sudo pbuilder build --basetgz /var/cache/pbuilder/$@.tgz --buildresult result/$@ ../webserver_$(VERSION).dsc ; \ + +debs: $(DISTROS) + +clean: + -rm -f test-$(PROJECTNAME) $(PROJECTNAME) + -find . -name '*.o' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f + +zip: clean + -rm -f ../$(PROJECTNAME).zip + zip -r ../$(PROJECTNAME).zip * + ls -l ../$(PROJECTNAME).zip + + + +.PHONY: clean all zip install deb deb-src debs all $(DISTROS) + +-include $(wildcard $(SRC:.cpp=.d)) diff --git a/plugins/weblog/weblog.cpp b/plugins/weblog/weblog.cpp new file mode 100644 index 0000000..ef90a53 --- /dev/null +++ b/plugins/weblog/weblog.cpp @@ -0,0 +1,26 @@ +#include "weblog.h" + +#include <iostream> + +using namespace std::string_literals; + +std::string weblog_plugin::name() +{ + return "weblog"; +} + +weblog_plugin::weblog_plugin() +{ + //std::cout << "Plugin constructor" << std::endl; +} + +weblog_plugin::~weblog_plugin() +{ + //std::cout << "Plugin destructor" << std::endl; +} + +std::string weblog_plugin::generate_page(std::string path) +{ + return "Blog "s + path; +} + diff --git a/plugins/weblog/weblog.h b/plugins/weblog/weblog.h new file mode 100644 index 0000000..5433e1c --- /dev/null +++ b/plugins/weblog/weblog.h @@ -0,0 +1,15 @@ +#pragma once + +#include "../plugin_interface.h" + +class weblog_plugin: public webserver_plugin_interface +{ +public: + weblog_plugin(); + ~weblog_plugin(); + std::string name(); + std::string generate_page(std::string path); +}; + +extern "C" BOOST_SYMBOL_EXPORT weblog_plugin webserver_plugin; +weblog_plugin webserver_plugin; |