diff --git a/open-codegen/opengen/builder/optimizer_builder.py b/open-codegen/opengen/builder/optimizer_builder.py index 55c96f64..75f46603 100644 --- a/open-codegen/opengen/builder/optimizer_builder.py +++ b/open-codegen/opengen/builder/optimizer_builder.py @@ -860,6 +860,11 @@ def build(self): self.__build_python_bindings() if self.__build_config.ros_config is not None: + if self.__generate_not_build: + self.__logger.fatal( + "Do not use with_ros and with_generate_not_build_flag simultaneously") + raise ValueError( + "Unless the optimiser has been built, a ROS package cannot be generated") ros_builder = RosBuilder( self.__meta, self.__build_config, diff --git a/open-codegen/opengen/builder/ros_builder.py b/open-codegen/opengen/builder/ros_builder.py index 0108a8a5..2e06694a 100644 --- a/open-codegen/opengen/builder/ros_builder.py +++ b/open-codegen/opengen/builder/ros_builder.py @@ -34,6 +34,11 @@ class RosBuilder: """ def __init__(self, meta, build_config, solver_config): + if os.name == 'nt': + self.__logger.warning( + "You're on Windows; you will not be able to run ROS!") + self.__logger.info( + "The ROS code will be generated, but without the static library") self.__meta = meta self.__build_config = build_config self.__solver_config = solver_config @@ -120,7 +125,27 @@ def __copy__ros_files(self): 'target', self.__build_config.build_mode, lib_file_name)) - shutil.copyfile(original_lib_file, target_lib_file_name) + + if not os.path.exists(original_lib_file): + # No static library file (most likely, because the user is on Windows) + # otherwise an error would have been produced earlier. Windows produces + # a DLL file, however it doesn't make sense to move it to the target + # directory (extern_lib) because ROS doesn't run on Windows anyway + self.__logger.warning( + f"File {original_lib_file} not found; proceeding without") + if os.name == 'nt': + self.__logger.warning( + "File {lib_file_name} not found because you're running on Windows") + # Create a LIBRARY_MISSING_README.md file in the target directory + warning_file_name = \ + os.path.abspath(os.path.join( + target_ros_dir, 'extern_lib', 'LIBRARY_MISSING_README.md')) + with open(warning_file_name, 'w') as wfh: + wfh.write(f"""WARNING!\n\n +Library file {lib_file_name} is missing. You will need to compile +on the target device and copy the library file here by yourself.""") + else: + shutil.copyfile(original_lib_file, target_lib_file_name) # 3. --- copy msg file OptimizationParameters.msg original_params_msg = os.path.abspath(