]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/config/ui.py
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / python / config / ui.py
1 #
2 # Copyright (c) 2016 Stefan Seefeld
3 # All rights reserved.
4 #
5 # Distributed under the Boost Software License, Version 1.0.
6 # (See accompanying file LICENSE_1_0.txt or copy at
7 # http://www.boost.org/LICENSE_1_0.txt)
8
9 from SCons.Script import AddOption
10 import sys
11
12 variables=[] # remember 'public' variables
13 options=[]
14
15 def add_option(*args, **kwds):
16 """Capture the help messages so we can produce a helpful usage text."""
17 options.append('{:25} {}'.format(', '.join(args), kwds.get('help', '')))
18 AddOption(*args, **kwds)
19
20 def add_variable(vars, var):
21 variables.append(var[0])
22 vars.Add(var)
23
24
25 def options_help(env):
26
27 return '\n '.join(options)
28
29
30 def variables_help(vars, env):
31 """This is cloned from SCons' Variables.GenerateHelpText, to only report 'public' variables."""
32
33 opts = [o for o in vars.options if o.key in variables]
34
35 def format(opt):
36 if opt.key in env:
37 actual = env.subst('${%s}' % opt.key)
38 else:
39 actual = None
40 return vars.FormatVariableHelpText(env, opt.key, opt.help, opt.default, actual, opt.aliases)
41 text = ''.join([f for f in map(format, opts) if f])
42 lines = [' %s'%l for l in text.split('\n')] # Add some indentation
43 return '\n'.join(lines)
44
45
46
47 def help(vars, env):
48
49 return """Usage: scons [--option...] [variable=value...] [target...]
50
51 available options:
52
53 {}
54
55 available variables:
56 {}
57 """.format(options_help(env), variables_help(vars, env))
58
59 def pretty_output(env):
60
61 colors = {}
62 colors['red'] = '\033[31m'
63 colors['green'] = '\033[32m'
64 colors['blue'] = '\033[34m'
65 colors['yellow'] = '\033[93m'
66 colors['Red'] = '\033[91m'
67 colors['Green'] = '\033[92m'
68 colors['Blue'] = '\033[94m'
69 colors['Purple'] = '\033[95m'
70 colors['Cyan'] = '\033[96m'
71 colors['end'] = '\033[0m'
72
73 #If the output is not a terminal, remove the colors
74 if not sys.stdout.isatty():
75 for key, value in colors.iteritems():
76 colors[key] = ''
77
78 compile_source_message = '{green}Compiling $TARGET{end}'.format(**colors)
79 compile_shared_source_message = '{green}Compiling $TARGET{end}'.format(**colors)
80 link_program_message = '{blue}Linking $TARGET{end}'.format(**colors)
81 link_library_message = '{blue}Linking $TARGET{end}'.format(**colors)
82 ranlib_library_message = '{blue}Ranlib $TARGET{end}'.format(**colors)
83 link_shared_library_message = '{blue}Linking $TARGET{end}'.format(**colors)
84 test_message = '{blue}Testing $SOURCE{end}'.format(**colors)
85 testsum_message = '{Blue}Test Summary{end}'.format(**colors)
86
87 env.Replace(CXXCOMSTR = compile_source_message,
88 CCCOMSTR = compile_source_message,
89 SHCCCOMSTR = compile_shared_source_message,
90 SHCXXCOMSTR = compile_shared_source_message,
91 ARCOMSTR = link_library_message,
92 RANLIBCOMSTR = ranlib_library_message,
93 SHLINKCOMSTR = link_shared_library_message,
94 LINKCOMSTR = link_program_message,
95 TESTCOMSTR = test_message,
96 TESTSUMCOMSTR = testsum_message)