Skip to content

Commit

Permalink
Add rolling (#17)
Browse files Browse the repository at this point in the history
* Add rolling to CI

* Add Rolling to sources

* Add fix includes for rolling

* Add roling to readme

* Modify builder with comments

* Remove typo

* Remove rsync depend

* Fix directory cp
  • Loading branch information
Acuadros95 authored Apr 21, 2022
1 parent 8e683d4 commit 66043ac
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [teensy41, teensy40, teensy36, teensy35, teensy31, due, zero, olimex_e407, esp32dev, nanorp2040connect, portenta_h7_m7, teensy41_eth, nanorp2040connect_wifi, portenta_h7_m7_wifi, esp32dev_wifi]
platform: [teensy41, teensy40, teensy36, teensy35, teensy31, due, zero, olimex_e407, esp32dev, nanorp2040connect, portenta_h7_m7, teensy41_eth, nanorp2040connect_wifi, portenta_h7_m7_wifi, esp32dev_wifi, portenta_h7_m7_rolling]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ A explanation for adding custom targets is also present
### ROS 2 distribution
The target ROS 2 distribution can be configured with the `board_microros_distro = <distribution>`, supported values are:
- `galactic` *(default value)*
- `rolling`

### Transport configuration
The transport can be configured with the `board_microros_transport = <transport>`, supported values and configurations are:
Expand Down
10 changes: 10 additions & 0 deletions ci/platformio.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
; Rolling test
[env:portenta_h7_m7_rolling]
platform = ststm32
board = portenta_h7_m7
framework = arduino
board_microros_transport = serial
board_microros_distro = rolling
lib_deps =
../

; Serial platforms

[env:portenta_h7_m7]
Expand Down
2 changes: 1 addition & 1 deletion extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def build_microros(*args, **kwargs):
"{} {} -fno-rtti -DCLOCK_MONOTONIC=0 -D'__attribute__(x)='".format(' '.join(env['CXXFLAGS']), ' '.join(env['CCFLAGS']))
)

builder = library_builder.Build(library_folder=main_path, packages_folder=extra_packages_path)
builder = library_builder.Build(library_folder=main_path, packages_folder=extra_packages_path, distro=microros_distro)
builder.run('{}/metas/{}'.format(main_path, selected_board_meta), cmake_toolchain.path, microros_user_meta)

#######################################################
Expand Down
131 changes: 18 additions & 113 deletions microros_utils/library_builder.py
Original file line number Diff line number Diff line change
@@ -1,76 +1,9 @@
import subprocess
import os, sys
import json
import yaml
import shutil
import xml.etree.ElementTree as xml_parser

def run_cmd(command):
return subprocess.run(command,
capture_output = True,
shell = True,
)

class Package:
def __init__(self, name, path):
self.name = name
self.path = path
self.ignored = False

def ignore(self):
self.ignored = True
ignore_path = self.path + '/COLCON_IGNORE'
with open(ignore_path, 'a'):
os.utime(ignore_path, None)

class Repository:
def __init__(self, name, url, distribution, branch=None):
self.name = name
self.url = url
self.distribution = distribution
self.branch = distribution if branch is None else branch
self.path = None

def clone(self, folder):
self.path = folder + "/" + self.name
# TODO(pablogs) ensure that git is installed
command = "git clone -b {} {} {}".format(self.branch, self.url, self.path)
result = run_cmd(command)

if 0 != result.returncode:
print("{} clone failed: \n{}".format(self.name, result.stderr.decode("utf-8")))
sys.exit(1)

def get_packages(self):
packages = []
if os.path.exists(self.path + '/package.xml'):
packages.append(Package(self.name, self.path))
else:
for root, dirs, files in os.walk(self.path):
path = root.split(os.sep)
if 'package.xml' in files:
package_name = Repository.get_package_name_from_package_xml(os.path.join(root, 'package.xml'))
package_path = os.path.join(os.getcwd(), root)
packages.append(Package(package_name, package_path))
elif 'colcon.pkg' in files:
package_name = Repository.get_package_name_from_colcon_pkg(os.path.join(root, 'colcon.pkg'))
package_path = os.path.join(os.getcwd(), root)
packages.append(Package(package_name, package_path))
return packages

def get_package_name_from_package_xml(xml_file):
root_node = xml_parser.parse(xml_file).getroot()
name_node = root_node.find('name')
if name_node is not None:
return name_node.text
return None

def get_package_name_from_colcon_pkg(colcon_pkg):
with open(colcon_pkg, 'r') as f:
content = json.load(f)
if content['name']:
return content['name']
return None
from .utils import run_cmd
from .repositories import Repository, Sources

class CMakeToolchain:
def __init__(self, path, cc, cxx, ar, cflags, cxxflags):
Expand Down Expand Up @@ -100,47 +33,7 @@ def __init__(self, path, cc, cxx, ar, cflags, cxxflags):
self.path = os.path.realpath(file.name)

class Build:
dev_environments = {
'galactic': [
Repository("ament_cmake", "https://github.com/ament/ament_cmake", "galactic"),
Repository("ament_lint", "https://github.com/ament/ament_lint", "galactic"),
Repository("ament_package", "https://github.com/ament/ament_package", "galactic"),
Repository("googletest", "https://github.com/ament/googletest", "galactic"),
Repository("ament_cmake_ros", "https://github.com/ros2/ament_cmake_ros", "galactic"),
Repository("ament_index", "https://github.com/ament/ament_index", "galactic")
]
}

mcu_environments = {
'galactic': [
Repository("micro-CDR", "https://github.com/eProsima/micro-CDR", "galactic", "ros2"),
Repository("Micro-XRCE-DDS-Client", "https://github.com/eProsima/Micro-XRCE-DDS-Client", "galactic", "ros2"),
Repository("rcl", "https://github.com/micro-ROS/rcl", "galactic"),
Repository("rclc", "https://github.com/ros2/rclc", "galactic"),
Repository("micro_ros_utilities", "https://github.com/micro-ROS/micro_ros_utilities", "galactic"),
Repository("rcutils", "https://github.com/micro-ROS/rcutils", "galactic"),
Repository("micro_ros_msgs", "https://github.com/micro-ROS/micro_ros_msgs", "galactic"),
Repository("rmw-microxrcedds", "https://github.com/micro-ROS/rmw-microxrcedds", "galactic"),
Repository("rosidl_typesupport", "https://github.com/micro-ROS/rosidl_typesupport", "galactic"),
Repository("rosidl_typesupport_microxrcedds", "https://github.com/micro-ROS/rosidl_typesupport_microxrcedds", "galactic"),
Repository("rosidl", "https://github.com/ros2/rosidl", "galactic"),
Repository("rmw", "https://github.com/ros2/rmw", "galactic"),
Repository("rcl_interfaces", "https://github.com/ros2/rcl_interfaces", "galactic"),
Repository("rosidl_defaults", "https://github.com/ros2/rosidl_defaults", "galactic"),
Repository("unique_identifier_msgs", "https://github.com/ros2/unique_identifier_msgs", "galactic"),
Repository("common_interfaces", "https://github.com/ros2/common_interfaces", "galactic"),
Repository("test_interface_files", "https://github.com/ros2/test_interface_files", "galactic"),
Repository("rmw_implementation", "https://github.com/ros2/rmw_implementation", "galactic"),
Repository("rcl_logging", "https://github.com/ros2/rcl_logging", "galactic"),
Repository("ros2_tracing", "https://gitlab.com/micro-ROS/ros_tracing/ros2_tracing", "galactic"),
]
}

ignore_packages = {
'galactic': ['rcl_logging_log4cxx', 'rcl_logging_spdlog', 'rcl_yaml_param_parser', 'rclc_examples']
}

def __init__(self, library_folder, packages_folder, distro = 'galactic'):
def __init__(self, library_folder, packages_folder, distro):
self.library_folder = library_folder
self.packages_folder = packages_folder
self.build_folder = library_folder + "/build"
Expand Down Expand Up @@ -182,7 +75,7 @@ def download_dev_environment(self):
shutil.rmtree(self.dev_src_folder, ignore_errors=True)
os.makedirs(self.dev_src_folder)
print("Downloading micro-ROS dev dependencies")
for repo in Build.dev_environments[self.distro]:
for repo in Sources.dev_environments[self.distro]:
repo.clone(self.dev_src_folder)
print("\t - Downloaded {}".format(repo.name))
self.dev_packages.extend(repo.get_packages())
Expand All @@ -200,11 +93,11 @@ def download_mcu_environment(self):
shutil.rmtree(self.mcu_src_folder, ignore_errors=True)
os.makedirs(self.mcu_src_folder)
print("Downloading micro-ROS library")
for repo in Build.mcu_environments[self.distro]:
for repo in Sources.mcu_environments[self.distro]:
repo.clone(self.mcu_src_folder)
self.mcu_packages.extend(repo.get_packages())
for package in repo.get_packages():
if package.name in Build.ignore_packages[self.distro] or package.name.endswith("_cpp"):
if package.name in Sources.ignore_packages[self.distro] or package.name.endswith("_cpp"):
package.ignore()

print('\t - Downloaded {}{}'.format(package.name, " (ignored)" if package.ignored else ""))
Expand Down Expand Up @@ -299,3 +192,15 @@ def package_mcu_library(self):

# Copy includes
shutil.copytree(self.build_folder + "/mcu/install/include", self.includes)

# Fix include paths
if self.distro is not "galactic":
include_folders = os.listdir(self.includes)

for folder in include_folders:
folder_path = self.includes + "/{}".format(folder)
repeated_path = folder_path + "/{}".format(folder)

if os.path.exists(repeated_path):
shutil.copytree(repeated_path, folder_path, copy_function=shutil.move, dirs_exist_ok=True)
shutil.rmtree(repeated_path)
138 changes: 138 additions & 0 deletions microros_utils/repositories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import os, sys
import json
import xml.etree.ElementTree as xml_parser

from .utils import run_cmd

class Package:
def __init__(self, name, path):
self.name = name
self.path = path
self.ignored = False

def ignore(self):
self.ignored = True
ignore_path = self.path + '/COLCON_IGNORE'
with open(ignore_path, 'a'):
os.utime(ignore_path, None)

class Repository:
def __init__(self, name, url, distribution, branch=None):
self.name = name
self.url = url
self.distribution = distribution
self.branch = distribution if branch is None else branch
self.path = None

def clone(self, folder):
self.path = folder + "/" + self.name
# TODO(pablogs) ensure that git is installed
command = "git clone -b {} {} {}".format(self.branch, self.url, self.path)
result = run_cmd(command)

if 0 != result.returncode:
print("{} clone failed: \n{}".format(self.name, result.stderr.decode("utf-8")))
sys.exit(1)

def get_packages(self):
packages = []
if os.path.exists(self.path + '/package.xml'):
packages.append(Package(self.name, self.path))
else:
for root, dirs, files in os.walk(self.path):
path = root.split(os.sep)
if 'package.xml' in files:
package_name = Repository.get_package_name_from_package_xml(os.path.join(root, 'package.xml'))
package_path = os.path.join(os.getcwd(), root)
packages.append(Package(package_name, package_path))
elif 'colcon.pkg' in files:
package_name = Repository.get_package_name_from_colcon_pkg(os.path.join(root, 'colcon.pkg'))
package_path = os.path.join(os.getcwd(), root)
packages.append(Package(package_name, package_path))
return packages

def get_package_name_from_package_xml(xml_file):
root_node = xml_parser.parse(xml_file).getroot()
name_node = root_node.find('name')
if name_node is not None:
return name_node.text
return None

def get_package_name_from_colcon_pkg(colcon_pkg):
with open(colcon_pkg, 'r') as f:
content = json.load(f)
if content['name']:
return content['name']
return None

class Sources:
dev_environments = {
'galactic': [
Repository("ament_cmake", "https://github.com/ament/ament_cmake", "galactic"),
Repository("ament_lint", "https://github.com/ament/ament_lint", "galactic"),
Repository("ament_package", "https://github.com/ament/ament_package", "galactic"),
Repository("googletest", "https://github.com/ament/googletest", "galactic"),
Repository("ament_cmake_ros", "https://github.com/ros2/ament_cmake_ros", "galactic"),
Repository("ament_index", "https://github.com/ament/ament_index", "galactic")
],
'rolling': [
Repository("ament_cmake", "https://github.com/ament/ament_cmake", "rolling", "master"),
Repository("ament_lint", "https://github.com/ament/ament_lint", "rolling", "master"),
Repository("ament_package", "https://github.com/ament/ament_package", "rolling", "master"),
Repository("googletest", "https://github.com/ament/googletest", "rolling", "ros2"),
Repository("ament_cmake_ros", "https://github.com/ros2/ament_cmake_ros", "rolling", "master"),
Repository("ament_index", "https://github.com/ament/ament_index", "rolling", "master")
]
}

mcu_environments = {
'galactic': [
Repository("micro-CDR", "https://github.com/eProsima/micro-CDR", "galactic", "ros2"),
Repository("Micro-XRCE-DDS-Client", "https://github.com/eProsima/Micro-XRCE-DDS-Client", "galactic", "ros2"),
Repository("rcl", "https://github.com/micro-ROS/rcl", "galactic"),
Repository("rclc", "https://github.com/ros2/rclc", "galactic"),
Repository("micro_ros_utilities", "https://github.com/micro-ROS/micro_ros_utilities", "galactic"),
Repository("rcutils", "https://github.com/micro-ROS/rcutils", "galactic"),
Repository("micro_ros_msgs", "https://github.com/micro-ROS/micro_ros_msgs", "galactic"),
Repository("rmw-microxrcedds", "https://github.com/micro-ROS/rmw-microxrcedds", "galactic"),
Repository("rosidl_typesupport", "https://github.com/micro-ROS/rosidl_typesupport", "galactic"),
Repository("rosidl_typesupport_microxrcedds", "https://github.com/micro-ROS/rosidl_typesupport_microxrcedds", "galactic"),
Repository("rosidl", "https://github.com/ros2/rosidl", "galactic"),
Repository("rmw", "https://github.com/ros2/rmw", "galactic"),
Repository("rcl_interfaces", "https://github.com/ros2/rcl_interfaces", "galactic"),
Repository("rosidl_defaults", "https://github.com/ros2/rosidl_defaults", "galactic"),
Repository("unique_identifier_msgs", "https://github.com/ros2/unique_identifier_msgs", "galactic"),
Repository("common_interfaces", "https://github.com/ros2/common_interfaces", "galactic"),
Repository("test_interface_files", "https://github.com/ros2/test_interface_files", "galactic"),
Repository("rmw_implementation", "https://github.com/ros2/rmw_implementation", "galactic"),
Repository("rcl_logging", "https://github.com/ros2/rcl_logging", "galactic"),
Repository("ros2_tracing", "https://gitlab.com/micro-ROS/ros_tracing/ros2_tracing", "galactic"),
],
'rolling': [
Repository("micro-CDR", "https://github.com/eProsima/micro-CDR", "rolling", "ros2"),
Repository("Micro-XRCE-DDS-Client", "https://github.com/eProsima/Micro-XRCE-DDS-Client", "rolling", "ros2"),
Repository("rcl", "https://github.com/micro-ROS/rcl", "rolling", "master"),
Repository("rclc", "https://github.com/ros2/rclc", "rolling", "master"),
Repository("micro_ros_utilities", "https://github.com/micro-ROS/micro_ros_utilities", "rolling", "main"),
Repository("rcutils", "https://github.com/micro-ROS/rcutils", "rolling", "master"),
Repository("micro_ros_msgs", "https://github.com/micro-ROS/micro_ros_msgs", "rolling", "main"),
Repository("rmw-microxrcedds", "https://github.com/micro-ROS/rmw-microxrcedds", "rolling", "main"),
Repository("rosidl_typesupport", "https://github.com/micro-ROS/rosidl_typesupport", "rolling", "master"),
Repository("rosidl_typesupport_microxrcedds", "https://github.com/micro-ROS/rosidl_typesupport_microxrcedds", "rolling", "main"),
Repository("rosidl", "https://github.com/ros2/rosidl", "rolling", "master"),
Repository("rmw", "https://github.com/ros2/rmw", "rolling", "master"),
Repository("rcl_interfaces", "https://github.com/ros2/rcl_interfaces", "rolling", "master"),
Repository("rosidl_defaults", "https://github.com/ros2/rosidl_defaults", "rolling", "master"),
Repository("unique_identifier_msgs", "https://github.com/ros2/unique_identifier_msgs", "rolling", "master"),
Repository("common_interfaces", "https://github.com/ros2/common_interfaces", "rolling", "master"),
Repository("test_interface_files", "https://github.com/ros2/test_interface_files", "rolling", "master"),
Repository("rmw_implementation", "https://github.com/ros2/rmw_implementation", "rolling", "master"),
Repository("rcl_logging", "https://github.com/ros2/rcl_logging", "rolling", "master"),
Repository("ros2_tracing", "https://gitlab.com/micro-ROS/ros_tracing/ros2_tracing", "rolling", "master"),
]
}

ignore_packages = {
'galactic': ['rcl_logging_log4cxx', 'rcl_logging_spdlog', 'rcl_yaml_param_parser', 'rclc_examples'],
'rolling': ['rcl_logging_log4cxx', 'rcl_logging_spdlog', 'rcl_yaml_param_parser', 'rclc_examples']
}
7 changes: 7 additions & 0 deletions microros_utils/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import subprocess

def run_cmd(command):
return subprocess.run(command,
capture_output = True,
shell = True,
)

0 comments on commit 66043ac

Please sign in to comment.