Mercurial > parpg-core
annotate wscript @ 18:2e2d6d9009a3
Added a --fifepath option to the WAF build script.
* Use the '--fifepath=<path/to/fife>' option to override the default search path and directly import the FIFE Python module from <path/to/fife>.
* Modified the parpg.main module to support the new --fifepath option and ensure that the FIFE Python module pointed to by the --fifepath option is imported, regardless of whether multiple FIFE modules are already in the default search path.
author | M. George Hansen <technopolitica@gmail.com> |
---|---|
date | Fri, 10 Jun 2011 11:29:38 -1000 |
parents | 927f2cf75357 |
children | 07ff8cf8a0f1 |
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') |
18
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
11 |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
12 ext_dep = opt.add_option_group( |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
13 'External dependencies', |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
14 '', |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
15 ) |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
16 ext_dep.add_option( |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
17 '--fifepath', |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
18 help='Path to where the fife Python package is located', |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
19 default='', |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
20 dest='fifepath', |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
21 ) |
16
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 def configure(cnf): |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
24 cnf.load('waf_paths python') |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
25 if sys.platform == 'Windows': |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
26 min_python_version = (2, 7) |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
27 else: |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
28 min_python_version = (2, 6) |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
29 cnf.check_python_version(min_python_version) |
18
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
30 |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
31 cnf.env['FIFEPATH'] = \ |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
32 os.path.abspath(os.path.expanduser(cnf.options.fifepath)) or \ |
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
33 cnf.env['PYTHONDIR'] |
16
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
34 |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
35 def build(bld): |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
36 subst_vars = _get_subst_vars(bld) |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
37 |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
38 if sys.platform == 'Windows': |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
39 launcher_template = 'bin/parpg.bat.in' |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
40 launcher = 'parpg.bat' |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
41 else: |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
42 launcher_template = 'bin/parpg.sh.in' |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
43 launcher = 'parpg' |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
44 args = dict( |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
45 features='subst', |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
46 source=launcher_template, |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
47 target=launcher, |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
48 install_path='${BINDIR}', |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
49 chmod=0755, |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
50 ) |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
51 args.update(subst_vars) |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
52 bld(**args) |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
53 |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
54 bld( |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
55 features='py', |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
56 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
|
57 install_from='src', |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
58 ) |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
59 |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
60 args = dict( |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
61 features='subst', |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
62 source='parpg.cfg.in', |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
63 target='parpg.cfg', |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
64 install_path='${SYSCONFDIR}', |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
65 chmod=0644, |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
66 ) |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
67 args.update(subst_vars) |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
68 bld(**args) |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
69 |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
70 bld.install_files( |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
71 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
|
72 dest='${DATADIR}', |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
73 relative_trick=True, |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
74 chmod=0644, |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
75 ) |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
76 |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
77 def _get_subst_vars(cnf): |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
78 # 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
|
79 subst_vars = {} |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
80 install_path_names = cnf.env['INSTALL_PATHS'] |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
81 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
|
82 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
|
83 # 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
|
84 # 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
|
85 # 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
|
86 # 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
|
87 # project. |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
88 destdir = cnf.options.destdir |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
89 if destdir: |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
90 for key, path in subst_vars.items(): |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
91 # 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
|
92 if os.path.isabs(path): |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
93 subst_vars[key] = os.path.join( |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
94 destdir, |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
95 os.path.splitdrive(path)[1].lstrip('/\\'), |
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
96 ) |
18
2e2d6d9009a3
Added a --fifepath option to the WAF build script.
M. George Hansen <technopolitica@gmail.com>
parents:
16
diff
changeset
|
97 subst_vars['FIFEPATH'] = cnf.env['FIFEPATH'] |
16
927f2cf75357
Changed build system from SCons to WAF.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
98 return subst_vars |