-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathlibmicroros.mk
More file actions
134 lines (123 loc) · 6.68 KB
/
libmicroros.mk
File metadata and controls
134 lines (123 loc) · 6.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
EXTENSIONS_DIR = $(shell pwd)
UROS_DIR = $(EXTENSIONS_DIR)/micro_ros_src
BUILD_DIR ?= $(EXTENSIONS_DIR)/build
DEBUG ?= 0
ifeq ($(DEBUG), 1)
BUILD_TYPE = Debug
else
BUILD_TYPE = Release
endif
CFLAGS_INTERNAL := $(X_CFLAGS) -ffunction-sections -fdata-sections
CXXFLAGS_INTERNAL := $(X_CXXFLAGS) -ffunction-sections -fdata-sections
all: $(EXTENSIONS_DIR)/libmicroros.a
clean:
rm -rf $(EXTENSIONS_DIR)/libmicroros.a; \
rm -rf $(EXTENSIONS_DIR)/include; \
rm -rf $(EXTENSIONS_DIR)/esp32_toolchain.cmake; \
rm -rf $(EXTENSIONS_DIR)/micro_ros_dev; \
rm -rf $(EXTENSIONS_DIR)/micro_ros_src;
$(EXTENSIONS_DIR)/esp32_toolchain.cmake: $(EXTENSIONS_DIR)/esp32_toolchain.cmake.in
rm -f $(EXTENSIONS_DIR)/esp32_toolchain.cmake; \
cat $(EXTENSIONS_DIR)/esp32_toolchain.cmake.in | \
sed "s/@CMAKE_C_COMPILER@/$(subst /,\/,$(X_CC))/g" | \
sed "s/@CMAKE_CXX_COMPILER@/$(subst /,\/,$(X_CXX))/g" | \
sed "s/@CFLAGS@/$(subst /,\/,$(CFLAGS_INTERNAL))/g" | \
sed "s/@CXXFLAGS@/$(subst /,\/,$(CXXFLAGS_INTERNAL))/g" | \
sed "s/@IDF_TARGET@/$(subst /,\/,$(IDF_TARGET))/g" | \
sed "s/@IDF_PATH@/$(subst /,\/,$(IDF_PATH))/g" | \
sed "s/@BUILD_CONFIG_DIR@/$(subst /,\/,$(BUILD_DIR)/config)/g" \
> $(EXTENSIONS_DIR)/esp32_toolchain.cmake
$(EXTENSIONS_DIR)/micro_ros_dev/install:
rm -rf micro_ros_dev; \
mkdir micro_ros_dev; cd micro_ros_dev; \
git clone -b rolling https://github.com/ament/ament_cmake src/ament_cmake; \
git clone -b rolling https://github.com/ament/ament_lint src/ament_lint; \
git clone -b rolling https://github.com/ament/ament_package src/ament_package; \
git clone -b rolling https://github.com/ament/googletest src/googletest; \
git clone -b rolling https://github.com/ros2/ament_cmake_ros src/ament_cmake_ros; \
git clone -b rolling https://github.com/ament/ament_index src/ament_index; \
touch src/ament_cmake_ros/rmw_test_fixture_implementation/COLCON_IGNORE; \
touch src/ament_cmake_ros/rmw_test_fixture/COLCON_IGNORE; \
colcon build --cmake-args -DBUILD_TESTING=OFF -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=gcc;
# ros2/rosidl needs to be pinned to an older version as ros2/rosidl#942 added rosidl_buffer as
# a dependency for various rosidl packages and we can't build it currently.
$(EXTENSIONS_DIR)/micro_ros_src/src:
rm -rf micro_ros_src; \
mkdir micro_ros_src; cd micro_ros_src; \
if [ "$(MIDDLEWARE)" = "embeddedrtps" ]; then \
git clone -b main https://github.com/micro-ROS/embeddedRTPS src/embeddedRTPS; \
git clone -b main https://github.com/micro-ROS/rmw_embeddedrtps src/rmw_embeddedrtps; \
else \
git clone -b ros2 https://github.com/eProsima/Micro-XRCE-DDS-Client src/Micro-XRCE-DDS-Client; \
git clone -b rolling https://github.com/micro-ROS/rmw_microxrcedds src/rmw_microxrcedds; \
fi; \
git clone -b ros2 https://github.com/eProsima/micro-CDR src/micro-CDR; \
git clone -b upstream-patches https://github.com/micro-ROS/rcl src/rcl; \
git clone -b rolling https://github.com/ros2/rclc src/rclc; \
git clone -b rolling https://github.com/micro-ROS/rcutils src/rcutils; \
git clone -b rolling https://github.com/micro-ROS/micro_ros_msgs src/micro_ros_msgs; \
git clone -b rolling https://github.com/micro-ROS/rosidl_typesupport src/rosidl_typesupport; \
git clone -b rolling https://github.com/micro-ROS/rosidl_typesupport_microxrcedds src/rosidl_typesupport_microxrcedds; \
git clone -b rolling https://github.com/ros2/rosidl src/rosidl; \
cd src/rosidl; \
git reset --hard 5f4ace0288ecf942307ed62b9239ab5986884676; \
cd ../..; \
git clone -b rolling https://github.com/ros2/rosidl_dynamic_typesupport src/rosidl_dynamic_typesupport; \
git clone -b rolling https://github.com/ros2/rmw src/rmw; \
git clone -b rolling https://github.com/ros2/rcl_interfaces src/rcl_interfaces; \
git clone -b rolling https://github.com/ros2/rosidl_defaults src/rosidl_defaults; \
git clone -b rolling https://github.com/ros2/unique_identifier_msgs src/unique_identifier_msgs; \
git clone -b rolling https://github.com/ros2/common_interfaces src/common_interfaces; \
git clone -b rolling https://github.com/ros2/example_interfaces src/example_interfaces; \
git clone -b rolling https://github.com/ros2/test_interface_files src/test_interface_files; \
git clone -b rolling https://github.com/ros2/rmw_implementation src/rmw_implementation; \
git clone -b rolling https://github.com/ros2/rcl_logging src/rcl_logging; \
git clone -b rolling https://github.com/ros2/ros2_tracing src/ros2_tracing; \
git clone -b rolling https://github.com/micro-ROS/micro_ros_utilities src/micro_ros_utilities; \
git clone -b rolling https://github.com/ros2/rosidl_core src/rosidl_core; \
touch src/rcl/rcl_yaml_param_parser/COLCON_IGNORE; \
touch src/rclc/rclc_examples/COLCON_IGNORE; \
touch src/rcl_logging/rcl_logging_implementation/COLCON_IGNORE; \
touch src/rcl_logging/rcl_logging_spdlog/COLCON_IGNORE; \
touch src/ros2_tracing/lttngpy/COLCON_IGNORE; \
touch src/ros2_tracing/test_tracetools/COLCON_IGNORE; \
touch src/rosidl/rosidl_buffer/COLCON_IGNORE; \
touch src/rosidl/rosidl_buffer_backend/COLCON_IGNORE; \
touch src/rosidl/rosidl_buffer_backend_registry/COLCON_IGNORE; \
touch src/rosidl/rosidl_typesupport_introspection_cpp/COLCON_IGNORE; \
cp -rfL $(EXTRA_ROS_PACKAGES) src/extra_packages || :; \
test -f src/extra_packages/extra_packages.repos && cd src/extra_packages && vcs import --input extra_packages.repos || :;
$(EXTENSIONS_DIR)/micro_ros_src/install: $(EXTENSIONS_DIR)/esp32_toolchain.cmake $(EXTENSIONS_DIR)/micro_ros_dev/install $(EXTENSIONS_DIR)/micro_ros_src/src
cd $(UROS_DIR); \
unset AMENT_PREFIX_PATH; \
PATH="$(subst /opt/ros/$(ROS_DISTRO)/bin,,$(PATH))"; \
. ../micro_ros_dev/install/local_setup.sh; \
colcon build \
--merge-install \
--packages-ignore-regex=.*_cpp \
--metas $(EXTENSIONS_DIR)/colcon.meta $(APP_COLCON_META) \
--cmake-args \
"--no-warn-unused-cli" \
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=OFF \
-DTHIRDPARTY=ON \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DCMAKE_TOOLCHAIN_FILE=$(EXTENSIONS_DIR)/esp32_toolchain.cmake \
-DCMAKE_VERBOSE_MAKEFILE=OFF \
-DIDF_INCLUDES='${IDF_INCLUDES}' \
-DCMAKE_C_STANDARD=$(C_STANDARD) \
-DUCLIENT_C_STANDARD=$(C_STANDARD);
$(EXTENSIONS_DIR)/libmicroros.a: $(EXTENSIONS_DIR)/micro_ros_src/install
mkdir -p $(UROS_DIR)/libmicroros; cd $(UROS_DIR)/libmicroros; \
for file in $$(find $(UROS_DIR)/install/lib/ -name '*.a'); do \
folder=$$(echo $$file | sed -E "s/(.+)\/(.+).a/\2/"); \
mkdir -p $$folder; cd $$folder; $(X_AR) x $$file; \
for f in *; do \
mv $$f ../$$folder-$$f; \
done; \
cd ..; rm -rf $$folder; \
done ; \
$(X_AR) rc -s libmicroros.a *.obj; cp libmicroros.a $(EXTENSIONS_DIR); \
cd ..; rm -rf libmicroros; \
cp -R $(UROS_DIR)/install/include $(EXTENSIONS_DIR)/include;