source: rtems-tools/wscript @ 2bb79f19

4.11
Last change on this file since 2bb79f19 was 2bb79f19, checked in by Chris Johns <chrisj@…>, on 12/15/15 at 00:24:00

Fix the 4.11 branch build from git.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2014-2015 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
33subdirs = ['rtemstoolkit',
34           'linkers',
35           'tester',
36           'tools/gdb/python']
37
38def get_version(ctx):
39    release = '4.11.not_released'
40    if os.path.exists('VERSION'):
41        try:
42            import configparser
43        except ImportError:
44            import ConfigParser as configparser
45        v = configparser.SafeConfigParser()
46        v.read('VERSION')
47        release = v.get('version', 'release')
48    else:
49        from rtemstoolkit import git
50        repo = git.repo('.')
51        if repo.valid():
52            head = repo.head()
53            if repo.dirty():
54                modified = '_modified'
55            else:
56                modified = ''
57            release = '4.11.%s%s' % (head[0:12], modified)
58    last_dot = release.rfind('.')
59    if last_dot == -1:
60        ctx.fatal('invalid VERSION file')
61    revision = release[0:last_dot]
62    return revision, release
63
64def recurse(ctx):
65    for sd in subdirs:
66        ctx.recurse(sd)
67
68def options(ctx):
69    ctx.add_option('--c-opts',
70                   default = '-O2',
71                   dest='c_opts',
72                   help = 'Set build options, default: -O2.')
73    ctx.add_option('--host',
74                   default = 'native',
75                   dest='host',
76                   help = 'Set host to build for, default: none.')
77    recurse(ctx)
78
79def init(ctx):
80    try:
81        import waflib.Options
82        import waflib.ConfigSet
83        env = waflib.ConfigSet.ConfigSet()
84        env.load(waflib.Options.lockfile)
85        check_options(ctx, env.options['host'])
86        for sd in subdirs:
87            ctx.recurse(sd)
88    except:
89        pass
90
91def configure(ctx):
92    try:
93        ctx.load("doxygen", tooldir = 'waf-tools')
94    except:
95        pass
96    ctx.env.RTEMS_VERSION, ctx.env.RTEMS_RELEASE = get_version(ctx)
97    ctx.start_msg('Version')
98    ctx.end_msg('%s (%s)' % (ctx.env.RTEMS_RELEASE, ctx.env.RTEMS_VERSION))
99    ctx.env.C_OPTS = ctx.options.c_opts.split(',')
100    check_options(ctx, ctx.options.host)
101    recurse(ctx)
102
103def build(ctx):
104    if os.path.exists('VERSION'):
105        ctx.install_files('${PREFIX}/share/rtems/rtemstoolkit', ['VERSION'])
106    recurse(ctx)
107
108def install(ctx):
109    recurse(ctx)
110
111def clean(ctx):
112    recurse(ctx)
113
114def rebuild(ctx):
115    import waflib.Options
116    waflib.Options.commands.extend(['clean', 'build'])
117
118def check_options(ctx, host):
119    if host in ['mingw32']:
120        ctx.env.HOST = host
121        ctx.env.CC = '%s-gcc' % (host)
122        ctx.env.CXX = '%s-g++' % (host)
123        ctx.env.AR = '%s-ar' % (host)
124        ctx.env.PYTHON = 'python'
125    elif host is not 'native':
126        ctx.fatal('unknown host: %s' % (host));
127
128#
129# The doxy command.
130#
131from waflib import Build
132class doxy(Build.BuildContext):
133    fun = 'build'
134    cmd = 'doxy'
Note: See TracBrowser for help on using the repository browser.