forked from micro-ROS/micro_ros_zephyr_module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibmicroros.mk
129 lines (116 loc) · 6.83 KB
/
libmicroros.mk
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
UROS_DIR = $(COMPONENT_PATH)/micro_ros_src
DEBUG ?= 0
ifeq ($(DEBUG), 1)
BUILD_TYPE = Debug
else
BUILD_TYPE = Release
endif
CFLAGS_INTERNAL := $(X_CFLAGS)
CXXFLAGS_INTERNAL := $(X_CXXFLAGS)
CFLAGS_INTERNAL := -c -I$(ZEPHYR_BASE)/include/posix -I$(PROJECT_BINARY_DIR)/include/generated $(CFLAGS_INTERNAL)
CXXFLAGS_INTERNAL := -c -I$(ZEPHYR_BASE)/include/posix -I$(PROJECT_BINARY_DIR)/include/generated $(CXXFLAGS_INTERNAL)
all: $(COMPONENT_PATH)/libmicroros.a
clean:
rm -rf $(COMPONENT_PATH)/libmicroros.a; \
rm -rf $(COMPONENT_PATH)/include; \
rm -rf $(COMPONENT_PATH)/zephyr_toolchain.cmake; \
rm -rf $(COMPONENT_PATH)/micro_ros_dev; \
rm -rf $(COMPONENT_PATH)/micro_ros_src;
ZEPHYR_CONF_FILE := $(PROJECT_BINARY_DIR)/.config
configure_colcon_meta: $(COMPONENT_PATH)/colcon.meta $(COMPONENT_PATH)/micro_ros_src/src
. $(COMPONENT_PATH)/utils.sh; \
cp $(COMPONENT_PATH)/colcon.meta $(COMPONENT_PATH)/configured_colcon.meta; \
ZEPHYR_CONF_FILE=$(ZEPHYR_CONF_FILE); \
update_meta_from_zephyr_config "CONFIG_MICROROS_NODES" "rmw_microxrcedds" "RMW_UXRCE_MAX_NODES"; \
update_meta_from_zephyr_config "CONFIG_MICROROS_PUBLISHERS" "rmw_microxrcedds" "RMW_UXRCE_MAX_PUBLISHERS"; \
update_meta_from_zephyr_config "CONFIG_MICROROS_SUBSCRIBERS" "rmw_microxrcedds" "RMW_UXRCE_MAX_SUBSCRIPTIONS"; \
update_meta_from_zephyr_config "CONFIG_MICROROS_CLIENTS" "rmw_microxrcedds" "RMW_UXRCE_MAX_CLIENTS"; \
update_meta_from_zephyr_config "CONFIG_MICROROS_SERVERS" "rmw_microxrcedds" "RMW_UXRCE_MAX_SERVICES"; \
update_meta_from_zephyr_config "CONFIG_MICROROS_RMW_HISTORIC" "rmw_microxrcedds" "RMW_UXRCE_MAX_HISTORY"; \
update_meta_from_zephyr_config "CONFIG_MICROROS_XRCE_DDS_HISTORIC" "rmw_microxrcedds" "RMW_UXRCE_STREAM_HISTORY"; \
update_meta "microxrcedds_client" "UCLIENT_PROFILE_SERIAL=OFF"; \
update_meta "microxrcedds_client" "UCLIENT_PROFILE_UDP=OFF"; \
update_meta "microxrcedds_client" "UCLIENT_PROFILE_TCP=OFF"; \
update_meta "microxrcedds_client" "UCLIENT_PROFILE_CUSTOM_TRANSPORT=ON"; \
update_meta "microxrcedds_client" "UCLIENT_PROFILE_STREAM_FRAMING=ON"; \
update_meta "rmw_microxrcedds" "RMW_UXRCE_TRANSPORT=custom";
configure_toolchain: $(COMPONENT_PATH)/zephyr_toolchain.cmake.in
rm -f $(COMPONENT_PATH)/zephyr_toolchain.cmake; \
cat $(COMPONENT_PATH)/zephyr_toolchain.cmake.in | \
sed "s/@CMAKE_C_COMPILER@/$(subst /,\/,$(X_CC))/g" | \
sed "s/@CMAKE_CXX_COMPILER@/$(subst /,\/,$(X_CXX))/g" | \
sed "s/@CMAKE_SYSROOT@/$(subst /,\/,$(COMPONENT_PATH))/g" | \
sed "s/@CFLAGS@/$(subst /,\/,$(CFLAGS_INTERNAL))/g" | \
sed "s/@CXXFLAGS@/$(subst /,\/,$(CXXFLAGS_INTERNAL))/g" \
> $(COMPONENT_PATH)/zephyr_toolchain.cmake
$(COMPONENT_PATH)/micro_ros_dev/install:
rm -rf micro_ros_dev; \
mkdir micro_ros_dev; cd micro_ros_dev; \
git clone -b galactic https://github.com/ament/ament_cmake src/ament_cmake; \
git clone -b galactic https://github.com/ament/ament_lint src/ament_lint; \
git clone -b galactic https://github.com/ament/ament_package src/ament_package; \
git clone -b galactic https://github.com/ament/googletest src/googletest; \
git clone -b galactic https://github.com/ros2/ament_cmake_ros src/ament_cmake_ros; \
git clone -b galactic https://github.com/ament/ament_index src/ament_index; \
colcon build --cmake-args -DBUILD_TESTING=OFF;
$(COMPONENT_PATH)/micro_ros_src/src:
rm -rf micro_ros_src; \
mkdir micro_ros_src; cd micro_ros_src; \
git clone -b foxy https://github.com/eProsima/micro-CDR src/micro-CDR; \
git clone -b foxy https://github.com/eProsima/Micro-XRCE-DDS-Client src/Micro-XRCE-DDS-Client; \
git clone -b galactic https://github.com/micro-ROS/rcl src/rcl; \
git clone -b galactic https://github.com/ros2/rclc src/rclc; \
git clone -b galactic https://github.com/micro-ROS/rcutils src/rcutils; \
git clone -b galactic https://github.com/micro-ROS/micro_ros_msgs src/micro_ros_msgs; \
git clone -b galactic https://github.com/micro-ROS/rmw-microxrcedds src/rmw-microxrcedds; \
git clone -b galactic https://github.com/micro-ROS/rosidl_typesupport src/rosidl_typesupport; \
git clone -b galactic https://github.com/micro-ROS/rosidl_typesupport_microxrcedds src/rosidl_typesupport_microxrcedds; \
git clone -b galactic https://github.com/ros2/rosidl src/rosidl; \
git clone -b galactic https://github.com/ros2/rmw src/rmw; \
git clone -b galactic https://github.com/ros2/rcl_interfaces src/rcl_interfaces; \
git clone -b galactic https://github.com/ros2/rosidl_defaults src/rosidl_defaults; \
git clone -b galactic https://github.com/ros2/unique_identifier_msgs src/unique_identifier_msgs; \
git clone -b galactic https://github.com/ros2/common_interfaces src/common_interfaces; \
git clone -b galactic https://github.com/ros2/test_interface_files src/test_interface_files; \
git clone -b galactic https://github.com/ros2/rmw_implementation src/rmw_implementation; \
git clone -b galactic https://github.com/ros2/rcl_logging src/rcl_logging; \
git clone -b galactic https://gitlab.com/micro-ROS/ros_tracing/ros2_tracing src/ros2_tracing; \
git clone -b galactic https://github.com/micro-ROS/micro_ros_utilities src/micro_ros_utilities; \
git clone -b master https://github.com/teamspatzenhirn/spatz_interfaces src/spatz_interfaces; \
touch src/rosidl/rosidl_typesupport_introspection_cpp/COLCON_IGNORE; \
touch src/rclc/rclc_examples/COLCON_IGNORE; \
touch src/common_interfaces/actionlib_msgs/COLCON_IGNORE; \
touch src/common_interfaces/std_srvs/COLCON_IGNORE; \
touch src/rcl/rcl_yaml_param_parser/COLCON_IGNORE; \
touch src/rcl_logging/rcl_logging_log4cxx/COLCON_IGNORE; \
touch src/rcl_logging/rcl_logging_spdlog/COLCON_IGNORE;
$(COMPONENT_PATH)/micro_ros_src/install: configure_colcon_meta configure_toolchain $(COMPONENT_PATH)/micro_ros_dev/install $(COMPONENT_PATH)/micro_ros_src/src
cd $(UROS_DIR); \
. ../micro_ros_dev/install/local_setup.sh; \
colcon build \
--merge-install \
--packages-ignore-regex=.*_cpp \
--metas $(COMPONENT_PATH)/configured_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=$(COMPONENT_PATH)/zephyr_toolchain.cmake \
-DSTATIC_ROSIDL_TYPESUPPORT_C=rosidl_typesupport_microxrcedds_c \
-DCMAKE_VERBOSE_MAKEFILE=OFF; \
$(COMPONENT_PATH)/libmicroros.a: $(COMPONENT_PATH)/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 libmicroros.a *.obj; cp libmicroros.a $(COMPONENT_PATH); ${X_RANLIB} $(COMPONENT_PATH)/libmicroros.a; \
cd ..; rm -rf libmicroros; \
cp -R $(UROS_DIR)/install/include $(COMPONENT_PATH)/include;