Permalink
Browse files

Migrated waf to waf v1.6.2b2

Added archpkg command
  • Loading branch information...
1 parent 494abdf commit edf3f6c84c55ab0a9671fdc32a66d3d348e36ba4 Paul Colomiets committed Dec 29, 2010
Showing with 134 additions and 90 deletions.
  1. +20 −0 PKGBUILD.tpl
  2. +4 −2 test/httptest.py
  3. BIN waf
  4. +110 −88 wscript
View
20 PKGBUILD.tpl
@@ -0,0 +1,20 @@
+# Maintainer: Paul Colomiets <pc@gafol.net>
+
+pkgname=libwebsite
+pkgver=${VERSION}
+pkgrel=1
+pkgdesc="An http/websocket protocol implementation for fast web servers"
+arch=('i686' 'x86_64')
+url="http://github.com/tailhook/libwebsite"
+license=('GPL')
+depends=('libyaml')
+makedepends=('python3')
+source=(https://github.com/downloads/tailhook/libwebsite/$pkgname-$pkgver.tar.bz2)
+md5sums=('${DIST_MD5}')
+
+build() {
+ cd $srcdir/$pkgname-$pkgver
+ ./waf configure --prefix=/usr
+ ./waf build
+ ./waf install --destdir=$pkgdir
+}
View
6 test/httptest.py
@@ -5,8 +5,10 @@
import socket
import time
-bin = os.path.join('.', 'build', 'default', 'simple')
-websockbin = os.path.join('.', 'build', 'default', 'websocket')
+bin = os.environ.get('SIMPLE_BIN',
+ os.path.join('.', 'build', 'test', 'simple'))
+websockbin = os.environ.get('WEBSOCK_BIN',
+ os.path.join('.', 'build', 'test', 'websocket'))
sample_output = (b'HTTP/1.1 200 OK\r\n'
b'Content-Length: 130\r\n'
View
BIN waf
Binary file not shown.
View
198 wscript
@@ -1,115 +1,137 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import Scripting, Options
+from waflib.Build import BuildContext
+from waflib import Utils, Options
APPNAME='libwebsite'
-VERSION='0.2.6'
+VERSION='0.2.7'
top = '.'
out = 'build'
-def set_options(opt):
- opt.tool_options('compiler_cc')
+def options(opt):
+ opt.load('compiler_c')
opt.add_option('--build-shared', action="store_true", dest="build_shared",
help="Build shared library instead of static", default=False)
- opt.add_option('--build-tests', action="store_true", dest="build_tests",
- help="Build test cases", default=False)
- opt.add_option('--run-tests', action="store_true", dest="run_tests",
- help="Run test cases as a part of build", default=False)
def configure(ctx):
- ctx.check_tool('compiler_cc')
- ctx.env.BUILD_TESTS = Options.options.build_tests
+ ctx.check_tool('compiler_c')
ctx.env.BUILD_SHARED = Options.options.build_shared
def build(bld):
bld(
- features = ['cc', ('cshlib'
- if bld.env.BUILD_SHARED else 'cstaticlib')],
+ features = ['c', ('cshlib'
+ if bld.env.BUILD_SHARED else 'cstlib')],
source = [
'src/core.c',
'src/search.c',
],
target = 'website',
includes = ['src', 'include'],
- defines = [],
- ccflags = ['-std=c99'],
+ cflags = ['-std=c99'],
lib = ['ev'],
)
if Options.options.build_shared:
- bld.install_files('${PREFIX}/lib', [bld.bdir+'/default/libwebsite.so'])
+ bld.install_files('${PREFIX}/lib', 'libwebsite.so')
else:
- bld.install_files('${PREFIX}/lib', [bld.bdir+'/default/libwebsite.a'])
- bld.install_files('${PREFIX}/include', ['include/website.h'])
- if bld.env.BUILD_TESTS:
- bld(
- features = ['cc', 'cprogram'],
- source = [
- 'test/simple.c',
- ],
- target = 'simple',
- includes = ['src', 'include'],
- defines = [],
- ccflags = ['-std=c99'],
- libpath = [bld.bdir+'/default'],
- lib = ['ev', 'website', 'crypto'],
- )
- bld(
- features = ['cc', 'cprogram'],
- source = [
- 'test/detailed.c',
- ],
- target = 'detailed',
- includes = ['src', 'include'],
- defines = [],
- ccflags = ['-std=c99'],
- libpath = [bld.bdir+'/default'],
- lib = ['ev', 'website', 'crypto'],
- )
- bld(
- features = ['cc', 'cprogram'],
- source = [
- 'test/routing.c',
- ],
- target = 'routing',
- includes = ['src', 'include'],
- defines = [],
- ccflags = ['-std=c99'],
- libpath = [bld.bdir+'/default'],
- lib = ['ev', 'website', 'crypto'],
- )
- bld(
- features = ['cc', 'cprogram'],
- source = [
- 'test/websocket.c',
- ],
- target = 'websocket',
- includes = ['src', 'include'],
- defines = [],
- ccflags = ['-std=c99'],
- libpath = [bld.bdir+'/default'],
- lib = ['ev', 'website', 'crypto'],
- )
- bld(
- features = ['cc', 'cprogram'],
- source = [
- 'test/runtests.c',
- ],
- target = 'runtests',
- includes = ['src', 'include'],
- defines = [],
- ccflags = ['-std=c99'],
- libpath = [bld.bdir+'/default'],
- lib = ['ev', 'cunit', 'website'],
- )
- if Options.options.run_tests:
- bld.add_group()
- bld(rule=bld.bdir + '/default/runtests', always=True)
- bld.add_group()
- bld(rule='cd '+bld.srcnode.abspath()+';'
- ' python '+bld.srcnode.abspath()+'/test/httptest.py -v',
- always=True)
+ bld.install_files('${PREFIX}/lib', 'libwebsite.a')
+ bld.install_files('${PREFIX}/include', 'include/website.h')
-def test(ctx):
- Scripting.commands += ['build']
- Options.options.run_tests = True
+def build_tests(bld):
+ bld(
+ features = ['c', 'cprogram'],
+ source = [
+ 'test/simple.c',
+ ],
+ target = 'simple',
+ includes = ['src', 'include'],
+ cflags = ['-std=c99'],
+ lib = ['ev', 'website', 'crypto'],
+ )
+ bld(
+ features = ['c', 'cprogram'],
+ source = [
+ 'test/detailed.c',
+ ],
+ target = 'detailed',
+ includes = ['src', 'include'],
+ defines = [],
+ cflags = ['-std=c99'],
+ lib = ['ev', 'website', 'crypto'],
+ )
+ bld(
+ features = ['c', 'cprogram'],
+ source = [
+ 'test/routing.c',
+ ],
+ target = 'routing',
+ includes = ['src', 'include'],
+ cflags = ['-std=c99'],
+ lib = ['ev', 'website', 'crypto'],
+ )
+ bld(
+ features = ['c', 'cprogram'],
+ source = [
+ 'test/websocket.c',
+ ],
+ target = 'websocket',
+ includes = ['src', 'include'],
+ cflags = ['-std=c99'],
+ lib = ['ev', 'website', 'crypto'],
+ )
+ bld(
+ features = ['c', 'cprogram'],
+ source = [
+ 'test/runtests.c',
+ ],
+ target = 'runtests',
+ includes = ['src', 'include'],
+ cflags = ['-std=c99'],
+ lib = ['ev', 'cunit', 'website'],
+ )
+ bld.add_group()
+ bld(rule='./runtests', always=True)
+ bld.add_group()
+ bld(rule='cd ${SRC[0].parent.abspath()};'
+ 'SIMPLE_BIN=${SRC[1].abspath()} WEBSOCK_BIN=${SRC[2].abspath()}'
+ ' python ${SRC[0].abspath()} -v',
+ source=['test/httptest.py', 'simple', 'websocket'],
+ always=True)
+
+class test(BuildContext):
+ cmd = 'test'
+ fun = 'build_tests'
+ variant = 'test'
+
+
+def dist(ctx):
+ ctx.excl = ['.waf*', '*.tar.bz2', '*.zip', 'build',
+ '.git*', '.lock*', '**/*.pyc']
+ ctx.algo = 'tar.bz2'
+
+def make_pkgbuild(task):
+ import hashlib
+ task.outputs[0].write(Utils.subst_vars(task.inputs[0].read(), {
+ 'VERSION': VERSION,
+ 'DIST_MD5': hashlib.md5(task.inputs[1].read('rb')).hexdigest(),
+ }))
+
+def archpkg(ctx):
+ from waflib import Options
+ Options.commands = ['dist', 'makepkg'] + Options.commands
+
+def build_package(bld):
+ distfile = APPNAME + '-' + VERSION + '.tar.bz2'
+ bld(rule=make_pkgbuild,
+ source=['PKGBUILD.tpl', distfile, 'wscript'],
+ target='PKGBUILD')
+ bld(rule='cp ${SRC} ${TGT}', source=distfile, target='.')
+ bld.add_group()
+ bld(rule='makepkg -f', source=distfile)
+ bld.add_group()
+ bld(rule='makepkg -f --source', source=distfile)
+
+class makepkg(BuildContext):
+ cmd = 'makepkg'
+ fun = 'build_package'
+ variant = 'archpkg'

0 comments on commit edf3f6c

Please sign in to comment.