source: rtems-tools/wscript @ 8b49f73

4.105
Last change on this file since 8b49f73 was 8b49f73, checked in by Chris Johns <chrisj@…>, on 12/10/15 at 01:26:49

Use the git hash for the revision in the version string.

  • 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            with open('VERSION') as v:
45                release = v.readline().strip()
46            v.close()
47        except:
48            ctx.fatal('cannot access the VERSION file')
49    else:
50        from rtemstoolkit import git
51        repo = git.repo('.')
52        if repo.valid():
53            head = repo.head()
54            if repo.dirty():
55                modified = '_modified'
56            else:
57                modified = ''
58            release = '%s.%s%s)' % (version, head[0:12], modified)
59    last_dot = release.rfind('.')
60    if last_dot == -1:
61        ctx.fatal('invalid VERSION file')
62    revision = release[0:last_dot]
63    return revision, release
64
65def recurse(ctx):
66    for sd in subdirs:
67        ctx.recurse(sd)
68
69def options(ctx):
70    ctx.add_option('--c-opts',
71                   default = '-O2',
72                   dest='c_opts',
73                   help = 'Set build options, default: -O2.')
74    ctx.add_option('--host',
75                   default = 'native',
76                   dest='host',
77                   help = 'Set host to build for, default: none.')
78    recurse(ctx)
79
80def init(ctx):
81    try:
82        import waflib.Options
83        import waflib.ConfigSet
84        env = waflib.ConfigSet.ConfigSet()
85        env.load(waflib.Options.lockfile)
86        check_options(ctx, env.options['host'])
87        for sd in subdirs:
88            ctx.recurse(sd)
89    except:
90        pass
91
92def configure(ctx):
93    try:
94        ctx.load("doxygen", tooldir = 'waf-tools')
95    except:
96        pass
97    ctx.env.RTEMS_VERSION, ctx.env.RTEMS_RELEASE = get_version(ctx)
98    ctx.start_msg('Version')
99    ctx.end_msg('%s (%s)' % (ctx.env.RTEMS_RELEASE, ctx.env.RTEMS_VERSION))
100    ctx.env.C_OPTS = ctx.options.c_opts.split(',')
101    check_options(ctx, ctx.options.host)
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']:
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.