|
| 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_cpp import generate_cpp |
| 22 | + |
| 23 | + |
| 24 | +class GenerateCpp(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_cpp' |
| 36 | + ) |
| 37 | + templates_path = os.path.join( |
| 38 | + package_share_path, 'resource' |
| 39 | + ) |
| 40 | + |
| 41 | + # Generate code |
| 42 | + with legacy_generator_arguments_file( |
| 43 | + package_name=package_name, |
| 44 | + interface_files=interface_files, |
| 45 | + include_paths=include_paths, |
| 46 | + templates_path=templates_path, |
| 47 | + output_path=output_path |
| 48 | + ) as path_to_arguments_file: |
| 49 | + generate_cpp(path_to_arguments_file) |
0 commit comments