source: rtems-tools/wscript @ ab57e79

5
Last change on this file since ab57e79 was 3018e2f, checked in by Chris Johns <chrisj@…>, on 02/20/16 at 01:44:44

Do not change the Python os.sep setting.

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