[PATCH 2/2] rtemstoolkit/rtems: Add support for a BSP in the build tree.

Chris Johns chrisj at rtems.org
Thu Apr 12 04:35:50 UTC 2018


Provide support to find and use a BSP in the build tree. This
change alllows tests to be added to the RTEMS testsuites that
use RTEMS Tools.

Update #2769
---
 rtemstoolkit/rld-rtems.cpp | 48 +++++++++++++++++++++++++++++++++++-----------
 1 file changed, 37 insertions(+), 11 deletions(-)

diff --git a/rtemstoolkit/rld-rtems.cpp b/rtemstoolkit/rld-rtems.cpp
index 806a2e1..2c4db1d 100644
--- a/rtemstoolkit/rld-rtems.cpp
+++ b/rtemstoolkit/rld-rtems.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2016, Chris Johns <chrisj at rtems.org>
+ * Copyright (c) 2011-2018, Chris Johns <chrisj at rtems.org>
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -27,6 +27,7 @@ namespace rld
     static std::string _version = RTEMS_VERSION;
     static std::string _path;
     static std::string _arch_bsp;
+    static bool        _bsp_not_installed;
 
     static uint64_t _version_major = 0;
     static uint64_t _version_minor = 0;
@@ -37,25 +38,50 @@ namespace rld
     {
       path::paths parts;
       std::string rtems_pkgconfig;
-      std::string bsp;
+      std::string bsp_pkgconfig;
 
       if (_path.empty ())
         throw rld::error ("Not set", "RTEMS path");
 
-      bsp = rtems_arch_bsp ();
+      if (!path::check_directory (path ()))
+        throw rld::error ("Invalid RTEMS path", path ());
 
-      parts.push_back ("lib");
-      parts.push_back ("pkgconfig");
+      bsp_pkgconfig = rtems_arch_bsp () + ".pc";
+
+      /*
+       * Check if the path is to the pkg-config file which indicates a flat or
+       * a BSP that is not installed.
+       */
+      parts.clear ();
+      parts.push_back (rtems_arch_prefix ());
+      parts.push_back ("c");
+      parts.push_back (bsp ());
+      parts.push_back (bsp_pkgconfig);
 
       rld::path::path_join (path (), parts, rtems_pkgconfig);
+      if (path::check_file (rtems_pkgconfig))
+      {
+        _bsp_not_installed = true;
+      }
+      else
+      {
+        /*
+         * Check for an installed BSP?
+         */
+        parts.clear ();
+        parts.push_back ("lib");
+        parts.push_back ("pkgconfig");
 
-      if (!path::check_directory (rtems_pkgconfig))
-        throw rld::error ("Invalid RTEMS path", path ());
+        rld::path::path_join (path (), parts, rtems_pkgconfig);
 
-      rld::path::path_join (rtems_pkgconfig, bsp + ".pc", rtems_pkgconfig);
+        if (!path::check_directory (rtems_pkgconfig))
+          throw rld::error ("Invalid RTEMS pkg-config path", rtems_pkgconfig);
 
-      if (!path::check_file (rtems_pkgconfig))
-        throw rld::error ("RTEMS BSP not found", arch_bsp ());
+        rld::path::path_join (rtems_pkgconfig, bsp_pkgconfig, rtems_pkgconfig);
+
+        if (!path::check_file (rtems_pkgconfig))
+          throw rld::error ("RTEMS BSP not found, no pkg-config file found", arch_bsp ());
+      }
 
       if (rld::verbose () >= RLD_VERBOSE_INFO)
         std::cout << " rtems: " << _arch_bsp << ": "
@@ -70,7 +96,7 @@ namespace rld
       if (!pkg.get ("name", name))
         throw rld::error ("RTEMS BSP no name in pkgconfig file", _arch_bsp);
 
-      if (name != bsp)
+      if (name != rtems_arch_bsp ())
         throw rld::error ("RTEMS BSP does not match the name in pkgconfig file",
                           _arch_bsp);
 
-- 
2.15.1



More information about the devel mailing list