From 192d384233dbd67db5252f0ccc26f6197034c85a Mon Sep 17 00:00:00 2001 From: Andre Rosa Date: Fri, 5 Apr 2019 19:15:04 -0700 Subject: [PATCH] DRAFT ament.bbclass: Fix PYTHON_SOABI * Make it conditional on the configured MACHINE. Otherwise needs to be reworked to avoid getting the SOABI from python3-native. * See: https://github.com/lgsvl/meta-ros2/commit/4b6bb786336695cd04144ff4eeb2e4d6b6b9ad3a https://github.com/ros2/rosidl_python/blob/master/python_cmake_module/cmake/Modules/FindPythonExtra.cmake https://discourse.ros.org/t/import-error-no-module-named-rclpy-rclpy-cross-compiling/2463/ * With the patch ros2 cli works well for all listed MACHINE(s): root@qemuarm64:~# ros2 topic list /parameter_events /rosout root@qemuarm64:~# ros2 topic pub /chatter std_msgs/String "data: Hello world" publisher: beginning loop publishing #1: std_msgs.msg.String(data='Hello world') publishing #2: std_msgs.msg.String(data='Hello world') ... root@qemuarm64:~# ros2 topic echo /chatter data: Hello world data: Hello world ... --- classes/ament.bbclass | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/classes/ament.bbclass b/classes/ament.bbclass index be9359a..cc42f79 100644 --- a/classes/ament.bbclass +++ b/classes/ament.bbclass @@ -1,5 +1,19 @@ -EXTRA_OECMAKE_append = " -DBUILD_TESTING=OFF -DPYTHON_SOABI=cpython-35m-${TUNE_ARCH}-${TARGET_OS}${ARMPKGSFX_EABI}" +def ament__get_python_soabi(d): + machine = d.getVar('MACHINE', True) + pysoabi_prefix = 'cpython-' + d.getVar('PYTHON_BASEVERSION', True).replace('.', '') + d.getVar('PYTHON_ABI', True) + machine_pysoabi_map = { + 'qemux86': (d.getVar('QB_SYSTEM_NAME_x86', True) or '').rsplit('-')[-1] + '-${TARGET_OS}-gnu', + 'qemux86-64': (d.getVar('QB_SYSTEM_NAME_x86-64', True) or '').rsplit('-')[-1] + '-${TARGET_OS}-gnu', + 'qemuarm64': '${TUNE_ARCH}-${TARGET_OS}${ARMPKGSFX_EABI}-gnu', + 'raspberrypi3': '${TUNE_ARCH}-${TARGET_OS}${ARMPKGSFX_EABI}', + } + try: + return pysoabi_prefix + '-' + machine_pysoabi_map[machine] + except KeyError: + bb.fatal('Unknown MACHINE name: ' + machine + '; can not determine the PYTHON_SOABI value.') + +EXTRA_OECMAKE_append = " -DBUILD_TESTING=OFF -DPYTHON_SOABI=${@ament__get_python_soabi(d)}" # XXX Without STAGING_DIR_HOST path included, rmw-implementation:do_configure() fails with: # # "Could not find ROS middleware implementation 'NOTFOUND'"