[PATCH] Avoid default RTEMS application configuration

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Oct 18 07:38:16 UTC 2018


Use a test body with a proper RTEMS application configuration to avoid a
dependency on the default configuration.  Do not include
<rtems/score/cpuopts.h> directly since this header file is an
implementation detail.

Update #3551.
---
 rtems.py | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/rtems.py b/rtems.py
index 1b0da60..c7a1966 100644
--- a/rtems.py
+++ b/rtems.py
@@ -259,13 +259,18 @@ def configure(conf, bsp_configure = None):
         #
         # Checks for various RTEMS features.
         #
-        conf.multicheck({ 'header_name': 'rtems/score/cpuopts.h'},
-                        msg = 'Checking for RTEMS CPU options header',
-                        mandatory = True)
-        load_cpuopts(conf, ab, rtems_path)
-        conf.multicheck({ 'header_name': 'rtems.h'},
-                        msg = 'Checking for RTEMS header',
-                        mandatory = True)
+        main = 'void Init(rtems_task_argument arg) { (void)arg; }%s' % (os.linesep)
+        main += '#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER 1%s' % (os.linesep)
+        main += '#define CONFIGURE_MAXIMUM_TASKS 1%s' % (os.linesep)
+        main += '#define CONFIGURE_RTEMS_INIT_TASKS_TABLE%s' % (os.linesep)
+        main += '#define CONFIGURE_INIT%s' % (os.linesep)
+        main += '#include <rtems/confdefs.h>%s' % (os.linesep)
+        code = '#include <rtems.h>%s' % (os.linesep)
+        code += main
+        conf.check_cc(fragment = code,
+                      execute = False,
+                      msg = 'Building a trivial RTEMS application')
+        load_cpuopts(conf, main)
 
         #
         # Add tweaks.
@@ -294,7 +299,7 @@ def build(bld):
     if bld.env.LONG_COMMANDS == 'yes':
         long_command_line()
 
-def load_cpuopts(conf, arch_bsp, rtems_path):
+def load_cpuopts(conf, main):
     options = ['RTEMS_DEBUG',
                'RTEMS_MULTIPROCESSING',
                'RTEMS_NEWLIB',
@@ -302,14 +307,14 @@ def load_cpuopts(conf, arch_bsp, rtems_path):
                'RTEMS_SMP',
                'RTEMS_NETWORKING']
     for opt in options:
-        enabled = check_opt(conf, opt, 'rtems/score/cpuopts.h', arch_bsp, rtems_path)
+        enabled = check_cpuopt(conf, opt, main)
         if enabled:
             conf.env[opt] = 'Yes'
         else:
             conf.env[opt] = 'No'
 
-def check_opt(conf, opt, header, arch_bsp, rtems_path):
-    code  = '#include <%s>%s' % (header, os.linesep)
+def check_cpuopt(conf, opt, main):
+    code  = '#include <rtems.h>%s' % (os.linesep)
     code += '#ifndef %s%s' % (opt, os.linesep)
     code += ' #error %s is not defined%s' % (opt, os.linesep)
     code += '#endif%s' % (os.linesep)
@@ -318,11 +323,10 @@ def check_opt(conf, opt, header, arch_bsp, rtems_path):
     code += '#else%s' % (os.linesep)
     code += ' #error %s is false%s' % (opt, os.linesep)
     code += '#endif%s' % (os.linesep)
-    code += 'int main() { return 0; }%s' % (os.linesep)
+    code += main
     try:
         conf.check_cc(fragment = code,
                       execute = False,
-                      define_ret = False,
                       msg = 'Checking for %s' % (opt))
     except conf.errors.WafError:
         return False;
-- 
2.16.4



More information about the devel mailing list