Mercurial > parpg-core
comparison waf_paths.py @ 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 | 15107282d9eb |
comparison
equal
deleted
inserted
replaced
14:6ff6a2f74f1e | 16:927f2cf75357 |
---|---|
1 #! /usr/bin/env python | |
2 # encoding: utf-8 | |
3 import sys | |
4 | |
5 from waflib import Utils, Options, Context | |
6 | |
7 option_values = { | |
8 'bindir' : ('user executables', '${EXEC_PREFIX}/bin'), | |
9 'sbindir' : ('system admin executables', '${EXEC_PREFIX}/sbin'), | |
10 'libexecdir' : ('program executables', '${EXEC_PREFIX}/libexec'), | |
11 'sysconfdir' : ('read-only single-machine data', '${PREFIX}/etc'), | |
12 'sharedstatedir': ('modifiable architecture-independent data', | |
13 '${PREFIX}/com'), | |
14 'localstatedir' : ('modifiable single-machine data', '${PREFIX}/var'), | |
15 'libdir' : ('object code libraries', '${EXEC_PREFIX}/lib'), | |
16 'includedir' : ('C header files', '${PREFIX}/include'), | |
17 'oldincludedir' : ('C header files for non-gcc', '/usr/include'), | |
18 'datarootdir' : ('read-only arch.-independent data root', | |
19 '${PREFIX}/share'), | |
20 # datadir definition deviates from GNU by appending the ${APPNAME}, but it | |
21 # makes the install script simpler since we don't have to redefine install | |
22 # paths on Windows. | |
23 'datadir' : ('read-only architecture-independent data', | |
24 '${DATAROOTDIR}/${APPNAME}'), | |
25 'infodir' : ('info documentation', '${DATAROOTDIR}/info'), | |
26 'localedir' : ('locale-dependent data', '${DATAROOTDIR}/locale'), | |
27 'mandir' : ('man documentation', '${DATAROOTDIR}/man'), | |
28 'docdir' : ('documentation root', '${DATAROOTDIR}/doc/${APPNAME}'), | |
29 'htmldir' : ('html documentation', '${DOCDIR}'), | |
30 'dvidir' : ('dvi documentation', '${DOCDIR}'), | |
31 'pdfdir' : ('pdf documentation', '${DOCDIR}'), | |
32 'psdir' : ('ps documentation', '${DOCDIR}'), | |
33 } | |
34 | |
35 if sys.platform == 'Windows': | |
36 option_values['PREFIX'][1] = '${PROGRAM_FILES}/${APPNAME}' | |
37 option_values['BINDIR'][1] = '${EXEC_PREFIX}' | |
38 option_values['SYSCONFDIR'][1] = '${PREFIX}' | |
39 option_values['DATAROOTDIR'][1] = '${PREFIX}' | |
40 option_values['DATADIR'][1] = '${DATAROOTDIR}/data' | |
41 option_values['DOCDIR'][1] = '${DATAROOTDIR}/doc' | |
42 | |
43 def get_param(varname, default): | |
44 return getattr(Options.options, varname, '') or default | |
45 | |
46 def configure(conf): | |
47 env = conf.env | |
48 env['LIBDIR'] = [] | |
49 env['BINDIR'] = [] | |
50 env['EXEC_PREFIX'] = get_param('EXEC_PREFIX', env['PREFIX']) | |
51 env['APPNAME'] = getattr(Context.g_module, 'APPNAME') | |
52 env['INSTALL_PATHS'] = ['PREFIX', 'EXEC_PREFIX'] | |
53 complete = False | |
54 iter = 0 | |
55 while not complete and iter < len(option_values) + 1: | |
56 iter += 1 | |
57 complete = True | |
58 for name in option_values: | |
59 help, default = option_values[name] | |
60 name = name.upper() | |
61 if not env[name]: | |
62 try: | |
63 env[name] = Utils.subst_vars(get_param(name, default), env) | |
64 except TypeError: | |
65 complete = False | |
66 env['INSTALL_PATHS'].append(name) | |
67 if not complete: | |
68 lst = [name for name in option_values if not env[name.upper()]] | |
69 raise Errors.WafError('Variable substitution failure %r' % lst) | |
70 | |
71 def options(opt): | |
72 inst_dir = opt.add_option_group( | |
73 'Installation directories', | |
74 'By default, "waf install" will install all files into their ' | |
75 'appropriate directories under ${PREFIX}. The installation prefix can ' | |
76 'be specified using the "--prefix" option, for example ' | |
77 '"--prefix=$HOME"' | |
78 ) | |
79 for k in ('--prefix', '--destdir'): | |
80 option = opt.parser.get_option(k) | |
81 if option: | |
82 opt.parser.remove_option(k) | |
83 inst_dir.add_option(option) | |
84 inst_dir.add_option( | |
85 '--exec-prefix', | |
86 help='installation prefix [Default: ${PREFIX}]', | |
87 default=inst_dir.defaults['prefix'], | |
88 dest='EXEC_PREFIX', | |
89 ) | |
90 dirs_options = opt.add_option_group( | |
91 'Pre-defined installation directories', | |
92 '' | |
93 ) | |
94 for name in option_values: | |
95 help, default = option_values[name] | |
96 option_name = '--' + name | |
97 str_help = '{0} [Default: %default]'.format(help) | |
98 dirs_options.add_option(option_name, help=str_help, default=default, | |
99 dest=name.upper()) |