source: rtems-tools/wscript @ 2244c9b

4.11
Last change on this file since 2244c9b was 2244c9b, 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.1 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 = '%s.%s%s' % (version, 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.env.C_OPTS = ctx.options.c_opts.split(',')
98    check_options(ctx, ctx.options.host)
99    recurse(ctx)
100
101def build(ctx):
102    if os.path.exists('VERSION'):
103        ctx.install_files('${PREFIX}/share/rtems/rtemstoolkit', ['VERSION'])
104    recurse(ctx)
105
106def install(ctx):
107    recurse(ctx)
108
109def clean(ctx):
110    recurse(ctx)
111
112def rebuild(ctx):
113    import waflib.Options
114    waflib.Options.commands.extend(['clean', 'build'])
115
116def check_options(ctx, host):
117    if host in ['mingw32']:
118        ctx.env.HOST = host
119        ctx.env.CC = '%s-gcc' % (host)
120        ctx.env.CXX = '%s-g++' % (host)
121        ctx.env.AR = '%s-ar' % (host)
122        ctx.env.PYTHON = 'python'
123    elif host is not 'native':
124        ctx.fatal('unknown host: %s' % (host));
125
126#
127# The doxy command.
128#
129from waflib import Build
130class doxy(Build.BuildContext):
131    fun = 'build'
132    cmd = 'doxy'
Note: See TracBrowser for help on using the repository browser.