Add './waf configure --libdir' option.

This commit is contained in:
Steve Chaplin 2010-09-18 15:08:55 +08:00 committed by Christoph Reiter
parent 6f5b170b78
commit 5d2a4d6682
6 changed files with 94 additions and 59 deletions

1
.gitignore vendored
View File

@ -25,6 +25,7 @@ aclocal.m4
autom4te.cache
autoscan.log
build
build_directory
config.cache
config.guess
config.h

View File

@ -3,7 +3,8 @@ Install Procedure
Waf
---
$ ./waf --help # shows available waf options
$ ./waf configure # use '--prefix=PREFIX' if needed
$ ./waf configure # use --prefix and --libdir if necessary
# --prefix=/usr --libdir=/usr/lib64 for Fedora 64-bit
$ ./waf build
$ ./waf install

View File

@ -803,7 +803,7 @@ pycairo_select_font_face (PycairoContext *o, PyObject *args) {
return NULL;
cairo_select_font_face (o->ctx, utf8, slant, weight);
PyMem_Free(utf8);
PyMem_Free((void *)utf8);
RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
Py_RETURN_NONE;
}
@ -1112,7 +1112,7 @@ pycairo_show_text (PycairoContext *o, PyObject *args) {
cairo_show_text (o->ctx, utf8);
Py_END_ALLOW_THREADS;
PyMem_Free(utf8);
PyMem_Free((void *)utf8);
RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
Py_RETURN_NONE;
}
@ -1152,7 +1152,7 @@ pycairo_text_extents (PycairoContext *o, PyObject *args) {
return NULL;
cairo_text_extents (o->ctx, utf8, &extents);
PyMem_Free(utf8);
PyMem_Free((void *)utf8);
RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
return Py_BuildValue("(dddddd)", extents.x_bearing, extents.y_bearing,
extents.width, extents.height, extents.x_advance,
@ -1167,7 +1167,7 @@ pycairo_text_path (PycairoContext *o, PyObject *args) {
return NULL;
cairo_text_path (o->ctx, utf8);
PyMem_Free(utf8);
PyMem_Free((void *)utf8);
RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
Py_RETURN_NONE;
}

View File

@ -159,7 +159,7 @@ toy_font_face_new (PyTypeObject *type, PyObject *args, PyObject *kwds) {
PyObject *o = PycairoFontFace_FromFontFace (
cairo_toy_font_face_create (utf8, slant, weight));
PyMem_Free(utf8);
PyMem_Free((void *)utf8);
return o;
}
@ -318,7 +318,7 @@ scaled_font_text_extents (PycairoScaledFont *o, PyObject *args) {
return NULL;
cairo_scaled_font_text_extents (o->scaled_font, utf8, &extents);
PyMem_Free(utf8);
PyMem_Free((void *)utf8);
RETURN_NULL_IF_CAIRO_SCALED_FONT_ERROR(o->scaled_font);
return Py_BuildValue("(dddddd)", extents.x_bearing, extents.y_bearing,
extents.width, extents.height, extents.x_advance,

View File

@ -5,28 +5,37 @@ import os
d = 'src'
def build(bld):
print(' %s/build' %d)
def build(ctx):
print(' %s/build()' %d)
pycairoLibDir = os.path.join(ctx.env['LIBDIR'],
'python'+ctx.env['PYTHON_VERSION'],
'site-packages', 'cairo')
# .py files
bld.new_task_gen(
features = 'py',
source = '__init__.py',
install_path = '${PYTHONDIR}/cairo',
ctx.new_task_gen(
features = 'py',
source = '__init__.py',
install_path = pycairoLibDir,
)
# C extension module
bld.new_task_gen(
features = 'cc cshlib pyext',
source = 'cairomodule.c context.c font.c path.c pattern.c matrix.c surface.c',
target = '_cairo',
includes = '.',
uselib = 'CAIRO',
install_path = '${PYTHONDIR}/cairo',
ctx.new_task_gen(
features = 'cc cshlib pyext',
source = ['cairomodule.c',
'context.c',
'font.c',
'path.c',
'pattern.c',
'matrix.c',
'surface.c',
],
target = '_cairo',
includes = '.',
uselib = 'CAIRO',
install_path = pycairoLibDir,
)
# C API
bld.install_files(os.path.join(bld.env['PREFIX'], 'include', 'pycairo'),
ctx.install_files(os.path.join(ctx.env['PREFIX'], 'include', 'pycairo'),
'pycairo.h')
# how to strip binaries ?

98
wscript
View File

@ -2,71 +2,95 @@
import os
top = '.'
out = 'build_directory'
d = top
APPNAME='py2cairo'
VERSION='1.8.11'
cairo_version_required = '1.8.10'
srcdir = '.'
blddir = '../%s-build' % APPNAME
d = srcdir
def set_options(opt):
print(' %s/set_options' %d)
opt.tool_options('compiler_cc')
opt.tool_options('python') # options for disabling pyc or pyo compilation
def set_options(ctx):
print(' %s/set_options()' %d)
ctx.tool_options('gnu_dirs')
ctx.tool_options('compiler_cc')
ctx.tool_options('python') # options for disabling pyc or pyo compilation
def init():
print(' %s/init' %d)
print(' %s/init()' %d)
def shutdown():
print(' %s/shutdown()' %d)
def configure(conf):
print(' %s/configure' %d)
def configure(ctx):
print(' %s/configure()' %d)
env = conf.env
conf.check_tool('misc')
conf.check_tool('compiler_cc')
conf.check_tool('python')
conf.check_python_version((2,6,0))
conf.check_python_headers()
conf.check_cfg(package='cairo', atleast_version=cairo_version_required,
env = ctx.env
ctx.check_tool('gnu_dirs')
ctx.check_tool('misc')
ctx.check_tool('compiler_cc')
ctx.check_tool('python')
ctx.check_python_version((2,6,0))
ctx.check_python_headers()
ctx.check_cfg(package='cairo', atleast_version=cairo_version_required,
args='--cflags --libs')
# add gcc options
if env['CC_NAME'] == 'gcc':
for opt in ('-std=c99', '-Wall'):
if opt not in env['CCFLAGS']:
env.append_value('CCFLAGS', opt)
env.append_unique('CCFLAGS', ['-std=c99', '-Wall'])
version = [int(s) for s in VERSION.split('.')]
conf.define('VERSION', VERSION)
conf.define('PYCAIRO_VERSION_MAJOR', version[0])
conf.define('PYCAIRO_VERSION_MINOR', version[1])
conf.define('PYCAIRO_VERSION_MICRO', version[2])
ctx.define('VERSION', VERSION)
ctx.define('PYCAIRO_VERSION_MAJOR', version[0])
ctx.define('PYCAIRO_VERSION_MINOR', version[1])
ctx.define('PYCAIRO_VERSION_MICRO', version[2])
conf.write_config_header('src/config.h')
ctx.write_config_header('src/config.h')
print("Configuration:")
print("%-40s : %s" % ('PREFIX', env['PREFIX']))
print("%-40s : %s" % ('LIBDIR', env['LIBDIR']))
def build(bld):
print(' %s/build' %d)
bld.add_subdirs('src')
def build(ctx):
print(' %s/build()' %d)
ctx.add_subdirs('src')
# generate and install the .pc file
obj = bld.new_task_gen('subst')
obj = ctx.new_task_gen('subst')
obj.source = 'pycairo.pc.in'
obj.target = 'pycairo.pc'
obj.dict = {
'VERSION' : VERSION,
'prefix' : bld.env['PREFIX'],
'includedir': os.path.join(bld.env['PREFIX'], 'include'),
'prefix' : ctx.env['PREFIX'],
'includedir': os.path.join(ctx.env['PREFIX'], 'include'),
}
obj.install_path = os.path.join(bld.env['PREFIX'], 'lib', 'pkgconfig')
obj.install_path = os.path.join(ctx.env['PREFIX'], 'lib', 'pkgconfig')
def dist(): # create archives of project
print(' %s/dist' %d)
def dist_hook():
# remove unwanted files from the archive
# individual files
for f in [
'RELEASING',
'examples/cairo_snippets/c_to_python.py',
'doc/html_docs_create.sh',
'doc/html_docs_upload.sh',
]:
os.remove(f)
# rm examples/*.{pdf,png,ps,svg}
D='examples'
for f in os.listdir(D):
if f.endswith(('.pdf', '.png', '.ps', '.svg')):
os.remove(os.path.join(D, f))
D='examples/cairo_snippets/snippets'
for f in os.listdir(D):
if f.endswith(('.pdf', '.png', '.ps', '.svg')):
os.remove(os.path.join(D, f))
def shutdown():
print(' %s/shutdown' %d)