apps/system/microros: add libmicroros.a colcon cross-build orchestration#3498
Open
arjav1528 wants to merge 9 commits into
Open
apps/system/microros: add libmicroros.a colcon cross-build orchestration#3498arjav1528 wants to merge 9 commits into
arjav1528 wants to merge 9 commits into
Conversation
Add micro_ros_lib/ subdirectory with a .keep sentinel so the directory is tracked by git before any generated build artifacts appear. All colcon/fetch outputs land here and are gitignored by the parent .gitignore. Signed-off-by: Arjav Patel <arjav1528@gmail.com>
Add a colcon.meta.in template that is substituted at build time with
Kconfig values. Key settings:
- Custom transport only (UCLIENT_PROFILE_CUSTOM_TRANSPORT=ON,
UCLIENT_PROFILE_STREAM_FRAMING=ON) -- actual UDP/serial callbacks
are wired in Phase 4.
- RCL_MICROROS=ON (Jazzy/Kilted renamed flag replacing the old
RCL_COMMAND_LINE_ENABLED/RCL_LOGGING_ENABLED pair).
- RCUTILS_NO_FILESYSTEM=OFF -- NuttX provides POSIX filesystem.
- Resource limits use @MAX_NODES@/@MAX_PUBLISHERS@ etc. placeholders
substituted from CONFIG_MICROROS_MAX_* Kconfig values.
Signed-off-by: Arjav Patel <arjav1528@gmail.com>
4c403a2 to
9d364bc
Compare
Add toolchain.cmake.in and include_override/assert.h for the colcon
cross-build. Key differences from the old robertobucher port:
- Drop -DCLOCK_MONOTONIC=0: NuttX defines CLOCK_MONOTONIC=1 and
the override broke nanosleep() on newer kernels.
- CMAKE_SYSTEM_PROCESSOR is a placeholder substituted per-arch.
- include_override/assert.h works around the rosidl NDEBUG issue
(ros2/rosidl#739).
Signed-off-by: Arjav Patel <arjav1528@gmail.com>
9d364bc to
832bb10
Compare
| +++ b/rcutils/src/strcasecmp.c | ||
| @@ -17,6 +17,9 @@ extern "C" | ||
| #include <errno.h> | ||
| #include <string.h> |
Contributor
There was a problem hiding this comment.
should we align with Linux?
Contributor
Author
There was a problem hiding this comment.
ahhhh, my bad
Changed the guard to #ifdef NuttX so the include is scoped to NuttX only coz Linux/glibc already exposes strcasecmp through <string.h>
Contributor
|
@arjav1528 please squash the intermediate patch |
Replace the Directory.mk stub with a full Application.mk-based Makefile
that builds libmicroros.a from upstream micro-ROS sources via colcon.
Build pipeline (six steps, each a Make target):
1. micro_ros_dev/install -- clone + build ament/colcon host tools
2. micro_ros_src/src -- git clone all Jazzy micro-ROS packages
with --depth 1; apply DIR-typedef guard
patch; mark unused packages COLCON_IGNORE
3. toolchain.cmake -- sed-substitute CC/CXX/CFLAGS into template
4. colcon.meta -- sed-substitute Kconfig resource limits
5. micro_ros_src/install -- colcon cross-build (merge-install,
packages-ignore-regex=.*_cpp)
6. libmicroros.a -- ar-merge all install/lib/*.a into one
archive; copy include/ tree
clean:: removes generated files; distclean:: removes all fetched dirs.
Signed-off-by: Arjav Patel <arjav1528@gmail.com>
When CONFIG_SYSTEM_MICROROS=y, add the prebuilt libmicroros.a to LDLIBS and the colcon-installed include/ tree to CFLAGS/CXXFLAGS so that any application in nuttx-apps can include micro-ROS headers and link against the library without extra flags. Signed-off-by: Arjav Patel <arjav1528@gmail.com>
NuttX defines DIR as a struct type in dirent.h. The rcutils filesystem source has a bare typedef int DIR that triggers a redefinition error when NuttX system headers are on the include path. Guard it with #ifndef DIR so the typedef is skipped when the type is already defined. Applied automatically during the micro_ros_src/src fetch step with patch -p1 --forward --ignore-whitespace ... || true so the build is idempotent if the upstream ever merges a fix. Signed-off-by: Arjav Patel <arjav1528@gmail.com>
Mirror the Makefile build pipeline into CMakeLists.txt using ExternalProject_Add so that CMake-based NuttX builds (cmake --build) can also produce libmicroros.a. The external project delegates to the existing Makefile targets, then exposes the result via an IMPORTED STATIC library target with correct INTERFACE_INCLUDE_DIRECTORIES. Signed-off-by: Arjav Patel <arjav1528@gmail.com>
Add -D__NuttX__ to CMAKE_C_FLAGS_INIT and CMAKE_CXX_FLAGS_INIT in toolchain.cmake.in so that all cross-compiled micro-ROS packages see the NuttX target macro. Without this, rcutils/src/process.c follows the __linux__ branch and references program_invocation_name, a glibc-only extension absent from the NuttX C library. Pair with 0002-rcutils-process-nuttx-compat.patch which additionally guards the linux branch with !defined(__NuttX__), ensuring the embedded fallback path is taken on NuttX even if the host compiler defines any linux-flavoured macros. Signed-off-by: Arjav Patel <arjav1528@gmail.com>
POSIX specifies strcasecmp/strncasecmp in <strings.h>, not <string.h>. On NuttX (and other strict POSIX environments) rcutils/src/strcasecmp.c only includes <string.h>, causing an implicit-declaration error for strcasecmp when cross-compiling. Patch 0003 adds #include <strings.h> guarded by !_WIN32, matching the existing Windows/POSIX split in the file. Signed-off-by: Arjav Patel <arjav1528@gmail.com>
832bb10 to
6d0d79e
Compare
Contributor
Author
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements an automated build pipeline that fetches all upstream micro-ROS jazzy packages, cross-compiles them with colcon and a NuttX CMake toolchain, and merges the resulting static libraries into a single
libmicroros.aready for linking into a NuttX image.Impact
CONFIG_SYSTEM_MICROROSautomaticallyget
libmicroros.alinked in and all micro-ROS headers available undersystem/microros/include/. No manual build steps are required.make contextin the apps tree triggers the colcon build the firsttime; subsequent builds are incremental. Full build time on a 2-core machine
is approximately 4–5 minutes.
make distcleanfully removes all downloadedsources.
space; only
libmicroros.a(~13–80 MB depending on included message types)and the headers are retained after the build.
colcon-common-extensions,cmake ≥ 3.16,Python 3, and a C/C++ cross-compiler matching
$(CROSSDEV).entirely gated behind
CONFIG_SYSTEM_MICROROS.Testing
Host: Ubuntu 22.04 (EC2
t3.medium),gcc 13,cmake 3.28,colcon 0.3Target:
stm32f4discovery:nsh(ARM Cortex-M4,arm-none-eabi-gcc 14.2)— library produced but not yet run on hardware due to availability issues.
Verified with
make contextend-to-end:phase3.log
make cleanverified removeslibmicroros.a,include/,toolchain.cmake,and
colcon.meta.