summaryrefslogtreecommitdiffstats
path: root/source-builder
diff options
context:
space:
mode:
authorRyan Long <ryan.long@oarcorp.com>2021-10-12 15:01:44 -0400
committerJoel Sherrill <joel@rtems.org>2021-11-09 11:10:40 -0600
commitdef934785d4ae3c4b90733e8d5c443d61368268f (patch)
tree3705b5955547b3b1f85d7278ba6e7666d48ba4be /source-builder
parentrtems-gcc-10-newlib-head: Uncomment patch lines (diff)
downloadrtems-source-builder-def934785d4ae3c4b90733e8d5c443d61368268f.tar.bz2
rtems-kernel: Implement kernel recipe using waf
Closes #4145
Diffstat (limited to 'source-builder')
-rwxr-xr-xsource-builder/sb/rtems-kernel-config-check147
1 files changed, 147 insertions, 0 deletions
diff --git a/source-builder/sb/rtems-kernel-config-check b/source-builder/sb/rtems-kernel-config-check
new file mode 100755
index 0000000..9bdff22
--- /dev/null
+++ b/source-builder/sb/rtems-kernel-config-check
@@ -0,0 +1,147 @@
+#! /usr/bin/env python
+
+"""
+SPDX-License-Identifier: BSD-2-Clause
+
+COPYRIGHT (C) 2021 On-Line Applications Research Corporation (OAR).
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+"""
+
+from __future__ import print_function
+
+import sys
+import argparse
+
+from os.path import exists
+
+try:
+ import ConfigParser
+ configparser = ConfigParser # used for python2
+except ImportError:
+ try:
+ import configparser # used for python3
+ except ImportError:
+ print("Could not import configparser. Exiting...", file = sys.stderr)
+ sys.exit(1)
+
+def run():
+ parser = argparse.ArgumentParser()
+ parser.add_argument("config", help="path to config file")
+ parser.add_argument(
+ "-a",
+ "--arch",
+ help="return target architecture specified in the config",
+ action="store_true"
+ )
+ parser.add_argument(
+ "-b",
+ "--bsp",
+ help="return BSP specified in the config",
+ action="store_true"
+ )
+ parser.add_argument(
+ "-c",
+ "--arch-bsp",
+ help="return target architecture and BSP specified in the config",
+ action="store_true"
+ )
+ parser.add_argument(
+ "-v",
+ "--rtems-version",
+ help="version of RTEMS",
+ type=int,
+ default=6
+ )
+ parser.add_argument(
+ "-t",
+ "--target",
+ help="return target (<arch-rtems<rtems-version>)",
+ action="store_true"
+ )
+ args = parser.parse_args()
+ config = configparser.ConfigParser()
+
+ if args.config[-4:] != ".ini":
+ print(
+ "The config file is missing an *.ini extension.",
+ file = sys.stderr
+ )
+ sys.exit(1)
+
+ try:
+ config.read(args.config)
+ except configparser.MissingSectionHeaderError:
+ print(
+ "There is no section header in the config file",
+ file = sys.stderr
+ )
+ sys.exit(1)
+ except configparser.ParsingError:
+ print(
+ "An exception occured when parsing the config file",
+ file = sys.stderr
+ )
+ sys.exit(1)
+ except:
+ print(
+ "An unknown exception occured",
+ file = sys.stderr
+ )
+
+ if len(config.sections()) != 1:
+ print(
+ "You can only have one arch/bsp section in your config.",
+ file = sys.stderr
+ )
+ sys.exit(1)
+
+ arch_bsp_str = config.sections()[0]
+ if arch_bsp_str.find("/") == -1:
+ print(
+ "arch/bsp section in config is missing '/'",
+ file = sys.stderr
+ )
+ sys.exit(1)
+
+ if ( args.arch or args.bsp) and args.arch_bsp:
+ args.arch = False
+
+ if args.arch:
+ print(arch_bsp_str.split("/")[0])
+ return
+
+ if args.bsp:
+ print(arch_bsp_str.split("/")[1])
+ return
+
+ if args.arch_bsp:
+ print(arch_bsp_str.replace("/", " "))
+ return
+
+ if args.target:
+ arch = arch_bsp_str.split("/")[0]
+ print(arch + "-rtems" + str(args.rtems_version))
+ return
+
+if __name__ == "__main__":
+ run()