diff wscript @ 16:927f2cf75357

Changed build system from SCons to WAF. * WAF is an old fork of SCons that is now for all intents and purposes a different build system. * Unlike SCons which requires a system install of the scons library to work, the entire WAF library is self-contained in a single 'waf' Python script provided with PARPG. * Build instructions are a little different from SCons - execute the local 'waf' script with the arguments 'configure install'. * To make a local install for testing, add the '--destdir=<directory>' option to make all files install under <directory> as a fake root (e.g. '--destdir=dev_install' would make WAF install all files under the 'dev_install' directory in the PARPG source). * Added a waf_paths.py WAF tool to set GNU-compatible installation path variables (i.e. PREFIX, EXEC_PREFIX, LIBDIR, etc.). These variables should be initialized to sane defaults on Windows, where GNU standards don't usually apply.
author M. George Hansen <technopolitica@gmail.com>
date Thu, 09 Jun 2011 21:35:19 -1000
parents
children 2e2d6d9009a3
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wscript	Thu Jun 09 21:35:19 2011 -1000
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+# encoding: utf-8
+import sys
+import os
+
+APPNAME = 'parpg'
+VERSION = '0.2.0'
+
+def options(opt):
+    opt.load('waf_paths python')
+
+def configure(cnf):
+    cnf.load('waf_paths python')
+    if sys.platform == 'Windows':
+        min_python_version = (2, 7)
+    else:
+        min_python_version = (2, 6)
+    cnf.check_python_version(min_python_version)
+
+def build(bld):
+    subst_vars = _get_subst_vars(bld)
+    
+    if sys.platform == 'Windows':
+        launcher_template = 'bin/parpg.bat.in'
+        launcher = 'parpg.bat'
+    else:
+        launcher_template = 'bin/parpg.sh.in'
+        launcher = 'parpg'
+    args = dict(
+        features='subst',
+        source=launcher_template,
+        target=launcher,
+        install_path='${BINDIR}',
+        chmod=0755,
+    )
+    args.update(subst_vars)
+    bld(**args)
+    
+    bld(
+        features='py',
+        source=bld.path.ant_glob('src/parpg/**/*.py', dir=True),
+        install_from='src',
+    )
+    
+    args = dict(
+        features='subst',
+        source='parpg.cfg.in',
+        target='parpg.cfg',
+        install_path='${SYSCONFDIR}',
+        chmod=0644,
+    )
+    args.update(subst_vars)
+    bld(**args)
+    
+    bld.install_files(
+        files=bld.path.find_node('data').ant_glob('**/*'),
+        dest='${DATADIR}',
+        relative_trick=True,
+        chmod=0644,
+    )
+
+def _get_subst_vars(cnf):
+    # Set up substitution variables for the launcher and configuration files.
+    subst_vars = {}
+    install_path_names = cnf.env['INSTALL_PATHS']
+    for path_name in install_path_names + ['PYTHONDIR']:
+        subst_vars[path_name] = cnf.env[path_name]
+    # If the destdir option is used we'll have to manually prefix any path
+    # variables with it since env doesn't get updated.
+    # NOTE M. George Hansen 2011-06-09: This should probably be done
+    #     automatically. Maybe we should patch WAF and contribute it the WAF
+    #     project.
+    destdir = cnf.options.destdir
+    if destdir:
+        for key, path in subst_vars.items():
+            # If this is an absolute path, prefix it with the destdir.
+            if os.path.isabs(path):
+                subst_vars[key] = os.path.join(
+                    destdir,
+                    os.path.splitdrive(path)[1].lstrip('/\\'),
+                )
+    return subst_vars
\ No newline at end of file