|
| 1 | +# SPDX-License-Identifier: BSD-2-Clause |
| 2 | + |
| 3 | +# Copyright (C) 2022 On-Line Applications Research Corporation (OAR) |
| 4 | +# Written by Kinsey Moore <kinsey.moore@oarcorp.com> |
| 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 "AS IS" |
| 16 | +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 | +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 19 | +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 | +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 | +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 22 | +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 | +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 | +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 | +# POSSIBILITY OF SUCH DAMAGE. |
| 26 | + |
| 27 | +from rtems_waf import rtems |
| 28 | +import json |
| 29 | +import os |
| 30 | + |
| 31 | + |
| 32 | +def removeprefix(data, prefix): |
| 33 | + if data.startswith(prefix): |
| 34 | + return data[len(prefix):] |
| 35 | + return data |
| 36 | + |
| 37 | + |
| 38 | +def build(bld): |
| 39 | + |
| 40 | + arch_lib_path = rtems.arch_bsp_lib_path(bld.env.RTEMS_VERSION, |
| 41 | + bld.env.RTEMS_ARCH_BSP) |
| 42 | + |
| 43 | + def install_headers(root_path): |
| 44 | + for root, dirs, files in os.walk(root_path): |
| 45 | + for name in files: |
| 46 | + ext = os.path.splitext(name)[1] |
| 47 | + src_root = os.path.split(root) |
| 48 | + path = os.path.join(src_root[0], src_root[1]) |
| 49 | + if ext == '.h': |
| 50 | + subpath = removeprefix(removeprefix(path, root_path), "/") |
| 51 | + bld.install_files( |
| 52 | + os.path.join("${PREFIX}", |
| 53 | + arch_lib_path, |
| 54 | + "include", |
| 55 | + subpath), |
| 56 | + os.path.join(path, name) |
| 57 | + ) |
| 58 | + |
| 59 | + lib_path = os.path.join(bld.env.PREFIX, arch_lib_path) |
| 60 | + bld.read_stlib('lwip', paths=[lib_path]) |
| 61 | + bld.read_stlib('rtemstest', paths=[lib_path]) |
| 62 | + |
| 63 | + |
| 64 | +def add_flags(flags, new_flags): |
| 65 | + for flag in new_flags: |
| 66 | + if flag not in flags: |
| 67 | + flags.append(flag) |
| 68 | + |
| 69 | + |
| 70 | +def bsp_configure(conf, arch_bsp): |
| 71 | + conf.env.LIB += ['m'] |
| 72 | + section_flags = ["-fdata-sections", "-ffunction-sections"] |
| 73 | + add_flags(conf.env.CFLAGS, section_flags) |
| 74 | + add_flags(conf.env.CXXFLAGS, section_flags) |
0 commit comments