Skip to content

Instantly share code, notes, and snippets.

@jsimmons
Created July 22, 2010 10:29
Show Gist options
  • Save jsimmons/485818 to your computer and use it in GitHub Desktop.
Save jsimmons/485818 to your computer and use it in GitHub Desktop.
waf example wscripts
#! /usr/bin/env python
# encoding: utf-8
# Joshua Simmons 2010
def configure(conf):
pass
def build(bld):
pong = bld(
features = 'c cprogram',
target = 'pong/pong',
ccflags = ['-std=c99', '-Wall'],
source = bld.path.ant_glob("pong/src/*.c"),
uselib_local = 'sgl-1.0',
)
from waflib import Options
if Options.options.debug:
pong.ccflags.extend(['-g', '-O0'])
else:
pong.ccflags.extend('-O3')
#! /usr/bin/env python
# encoding: utf-8
# Joshua Simmons 2010
name = 'sgl'
major = 1
minor = 0
bugfix = 0
name_version = '%s-%d.%d' % (name, major, minor)
long_version = '%d.%d.%d' % (major, minor, bugfix)
# Magic Waf variables here.
top = '.'
out = 'build'
APPNAME = name
VERSION = long_version
def options(opt):
opt.tool_options('compiler_cc')
opt.add_option('--shared', action='store_true', default=False, help='build shared library')
opt.add_option('--debug', action='store_false', default=True, help='enable debugging')
opt.add_option('--build-gtk-doc', action='store_false', default=True, help='build gtk-doc api documentation')
opt.add_option('--build-demos', action='store_false', default=True, help='build demo applications')
opt.add_option('--build-tests', action='store_true', default=False, help='build and run unit tests')
def configure(conf):
conf.env.CC = 'clang'
conf.check_tool('compiler_cc')
conf.check_cfg(package='glew', uselib_store='GLEW', args='--cflags --libs', mandatory=True)
conf.check_cfg(package='glib-2.0', uselib_store='GLIB', args='--cflags --libs', mandatory=True)
conf.check_cfg(package='gobject-2.0', uselib_store='GOBJECT', args='--cflags --libs', mandatory=True)
conf.define('SGL_VERSION', long_version)
from waflib import Options
conf.define('SGL_DEBUG', int(Options.options.debug))
conf.write_config_header('sglconfig.h')
if Options.options.build_demos:
conf.recurse('demos')
if Options.options.build_tests:
conf.recurse('tests')
def build(bld):
lib = bld(
features = ['c'],
target = name_version,
ccflags = ['-std=c99', '-Wall'],
source = bld.path.ant_glob("sgl/*.c"),
includes = '. sgl',
export_incdirs = '. sgl',
uselib = 'GLEW GLIB GOBJECT'
)
from waflib import Options
lib.features.append('cshlib' if Options.options.shared else 'cstaticlib')
if Options.options.debug:
lib.ccflags.extend(['-g', '-O0'])
else:
lib.ccflags.extend(['-O3'])
pc = bld(source='sgl.pc.in', target='%s.pc' % name_version, install_path='${PREFIX}/lib/pkgconfig')
pc.env.prefix = bld.env.PREFIX
pc.env.exec_prefix = '${prefix}'
pc.env.libdir = '${exec_prefix}/lib'
pc.env.includedir = '${prefix}/include/%s/%s' % (name_version, name)
pc.env.long_version = long_version
pc.env.name_version = name_version
bld.install_files('${PREFIX}/lib/%s/include' % name_version, 'sglconfig.h')
bld.install_files('${PREFIX}/include/%s/%s' % (name_version, name), bld.path.ant_glob('sgl/*.h'))
if Options.options.build_demos:
bld.recurse('demos')
if Options.options.build_tests:
bld.recurse('tests')
@FaizalJnu
Copy link

I'm trying to run ./waf configure --enable-python
But it says wscript isn't installed. I've used yours but then again getting some errors. (am coding on macOS by the way), any help if possible? I have my assignment due tomorrow!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment