[Gfxprim] [repo.or.cz] gfxprim.git branch generate-waf created: bc6e962ae2c0418d82e47e7f10601352679a041f

gavento gavento at ucw.cz
Fri Aug 26 11:20:46 CEST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.

The branch, generate-waf has been created
        at  bc6e962ae2c0418d82e47e7f10601352679a041f (commit)

- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/bc6e962ae2c0418d82e47e7f10601352679a041f

commit bc6e962ae2c0418d82e47e7f10601352679a041f
Author: Tomas Gavenciak <gavento at ucw.cz>
Date:   Fri Aug 26 11:13:15 2011 +0200

    Experimental build overhaul with WAF
    
    Supports:
    * out-of-tree build (generated headers are in-tree for now and not getting
    cleaned)
    * configure, build, dist, install. try: ./waf configure build
    * not all modules have wscript (just a demo for now), no test building
    * gitdist, gitcheck (clean HEAD checkout for dist and clean build testing)

diff --git a/libs/core/wscript b/libs/core/wscript
index d10daa6..3e98adc 100644
--- a/libs/core/wscript
+++ b/libs/core/wscript
@@ -1,9 +1,5 @@
 #! /usr/bin/env python
+# encoding: utf-8
 
 def build(bld):
-  sources = bld.path.ant_glob('*.c *.c.t')
-  includes=['../../include/core', '../../include']
-  bld(name='core_objs', source=sources, includes=includes, features='c')
-  bld(target='GP_core', source='', use='core_objs', features='c cshlib')
-  bld(target='GP_core', source='', use='core_objs', features='c cstlib')
-
+  bld.GP_std_module('core')
diff --git a/libs/filters/wscript b/libs/filters/wscript
new file mode 100644
index 0000000..4e255f4
--- /dev/null
+++ b/libs/filters/wscript
@@ -0,0 +1,5 @@
+#! /usr/bin/env python
+# encoding: utf-8
+
+def build(bld):
+  bld.GP_std_module('filters')
diff --git a/libs/text/wscript b/libs/text/wscript
new file mode 100644
index 0000000..7deed9b
--- /dev/null
+++ b/libs/text/wscript
@@ -0,0 +1,5 @@
+#! /usr/bin/env python
+# encoding: utf-8
+
+def build(bld):
+  bld.GP_std_module('text')
diff --git a/wscript b/wscript
index caef639..25cae62 100644
--- a/wscript
+++ b/wscript
@@ -8,11 +8,11 @@
 
 
 import datetime
-from Utils import subst_vars
+from wscript_lib import *
 
+# Gobal settings
 top = '.'
 out = 'build'
-
 APPNAME = 'gfxprim'
 VERSION = 'dev-' + datetime.datetime.utcnow().strftime("%Y%m%d%H%M")
 
@@ -37,47 +37,36 @@ def configure(cnf):
   cnf.env['PYLIBSDIR'] = cnf.path.find_node('pylib').abspath()
 
 
-def dist(ctx):
-  ctx.excl = ' **/.waf-* **/*~ **/*.pyc **/*.swp **/.lock-w* **/.git* **/virtualpy* **.tar.bz2'
-
-
 def build(bld):
   # Generate all generated headers, regardless of the module
   include = bld.path.find_node('include')
-  bld.template(source=include.ant_glob('**/*.h.t'))
+  bld.template(source=include.ant_glob('**/*.h.t'), in_src=True)
   # Recurse on modules
-  bld.recurse('libs/core')
-  bld.recurse('tests/core')
-
-
-
-### Template processing lib
-
-from waflib.Task import Task
-from waflib.TaskGen import extension
-from waflib.Configure import conf
-from waflib.Utils import to_list
-
- at conf
-def template(ctx, source=[], target=[], template_ext='.t', **kw):
-  "Task generator for Template processing. Only one of `source` and `target` need to be given."
-  src = to_list(source)
-  tgt = to_list(target)
-  assert len(src) + len(tgt) > 0
-  if not src:
-    src = [i.change_ext(template_ext, ext_in='') for i in tgt]
-  if not tgt:
-    tgt = [i.change_ext('', ext_in=template_ext) for i in src]
-  if len(src) != len(tgt):
-    ctx.fatal('"template" task needs the same number of sources as targets!')
-  kw.setdefault('name', 'template')
-  for s, t in zip(src, tgt):
-    ctx(rule = 'PYTHONPATH=$PYTHONPATH:${PYLIBSDIR} ${PYTHON} ${TEMPLATER} -t ${TEMPLATE_DIR} ${SRC} ${TGT}',
-	source=s, target=t, color='CYAN', **kw)
-
-# Implicit .c.t -> .c rule
-
- at extension('.c.t')
-def process_c_t(self, node):
-  self.bld.template(source = [node])
-  self.source.append(node.change_ext('', ext_in='.t'))
+  uses = []
+  for mod in 'core gfx text loaders filters input backends SDL'.split():
+    bld.recurse('libs/' + mod, mandatory=False)
+    uses.append(mod + '_objs')
+    bld.recurse('tests/' + mod, mandatory=False)
+  # Create the global libraries
+  bld(target='GP', source='', features='c cshlib', use=uses, name='libGP_st')
+  bld(target='GP', source='', features='c cstlib', use=uses, name='libGP_sh')
+
+
+def dist(ctx):
+  'Distribute current tree contents as a package.'
+  ctx.excl = ' **/.waf-* **/*~ **/*.pyc **/*.swp **/.lock-w* **/.git* **/virtualpy* **.tar.bz2'
+
+
+def gitdist(ctx):
+  'Create an archive from a fresh git HEAD checkout.'
+
+
+def gitcheck(ctx):
+  'Try to compile a fresh git HEAD checkout.'
+
+
+def gittest(ctx):
+  'Compile and test a fresh git checkout.'
+
+
+
diff --git a/wscript_lib.py b/wscript_lib.py
new file mode 100644
index 0000000..fa9c4df
--- /dev/null
+++ b/wscript_lib.py
@@ -0,0 +1,93 @@
+### GP - specific Waf library
+
+from waflib.Task import Task
+from waflib.TaskGen import extension
+from waflib.Configure import conf
+from waflib.Utils import to_list
+
+### Module library shorthand
+# Roughly the same as:
+#  sources = bld.path.ant_glob('*.c *.c.t')
+#  includes=['../../include/core', '../../include']
+#  bld(name='core_objs', source=sources, includes=includes, features='c')
+#  bld(target='GP_core', source='', use='core_objs', features='c cshlib')
+#  bld(target='GP_core', source='', use='core_objs', features='c cstlib')
+
+ at conf
+def GP_std_module(bld, name, extra_includes=[]):
+  sources = bld.path.ant_glob('*.c *.c.t')
+  includes = ['../../include/' + name, '../../include']
+  includes.extend(extra_includes)
+  objs_name = name + '_objs'
+  lib_name = 'GP_' + name
+  bld(name=objs_name, source=sources, includes=includes, features='c')
+  bld(target=lib_name, source='', use=objs_name, features='c cshlib')
+  bld(target=lib_name, source='', use=objs_name, features='c cstlib')
+
+### Template processing lib
+
+ at conf
+def template(ctx, source=[], target=[], template_ext='.t', in_src=False, **kw):
+  """
+  Task generator for Template processing. Only one of `source` and `target` need to be given.
+  Optionally create targets winthin souce tree.
+  """
+  src = to_list(source)
+  tgt = to_list(target)
+  assert len(src) + len(tgt) > 0
+  if not src:
+    src = [i.change_ext(template_ext, ext_in='') for i in tgt]
+  if not tgt:
+    tgt = [i.change_ext('', ext_in=template_ext) for i in src]
+  if len(src) != len(tgt):
+    ctx.fatal('"template" task needs the same number of sources as targets!')
+  kw.setdefault('name', 'template')
+  for s, t in zip(src, tgt):
+    if in_src:
+      t = t.get_src()
+    ctx(rule = 'PYTHONPATH=$PYTHONPATH:${PYLIBSDIR} ${PYTHON} ${TEMPLATER} -t ${TEMPLATE_DIR} ${SRC} ${TGT}',
+	source=s, target=t, color='CYAN', **kw)
+
+### Implicit .c.t -> .c rule
+
+ at extension('.c.t')
+def process_c_t(self, node):
+  self.bld.template(source = [node])
+  self.source.append(node.change_ext('', ext_in='.t'))
+
+### git[dist,check] commands
+
+from Scripting import Dist, DistCheck
+from waflib import Context, Node, Logs
+import tempfile, os, shutil
+
+class GitDist(Dist):
+  cmd = 'gitdist'
+  fun = 'gitdist'
+  ext_algo = {}
+  def execute(self):
+    self.recurse([os.path.dirname(Context.g_module.root_path)])
+    self.git_archive(self)
+
+  def git_archive(self):
+    self.base_path = self.root.find_dir(tempfile.mkdtemp())
+    Logs.info('Temporary git checkout dir: %s' % (self.base_path,))
+    try:
+      self.exec_command(['git', '--work-tree', self.base_path.abspath(), 'checkout', '-f'])
+      self.archive()
+    finally:
+      shutil.rmtree(self.base_path.abspath())
+
+class GitCheck(GitDist, DistCheck):
+  cmd = 'gitcheck'
+  fun = 'gitcheck'
+  ext_algo = {}
+  def execute(self):
+    self.recurse([os.path.dirname(Context.g_module.root_path)])
+    Logs.info('A0')
+    self.git_archive()
+    Logs.info('A1')
+    self.check()
+
+
+

http://repo.or.cz/w/gfxprim.git/commit/1d41338f4422e5f7fc5fc4b40528f1aafcc1aa9b

commit 1d41338f4422e5f7fc5fc4b40528f1aafcc1aa9b
Author: Tomas Gavenciak <gavento at ucw.cz>
Date:   Thu Aug 25 15:18:05 2011 +0200

    Waf support for libs/core, the rest is WIP

diff --git a/.gitignore b/.gitignore
index d949366..1dd2a3c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 *.pyc
 *.swp
 /.waf-*
+/.lock-waf*
 /build
diff --git a/app.mk b/app.mk
deleted file mode 100644
index 4c90884..0000000
--- a/app.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-ifndef APPS
-$(error APPS not defined, fix your library Makefile)
-endif
-
-all: $(APPS)
-
-CLEAN+=$(APPS)
-
-%: %.o
-ifdef VERBOSE
-	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $(LDLIBS) $^ -Wl,--end-group -o $@
-else
-	@echo "LD  $@"
-	@$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $(LDLIBS) $^ -Wl,--end-group -o $@
-endif
diff --git a/build/Makefile b/build/Makefile
deleted file mode 100644
index 709dd08..0000000
--- a/build/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
-LIB_OBJECTS=$(shell ./get_objs.sh)
-
-all: libGP.a libGP.so libGP.so.0
-
-clean:
-ifdef VERBOSE
-	rm -f libGP.a libGP.so libGP.so.0
-else
-	@echo "RM  libGP.a libGP.so libGP.so.0"
-	@rm -f libGP.a libGP.so libGP.so.0
-endif
-
-libGP.a:
-	@. ./liblock.sh; spinlock .
-ifdef VERBOSE
-	$(AR) rcs libGP.a $(LIB_OBJECTS)
-else
-	@echo "AR  libGP.a"
-	@$(AR) rcs libGP.a $(LIB_OBJECTS)
-endif
-	@. ./liblock.sh; spinunlock .
-
-libGP.so:
-	@. ./liblock.sh; spinlock .
-ifdef VERBOSE
-	$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,libGP.so.0 $(LIB_OBJECTS) -o libGP.so
-else
-	@echo "LD  libGP.so"
-	@$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,libGP.so.0 $(LIB_OBJECTS) -o libGP.so
-endif
-	@. ./liblock.sh; spinunlock .
-
-libGP.so.0: libGP.so
-	@. ./liblock.sh; spinlock .
-ifdef VERBOSE
-	rm -f libGP.so.0
-	ln -s libGP.so libGP.so.0
-else
-	@echo "LN  libGP.so.0"
-	@rm -f libGP.so.0
-	@ln -s libGP.so libGP.so.0
-endif
-	@. ./liblock.sh; spinunlock .
diff --git a/build/get_objs.sh b/build/get_objs.sh
deleted file mode 100755
index 834fd77..0000000
--- a/build/get_objs.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-TOPDIR=..
-LIBDIRS="core gfx text loaders filters backends input"
-
-for i in $LIBDIRS; do
-	OBJECTS=`echo $TOPDIR/libs/$i/*.o`;
-
-	if [ "$OBJECTS" != "$TOPDIR/libs/$i/*.o" ]; then
-		echo "$OBJECTS"
-	fi
-done
diff --git a/build/liblock.sh b/build/liblock.sh
deleted file mode 100644
index 2af11e4..0000000
--- a/build/liblock.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Takes directory as parameter
-#
-spinlock()
-{
-	I=0
-	#echo -n "Trying to acquire lock in '$1' ."
-	while ! `mkdir "$1/.lock" &> /dev/null`; do
-		sleep 1;
-		((I=I+1))
-		echo $I
-		if [ $I -gt 10 ]; then
-			echo "Failed to acquire lock '`pwd`/.lock'"
-			exit 1
-		fi
-	#	echo -n .
-	done
-	#echo " done"
-}
-
-spinunlock()
-{
-	#echo "Removing lock in '$1'"
-	rmdir "$1/.lock" &> /dev/null
-}
diff --git a/config.mk b/config.mk
deleted file mode 100644
index 962c414..0000000
--- a/config.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-CFLAGS+=-W -Wall -Wextra -fPIC -ggdb -O2 -std=gnu99
-CFLAGS+=-I$(TOPDIR)/include/
-LDLIBS+=-ldl
-
-# path to local module directory
-PYLIBSDIR=$(TOPDIR)/pylib
-
-# Python binary/version
-PYTHON_BIN=python
-# To test with other python versions (example):
-#PYTHON_BIN=${TOPDIR}/virtualpy2.4/bin/python
-
-# Command to run Python with pylib/ modules
-PYTHON=PYTHONPATH=$$PYTHONPATH:${PYLIBSDIR} ${PYTHON_BIN} -Werror
diff --git a/gen.mk b/gen.mk
deleted file mode 100644
index 41ad5f5..0000000
--- a/gen.mk
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# This is makefile rule for generating C sources from python generators
-#
-ifndef LIBNAME
-$(error LIBNAME not defined, fix your library Makefile)
-endif
-
-ifndef GENHEADERS
-GENHEADERS=
-endif
-
-ifndef GENSOURCES
-GENSOURCES=
-endif
-
-#
-# Headers go into include/core/
-#
-INCLUDE_PREFIX=$(TOPDIR)/include/$(LIBNAME)/
-RGENHEADERS=$(addprefix $(INCLUDE_PREFIX),$(GENHEADERS))
-
-#
-# Generate genfiles for generated sources
-#
-CSOURCES+=$(GENSOURCES)
-
-#
-# Make the genrated headers actually build
-#
-all: $(RGENHEADERS)
-$(CSOURCES): $(RGENHEADERS)
-
-#
-# Base common templates location
-#
-TEMPLATE_DIR=$(TOPDIR)/pylib/templates/
-
-#
-# ALL templates and potential generated files (not generated automatically)
-# NOTE: Currently unused
-# 
-ALL_TEMPLATES=$(shell find $(TOPDIR) -name '*.t')
-ALL_GENERATED=$(basename $(ALL_TEMPLATES))
-
-#
-# And clean them
-#
-CLEAN+=$(GENSOURCES) $(RGENHEADERS)
-
-#
-# Generated files depend on python generators and the template
-#
-$(GENSOURCES) $(RGENHEADERS): %: %.t $(PYTHON_FILES)
-ifdef VERBOSE
-	${PYTHON} ${TOPDIR}/pylib/bin/generate_file.py -t $(TEMPLATE_DIR) "$@.t" "$@"
-else
-	@echo "GEN  $@"
-	@${PYTHON} ${TOPDIR}/pylib/bin/generate_file.py -t $(TEMPLATE_DIR) "$@.t" "$@"
-endif
-
diff --git a/include.mk b/include.mk
deleted file mode 100644
index c8f8b18..0000000
--- a/include.mk
+++ /dev/null
@@ -1,113 +0,0 @@
-#
-# Make no subdirs by default
-#
-ifndef SUBDIRS
-SUBDIRS=
-endif
-
-.PHONY: $(SUBDIRS) all clean help
-
-all: $(SUBDIRS)
-clean: $(SUBDIRS)
-
-help:
-	@echo "***      Available targets      ***"
-	@echo ""
-	@echo "help: prints this help"
-	@echo ""
-	@echo "clean: cleans current directory and all subdirectories"
-	@echo ""
-	@echo "all:   make current directory and all subdirectories"
-	@echo ""
-	@echo "The default silent output could be turned off by defining"
-	@echo "'VERBOSE' shell variable as 'VERBOSE=1 make'"
-	@echo ""
-
-include $(TOPDIR)/config.mk
-
-#
-# Determine mode (eg do not generate anything if not in compile mode
-#
-COMPILE=no
-
-ifeq ($(MAKECMDGOALS),all)
-COMPILE=yes
-endif
-
-ifeq ($(MAKECMDGOALS),)
-COMPILE=yes
-endif
-
-#
-# Potential python dependencies for generated files and scripts
-#
-PYTHON_FILES=$(shell find "${PYLIBSDIR}" -name '*.py')
-
-#
-# 1. Generate and include dependencies for all C sources
-# 2. Generate OBJECTS list from CSOURCES list
-# 3. Adds OBJECTS to CLEAN list
-#
-ifdef CSOURCES
-DEPFILES=$(subst .c,.dep,$(CSOURCES))
-ifeq ($(COMPILE),yes)
--include $(DEPFILES)
-endif
-CLEAN+=$(subst .c,.dep,$(CSOURCES))
-OBJECTS=$(CSOURCES:.c=.o)
-CLEAN+=$(OBJECTS)
-endif
-
-#
-# Automatically include library headers
-#
-ifdef LIBNAME
-INCLUDE+=$(LIBNAME)
-endif
-
-#
-# If there was anything in INCLUDE list, create CFLAGS for each entry
-#
-ifdef INCLUDE
-CFLAGS+=$(addprefix -I$(TOPDIR)/include/, $(INCLUDE))
-endif
-
-#
-# Walk trought SUBDIRS, this code works even for -jX
-#
-$(SUBDIRS):
-ifdef VERBOSE
-	$(MAKE) -C $@ $(MAKECMDGOALS)
-else
-	@export CURSUBDIR="$$CURSUBDIR/$@" && echo "DIR $$CURSUBDIR" &&-	$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS)
-endif
-
-#
-# Actual make rules
-#
-$(DEPFILES): %.dep: %.c
-ifdef VERBOSE
-	$(CC) -MM $(CFLAGS) $< -o $@
-else
-	@echo "DEP -I(include $(INCLUDE)) $@"
-	@$(CC) -MM $(CFLAGS) $< -o $@
-endif
-
-$(OBJECTS): %.o: %.c
-ifdef VERBOSE
-	$(CC) $(CFLAGS) -c $< -o $@
-else
-	@echo "CC  -I(include $(INCLUDE)) $@"
-	@$(CC) $(CFLAGS) -c $< -o $@
-endif
-
-ifdef CLEAN
-clean:
-ifdef VERBOSE
-	rm -f $(CLEAN)
-else
-	@echo "RM  $(CLEAN)"
-	@rm -f $(CLEAN)
-endif
-endif
diff --git a/install.sh b/install.sh
deleted file mode 100755
index ee5403f..0000000
--- a/install.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-INSTALL_PREFIX="$1"
-
-HEADER_LOC="$INSTALL_PREFIX/usr/include/"
-LIB_LOC="$INSTALL_PREFIX/usr/lib/"
-
-# Headers
-echo "INSTALL headers"
-install -m 775 -d "${HEADER_LOC}GP"
-for i in `ls include/`; do
-	if [ -d "include/$i" ]; then
-		echo " $i"
-		install -m 775 -d "${HEADER_LOC}GP/$i"
-		install -m 664 "include/$i/"*.h "${HEADER_LOC}GP/$i"
-	else
-		install -m 664 "include/$i" "${HEADER_LOC}GP/$i"
-	fi
-done
-
-# Library
-echo "INSTALL libraries"
-install -m 775 -d "$LIB_LOC" 
-install -m 664 build/*.so build/*.so.0 build/*.a "$LIB_LOC"
diff --git a/lib.mk b/lib.mk
deleted file mode 100644
index 397515a..0000000
--- a/lib.mk
+++ /dev/null
@@ -1,48 +0,0 @@
-ifndef LIBNAME
-$(error LIBNAME not defined, fix your library Makefile)
-endif
-
-LIB=libGP_$(LIBNAME)
-LIBP=$(TOPDIR)/build/
-
-#
-# If set to yes, builds single library for directory
-#
-ifeq ($(BUILDLIB),yes)
-all: $(LIBP)$(LIB).so $(LIBP)$(LIB).a
-endif
-
-ifeq ($(BUILDLIB),yes)
-CLEAN+=$(LIBP)$(LIB).so $(LIBP)$(LIB).so.0 $(LIBP)$(LIB).a
-endif
-
-#
-# Trigger libGP.XX library rebuild
-#
-all: $(OBJECTS)
-	@$(MAKE) --no-print-directory -C $(TOPDIR)/build/
-
-#
-# Rules for single library
-#
-$(LIBP)$(LIB).so: $(OBJECTS)
-ifdef VERBOSE
-	rm -f $(LIBP)$(LIB).so.0
-	cd $(LIBP) && ln -s $(LIB).so $(LIB).so.0
-	$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(LIB).so.0 $(OBJECTS) -o $@
-else
-	@rm -f $(LIBP)$(LIB).so.0
-	@cd $(LIBP) && ln -s $(LIB).so $(LIB).so.0
-	@echo "LD  $@"
-	@$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(LIB).so.0 $(OBJECTS) -o $@
-endif
-
-$(LIBP)$(LIB).a: $(OBJECTS)
-ifdef VERBOSE
-	$(AR) rcs $@ $(OBJECTS)
-else
-	@echo "AR  $@"
-	@$(AR) rcs $@ $(OBJECTS)
-endif
-
-CLEAN+=$(OBJECTS)
diff --git a/libs/core/Makefile b/libs/core/Makefile
deleted file mode 100644
index b8c7cf7..0000000
--- a/libs/core/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-TOPDIR=../..
-GENSOURCES=GP_Pixel.gen.c GP_Blit.gen.c GP_Convert.gen.c
-GENHEADERS=GP_Convert_Scale.gen.h GP_Blit.gen.h GP_Pixel.gen.h GP_GetPutPixel.gen.h GP_Convert.gen.h
-CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
-LIBNAME=core
-
-include $(TOPDIR)/gen.mk
-include $(TOPDIR)/include.mk
-include $(TOPDIR)/lib.mk
diff --git a/libs/core/wscript b/libs/core/wscript
new file mode 100644
index 0000000..d10daa6
--- /dev/null
+++ b/libs/core/wscript
@@ -0,0 +1,9 @@
+#! /usr/bin/env python
+
+def build(bld):
+  sources = bld.path.ant_glob('*.c *.c.t')
+  includes=['../../include/core', '../../include']
+  bld(name='core_objs', source=sources, includes=includes, features='c')
+  bld(target='GP_core', source='', use='core_objs', features='c cshlib')
+  bld(target='GP_core', source='', use='core_objs', features='c cstlib')
+
diff --git a/waf-1.6.7.py b/pylib/waf-1.6.7.py
similarity index 100%
rename from waf-1.6.7.py
rename to pylib/waf-1.6.7.py
diff --git a/tests.mk b/tests.mk
deleted file mode 100644
index 39f0835..0000000
--- a/tests.mk
+++ /dev/null
@@ -1,55 +0,0 @@
-.PHONY: tests runtests
-
-#
-# List of test targets (testsuite incl. automatically)
-#
-ifndef TESTS
-TESTS=
-endif
-
-#
-# Testsuite with automated collection of tests
-# All .test.c files are scraped for GP_TEST definitions
-#
-
-ifdef TESTSUITE
-# a bit crude way to link with test minilibrary 
-GP_TESTLIB_SRCS=$(wildcard ${TOPDIR}/tests/common/*.c)
-CSOURCES+=${GP_TESTLIB_SRCS}
-
-# generated suite creation code
-TESTSUITE_GEN=collected_tests.gen.c # also fixed in the code generator
-CLEAN+=${TESTSUITE_GEN}
-
-${TESTSUITE_GEN}: $(filter-out ${TESTSUITE_GEN},${GENSOURCES}) ${GENHEADERS}
-ifdef VERBOSE
-	${PYTHON} ${TOPDIR}/pylib/bin/generate_collected_tests.py -t $(TEMPLATE_DIR) "." "$@"
-else
-	@echo "TSTS $@"
-	@${PYTHON} ${TOPDIR}/pylib/bin/generate_collected_tests.py -t $(TEMPLATE_DIR) "." "$@"
-endif
-
-
-TESTSUITE_SRCS=$(wildcard *.test.c) ${GENSOURCES} ${GENHEADERS} ${GP_TESTLIB_SRCS} ${TESTSUITE_GEN}
-INCLUDE+=../tests/common
-TESTSUITE_OBJS=$(patsubst %.c,%.o,$(TESTSUITE_SRCS))
-CLEAN+=${TESTSUITE} ${TESTSUITE_OBJS}
-TESTS+=${TESTSUITE}
-
-${TESTSUITE}: ${TESTSUITE_OBJS}
-ifdef VERBOSE
-	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $(LDLIBS) $^ -Wl,--end-group -o $@
-else
-	@echo "LD  $@"
-	@$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $(LDLIBS) $^ -Wl,--end-group -o $@
-endif # VERBOSE
-
-endif # TESTSUITE
-
-tests: $(TESTS)
-
-runtests: tests
-	for test in $(TESTS); do LD_LIBRARY_PATH=../../build ./"$$test"; done
-
-# WARN: avoid double includion?
-include $(TOPDIR)/gen.mk
diff --git a/tests/core/wscript b/tests/core/wscript
new file mode 100644
index 0000000..9995a96
--- /dev/null
+++ b/tests/core/wscript
@@ -0,0 +1,4 @@
+#! /usr/bin/env python
+
+def build(bld):
+  pass
diff --git a/waf b/waf
index e6711aa..317b501 120000
--- a/waf
+++ b/waf
@@ -1 +1 @@
-waf-1.6.7.py
 No newline at end of file
+pylib/waf-1.6.7.py
 No newline at end of file
diff --git a/wscript b/wscript
index cb76681..caef639 100644
--- a/wscript
+++ b/wscript
@@ -1,25 +1,83 @@
 #! /usr/bin/env python
 # encoding: utf-8
 
+# Useful ENV params:
+#  PYTHON - python executable
+#  CC - gcc-like compiler
+#  CFLAGS - Additional C flags
+
+
 import datetime
+from Utils import subst_vars
 
 top = '.'
 out = 'build'
+
 APPNAME = 'gfxprim'
 VERSION = 'dev-' + datetime.datetime.utcnow().strftime("%Y%m%d%H%M")
 
 
-def options(opts):
-  pass
+def options(opt):
+  opt.load('compiler_c python')
 
 
-def configure(ctx):
-  pass
+def configure(cnf):
+  # Finds tools, sets basic options, reads CFLAGS from ENV, ...
+  cnf.load('compiler_c python')
+  cnf.check_python_version((2,4))
+  # NOTE: remove/modify if jinja2 bundled with lib
+  cnf.check_python_module('jinja2')
+  # Set CFLAGS
+  cnf.env.prepend_value('CFLAGS', ['-W', '-Wall', '-Wextra', '-fPIC', '-ggdb',
+                                   '-O2', '-std=gnu99'])
+  #LDLIBS+=-ldl
+  # Set-up code generator options
+  cnf.env['TEMPLATE_DIR'] = cnf.path.find_node('pylib/templates').abspath()
+  cnf.env['TEMPLATER'] = cnf.path.find_node('/pylib/bin/generate_file.py').abspath()
+  cnf.env['PYLIBSDIR'] = cnf.path.find_node('pylib').abspath()
 
 
 def dist(ctx):
-  ctx.excl = ' **/.waf-* **/*~ **/*.pyc **/*.swp **/.lock-w*'
+  ctx.excl = ' **/.waf-* **/*~ **/*.pyc **/*.swp **/.lock-w* **/.git* **/virtualpy* **.tar.bz2'
+
+
+def build(bld):
+  # Generate all generated headers, regardless of the module
+  include = bld.path.find_node('include')
+  bld.template(source=include.ant_glob('**/*.h.t'))
+  # Recurse on modules
+  bld.recurse('libs/core')
+  bld.recurse('tests/core')
+
+
+
+### Template processing lib
+
+from waflib.Task import Task
+from waflib.TaskGen import extension
+from waflib.Configure import conf
+from waflib.Utils import to_list
+
+ at conf
+def template(ctx, source=[], target=[], template_ext='.t', **kw):
+  "Task generator for Template processing. Only one of `source` and `target` need to be given."
+  src = to_list(source)
+  tgt = to_list(target)
+  assert len(src) + len(tgt) > 0
+  if not src:
+    src = [i.change_ext(template_ext, ext_in='') for i in tgt]
+  if not tgt:
+    tgt = [i.change_ext('', ext_in=template_ext) for i in src]
+  if len(src) != len(tgt):
+    ctx.fatal('"template" task needs the same number of sources as targets!')
+  kw.setdefault('name', 'template')
+  for s, t in zip(src, tgt):
+    ctx(rule = 'PYTHONPATH=$PYTHONPATH:${PYLIBSDIR} ${PYTHON} ${TEMPLATER} -t ${TEMPLATE_DIR} ${SRC} ${TGT}',
+	source=s, target=t, color='CYAN', **kw)
 
+# Implicit .c.t -> .c rule
 
-def build(ctx):
-  pass
+ at extension('.c.t')
+def process_c_t(self, node):
+  self.bld.template(source = [node])
+  self.source.append(node.change_ext('', ext_in='.t'))

http://repo.or.cz/w/gfxprim.git/commit/8a83be73956286ed70b13d97abf326078b50e933

commit 8a83be73956286ed70b13d97abf326078b50e933
Author: Tomas Gavenciak <gavento at ucw.cz>
Date:   Wed Aug 24 21:05:43 2011 +0200

    Initial waf support and configuration

diff --git a/.gitignore b/.gitignore
index 1d500c6..d949366 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,4 @@
-*.o
-*.dep
 *.pyc
-*.gen.c
-*.gen.h
 *.swp
-libGP.so*
-libGP.a
-
+/.waf-*
+/build
diff --git a/waf b/waf
new file mode 120000
index 0000000..e6711aa
--- /dev/null
+++ b/waf
@@ -0,0 +1 @@
+waf-1.6.7.py
 No newline at end of file
diff --git a/waf-1.6.7.py b/waf-1.6.7.py
new file mode 100755
index 0000000..f7c97d6
Binary files /dev/null and b/waf-1.6.7.py differ
diff --git a/wscript b/wscript
new file mode 100644
index 0000000..cb76681
--- /dev/null
+++ b/wscript
@@ -0,0 +1,25 @@
+#! /usr/bin/env python
+# encoding: utf-8
+
+import datetime
+
+top = '.'
+out = 'build'
+APPNAME = 'gfxprim'
+VERSION = 'dev-' + datetime.datetime.utcnow().strftime("%Y%m%d%H%M")
+
+
+def options(opts):
+  pass
+
+
+def configure(ctx):
+  pass
+
+
+def dist(ctx):
+  ctx.excl = ' **/.waf-* **/*~ **/*.pyc **/*.swp **/.lock-w*'
+
+
+def build(ctx):
+  pass

http://repo.or.cz/w/gfxprim.git/commit/97c40ce239774949579fd67651f5a602c22c69a8

commit 97c40ce239774949579fd67651f5a602c22c69a8
Merge: a5fc0cc ce1f7e6
Author: Tomas Gavenciak <gavento at ucw.cz>
Date:   Mon Aug 22 11:45:10 2011 +0200

    Merge branch 'generate' of git://repo.or.cz/gfxprim into generate
    
    Conflicts:
    	pylib/templates/collected_tests.c.t


http://repo.or.cz/w/gfxprim.git/commit/a5fc0ccc8cd3f3204849a41f497c6f1c91adb787

commit a5fc0ccc8cd3f3204849a41f497c6f1c91adb787
Author: Tomas Gavenciak <gavento at ucw.cz>
Date:   Thu Aug 18 21:01:26 2011 +0200

    Remove a warning from pixel print

diff --git a/libs/core/GP_Pixel.gen.c.t b/libs/core/GP_Pixel.gen.c.t
index e0cf7c0..6f10425 100644
--- a/libs/core/GP_Pixel.gen.c.t
+++ b/libs/core/GP_Pixel.gen.c.t
@@ -37,7 +37,7 @@ const GP_PixelTypeDescription const GP_PixelTypes [] = {
 void GP_PixelSNPrint_{{ pt.name }}(char *buf, size_t len, GP_Pixel p)
 {
 	snprintf(buf, len, "<{{ pt.name }} 0x%0{{ (pt.pixelsize.size+3)//4 }}x{% for c in pt.chanslist %} {{ c[0] }}=%d{% endfor %}>",
-	GP_GET_BITS(0, {{ pt.pixelsize.size }}, p){% for c in pt.chanslist %}, GP_GET_BITS({{ c[1] }}, {{ c[2] }}, p){% endfor %});
+		GP_GET_BITS_CHECK(0, {{ pt.pixelsize.size }}, p){% for c in pt.chanslist %}, GP_GET_BITS_CHECK({{ c[1] }}, {{ c[2] }}, p){% endfor %});
 }
 
 %% endif

http://repo.or.cz/w/gfxprim.git/commit/e5756d9af1c5b495e136743368f7d36d6e181d98

commit e5756d9af1c5b495e136743368f7d36d6e181d98
Author: Tomas Gavenciak <gavento at ucw.cz>
Date:   Thu Aug 18 21:00:53 2011 +0200

    Remove stray template comment.

diff --git a/pylib/templates/collected_tests.c.t b/pylib/templates/collected_tests.c.t
index cd24232..f3ae6f5 100644
--- a/pylib/templates/collected_tests.c.t
+++ b/pylib/templates/collected_tests.c.t
@@ -21,7 +21,7 @@ Code creating the tests and suites for tests collected from .test.c files.
 
 void GP_TEST_{{ t['name'] }}(int);
 
-## TODO: Handle special test requirements (timing, fixture, ...)
+{# TODO: Handle special test requirements (timing, fixture, ...) -#}
 TCase *GP_TC_{{ suite }}_{{ t['name'] }}()
 {
 	TCase *tc = tcase_create("{{ t['name'] }}");

http://repo.or.cz/w/gfxprim.git/commit/4be94324decaaa508300a371010aa46537d33111

commit 4be94324decaaa508300a371010aa46537d33111
Author: Tomas Gavenciak <gavento at ucw.cz>
Date:   Thu Aug 18 20:54:09 2011 +0200

    Add CHECK variants of SET/GET_BITS

diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h
index 23e5527..ac2bf3c 100644
--- a/include/core/GP_Common.h
+++ b/include/core/GP_Common.h
@@ -150,11 +150,18 @@
 	( ( (val)>>(offset) ) & ( ((((typeof(val))1)<<(count)) - 1) ) )
 
 /*
- * Debugging version, evaluates args twice.
+ * Variant with checks for overflow and special case avoiding
+ * overflow warnings.
+ * The check may be slow, but should be optimized away for constant
+ * offset and count.
  */
-#define GP_GET_BITS_DBG(offset, count, val) -	( printf("GET_BITS(%d, %d, 0x%x)=%d", offset, count, val, -	GP_GET_BITS(offset, count, val)), GP_GET_BITS(offset, count, val))
+#define GP_GET_BITS_CHECK(offset, count, val) ({ +	GP_CHECK(sizeof(val) * 8 <= (count) + (offset)); +	GP_CHECK((count) > 0); +	GP_CHECK((offset) >= 0); +	(((offset) == 0) && (sizeof(val) * 8 == (count))) ? (val) : +		GP_GET_BITS((offset), (count), (val)); +	})
 
 /*
  * Set count bits of dest at ofset to val (shifted by offset)
@@ -177,6 +184,20 @@
 		GP_SET_BITS_OR(offset, dest, val);  } while (0)
 
+/*
+ * Variant with checks for overflow and special cases (avoiding
+ * overflow warnings etc.).
+ * The check may be slow, but should be optimized away for constant
+ * offset and count.
+ */
+#define GP_SET_BITS_CHECK(offset, count, dest, val) do { +	GP_CHECK(sizeof(dest) * 8 <= (count) + (offset)); +	GP_CHECK((count) > 0); +	GP_CHECK((offset) >= 0); +	if (((offset) == 0) && (sizeof(dest) * 8 == (count))) (dest) = (val); +	else GP_SET_BITS((offset), (count), (dest), (val)); +	} while (0)
+
 /* 
  * Debugging version, evaluates args twice.
  */

-----------------------------------------------------------------------


repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos at gmail.com
if you want to unsubscribe, or site admin admin at repo.or.cz if you receive
no reply.
-- 
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")



More information about the Gfxprim mailing list