Added skeleton and script for creating new module
This commit is contained in:
parent
e96b1bc5f4
commit
4120b1855a
7
newmodule
Executable file
7
newmodule
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
mkdir modules/$1
|
||||
cp skeleton/Makefile modules/$1/
|
||||
srchead screensaver-modules/$1/$1.hpp > modules/$1/$1.hpp
|
||||
sed -e "s/{MODULE}/$1/" skeleton/MODULE.hpp >> modules/$1/$1.hpp
|
||||
srchead screensaver-modules/$1/$1.cpp > modules/$1/$1.cpp
|
||||
sed -e "s/{MODULE}/$1/" skeleton/MODULE.cpp >> modules/$1/$1.cpp
|
30
skeleton/MODULE.cpp
Normal file
30
skeleton/MODULE.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include "{MODULE}.hpp"
|
||||
#include <libscscreensaver.hpp>
|
||||
|
||||
class {MODULE} : public ScreensaverPlugin {
|
||||
public:
|
||||
{MODULE}() = default;
|
||||
~{MODULE}() = default;
|
||||
|
||||
int fps() const override;
|
||||
void update() override;
|
||||
void render() override;
|
||||
};
|
||||
|
||||
ScreensaverPlugin* create_instance() {
|
||||
return new {MODULE};
|
||||
}
|
||||
|
||||
int {MODULE}::fps() const {
|
||||
return 30;
|
||||
}
|
||||
|
||||
void {MODULE}::update() {
|
||||
// adjust state for next render
|
||||
|
||||
}
|
||||
|
||||
void {MODULE}::render() {
|
||||
// render one frame based on current state
|
||||
|
||||
}
|
10
skeleton/MODULE.hpp
Normal file
10
skeleton/MODULE.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef _{MODULE}_H_
|
||||
#define _{MODULE}_H_
|
||||
|
||||
class ScreensaverPlugin;
|
||||
|
||||
extern "C" {
|
||||
ScreensaverPlugin* create_instance();
|
||||
}
|
||||
|
||||
#endif // _{MODULE}_H_
|
62
skeleton/Makefile
Normal file
62
skeleton/Makefile
Normal file
@ -0,0 +1,62 @@
|
||||
LIBNAME := $(shell basename $$(pwd))
|
||||
MAJOR := 1
|
||||
MINOR := 0.0
|
||||
|
||||
UNAME_S := $(shell uname -s)
|
||||
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
LINKERNAME := $(LIBNAME).dylib
|
||||
SONAME := $(LIBNAME).$(MAJOR).dylib
|
||||
REALNAME := $(LINKERNAME)
|
||||
else
|
||||
LINKERNAME := $(LIBNAME).so
|
||||
SONAME := $(LINKERNAME).$(MAJOR)
|
||||
REALNAME := $(SONAME).$(MINOR)
|
||||
endif
|
||||
|
||||
PREFIX ?= ../..
|
||||
LIBDIR ?= $(PREFIX)/plugins
|
||||
|
||||
SRCS := $(wildcard *.cpp)
|
||||
OBJS := $(subst .cpp,.o,$(SRCS))
|
||||
DEPS := $(subst .cpp,.d,$(SRCS))
|
||||
HDRS := $(filter-out $(LIBNAME).hpp,$(wildcard *.hpp))
|
||||
|
||||
CXX ?= g++
|
||||
|
||||
CXXFLAGS := $(CXXFLAGS) -Wshadow -Wall -Wpedantic -Wextra -g -fno-strict-aliasing -std=c++17 -fPIC
|
||||
ifeq ($(DEBUG),1)
|
||||
CXXFLAGS += -D DEBUG -O0
|
||||
else
|
||||
CXXFLAGS += -D NDEBUG -O3
|
||||
endif
|
||||
|
||||
LDLIBS := -lcairo -lscscreensaver
|
||||
|
||||
RM := /bin/rm -f
|
||||
INSTALL := /usr/bin/install -c
|
||||
|
||||
.PHONY: all clean install
|
||||
|
||||
all: $(REALNAME)
|
||||
|
||||
$(REALNAME): $(OBJS) $(DEPS)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
$(CXX) -dynamiclib -o $(REALNAME) -current_version $(MAJOR) -compatibility_version $(MINOR) $(LDFLAGS) $(LDLIBS) $(OBJS)
|
||||
else
|
||||
$(CXX) -g -shared -Wl,-soname,$(SONAME) -o $(REALNAME) $(LDFLAGS) $(LDLIBS) $(OBJS)
|
||||
endif
|
||||
|
||||
%.o: %.cpp %.d Makefile
|
||||
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
|
||||
|
||||
-include *.d
|
||||
|
||||
%.d: ;
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJS) $(DEPS) $(REALNAME)
|
||||
|
||||
install: $(REALNAME)
|
||||
$(INSTALL) -d $(LIBDIR)
|
||||
$(INSTALL) -m 644 $(REALNAME) $(LIBDIR)/$(LIBNAME).saver
|
Loading…
x
Reference in New Issue
Block a user