source: rtems-tools/wscript @ 3828e50

4.10
Last change on this file since 3828e50 was 3828e50, checked in by Chris Johns <chrisj@…>, on Dec 11, 2015 at 6:01:51 AM

VERSION as an INI format file.

One section is supported [version] with a 'release' entry.

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