Commit 7cf599a0 authored by Jim Nelson's avatar Jim Nelson

#3160: Plugin headers and VAPI files are now installable. Must be enabled...

#3160: Plugin headers and VAPI files are now installable.  Must be enabled with the configure script.  A .pc file is also installed.  #2535: Now that all valac warnings have been eliminated and we require Vala 0.10.0 or above, added --fatal-warnings option to Makefile.  #3167: Fixed "unreachable catch clause" build warning.  Also added sample plugin to source tree.
parent 1f813bac
......@@ -18,15 +18,16 @@ BUILD_RELEASE=1
-include configure.mk
VALAFLAGS = -g --enable-checking --thread $(USER_VALAFLAGS)
DEFINES=_PREFIX='"$(PREFIX)"' _VERSION='"$(VERSION)"' GETTEXT_PACKAGE='"$(GETTEXT_PACKAGE)"' \
_LANG_SUPPORT_DIR='"$(SYSTEM_LANG_DIR)"'
VALAFLAGS := -g --enable-checking --thread --fatal-warnings $(USER_VALAFLAGS)
DEFINES := _PREFIX='"$(PREFIX)"' _VERSION='"$(VERSION)"' GETTEXT_PACKAGE='"$(GETTEXT_PACKAGE)"' \
_LANG_SUPPORT_DIR='"$(SYSTEM_LANG_DIR)"'
EXPORT_FLAGS = -export-dynamic
SUPPORTED_LANGUAGES=fr de it es pl et sv sk lv pt bg bn nl da zh_CN el ru pa hu en_GB uk ja fi zh_TW cs nb id th sl hr ar ast ro sr lt gl tr ca ko kk pt_BR eu he mk
LOCAL_LANG_DIR=locale-langpack
SYSTEM_LANG_DIR=$(DESTDIR)$(PREFIX)/share/locale
LIB=lib
include units.mk
include plugins/plugins.mk
......@@ -343,19 +344,21 @@ EXPANDED_HELP_IMAGES := $(foreach file,$(HELP_IMAGES),help/C/figures/$(file))
VALA_STAMP := $(BUILD_DIR)/.stamp
LANG_STAMP := $(LOCAL_LANG_DIR)/.langstamp
MAKE_FILES := Makefile $(CONFIG_IN) $(UNIT_MKS) unitize.mk units.mk
PC_INPUT := shotwell-plugin-dev-1.0.m4
PC_FILE := $(PC_INPUT:.m4=.pc)
DIST_FILES = Makefile configure chkver $(EXPANDED_SRC_FILES) $(EXPANDED_VAPI_FILES) \
$(EXPANDED_SRC_HEADER_FILES) $(EXPANDED_RESOURCE_FILES) $(TEXT_FILES) $(EXPANDED_ICON_FILES) \
$(EXPANDED_SYS_INTEGRATION_FILES) $(EXPANDED_PO_FILES) po/shotwell.pot libraw-config \
$(EXPANDED_HELP_FILES) $(EXPANDED_HELP_IMAGES) apport/shotwell.py $(UNIT_RESOURCES) $(UNIT_MKS) \
unitize.mk units.mk
unitize.mk units.mk $(PC_INPUT)
DIST_TAR = $(PROGRAM)-$(VERSION).tar
DIST_TAR_BZ2 = $(DIST_TAR).bz2
DIST_TAR_GZ = $(DIST_TAR).gz
PACKAGE_ORIG_GZ = $(PROGRAM)_`parsechangelog | grep Version | sed 's/.*: //'`.orig.tar.gz
VALAFLAGS := --vapidir=plugins/
VALAFLAGS := $(VALAFLAGS) --vapidir=plugins/
VALA_CFLAGS := `pkg-config --cflags $(EXT_PKGS) $(DIRECT_LIBS) gthread-2.0` \
$(foreach hdir,$(HEADER_DIRS),-I$(hdir)) \
......@@ -386,9 +389,9 @@ define check_valac_version
endef
ifdef ENABLE_BUILD_FOR_GLADE
all: $(PLUGINS_DIR) lib$(PROGRAM).so $(PROGRAM)
all: $(PLUGINS_DIR) lib$(PROGRAM).so $(PROGRAM) $(PC_FILE)
else
all: $(PLUGINS_DIR) $(PROGRAM)
all: $(PLUGINS_DIR) $(PROGRAM) $(PC_FILE)
endif
include src/plugins/mk/interfaces.mk
......@@ -409,11 +412,12 @@ clean:
rm -f $(TEMPORARY_DESKTOP_FILES)
rm -f lib$(PROGRAM).so
rm -rf $(UNITIZE_DIR)
rm -f $(PLUGIN_VAPIS)
rm -f $(PLUGIN_HEADERS)
rm -f $(PLUGIN_VAPI)
rm -f $(PLUGIN_HEADER)
rm -f $(PLUGIN_DEPS)
rm -f $(PLUGINS_SO)
@$(MAKE) --directory=plugins clean
rm -f $(PC_FILE)
cleantemps:
rm -f $(EXPANDED_C_FILES)
......@@ -496,8 +500,16 @@ endif
-$(foreach lang,$(SUPPORTED_LANGUAGES),`mkdir -p $(SYSTEM_LANG_DIR)/$(lang)/LC_MESSAGES ; \
$(INSTALL_DATA) $(LOCAL_LANG_DIR)/$(lang)/LC_MESSAGES/shotwell.mo \
$(SYSTEM_LANG_DIR)/$(lang)/LC_MESSAGES/shotwell.mo`)
mkdir -p $(DESTDIR)$(PREFIX)/lib/shotwell/plugins/builtin
$(INSTALL_PROGRAM) $(PLUGINS_SO) $(DESTDIR)$(PREFIX)/lib/shotwell/plugins/builtin
mkdir -p $(DESTDIR)$(PREFIX)/$(LIB)/shotwell/plugins/builtin
$(INSTALL_PROGRAM) $(PLUGINS_SO) $(DESTDIR)$(PREFIX)/$(LIB)/shotwell/plugins/builtin
ifdef INSTALL_HEADERS
mkdir -p $(DESTDIR)$(PREFIX)/include/shotwell/plugins
$(INSTALL_DATA) $(PLUGIN_HEADER) $(DESTDIR)$(PREFIX)/include/shotwell/plugins
mkdir -p $(DESTDIR)$(PREFIX)/share/vala/vapi
$(INSTALL_DATA) $(PLUGIN_VAPI) $(DESTDIR)$(PREFIX)/share/vala/vapi
$(INSTALL_DATA) $(PLUGIN_DEPS) $(DESTDIR)$(PREFIX)/share/vala/vapi
$(INSTALL_DATA) $(PC_FILE) $(DESTDIR)$(PREFIX)/$(LIB)/pkgconfig
endif
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(PROGRAM)
......@@ -522,7 +534,16 @@ ifdef ENABLE_APPORT_HOOK_INSTALL
rm -f $(DESTDIR)$(PREFIX)/share/apport/package-hooks/shotwell.py
endif
$(foreach lang,$(SUPPORTED_LANGUAGES),`rm -f $(SYSTEM_LANG_DIR)/$(lang)/LC_MESSAGES/shotwell.mo`)
rm -rf $(DESTDIR)$(PREFIX)/lib/shotwell/plugins/builtin
rm -rf $(DESTDIR)$(PREFIX)/$(LIB)/shotwell/plugins/builtin
ifdef INSTALL_HEADERS
rm -rf $(DESTDIR)$(PREFIX)/include/shotwell
rm -f $(foreach vapi,$(PLUGIN_VAPI),$(DESTDIR)$(PREFIX)/share/vala/vapi/$(notdir $(vapi)))
rm -f $(foreach dep,$(PLUGIN_DEPS),$(DESTDIR)$(PREFIX)/share/vala/vapi/$(notdir $(dep)))
rm -f $(DESTDIR)$(PREFIX)/$(LIB)/pkgconfig/$(PC_FILE)
endif
$(PC_FILE): $(PC_INPUT) $(MAKE_FILES)
m4 '--define=_VERSION_=$(VERSION)' '--define=_PREFIX_=$(PREFIX)' '--define=_REQUIREMENTS_=$(PLUGIN_PKG_REQS)' $< > $@
$(BUILD_DIR):
@mkdir -p $(BUILD_DIR)
......@@ -554,7 +575,7 @@ endif
endif
@ type msgfmt > /dev/null || ( echo 'msgfmt (usually found in the gettext package) is missing and is required to build Shotwell. ' ; exit 1 )
@echo Compiling Vala code...
@$(VALAC) --ccode --directory=$(BUILD_DIR) --basedir=src $(VALAFLAGS) \
@$(VALAC) --ccode --directory=$(BUILD_DIR) --basedir=src \
$(foreach pkg,$(VALA_PKGS),--pkg=$(pkg)) \
$(foreach vapidir,$(VAPI_DIRS),--vapidir=$(vapidir)) \
$(foreach def,$(DEFINES),-X -D$(def)) \
......@@ -577,7 +598,7 @@ $(PLUGINS_SO): $(PLUGINS_DIR)
@
.PHONY: $(PLUGINS_DIR)
$(PLUGINS_DIR): $(PLUGIN_VAPIS) $(PLUGIN_HEADERS) $(PLUGIN_DEPS)
$(PLUGINS_DIR): $(PLUGIN_VAPI) $(PLUGIN_HEADER) $(PLUGIN_DEPS)
$(call check_valac_version)
@$(MAKE) --directory=$@ PLUGINS_VERSION="$(VERSION)"
......
......@@ -32,6 +32,8 @@ configure_help() {
printf "\t\t\t\tEnable build for Glade-related development.\n"
printf "\t--disable-help-install\n"
printf "\t\t\t\tDisable installation of online help.\n"
printf "\t--install-headers\n"
printf "\t\t\t\tInstall headers and VAPI files (developers only).\n"
printf "\n"
}
......@@ -104,7 +106,10 @@ do
--disable-help-install) variables="${variables}DISABLE_HELP_INSTALL=1\n"
;;
--install-headers) variables="${variables}INSTALL_HEADERS=1\n"
;;
*) if [ ! $value ]
then
abort $1
......
......@@ -16,6 +16,9 @@ HEADER_FILES := $(wildcard ../*.vapi ../*.h ../*.deps)
include ../plugins.mk
# automatically include the shotwell-plugin-dev-1.0 package
PKGS := shotwell-plugin-dev-1.0 $(PKGS)
all: $(PLUGIN).so
$(PLUGIN).so: $(SRC_FILES) $(MAKE_FILES) $(HEADER_FILES)
......
PLUGIN := shotwell-publishing
PKGS := shotwell-publishing-1.0 \
gtk+-2.0 \
libsoup-2.4 \
libxml-2.0 \
webkit-1.0 \
shotwell-spit-1.0
PKGS := \
gtk+-2.0 \
libsoup-2.4 \
libxml-2.0 \
webkit-1.0
SRC_FILES := \
shotwell-publishing.vala \
......
PLUGIN := shotwell-transitions
PKGS := shotwell-transitions-1.0
SRC_FILES := \
shotwell-transitions.vala \
......
PLUGIN := spitter
PKGS := shotwell-spit-1.0
SRC_FILES := spitter.vala
......
PROGRAM := simple-plugin
VERSION := 0.1.0
all: $(PROGRAM).so
clean:
rm -f $(PROGRAM).c $(PROGRAM).so
install:
@ [ `whoami` != "root" ] || ( echo 'Run make install as yourself, not as root.' ; exit 1 )
mkdir -p ~/.gnome2/shotwell/plugins
install -m 644 $(PROGRAM).so ~/.gnome2/shotwell/plugins
uninstall:
@ [ `whoami` != "root" ] || ( echo 'Run make install as yourself, not as root.' ; exit 1 )
rm -f ~/.gnome2/shotwell/plugins/$(PROGRAM).so
$(PROGRAM).so: $(PROGRAM).vala Makefile
valac --save-temps --main=dummy_main -X -D_VERSION='"$(VERSION)"' --pkg=shotwell-plugin-dev-1.0 \
-X --shared -X -fPIC $< -o $@
simple-plugin
-------------
This sample plugin implements the barebones for a SPIT module that can be
loaded by Shotwell at startupp. However, because it implements no
Spit.Pluggables, is does not actually extend Shotwell's functionality.
Note that the Shotwell plugin developer headers must be installed prior
to building simple-plugin. This can be done from the source code like so:
$ ./configure --install-headers
$ make
$ make install
You probably need to be root prior to running "make install" ("sudo make
install" or some variant).
NOTE: simple-plugin's Makefile is *not* designed to install the plugin in
a system directory. Rather, it installs the plugin in the user's plugin
directory (in ~/.gnome2/shotwell/plugins). To build and install
simple-plugin:
$ make
$ make install
Copyright 2011 Yorba Foundation
/* Copyright 2011 Yorba Foundation
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
extern const string _VERSION;
//
// Each .so has a Spit.Module that describes the module and offers zero or more Spit.Pluggables
// to Shotwell to extend its functionality,
//
private class SimplePluginModule : Object, Spit.Module {
public string get_name() {
return "Simple Plugin Sample";
}
public string get_version() {
return _VERSION;
}
// Every module needs to have a unique ID.
public string get_id() {
return "org.yorba.shotwell.samples.simple-plugin";
}
public Spit.Pluggable[]? get_pluggables() {
return null;
}
}
//
// The module is responsible for holding a ref to its Spit.Module until it's unloaded
// (see g_module_unload)
//
private SimplePluginModule? simple = null;
//
// spit_entry_point() is required for all SPIT modules.
//
public unowned Spit.Module? spit_entry_point(int host_min_spit_interface, int host_max_spit_interface,
out int module_spit_interface) {
// Spit.negotiate_interfaces is a simple way to deal with the parameters from the host
module_spit_interface = Spit.negotiate_interfaces(host_min_spit_interface, host_max_spit_interface,
Spit.CURRENT_INTERFACE);
if (module_spit_interface == Spit.UNSUPPORTED_INTERFACE)
return null;
// Although the entry point should only be called once, easy to guard against the possibility
// and still do the right thing
if (simple == null)
simple = new SimplePluginModule();
return simple;
}
//
// The module is responsible for releasing its reference to its Spit.Module when the .so is
// unloaded from memory.
//
public void g_module_unload() {
simple = null;
}
// This is here to keep valac happy.
private void dummy_main() {
}
prefix=_PREFIX_
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: Shotwell Plugin Development
Description: Headers for building Shotwell plugins
Requires: _REQUIREMENTS_
Version: _VERSION_
Cflags: -I${includedir}/shotwell
......@@ -504,12 +504,9 @@ public class Video : VideoSource, Flaggable, Monitorable {
public override Gdk.Pixbuf? create_thumbnail(int scale) throws Error {
VideoReader reader = new VideoReader(backing_row.filepath);
Gdk.Pixbuf? frame = reader.read_preview_frame();
try {
return reader.read_preview_frame();
} catch (VideoError err) {
return Resources.get_noninterpretable_badge_pixbuf().copy();
}
return (frame != null) ? frame : Resources.get_noninterpretable_badge_pixbuf().copy();
}
public override string get_typename() {
......
PLUGIN_VAPIS := \
plugins/shotwell-spit-1.0.vapi \
plugins/shotwell-transitions-1.0.vapi \
plugins/shotwell-publishing-1.0.vapi
PLUGIN_INTERFACES := \
src/plugins/SpitInterfaces.vala \
src/plugins/TransitionsInterfaces.vala \
src/plugins/PublishingInterfaces.vala
PLUGIN_HEADERS := $(PLUGIN_VAPIS:.vapi=.h)
PLUGIN_DEPS := $(PLUGIN_VAPIS:.vapi=.deps)
PLUGIN_PKG_REQS := \
gobject-2.0 \
glib-2.0 \
gdk-2.0 \
gtk+-2.0
$(PLUGIN_HEADERS): %.h: %.vapi
PLUGIN_VAPI := plugins/shotwell-plugin-dev-1.0.vapi
PLUGIN_HEADER := $(PLUGIN_VAPI:.vapi=.h)
PLUGIN_DEPS := $(PLUGIN_VAPI:.vapi=.deps)
plugins/shotwell-spit-1.0.deps: plugins/shotwell-spit-1.0.vapi
@echo "gdk-2.0" > $@
$(PLUGIN_DEPS): src/plugins/mk/interfaces.mk
rm -f $@
$(foreach pkg,$(PLUGIN_PKG_REQS),`echo $(pkg) >> $@`)
plugins/shotwell-spit-1.0.vapi: src/plugins/SpitInterfaces.vala
$(call check_valac_version)
$(VALAC) -c $(VALAFLAGS) -X -I. --pkg=gdk-2.0 --includedir=plugins --vapi=$@ --header=$(basename $@).h $<
rm $(notdir $<).o
plugins/shotwell-transitions-1.0.deps: plugins/shotwell-transitions-1.0.vapi
@printf "gdk-2.0\nshotwell-spit-1.0\n" > $@
plugins/shotwell-transitions-1.0.vapi: src/plugins/TransitionsInterfaces.vala plugins/shotwell-spit-1.0.vapi
$(call check_valac_version)
$(VALAC) -c $(VALAFLAGS) -X -I. --pkg=gdk-2.0 --pkg=shotwell-spit-1.0 --includedir=plugins --vapi=$@ --header=$(basename $@).h $<
rm $(notdir $<).o
plugins/shotwell-publishing-1.0.deps: plugins/shotwell-publishing-1.0.vapi
@printf "gtk+-2.0\nshotwell-spit-1.0" > $@
$(PLUGIN_HEADER): $(PLUGIN_VAPI)
plugins/shotwell-publishing-1.0.vapi: src/plugins/PublishingInterfaces.vala plugins/shotwell-spit-1.0.vapi
$(PLUGIN_VAPI): $(PLUGIN_INTERFACES) src/plugins/mk/interfaces.mk
$(call check_valac_version)
$(VALAC) -c $(VALAFLAGS) -X -I. -X -DGETTEXT_PACKAGE='"shotwell"' --pkg=gtk+-2.0 --pkg=shotwell-spit-1.0 --includedir=plugins --vapi=$@ --header=$(basename $@).h $<
rm $(notdir $<).o
$(VALAC) -c $(VALAFLAGS) -X -DGETTEXT_PACKAGE='"shotwell"' -X -I. $(foreach pkg,$(PLUGIN_PKG_REQS),--pkg=$(pkg)) --includedir=plugins --vapi=$@ --header=$(basename $@).h $(PLUGIN_INTERFACES)
$(foreach src,$(PLUGIN_INTERFACES),`rm $(notdir $(src)).o`)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment