Skip to content

Commit

Permalink
Reuse colcon_ros package identification (#32)
Browse files Browse the repository at this point in the history
* Reuse colcon_ros package identification

Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>

* Fix dependencies and unit tests

Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>

* Remove single warning logic

Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>

---------

Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
  • Loading branch information
luca-della-vedova authored Dec 6, 2024
1 parent 82811c5 commit 7d90af6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 94 deletions.
Empty file.
85 changes: 0 additions & 85 deletions colcon_ros_cargo/package_identification/ament_cargo.py

This file was deleted.

10 changes: 10 additions & 0 deletions colcon_ros_cargo/task/ament_cargo/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
from pathlib import Path
import subprocess

from colcon_cargo.task.cargo import CARGO_EXECUTABLE
from colcon_cargo.task.cargo.build import CargoBuildTask
Expand Down Expand Up @@ -47,6 +48,15 @@ def add_arguments(self, *, parser): # noqa: D102
'.cargo/config.toml for subsequent builds with cargo.')

def _prepare(self, env, additional_hooks):
ament_build = 'cargo ament-build --help'.split()
if subprocess.run(ament_build, capture_output=True).returncode != 0:
logger.error(
'\n\nament_cargo package found but cargo ament-build was '
'not detected.'
'\n\nPlease install it by running:'
'\n $ cargo install cargo-ament-build\n')
return 1

args = self.context.args

global package_paths
Expand Down
6 changes: 2 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,10 @@ markers =
linter

[options.entry_points]
colcon_core.package_identification =
ament_cargo = colcon_ros_cargo.package_identification.ament_cargo:AmentCargoPackageIdentification
colcon_core.task.build =
ament_cargo = colcon_ros_cargo.task.ament_cargo.build:AmentCargoBuildTask
ros.ament_cargo = colcon_ros_cargo.task.ament_cargo.build:AmentCargoBuildTask
colcon_core.task.test =
ament_cargo = colcon_ros_cargo.task.ament_cargo.test:AmentCargoTestTask
ros.ament_cargo = colcon_ros_cargo.task.ament_cargo.test:AmentCargoTestTask

[flake8]
import-order-style = google
2 changes: 1 addition & 1 deletion stdeb.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[colcon-ros-cargo]
No-Python2:
Depends3: python3-colcon-core, python3-colcon-cargo, python3-toml, python3-cargo-ament-build
Depends3: python3-colcon-core, python3-colcon-cargo, python3-colcon-ros, python3-toml, python3-cargo-ament-build
Suite: focal jammy noble bookworm trixie
X-Python3-Version: >= 3.6
Debian-Version: 100
8 changes: 4 additions & 4 deletions test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from colcon_core.package_descriptor import PackageDescriptor
from colcon_core.subprocess import new_event_loop
from colcon_core.task import TaskContext
from colcon_ros_cargo.package_identification.ament_cargo import AmentCargoPackageIdentification # noqa: E501
from colcon_ros.package_identification.ros import RosPackageIdentification
from colcon_ros_cargo.task.ament_cargo.build import AmentCargoBuildTask
from colcon_ros_cargo.task.ament_cargo.test import AmentCargoTestTask
import pytest
Expand All @@ -34,10 +34,10 @@ def monkey_patch_put_event_into_queue(monkeypatch):


def test_package_identification():
cpi = AmentCargoPackageIdentification()
cpi = RosPackageIdentification()
desc = PackageDescriptor(test_project_path)
cpi.identify(desc)
assert desc.type == 'ament_cargo'
assert desc.type == 'ros.ament_cargo'
assert desc.name == TEST_PACKAGE_NAME


Expand All @@ -49,7 +49,7 @@ def test_build_and_test_package():
asyncio.set_event_loop(event_loop)

try:
cpi = AmentCargoPackageIdentification()
cpi = RosPackageIdentification()
package = PackageDescriptor(test_project_path)
cpi.identify(package)

Expand Down

0 comments on commit 7d90af6

Please sign in to comment.