@@ -96,7 +96,8 @@ def download_dev_environment(self):
9696
9797 def build_dev_environment (self ):
9898 print ("Building micro-ROS dev dependencies" )
99- self .patch_dev_sources ()
99+ if self .distro == "lyrical" :
100+ self .patch_dev_sources ()
100101
101102 # Fix build: Ignore rmw_test_fixture_implementation in rolling, kilted, lyrical
102103 touch_command = ''
@@ -174,7 +175,8 @@ def get_repositories_from_yaml(self, yaml_file):
174175
175176 def build_mcu_environment (self , meta_file , toolchain_file , user_meta = "" ):
176177 print ("Building micro-ROS library" )
177- self .patch_mcu_sources ()
178+ if self .distro == "lyrical" :
179+ self .patch_mcu_sources ()
178180
179181 common_meta_path = self .library_folder + '/metas/common.meta'
180182 colcon_command = '. {} && colcon build --merge-install --packages-ignore-regex=.*_cpp --metas {} {} {} --cmake-args -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=OFF -DTHIRDPARTY=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE={} -DPython3_EXECUTABLE=`which python`' .format (self .python_env , common_meta_path , meta_file , user_meta , toolchain_file )
@@ -215,17 +217,18 @@ def package_mcu_library(self):
215217 # Copy includes
216218 shutil .copytree (self .build_folder + "/mcu/install/include" , self .includes )
217219
218- timer_h = os .path .join (self .includes , "rclc" , "timer.h" )
219- if os .path .exists (timer_h ):
220- with open (timer_h , "r" ) as f_t :
221- ct = f_t .read ()
222- if "rclc_timer_init_default2" not in ct :
223- ct = ct .replace (
224- "#if __cplusplus\n }\n #endif" ,
225- "static inline rcl_ret_t rclc_timer_init_default2(rcl_timer_t * timer, rclc_support_t * support, const uint64_t timeout_ns, const rcl_timer_callback_t callback, bool autostart) { (void)autostart; return rclc_timer_init_default(timer, support, timeout_ns, callback); }\n \n #if __cplusplus\n }\n #endif"
226- )
227- with open (timer_h , "w" ) as f_t :
228- f_t .write (ct )
220+ if self .distro == "lyrical" :
221+ timer_h = os .path .join (self .includes , "rclc" , "timer.h" )
222+ if os .path .exists (timer_h ):
223+ with open (timer_h , "r" ) as f_t :
224+ ct = f_t .read ()
225+ if "rclc_timer_init_default2" not in ct :
226+ ct = ct .replace (
227+ "#if __cplusplus\n }\n #endif" ,
228+ "static inline rcl_ret_t rclc_timer_init_default2(rcl_timer_t * timer, rclc_support_t * support, const uint64_t timeout_ns, const rcl_timer_callback_t callback, bool autostart) { (void)autostart; return rclc_timer_init_default(timer, support, timeout_ns, callback); }\n \n #if __cplusplus\n }\n #endif"
229+ )
230+ with open (timer_h , "w" ) as f_t :
231+ f_t .write (ct )
229232
230233 # Fix include paths
231234 include_folders = os .listdir (self .includes )
@@ -251,6 +254,15 @@ def resolve_binutils_path(self):
251254 return ""
252255
253256 def patch_dev_sources (self ):
257+ # 1. Relax C/C++ standards for embedded MCU cross-compilers (e.g. GCC 7.2.1 on Portenta)
258+ defaults_cmake = os .path .join (self .dev_src_folder , "ament_cmake_ros" , "ament_cmake_ros_core" , "cmake" , "ament_ros_defaults.cmake" )
259+ if os .path .exists (defaults_cmake ):
260+ with open (defaults_cmake , "r" ) as f :
261+ dc = f .read ()
262+ dc = dc .replace ("cxx_std_20" , "cxx_std_14" ).replace ("c_std_17" , "c_std_11" )
263+ with open (defaults_cmake , "w" ) as f :
264+ f .write (dc )
265+
254266 all_cmake = os .path .join (self .dev_src_folder , "ament_cmake" , "ament_cmake_core" , "cmake" , "core" , "all.cmake" )
255267 if os .path .exists (all_cmake ):
256268 with open (all_cmake , "r" ) as f :
0 commit comments