source: rtems_waf/rtems_bsd.py

Last change on this file was c60c068, checked in by Chris Johns <chrisj@…>, on Sep 11, 2016 at 7:02:51 AM

libbsd: Fix UnboundLocalError? when rtems_libbsd is None.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1#
2# RTEMS Project (https://www.rtems.org/)
3#
4# Copyright (c) 2016 Chris Johns <chrisj@rtems.org>. All rights reserved.
5#
6#  Redistribution and use in source and binary forms, with or without
7#  modification, are permitted provided that the following conditions
8#  are met:
9#  1. Redistributions of source code must retain the above copyright
10#     notice, this list of conditions and the following disclaimer.
11#  2. Redistributions in binary form must reproduce the above copyright
12#     notice, this list of conditions and the following disclaimer in the
13#     documentation and/or other materials provided with the distribution.
14#
15#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27from __future__ import print_function
28
29import os.path
30
31try:
32    import rtems_waf.rtems as rtems
33except:
34    print("error: no rtems_waf module")
35    import sys
36    sys.exit(1)
37
38def init(ctx):
39    pass
40
41def options(opt):
42    opt.add_option('--net-test-config',
43                   default = 'config.inc',
44                   dest = 'net_config',
45                   help = 'Network test configuration.')
46    opt.add_option('--rtems-libbsd',
47                   action = 'store',
48                   default = None,
49                   dest = 'rtems_libbsd',
50                   help = 'Path to install RTEMS LibBSD (defauls to prefix).')
51
52def bsp_configure(conf, arch_bsp):
53    conf.check(header_name = 'dlfcn.h', features = 'c')
54    if not rtems.check_posix(conf):
55        conf.fatal("RTEMS kernel POSIX support is disabled; configure RTEMS with --enable-posix")
56    if rtems.check_networking(conf):
57        conf.fatal("RTEMS kernel contains the old network support; configure RTEMS with --disable-networking")
58    if conf.options.rtems_libbsd is None:
59        rtems_libbsd_path = conf.env.PREFIX
60    else:
61        if not os.path.exists(conf.options.rtems_libbsd):
62            conf.fatal('RTEMS LibBSD not found')
63        rtems_libbsd_path = conf.options.rtems_libbsd
64
65    rtems_libbsd_inc_path = os.path.join(rtems_libbsd_path,
66                                         rtems.arch_bsp_include_path(conf.env.RTEMS_VERSION,
67                                                                     conf.env.RTEMS_ARCH_BSP))
68    rtems_libbsd_lib_path = os.path.join(rtems_libbsd_path,
69                                         rtems.arch_bsp_lib_path(conf.env.RTEMS_VERSION,
70                                                                 conf.env.RTEMS_ARCH_BSP))
71
72    conf.env.IFLAGS += [rtems_libbsd_inc_path]
73    conf.check(header_name = 'machine/rtems-bsd-sysinit.h', features = 'c', includes = conf.env.IFLAGS)
74
75    conf.env.INCLUDES = conf.env.IFLAGS
76    conf.env.LIBPATH += [rtems_libbsd_lib_path]
77    conf.env.LIB += ['bsd', 'z', 'm']
Note: See TracBrowser for help on using the repository browser.