source: rtems-tools/wscript @ 5416cfa

Last change on this file since 5416cfa was 5416cfa, checked in by Chris Johns <chrisj@…>, on Oct 2, 2018 at 6:49:54 AM

config: Create a config directory and move the RTEMS arch/bsp data to it.

Closes #3536

  • Property mode set to 100644
File size: 4.9 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    version = '5'
44    revision = 'not_released'
45    release = '%s.%s' % (version, revision)
46    if os.path.exists('VERSION'):
47        try:
48            import configparser
49        except ImportError:
50            import ConfigParser as configparser
51        v = configparser.SafeConfigParser()
52        v.read('VERSION')
53        release = v.get('version', 'release')
54    else:
55        #
56        # waf after 1.9.9 does not place the current directory in Python's
57        # system path which means importing the RTEMS toolkit
58        # fails. Temporarily add it so we can import the git module.
59        #
60        import sys
61        current_sys_path = sys.path
62        try:
63            sys.path = [os.getcwd()] + sys.path
64            from rtemstoolkit import git
65        finally:
66            sys.path = current_sys_path
67        repo = git.repo('.')
68        if repo.valid():
69            head = repo.head()
70            if repo.dirty():
71                modified = '_modified'
72            else:
73                modified = ''
74            release = '%s.%s%s' % (version, head[0:12], modified)
75    last_dot = release.rfind('.')
76    if last_dot == -1:
77        ctx.fatal('invalid VERSION file')
78    revision = release[0:last_dot]
79    return revision, release
80
81def recurse(ctx):
82    for sd in subdirs:
83        ctx.recurse(sd)
84
85def options(ctx):
86    ctx.add_option('--c-opts',
87                   default = '-O2',
88                   dest='c_opts',
89                   help = 'Set build options, default: -O2.')
90    ctx.add_option('--host',
91                   default = 'native',
92                   dest='host',
93                   help = 'Set host to build for, default: none.')
94    recurse(ctx)
95
96def init(ctx):
97    wafwindows.set_compilers()
98    try:
99        import waflib.Options
100        import waflib.ConfigSet
101        env = waflib.ConfigSet.ConfigSet()
102        env.load(waflib.Options.lockfile)
103        check_options(ctx, env.options['host'])
104        recurse(ctx)
105    except:
106        pass
107
108def shutdown(ctx):
109    pass
110
111def configure(ctx):
112    try:
113        ctx.load("doxygen", tooldir = 'waf-tools')
114    except:
115        pass
116    ctx.env.RTEMS_VERSION, ctx.env.RTEMS_RELEASE = get_version(ctx)
117    ctx.start_msg('Version')
118    ctx.end_msg('%s (%s)' % (ctx.env.RTEMS_RELEASE, ctx.env.RTEMS_VERSION))
119    ctx.env.C_OPTS = ctx.options.c_opts.split(',')
120    check_options(ctx, ctx.options.host)
121    #
122    # Common Python check.
123    #
124    ctx.load('python')
125    ctx.check_python_version((2,6,6))
126    #
127    # Installing the PYO,PYC seems broken on 1.8.19. The path is wrong.
128    #
129    ctx.env.PYO = 0
130    ctx.env.PYC = 0
131    recurse(ctx)
132
133def build(ctx):
134    if os.path.exists('VERSION'):
135        ctx.install_files('${PREFIX}/share/rtems/rtemstoolkit', ['VERSION'])
136    recurse(ctx)
137
138def install(ctx):
139    recurse(ctx)
140
141def clean(ctx):
142    recurse(ctx)
143
144def rebuild(ctx):
145    import waflib.Options
146    waflib.Options.commands.extend(['clean', 'build'])
147
148def check_options(ctx, host):
149    if host in ['mingw32', 'x86_64-w64-mingw32']:
150        ctx.env.HOST = host
151        ctx.env.CC = '%s-gcc' % (host)
152        ctx.env.CXX = '%s-g++' % (host)
153        ctx.env.AR = '%s-ar' % (host)
154        ctx.env.PYTHON = 'python'
155    elif host is not 'native':
156        ctx.fatal('unknown host: %s' % (host));
157
158#
159# The doxy command.
160#
161from waflib import Build
162class doxy(Build.BuildContext):
163    fun = 'build'
164    cmd = 'doxy'
Note: See TracBrowser for help on using the repository browser.