source: rtems-libbsd/wscript @ f7a09b5

55-freebsd-126-freebsd-12
Last change on this file since f7a09b5 was f7a09b5, checked in by Chris Johns <chrisj@…>, on 03/26/18 at 04:14:52

waf: Support building from libbsd.py directly from waf.

Remove the need to generate a waf script.

Move various pieces of data from the builder code to libbsd.py and make
it configuration data.

Update #3351

  • Property mode set to 100644
File size: 4.4 KB
RevLine 
[feaf877]1#
[051ef30]2# RTEMS Project (https://www.rtems.org/)
[8b10210]3#
[051ef30]4# Copyright (c) 2015-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
27#
28# RTEMS LibBSD is a transparent source build of the FreeBSD kernel source for RTEMS.
[8b10210]29#
30# To use see README.waf shipped with this file.
[feaf877]31#
32
[97c5024a]33from __future__ import print_function
34
[b15a719]35rtems_version = "5"
[97c5024a]36
[feaf877]37try:
38    import rtems_waf.rtems as rtems
39except:
[d6c6017]40    print("error: no rtems_waf git submodule; see README.waf")
[feaf877]41    import sys
42    sys.exit(1)
43
[f7a09b5]44import libbsd
45import waf_libbsd
46
47builder = None
48
49def create_builder():
50    global builder
51    if builder is None:
52        builder = waf_libbsd.Builder()
53        libbsd.load(builder)
54        builder.generate(rtems_version)
[051ef30]55
[feaf877]56def init(ctx):
[f7a09b5]57    create_builder();
[32ceb14]58    rtems.init(ctx, version = rtems_version, long_commands = True)
[f7a09b5]59    builder.init(ctx)
[feaf877]60
61def options(opt):
[f7a09b5]62    create_builder();
[feaf877]63    rtems.options(opt)
[8b10210]64    opt.add_option("--enable-auto-regen",
65                   action = "store_true",
66                   default = False,
67                   dest = "auto_regen",
68                   help = "Enable auto-regeneration of LEX, RPC and YACC files.")
69    opt.add_option("--enable-warnings",
70                   action = "store_true",
71                   default = False,
72                   dest = "warnings",
73                   help = "Enable all warnings. The default is quiet builds.")
[56d787f]74    opt.add_option("--net-test-config",
75                   default = "config.inc",
76                   dest = "net_config",
77                   help = "Network test configuration.")
[e1e10cd]78    opt.add_option("--freebsd-options",
79                   action = "store",
80                   default = "",
81                   dest = "freebsd_options",
82                   help = "Set FreeBSD options (developer option).")
[d18c643]83    opt.add_option("--optimization",
84                   action = "store",
85                   default = "2",
86                   dest = "optimization",
87                   help = "Set optimization level to OPTIMIZATION (-On compiler flag). Default is 2 (-O2).")
[f7a09b5]88    builder.options(opt)
[feaf877]89
[84288f4]90def bsp_configure(conf, arch_bsp):
[f7a09b5]91    create_builder();
[84288f4]92    conf.check(header_name = "dlfcn.h", features = "c")
[1383c80]93    conf.check(header_name = "rtems/pci.h", features = "c", mandatory = False)
[98d7c3c]94    if not rtems.check_posix(conf):
95        conf.fatal("RTEMS kernel POSIX support is disabled; configure RTEMS with --enable-posix")
96    if rtems.check_networking(conf):
97        conf.fatal("RTEMS kernel contains the old network support; configure RTEMS with --disable-networking")
[f7a09b5]98    builder.bsp_configure(conf, arch_bsp)
[84288f4]99
[feaf877]100def configure(conf):
[f7a09b5]101    create_builder();
[8b10210]102    if conf.options.auto_regen:
103        conf.find_program("lex", mandatory = True)
104        conf.find_program("rpcgen", mandatory = True)
105        conf.find_program("yacc", mandatory = True)
106    conf.env.AUTO_REGEN = conf.options.auto_regen
107    conf.env.WARNINGS = conf.options.warnings
[56d787f]108    conf.env.NET_CONFIG = conf.options.net_config
[e1e10cd]109    conf.env.FREEBSD_OPTIONS =conf.options.freebsd_options
[d18c643]110    conf.env.OPTIMIZATION = conf.options.optimization
[84288f4]111    rtems.configure(conf, bsp_configure)
[f7a09b5]112    builder.configure(conf)
[feaf877]113
114def build(bld):
[f7a09b5]115    create_builder();
[feaf877]116    rtems.build(bld)
[f7a09b5]117    builder.build(bld)
Note: See TracBrowser for help on using the repository browser.