[RTEMS Project] #4927: "Build Your Application" (Quick Start section 2.7) doesn't work

RTEMS trac trac at rtems.org
Sat Oct 7 17:10:39 UTC 2023


#4927: "Build Your Application" (Quick Start section 2.7) doesn't work
-----------------------+---------------------
 Reporter:  bsterling  |       Owner:  (none)
     Type:  defect     |      Status:  new
 Priority:  normal     |   Milestone:
Component:  admin      |     Version:
 Severity:  normal     |  Resolution:
 Keywords:             |  Blocked By:
 Blocking:             |
-----------------------+---------------------

Comment (by John Willis):

 Replying to [comment:12 Chris Johns]:
 > Replying to [comment:11 John Willis]:
 > > Replying to [comment:10 Chris Johns]:
 > > > Can this now be closed given Martin's patch was pushed?
 > >
 > > I found Martin's commit. I am worried that this will cause other
 problems. This is a very similar solution that I initially had, but the
 following lines in `configure` in `rtems.py` worry me:
 > >
 > > {{{
 > > arch = _arch_from_arch_bsp(ab)
 > > bsp = _bsp_from_arch_bsp(ab)
 > >
 > > conf.env.ARCH_BSP = '%s/%s' % (arch.split('-')[0], bsp)
 > > }}}
 > >
 > > If we return `None` from `_arch_from_arch_bsp` then
 `arch.split('-')[0]` will fail.
 >
 > Do you have a suggestion?

 This might be overkill, but my thought here is to have the caller handle
 the case that the return value is None, and to fail elegantly as opposed
 to opaquely:

 {{{
 From c22c450f2fa39e25ea2c3f789df5df12e59e7c3f Mon Sep 17 00:00:00 2001
 From: jmart <jmart.will at gmail.com>
 Date: Sat, 7 Oct 2023 11:33:10 -0600
 Subject: [PATCH] If we try to call _arch_from_arch_bsp in config on an
  arch_bsp that does not contain the string 'rtems', then we will return
 None,
  and eventually try to call split('-') on none type, which will fail.
 Instead,
  we could catch this situation and raise an informative exception to the
 user.

 ---
  rtems.py | 5 +++++
  1 file changed, 5 insertions(+)

 diff --git a/rtems.py b/rtems.py
 index 1566e58..37cc32e 100644
 --- a/rtems.py
 +++ b/rtems.py
 @@ -222,7 +222,12 @@ def configure(conf, bsp_configure=None):
          conf.msg('Long commands', long_commands)

          arch = _arch_from_arch_bsp(ab)
 +        if arch is None:
 +            raise Exception(f"No valid arch in {ab}")
 +
          bsp = _bsp_from_arch_bsp(ab)
 +        if bsp is None:
 +            raise Exception(f"No valid bsp in {ab}")

          conf.env.ARCH_BSP = '%s/%s' % (arch.split('-')[0], bsp)

 --
 2.34.1


 }}}

 This is definitely an edge case and given that there are no tests in this
 repo, it is hard too say if this will ever occur -- it seems like this
 situation would be caught earlier on in the process since we would be
 trying to build an unsupported bsp. In any case, if we don't do something
 like this, I think I am good with Martin's patch.

 Thanks for your patience.

--
Ticket URL: <http://devel.rtems.org/ticket/4927#comment:13>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list