source: rtems-tools/wscript @ 3bd8def

Last change on this file since 3bd8def was 3bd8def, checked in by Chris Johns <chrisj@…>, on Oct 3, 2018 at 1:38:09 AM

config: Consolidate the version information into a single configuration file

  • Property mode set to 100644
File size: 4.0 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    from rtemstoolkit import version as rtemsversion
44    try:
45        version = rtemsversion.version()
46        revision = rtemsversion.revision()
47    except Exception as e:
48        ctx.fatal('invalid version file: %s' % (e))
49    release = '%s.%s' % (version, revision)
50    return version, release
51
52def recurse(ctx):
53    for sd in subdirs:
54        ctx.recurse(sd)
55
56def options(ctx):
57    ctx.add_option('--c-opts',
58                   default = '-O2',
59                   dest='c_opts',
60                   help = 'Set build options, default: -O2.')
61    ctx.add_option('--host',
62                   default = 'native',
63                   dest='host',
64                   help = 'Set host to build for, default: none.')
65    recurse(ctx)
66
67def init(ctx):
68    wafwindows.set_compilers()
69    try:
70        import waflib.Options
71        import waflib.ConfigSet
72        env = waflib.ConfigSet.ConfigSet()
73        env.load(waflib.Options.lockfile)
74        check_options(ctx, env.options['host'])
75        recurse(ctx)
76    except:
77        pass
78
79def shutdown(ctx):
80    pass
81
82def configure(ctx):
83    try:
84        ctx.load("doxygen", tooldir = 'waf-tools')
85    except:
86        pass
87    ctx.env.RTEMS_VERSION, ctx.env.RTEMS_RELEASE = get_version(ctx)
88    ctx.start_msg('Version')
89    ctx.end_msg('%s (%s)' % (ctx.env.RTEMS_RELEASE, ctx.env.RTEMS_VERSION))
90    ctx.env.C_OPTS = ctx.options.c_opts.split(',')
91    check_options(ctx, ctx.options.host)
92    #
93    # Common Python check.
94    #
95    ctx.load('python')
96    ctx.check_python_version((2,6,6))
97    #
98    # Installing the PYO,PYC seems broken on 1.8.19. The path is wrong.
99    #
100    ctx.env.PYO = 0
101    ctx.env.PYC = 0
102    recurse(ctx)
103
104def build(ctx):
105    if os.path.exists('VERSION'):
106        ctx.install_files('${PREFIX}/share/rtems/rtemstoolkit', ['VERSION'])
107    recurse(ctx)
108
109def install(ctx):
110    recurse(ctx)
111
112def clean(ctx):
113    recurse(ctx)
114
115def rebuild(ctx):
116    import waflib.Options
117    waflib.Options.commands.extend(['clean', 'build'])
118
119def check_options(ctx, host):
120    if host in ['mingw32', 'x86_64-w64-mingw32']:
121        ctx.env.HOST = host
122        ctx.env.CC = '%s-gcc' % (host)
123        ctx.env.CXX = '%s-g++' % (host)
124        ctx.env.AR = '%s-ar' % (host)
125        ctx.env.PYTHON = 'python'
126    elif host is not 'native':
127        ctx.fatal('unknown host: %s' % (host));
128
129#
130# The doxy command.
131#
132from waflib import Build
133class doxy(Build.BuildContext):
134    fun = 'build'
135    cmd = 'doxy'
Note: See TracBrowser for help on using the repository browser.