source: rtems-tools/rtemstoolkit/wscript @ 0c0b2d4

4.10
Last change on this file since 0c0b2d4 was 7148cae, checked in by Chris Johns <chrisj@…>, on Feb 19, 2016 at 3:46:15 AM

Add Windows specific waf support for MSYS2.

Limit the compilers used to gcc and clang. Clang has not been tested.
Users with MSVC install does not need to remove now.

Force the os.sep path to the standard '
' on Windows. The MSYS2 python
sets it to '/' for internal project reasons. Doing this does cause waf
problems when running configure so only do this for the build target.

Closes #2583.

  • Property mode set to 100644
File size: 10.9 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
31#
32# RTEMS Toolkit build script.
33#
34import sys
35
36#
37# Waf system setup. Allow more than one build in the same tree.
38#
39top = '.'
40out = 'build-' + sys.platform
41
42def init(ctx):
43    pass
44
45def options(opt):
46    opt.load('compiler_c')
47    opt.load('compiler_cxx')
48
49def configure(conf):
50    conf.load('compiler_c')
51    conf.load('compiler_cxx')
52    conf_libiberty(conf)
53    conf_libelf(conf)
54
55    conf.find_program('m4')
56
57    conf.check(header_name = 'sys/wait.h',  features = 'c', mandatory = False)
58    conf.check_cc(function_name = 'kill', header_name="signal.h",
59                  features = 'c', mandatory = False)
60    conf.write_config_header('config.h')
61
62def build(bld):
63    #
64    # The local configuration.
65    #
66    conf = {}
67
68    #
69    # The include paths.
70    #
71    conf['includes'] = ['elftoolchain/libelf', 'elftoolchain/common', 'libiberty']
72    if bld.env.DEST_OS == 'win32':
73        conf['includes'] += ['win32']
74
75    #
76    # Build flags.
77    #
78    conf['warningflags'] = ['-Wall', '-Wextra', '-pedantic']
79    conf['optflags'] = bld.env.C_OPTS
80    conf['cflags'] = ['-pipe', '-g'] + conf['optflags']
81    conf['cxxflags'] = ['-pipe', '-g'] + conf['optflags']
82    conf['linkflags'] = ['-g']
83
84    #
85    # Create each of the modules as object files each with their own
86    # configurations.
87    #
88    bld_libelf(bld, conf)
89    bld_libiberty(bld, conf)
90
91    #
92    # RLD source.
93    #
94    rld_source = ['ConvertUTF.c',
95                  'pkgconfig.cpp',
96                  'rld-config.cpp',
97                  'rld-elf.cpp',
98                  'rld-files.cpp',
99                  'rld-cc.cpp',
100                  'rld-compression.cpp',
101                  'rld-outputter.cpp',
102                  'rld-path.cpp',
103                  'rld-process.cpp',
104                  'rld-resolver.cpp',
105                  'rld-rtems.cpp',
106                  'rld-symbols.cpp',
107                  'rld-rap.cpp',
108                  'rld.cpp']
109
110    #
111    # RTEMS Utilities.
112    #
113    rtems_utils = ['rtems-utils.cpp']
114
115    #
116    # Compression.
117    #
118    compression = ['fastlz.c']
119
120    #
121    # RTL static library
122    #
123    bld.stlib(target = 'rld',
124              install_path = None,
125              source = rld_source + rtems_utils + compression,
126              defines = ['HAVE_CONFIG_H=1',
127                         'RTEMS_VERSION=\"%s\"' % (bld.env.RTEMS_VERSION),
128                         'RTEMS_RELEASE=\"%s\"' % (bld.env.RTEMS_RELEASE),
129                         'FASTLZ_LEVEL=1'],
130              includes = ['.'] + conf['includes'],
131              cflags = conf['cflags'] + conf['warningflags'],
132              cxxflags = conf['cxxflags'] + conf['warningflags'],
133              linkflags = conf['linkflags'])
134
135    #
136    # The Python toolkit.
137    #
138    bld(features = 'py',
139        source = ['__init__.py',
140                  'check.py',
141                  'config.py',
142                  'darwin.py',
143                  'error.py',
144                  'execute.py',
145                  'freebsd.py',
146                  'git.py',
147                  'linux.py',
148                  'log.py',
149                  'macros.py',
150                  'mailer.py',
151                  'options.py',
152                  'path.py',
153                  'stacktraces.py',
154                  'version.py',
155                  'windows.py'],
156        install_from = '.',
157        install_path = '${PREFIX}/share/rtems/rtemstoolkit')
158
159def rebuild(ctx):
160    import waflib.Options
161    waflib.Options.commands.extend(['clean', 'build'])
162
163def tags(ctx):
164    ctx.exec_command('etags $(find . -name \*.[sSch])', shell = True)
165
166#
167# Libelf module.
168#
169def conf_libelf(conf):
170    pass
171
172def bld_libelf(bld, conf):
173    libelf = 'elftoolchain/libelf/'
174    m4_rule = '${M4} -D SRCDIR=../rtemstoolkit/' + libelf[:-1] + ' ${SRC} > ${TGT}'
175    if bld.env.DEST_OS == 'win32':
176        includes = ['win32']
177    else:
178        includes = []
179
180    bld(target = 'libelf_convert.c', source = libelf + 'libelf_convert.m4', rule = m4_rule)
181    bld(target = 'libelf_fsize.c',   source = libelf + 'libelf_fsize.m4',   rule = m4_rule)
182    bld(target = 'libelf_msize.c',   source = libelf + 'libelf_msize.m4',   rule = m4_rule)
183
184    host_source = []
185
186    if bld.env.DEST_OS == 'linux':
187        common = 'elftoolchain/common/'
188        bld(target = common + 'native-elf-format.h',
189            source = common + 'native-elf-format',
190            name = 'native-elf-format',
191            rule   = './${SRC} > ${TGT}')
192        bld.add_group ()
193    elif bld.env.DEST_OS == 'win32':
194        host_source += [libelf + 'mmap_win32.c']
195
196    bld.stlib(target = 'elf',
197              features = 'c',
198              install_path = None,
199              uses = ['native-elf-format'],
200              includes = [bld.bldnode.abspath(),
201                          'elftoolchain/libelf', 'elftoolchain/common'] + includes,
202              cflags = conf['cflags'],
203              source =[libelf + 'elf.c',
204                       libelf + 'elf_begin.c',
205                       libelf + 'elf_cntl.c',
206                       libelf + 'elf_end.c',
207                       libelf + 'elf_errmsg.c',
208                       libelf + 'elf_errno.c',
209                       libelf + 'elf_data.c',
210                       libelf + 'elf_fill.c',
211                       libelf + 'elf_flag.c',
212                       libelf + 'elf_getarhdr.c',
213                       libelf + 'elf_getarsym.c',
214                       libelf + 'elf_getbase.c',
215                       libelf + 'elf_getident.c',
216                       libelf + 'elf_hash.c',
217                       libelf + 'elf_kind.c',
218                       libelf + 'elf_memory.c',
219                       libelf + 'elf_next.c',
220                       libelf + 'elf_rand.c',
221                       libelf + 'elf_rawfile.c',
222                       libelf + 'elf_phnum.c',
223                       libelf + 'elf_shnum.c',
224                       libelf + 'elf_shstrndx.c',
225                       libelf + 'elf_scn.c',
226                       libelf + 'elf_strptr.c',
227                       libelf + 'elf_update.c',
228                       libelf + 'elf_version.c',
229                       libelf + 'gelf_cap.c',
230                       libelf + 'gelf_checksum.c',
231                       libelf + 'gelf_dyn.c',
232                       libelf + 'gelf_ehdr.c',
233                       libelf + 'gelf_getclass.c',
234                       libelf + 'gelf_fsize.c',
235                       libelf + 'gelf_move.c',
236                       libelf + 'gelf_phdr.c',
237                       libelf + 'gelf_rel.c',
238                       libelf + 'gelf_rela.c',
239                       libelf + 'gelf_shdr.c',
240                       libelf + 'gelf_sym.c',
241                       libelf + 'gelf_syminfo.c',
242                       libelf + 'gelf_symshndx.c',
243                       libelf + 'gelf_xlate.c',
244                       libelf + 'libelf_align.c',
245                       libelf + 'libelf_allocate.c',
246                       libelf + 'libelf_ar.c',
247                       libelf + 'libelf_ar_util.c',
248                       libelf + 'libelf_checksum.c',
249                       libelf + 'libelf_data.c',
250                       libelf + 'libelf_ehdr.c',
251                       libelf + 'libelf_extended.c',
252                       libelf + 'libelf_phdr.c',
253                       libelf + 'libelf_shdr.c',
254                       libelf + 'libelf_xlate.c',
255                       'libelf_convert.c',
256                       'libelf_fsize.c',
257                       'libelf_msize.c'] + host_source)
258
259#
260# Libiberty module.
261#
262def conf_libiberty(conf):
263    conf.check(header_name='alloca.h',    features = 'c', mandatory = False)
264    conf.check(header_name='fcntl.h',     features = 'c', mandatory = False)
265    conf.check(header_name='process.h',   features = 'c', mandatory = False)
266    conf.check(header_name='stdlib.h',    features = 'c')
267    conf.check(header_name='string.h',    features = 'c')
268    conf.check(header_name='strings.h',   features = 'c', mandatory = False)
269    conf.check(header_name='sys/file.h',  features = 'c', mandatory = False)
270    conf.check(header_name='sys/stat.h',  features = 'c', mandatory = False)
271    conf.check(header_name='sys/time.h',  features = 'c', mandatory = False)
272    conf.check(header_name='sys/types.h', features = 'c', mandatory = False)
273    conf.check(header_name='sys/wait.h',  features = 'c', mandatory = False)
274    conf.check(header_name='unistd.h',    features = 'c', mandatory = False)
275    conf.check(header_name='vfork.h',     features = 'c', mandatory = False)
276
277    conf.check_cc(function_name='getrusage',
278                  header_name="sys/time.h sys/resource.h",
279                  features = 'c', mandatory = False)
280
281    conf.write_config_header('libiberty/config.h')
282
283def bld_libiberty(bld, conf):
284    if bld.env.DEST_OS == 'win32':
285        pex_host = 'libiberty/pex-win32.c'
286    else:
287        pex_host = 'libiberty/pex-unix.c'
288    bld.stlib(target = 'iberty',
289              features = 'c',
290              install_path = None,
291              includes = ['libiberty'],
292              cflags = conf['cflags'],
293              defines = ['HAVE_CONFIG_H=1'],
294              source =['libiberty/concat.c',
295                       'libiberty/cplus-dem.c',
296                       'libiberty/cp-demangle.c',
297                       'libiberty/make-temp-file.c',
298                       'libiberty/mkstemps.c',
299                       'libiberty/safe-ctype.c',
300                       'libiberty/stpcpy.c',
301                       'libiberty/pex-common.c',
302                       'libiberty/pex-one.c',
303                       pex_host])
304
305#
306# The doxy command.
307#
308from waflib import Build
309class doxy(Build.BuildContext):
310    fun = 'build'
311    cmd = 'doxy'
Note: See TracBrowser for help on using the repository browser.