From e8d50fa4586675bb280be98812e5d028d65dbb5f Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Thu, 31 Jul 2008 11:37:54 +0100 Subject: [PATCH] Changes for the new waf (trunk). --- pybindgen/wscript | 6 +++--- tests/c-hello/wscript | 21 ++++++++++----------- tests/wscript | 41 ++++++++++++++++++----------------------- wscript | 40 ++++++++++++++++++---------------------- 4 files changed, 49 insertions(+), 59 deletions(-) diff --git a/pybindgen/wscript b/pybindgen/wscript index 0e6814c..708c461 100644 --- a/pybindgen/wscript +++ b/pybindgen/wscript @@ -2,18 +2,18 @@ def build(bld): - obj = bld.create_obj('py') + obj = bld.new_task_gen('py') obj.find_sources_in_dirs('.') obj.source.append('version.py') obj.inst_dir = 'pybindgen' obj.prio = 50 - obj = bld.create_obj('py') + obj = bld.new_task_gen('py') obj.find_sources_in_dirs('typehandlers') obj.inst_dir = 'pybindgen/typehandlers' obj.prio = 50 - obj = bld.create_obj('py') + obj = bld.new_task_gen('py') obj.find_sources_in_dirs('typehandlers/ctypeparser') obj.inst_dir = 'pybindgen/typehandlers/ctypeparser' obj.prio = 50 diff --git a/tests/c-hello/wscript b/tests/c-hello/wscript index 7ede17d..b55f01b 100644 --- a/tests/c-hello/wscript +++ b/tests/c-hello/wscript @@ -1,23 +1,21 @@ ## -*- python -*- -import Action -import Object -import Params -import Task +#import Action +#import Object +#import Params +#import Task def create_pyext_obj(bld, c_or_cpp_type): - waf_version = [int (s) for s in Params.g_version.split('.')] - if waf_version >= [1,4]: - return bld.create_obj(c_or_cpp_type, 'shlib', 'pyext') - else: - return bld.create_obj(c_or_cpp_type, 'plugin', 'pyext') + return bld.new_task_gen(c_or_cpp_type, 'shlib', 'pyext') def build(bld): - if not bld.env()['ENABLE_PYGCCXML']: + if not bld.env['ENABLE_PYGCCXML']: print "gccxml not available; skipping the C hello demo" return - bindgen = bld.create_obj('command-output') + bld.add_group() + + bindgen = bld.new_task_gen('command-output') bindgen.stdout = 'hellomodule.c' bindgen.argv = [bindgen.input_file('hellomodulegen.py'), bindgen.input_file('hello.h')] @@ -25,6 +23,7 @@ def build(bld): bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../../pybindgen + bld.add_group() obj = create_pyext_obj(bld, 'cc') obj.source = [ 'hello.c', diff --git a/tests/wscript b/tests/wscript index f356c96..afcb2dc 100644 --- a/tests/wscript +++ b/tests/wscript @@ -1,7 +1,7 @@ ## -*- python -*- -import Action -import Object -import Params +#import Action +#import Object +#import Params import Task import sys @@ -11,12 +11,7 @@ import pproc as subprocess def create_pyext_obj(bld, c_or_cpp_type): - waf_version = [int (s) for s in Params.g_version.split('.')] - if waf_version >= [1,4]: - return bld.create_obj(c_or_cpp_type, 'shlib', 'pyext') - else: - return bld.create_obj(c_or_cpp_type, 'plugin', 'pyext') - + return bld.new_task_gen(c_or_cpp_type, 'shlib', 'pyext') if 1: DEPRECATION_ERRORS = '-Werror::DeprecationWarning' # deprecations become errors @@ -25,23 +20,23 @@ else: def build(bld): - top_srcdir = bld.m_srcnode.abspath() + top_srcdir = bld.srcnode.abspath() - gen = bld.create_obj('command-output') + gen = bld.new_task_gen('command-output') gen.command = 'test-generation.py' gen.stdout = 'test.cc' gen.argv = [gen.input_file('test-generation.py'), top_srcdir] - gen.command = bld.env()['PYTHON'] + gen.command = bld.env['PYTHON'] gen.command_is_external = True gen.prio = 55 - obj = bld.create_obj('cpp', 'objects', 'pyext') + obj = bld.new_task_gen('cxx', 'objects', 'pyext') obj.source = 'test.cc' if os.path.basename(obj.env['CXX']).startswith("g++"): obj.env.append_value('CXXFLAGS', ['-Werror', '-Wno-unused']) ## manual code generation using simple pybindgen API calls - bindgen = bld.create_obj('command-output') + bindgen = bld.new_task_gen('command-output') bindgen.stdout = 'foomodule.cc' bindgen.argv = [ DEPRECATION_ERRORS, @@ -51,7 +46,7 @@ def build(bld): bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen - obj = create_pyext_obj(bld, 'cpp') + obj = create_pyext_obj(bld, 'cxx') obj.source = [ 'foo.cc', 'foomodule.cc' @@ -61,9 +56,9 @@ def build(bld): obj.includes = '.' ## automatic code scanning using gccxml - if bld.env()['ENABLE_PYGCCXML']: + if bld.env['ENABLE_PYGCCXML']: ### Same thing, but using gccxml autoscanning - bindgen = bld.create_obj('command-output') + bindgen = bld.new_task_gen('command-output') bindgen.stdout = 'foomodule2.cc' bindgen.argv = [ DEPRECATION_ERRORS, @@ -76,7 +71,7 @@ def build(bld): bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen ### Now using the generated python script - bindgen = bld.create_obj('command-output') + bindgen = bld.new_task_gen('command-output') bindgen.stdout = 'foomodule3.cc' bindgen.argv = [ DEPRECATION_ERRORS, @@ -91,7 +86,7 @@ def build(bld): ## TODO: add WAF command-output support for customising command OS environment os.environ["PYTHONPATH"] = os.pathsep.join([os.environ.get("PYTHONPATH", ''), bindgen.path.abspath(bindgen.env)]) - obj = create_pyext_obj(bld, 'cpp') + obj = create_pyext_obj(bld, 'cxx') obj.source = [ 'foo.cc', 'foomodule3.cc' @@ -103,7 +98,7 @@ def build(bld): ## --- ### using gccxml autoscanning, but split the generated python script into modules - bindgen = bld.create_obj('command-output') + bindgen = bld.new_task_gen('command-output') bindgen.argv = [ DEPRECATION_ERRORS, bindgen.input_file('foomodulegen-auto-split.py'), @@ -116,7 +111,7 @@ def build(bld): bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen - obj = create_pyext_obj(bld, 'cpp') + obj = create_pyext_obj(bld, 'cxx') obj.source = [ 'foo.cc', 'foomodule2.cc' @@ -126,7 +121,7 @@ def build(bld): obj.includes = '.' ### Run the generated python script with split modules - bindgen = bld.create_obj('command-output') + bindgen = bld.new_task_gen('command-output') bindgen.argv = [ DEPRECATION_ERRORS, bindgen.input_file('foomodulegen4.py'), @@ -146,7 +141,7 @@ def build(bld): 'foomodulegen_module2.cc', ] - obj = create_pyext_obj(bld, 'cpp') + obj = create_pyext_obj(bld, 'cxx') obj.source = [ 'foo.cc', 'foomodule4.cc', diff --git a/wscript b/wscript index dc5e7b3..31cfaee 100644 --- a/wscript +++ b/wscript @@ -1,10 +1,11 @@ ## -*- python -*- ## (C) 2007,2008 Gustavo J. A. M. Carneiro -import Params -Params.g_autoconfig = True +import Options +#Params.g_autoconfig = True +import Logs +#from Params import fatal -from Params import fatal import os import pproc as subprocess import shutil @@ -14,14 +15,7 @@ import tarfile ## Add the pybindgen dir to PYTHONPATH, so that the examples and tests are properly built before pybindgen is installed. -waf_version = [int (s) for s in Params.g_version.split('.')] -if waf_version >= [1,4,1]: - ## Since WAF 1.4.1, WAF does not byte-compile python files during - ## build, so we add the source dir instead of the build dir. - os.environ['PYTHONPATH'] = os.getcwd() -else: - os.environ['PYTHONPATH'] = os.path.join(os.getcwd(), 'build', 'default') -del waf_version +os.environ['PYTHONPATH'] = os.getcwd() _version = None @@ -110,7 +104,7 @@ def dist_hook(): ## Package the api docs in a separate tarball apidocs = 'apidocs' if not os.path.isdir('apidocs'): - Params.warning("Not creating apidocs archive: the `apidocs' directory does not exist") + Logs.warning("Not creating apidocs archive: the `apidocs' directory does not exist") else: tar = tarfile.open(os.path.join("..", "pybindgen-%s-apidocs.tar.bz2" % version), 'w:bz2') tar.add('apidocs', "pybindgen-%s-apidocs" % version) @@ -152,7 +146,7 @@ def configure(conf): conf.check_tool('compiler_cxx') if os.path.basename(conf.env['CXX']).startswith("g++"): conf.env.append_value('CXXFLAGS', ['-Wall', '-fno-strict-aliasing']) - if Params.g_options.debug_level == 'ultradebug': + if Options.options.debug_level == 'ultradebug': conf.env.append_value('CXXFLAGS', ['-Wextra']) conf.check_tool('python') conf.check_python_version((2,3)) @@ -171,22 +165,22 @@ def configure(conf): def build(bld): - if getattr(Params.g_options, 'generate_version', False): + if getattr(Options.options, 'generate_version', False): generate_version_py(force=True) bld.add_subdirs('pybindgen') - if Params.g_options.examples: + if Options.options.examples: bld.add_subdirs('examples') - if Params.g_commands['check'] or Params.g_commands['clean']: + if Options.commands['check'] or Options.commands['clean']: bld.add_subdirs('tests') def shutdown(): - if Params.g_commands['check']: + if Options.commands['check']: print "Running pure python unit tests..." - retval1 = subprocess.Popen([Params.g_build.env()['PYTHON'], 'tests/test.py']).wait() + retval1 = subprocess.Popen([Build.bld.env()['PYTHON'], 'tests/test.py']).wait() - env = Params.g_build.env() + env = Build.bld.env() print "Running manual module generation unit tests (module foo)..." retval2 = subprocess.Popen([env['PYTHON'], 'tests/footest.py', '1']).wait() @@ -208,9 +202,10 @@ def shutdown(): retval3 = retval3b = retval3c = retval4 = 0 if retval1 or retval2 or retval3 or retval3b or retval3c or retval4: - raise Params.fatal("Unit test failures") + Logs.error("Unit test failures") + raise SystemExit(2) - if Params.g_options.generate_api_docs: + if Options.options.generate_api_docs: generate_version_py(force=True) retval = subprocess.Popen(["epydoc", "-v", "--html", "--graph=all", "pybindgen", "-o", "apidocs", @@ -220,7 +215,8 @@ def shutdown(): "--no-private", ]).wait() if retval: - raise Params.fatal("epydoc returned with code %i" % retval) + Logs.error("epydoc returned with code %i" % retval) + raise SystemExit(2) # Patch the generated CSS file to highlight literal blocks (this is a copy of pre.py-doctest) css = open("apidocs/epydoc.css", "at")