comparison 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
comparison
equal deleted inserted replaced
14:6ff6a2f74f1e 16:927f2cf75357
1 #!/usr/bin/env python
2 # encoding: utf-8
3 import sys
4 import os
5
6 APPNAME = 'parpg'
7 VERSION = '0.2.0'
8
9 def options(opt):
10 opt.load('waf_paths python')
11
12 def configure(cnf):
13 cnf.load('waf_paths python')
14 if sys.platform == 'Windows':
15 min_python_version = (2, 7)
16 else:
17 min_python_version = (2, 6)
18 cnf.check_python_version(min_python_version)
19
20 def build(bld):
21 subst_vars = _get_subst_vars(bld)
22
23 if sys.platform == 'Windows':
24 launcher_template = 'bin/parpg.bat.in'
25 launcher = 'parpg.bat'
26 else:
27 launcher_template = 'bin/parpg.sh.in'
28 launcher = 'parpg'
29 args = dict(
30 features='subst',
31 source=launcher_template,
32 target=launcher,
33 install_path='${BINDIR}',
34 chmod=0755,
35 )
36 args.update(subst_vars)
37 bld(**args)
38
39 bld(
40 features='py',
41 source=bld.path.ant_glob('src/parpg/**/*.py', dir=True),
42 install_from='src',
43 )
44
45 args = dict(
46 features='subst',
47 source='parpg.cfg.in',
48 target='parpg.cfg',
49 install_path='${SYSCONFDIR}',
50 chmod=0644,
51 )
52 args.update(subst_vars)
53 bld(**args)
54
55 bld.install_files(
56 files=bld.path.find_node('data').ant_glob('**/*'),
57 dest='${DATADIR}',
58 relative_trick=True,
59 chmod=0644,
60 )
61
62 def _get_subst_vars(cnf):
63 # Set up substitution variables for the launcher and configuration files.
64 subst_vars = {}
65 install_path_names = cnf.env['INSTALL_PATHS']
66 for path_name in install_path_names + ['PYTHONDIR']:
67 subst_vars[path_name] = cnf.env[path_name]
68 # If the destdir option is used we'll have to manually prefix any path
69 # variables with it since env doesn't get updated.
70 # NOTE M. George Hansen 2011-06-09: This should probably be done
71 # automatically. Maybe we should patch WAF and contribute it the WAF
72 # project.
73 destdir = cnf.options.destdir
74 if destdir:
75 for key, path in subst_vars.items():
76 # If this is an absolute path, prefix it with the destdir.
77 if os.path.isabs(path):
78 subst_vars[key] = os.path.join(
79 destdir,
80 os.path.splitdrive(path)[1].lstrip('/\\'),
81 )
82 return subst_vars