Skip to content

Commit 7bbbf8b

Browse files
committed
Expose C code generation via rosidl generate CLI.
Signed-off-by: Michel Hidalgo <[email protected]>
1 parent 6c90160 commit 7bbbf8b

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

rosidl_generator_c/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
<build_export_depend>rosidl_typesupport_interface</build_export_depend>
2020

21+
<exec_depend>rosidl_cli</exec_depend>
2122
<exec_depend>rosidl_parser</exec_depend>
2223

2324
<test_depend>ament_cmake_gtest</test_depend>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2021 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import os
16+
17+
from ament_index_python import get_package_share_directory
18+
from rosidl_cli.command.generate.extensions import GenerateCommandExtension
19+
from rosidl_cli.command.generate.helpers import legacy_generator_arguments_file
20+
21+
from rosidl_generator_c import generate_c
22+
23+
24+
class GenerateC(GenerateCommandExtension):
25+
26+
def generate(
27+
self,
28+
package_name,
29+
interface_files,
30+
include_paths,
31+
output_path
32+
):
33+
package_share_path = \
34+
get_package_share_directory(
35+
'rosidl_generator_c'
36+
)
37+
templates_path = os.path.join(
38+
package_share_path, 'resource'
39+
)
40+
with legacy_generator_arguments_file(
41+
package_name, interface_files,
42+
include_paths, templates_path,
43+
output_path
44+
) as path_to_arguments_file:
45+
generate_c(path_to_arguments_file)

rosidl_generator_c/setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[options.entry_points]
2+
rosidl_cli.command.generate.type_extensions =
3+
c = rosidl_generator_c.cli:GenerateC

0 commit comments

Comments
 (0)