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