source: rtems-tools/wscript @ 156b227

Last change on this file since 156b227 was 845054a, checked in by Sebastian Huber <sebastian.huber@…>, on Jun 19, 2018 at 10:15:17 AM

Fix CXC build for x86-w64-mingw32

Update #3461.

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