source: rtems-tools/wscript @ 6c79a16

Last change on this file since 6c79a16 was 6db01e5, checked in by Chris Johns <chrisj@…>, on Nov 28, 2018 at 11:14:14 PM

rtemstoolkit/host: Fix the darwin support.

  • Add python as a unit test variant.
  • Property mode set to 100644
File size: 5.8 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2014-2018 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions are met:
10#
11# 1. Redistributions of source code must retain the above copyright notice,
12# this list of conditions and the following disclaimer.
13#
14# 2. Redistributions in binary form must reproduce the above copyright notice,
15# this list of conditions and the following disclaimer in the documentation
16# and/or other materials provided with the distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE.
29#
30
31import os.path
32
33import wafwindows
34
35subdirs = ['rtemstoolkit',
36           'config',
37           'linkers',
38           'misc',
39           'tester',
40           'tools/gdb/python']
41
42def get_version(ctx):
43    #
44    # The file config/rtems-versin.ini contains the version.
45    #
46    from rtemstoolkit import version as rtemsversion
47    try:
48        version = rtemsversion.version()
49        revision = rtemsversion.revision()
50    except Exception as e:
51        ctx.fatal('invalid version file: %s' % (e))
52    release = '%s.%s' % (version, revision)
53    return version, release
54
55def recurse(ctx):
56    for sd in subdirs:
57        ctx.recurse(sd)
58
59def options(ctx):
60    ctx.add_option('--c-opts',
61                   default = '-O2',
62                   dest='c_opts',
63                   help = 'Set build options, default: -O2.')
64    ctx.add_option('--host',
65                   default = 'native',
66                   dest='host',
67                   help = 'Set host to build for, default: none.')
68    recurse(ctx)
69
70def init(ctx):
71    wafwindows.set_compilers()
72    try:
73        import waflib.Options
74        import waflib.ConfigSet
75        env = waflib.ConfigSet.ConfigSet()
76        env.load(waflib.Options.lockfile)
77        check_options(ctx, env.options['host'])
78        recurse(ctx)
79    except:
80        pass
81
82def shutdown(ctx):
83    pass
84
85def configure(ctx):
86    try:
87        ctx.load("doxygen", tooldir = 'waf-tools')
88    except:
89        pass
90    ctx.env.RTEMS_VERSION, ctx.env.RTEMS_RELEASE = get_version(ctx)
91    ctx.start_msg('Version')
92    ctx.end_msg('%s (%s)' % (ctx.env.RTEMS_RELEASE, ctx.env.RTEMS_VERSION))
93    ctx.env.C_OPTS = ctx.options.c_opts.split(',')
94    check_options(ctx, ctx.options.host)
95    #
96    # Common Python check.
97    #
98    ctx.load('python')
99    ctx.check_python_version((2,6,6))
100    #
101    # Find which versions of python are installed for testing.
102    #
103    ctx.find_program('python', mandatory = False)
104    ctx.find_program('python2', mandatory = False)
105    ctx.find_program('python3', mandatory = False)
106    #
107    # Installing the PYO,PYC seems broken on 1.8.19. The path is wrong.
108    #
109    ctx.env.PYO = 0
110    ctx.env.PYC = 0
111    recurse(ctx)
112
113def build(ctx):
114    if os.path.exists('VERSION'):
115        ctx.install_files('${PREFIX}/share/rtems/rtemstoolkit', ['VERSION'])
116    recurse(ctx)
117    if ctx.cmd == 'test':
118        rtemstoolkit_tests(ctx)
119
120def install(ctx):
121    recurse(ctx)
122
123def clean(ctx):
124    recurse(ctx)
125
126def rebuild(ctx):
127    import waflib.Options
128    waflib.Options.commands.extend(['clean', 'build'])
129
130def check_options(ctx, host):
131    if host in ['mingw32', 'x86_64-w64-mingw32']:
132        ctx.env.HOST = host
133        ctx.env.CC = '%s-gcc' % (host)
134        ctx.env.CXX = '%s-g++' % (host)
135        ctx.env.AR = '%s-ar' % (host)
136        ctx.env.PYTHON = 'python'
137    elif host is not 'native':
138        ctx.fatal('unknown host: %s' % (host));
139
140#
141# Custom commands
142#
143import waflib
144
145class test(waflib.Build.BuildContext):
146    fun = 'build'
147    cmd = 'test'
148
149class doxy(waflib.Build.BuildContext):
150    fun = 'build'
151    cmd = 'doxy'
152
153#
154# RTEMS Toolkit Tests.
155#
156# Run the tests from the top directory so they are run as python modules.
157#
158def rtemstoolkit_tests(ctx):
159    log = ctx.path.find_or_declare('tests.log')
160    ctx.logger = waflib.Logs.make_logger(log.abspath(), 'build')
161    failures = False
162    from rtemstoolkit import all as toolkit_tests
163    from rtemstoolkit import args as toolkit_test_args
164    for tt in toolkit_tests:
165        for py in ['', '2', '3']:
166            PY = 'PYTHON%s' % (py)
167            if PY in ctx.env:
168                test = 'rtemstoolkit.%s' % (tt)
169                ctx.start_msg('Test python%s %s' % (py, test))
170                cmd = '%s -m %s' % (ctx.env[PY][0], test)
171                if tt in toolkit_test_args:
172                    cmd += ' ' + ' '.join(toolkit_test_args[tt])
173                ctx.to_log('test command: ' + cmd)
174                try:
175                    (out, err) = ctx.cmd_and_log(cmd,
176                                                 output = waflib.Context.BOTH,
177                                                 quiet = waflib.Context.BOTH)
178                    ctx.to_log(out)
179                    ctx.to_log(err)
180                    ctx.end_msg('pass')
181                except waflib.Errors.WafError as e:
182                    failures = True
183                    ctx.to_log(e.stdout)
184                    ctx.to_log(e.stderr)
185                    ctx.end_msg('fail', color = 'RED')
186    if failures:
187        ctx.fatal('Test failures')
Note: See TracBrowser for help on using the repository browser.