Fix typo in option_defaults.
[libcxml.git] / cscript
1 # -*- mode: python -*-
2 #
3 #    Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net>
4 #
5 #    This file is part of libcxml.
6 #
7 #    libcxml is free software; you can redistribute it and/or modify
8 #    it under the terms of the GNU General Public License as published by
9 #    the Free Software Foundation; either version 2 of the License, or
10 #    (at your option) any later version.
11 #
12 #    libcxml is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU General Public License for more details.
16 #
17 #    You should have received a copy of the GNU General Public License
18 #    along with libcxml.  If not, see <http://www.gnu.org/licenses/>.
19 #
20
21 import os
22
23 option_defaults = { 'force-cpp11': False }
24
25 def build(target, options):
26     cmd = './waf configure --prefix=%s' % target.directory
27     if target.platform == 'linux':
28         cmd += ' --static'
29         if target.distro == 'centos':
30             # Centos builds using static boost, which means tests don't
31             # build as test/tests.cc defines BOOST_TEST_DYN_LINK
32             cmd += ' --disable-tests'
33     elif target.platform == 'windows':
34         cmd += ' --target-windows'
35
36     # Centos 7 ships with glibmm 2.50.0 which requires C++11
37     # but its compiler (gcc 4.8.5) defaults to C++97.  Go figure.
38     # I worry that this will cause ABI problems but I don't have
39     # a better solution.  Mageia 6 pulls the same stunt except it's
40     # libxml++ that requires C++11
41     force_cpp11 = False
42     if target.platform == 'linux':
43         if target.distro == 'centos' and target.version == '7':
44             force_cpp11 = True
45         if target.distro == 'mageia' and target.version == '6':
46             force_cpp11 = True
47     if target.platform == 'windows':
48         force_cpp11 = True
49     if force_cpp11 or options['force-cpp11']:
50         cmd += ' --force-cpp11'
51
52     target.command(cmd)
53     target.command('./waf build install')
54
55 def test(target, test):
56     if target.platform != 'windows':
57         target.set('LC_ALL', 'C')
58         target.command('./run-tests.sh')
59
60 def make_doxygen(target):
61     os.makedirs('build/doc')
62     target.command('doxygen')
63     return os.path.abspath('build/doc/html')