diff options
author | Aleksey Lim <alsroot@member.fsf.org> | 2009-04-17 13:20:35 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@member.fsf.org> | 2009-04-17 13:20:35 (GMT) |
commit | ccca798196b9eef3e08c93826f4d4f8f4f85327e (patch) | |
tree | 4448b1c482622bf84aa7205fe2efb917ba7d203d | |
parent | 192750ecf53a180fc2dba141b4d149ce5abf9bf4 (diff) |
Add binary blobs selector
-rw-r--r-- | .gitignore | 4 | ||||
-rwxr-xr-x | _camera.so | bin | 32196 -> 0 bytes | |||
-rw-r--r-- | camerac/Makefile (renamed from Makefile) | 22 | ||||
-rw-r--r-- | camerac/__init__.py | 21 | ||||
-rw-r--r-- | camerac/camera.c (renamed from _camera.c) | 6 | ||||
-rw-r--r-- | constants.py | 4 | ||||
-rw-r--r-- | ui.py | 8 | ||||
-rw-r--r-- | utils.py | 4 |
8 files changed, 47 insertions, 22 deletions
@@ -1,3 +1,5 @@ -_camera.o +*.o +*.so +linux* dist locale diff --git a/_camera.so b/_camera.so Binary files differdeleted file mode 100755 index ec00d95..0000000 --- a/_camera.so +++ /dev/null diff --git a/Makefile b/camerac/Makefile index 265b3ee..ce80618 100644 --- a/Makefile +++ b/camerac/Makefile @@ -17,20 +17,22 @@ PYCAIRO_INCLUDES=`pkg-config --cflags pycairo` PYCAIRO_LIBS=`pkg-config --libs pycairo` INCLUDES=-I. -I/usr/include/${PYTHON} ${GLIB_INCLUDES} ${PYGTK_INCLUDES} ${CAIRO_INCLUDES} ${PYCAIRO_INCLUDES} ${GTK_INCLUDES} -ARCHFLAGS=-m32 -march=i386 -mtune=generic OPTFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -CFLAGS=-g -fPIC -DPIC -LDFLAGS=-shared -nostdlib -Wl,--export-dynamic -pthread +CFLAGS=-g -fPIC -DPIC $(OPTFLAGS) $(INCLUDES) +LDFLAGS=-shared -nostdlib -Wl,--export-dynamic -pthread ${GLIB_LIBS} ${PYGTK_LIBS} ${CAIRO_LIBS} ${PYCAIRO_LIBS} ${GTK_LIBS} -all: build link +ARCH = $(shell arch | grep 64 >/dev/null && echo linux64 || echo linux32) +LIB_DIR = $(ARCH)_$(PYVER) -build: _camera.o -_camera.o: _camera.c - gcc ${INCLUDES} ${ARCHFLAGS} ${OPTFLAGS} ${CFLAGS} -c _camera.c -o _camera.o +all: camera.so + rm -rf $(LIB_DIR) + mkdir $(LIB_DIR) + strip -s $^ + mv $^ $(LIB_DIR)/ + touch $(LIB_DIR)/__init__.py -link: _camera.so -_camera.so: _camera.o - g++ ${LDFLAGS} _camera.o ${GLIB_LIBS} ${PYGTK_LIBS} ${CAIRO_LIBS} ${PYCAIRO_LIBS} ${GTK_LIBS} -Wl,-soname -Wl,_camera.so -o _camera.so +camera.so: camera.o + $(CXX) $(LDFLAGS) -o $@ $^ clean: @find -name "*.o" -exec rm {} \; diff --git a/camerac/__init__.py b/camerac/__init__.py new file mode 100644 index 0000000..dba55ae --- /dev/null +++ b/camerac/__init__.py @@ -0,0 +1,21 @@ +import os +import sys +import logging + +_sys_path = sys.path +_root_path = os.path.dirname(__file__) + +for i in os.listdir(_root_path): + path = os.path.join(_root_path, i) + if (os.path.isdir(path)): + sys.path = _sys_path + [os.path.join('.', path)] + try: + from camera import * + logging.debug('use %s blobs' % path) + _sys_path = None + break + except Exception, e: + logging.debug('skip %s blobs: %s' % (path, e)) + +if _sys_path: + raise('cannot find proper binary blobs') diff --git a/_camera.c b/camerac/camera.c index 694f0a4..cf4795d 100644 --- a/_camera.c +++ b/camerac/camera.c @@ -260,17 +260,17 @@ py_camera_register_classes(PyObject *d) } DL_EXPORT(void) -init_camera(void) +initcamera(void) { PyObject *m, *d; Pycairo_IMPORT; - m = Py_InitModule ("_camera", py_camera_functions); + m = Py_InitModule ("camera", py_camera_functions); d = PyModule_GetDict (m); py_camera_register_classes (d); if (PyErr_Occurred ()) { - Py_FatalError ("can't initialise module _camera"); + Py_FatalError ("can't initialise module camera"); } } diff --git a/constants.py b/constants.py index 64fbc4f..e24227d 100644 --- a/constants.py +++ b/constants.py @@ -10,7 +10,7 @@ from instance import Instance from sugar import profile from color import Color import utils -import _camera +import camerac import cairo import pango import pangocairo @@ -269,7 +269,7 @@ class Constants: recCircleFile = os.path.join(self.__class__.gfxPath, 'media-circle.png') recCirclePixbuf = gtk.gdk.pixbuf_new_from_file(recCircleFile) - self.__class__.recCircleCairo = _camera.cairo_surface_from_gdk_pixbuf(recCirclePixbuf) + self.__class__.recCircleCairo = camerac.cairo_surface_from_gdk_pixbuf(recCirclePixbuf) recInsFile = os.path.join(self.__class__.gfxPath, 'media-insensitive.png') recInsPixbuf = gtk.gdk.pixbuf_new_from_file(recInsFile) @@ -56,7 +56,7 @@ from recorded import Recorded from button import RecdButton import utils import record -import _camera +import camerac from tray import HTray from toolbarcombobox import ToolComboBox @@ -739,7 +739,7 @@ class UI: if (pixbuf != None): #self.shownRecd = recd - img = _camera.cairo_surface_from_gdk_pixbuf(pixbuf) + img = camerac.cairo_surface_from_gdk_pixbuf(pixbuf) self.livePhotoCanvas.setImage( img ) self.LIVEMODE = False @@ -1599,7 +1599,7 @@ class UI: #if (recd != self.shownRecd): pixbuf = recd.getAudioImagePixbuf() - img = _camera.cairo_surface_from_gdk_pixbuf(pixbuf) + img = camerac.cairo_surface_from_gdk_pixbuf(pixbuf) self.livePhotoCanvas.setImage( img ) #self.shownRecd = recd self.showRecdMeta(recd) @@ -1708,7 +1708,7 @@ class UI: pixbuf = pixbuf.scale_simple(self.__class__.dim_THUMB_WIDTH, self.__class__.dim_THUMB_HEIGHT, gtk.gdk.INTERP_NEAREST) pixbuf = utils.grayScalePixBuf(pixbuf, True) - img = _camera.cairo_surface_from_gdk_pixbuf(pixbuf) + img = camerac.cairo_surface_from_gdk_pixbuf(pixbuf) self.backgdCanvas.setImage(img) @@ -11,7 +11,7 @@ import time from time import strftime from sugar import util -import _camera +import camerac def getStringFromPixbuf(pixbuf): data = [""] @@ -68,7 +68,7 @@ def generateThumbnail( pixbuf, scale, thumbw, thumbh ): #need to generate thumbnail version here thumbImg = cairo.ImageSurface(cairo.FORMAT_ARGB32, thumbw, thumbh) tctx = cairo.Context(thumbImg) - img = _camera.cairo_surface_from_gdk_pixbuf(pixbuf) + img = camerac.cairo_surface_from_gdk_pixbuf(pixbuf) tctx.scale(scale, scale) tctx.set_source_surface(img, 0, 0) tctx.paint() |