From a28e4be33208a01df0feffe6189e81c8f9617822 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 5 Aug 2021 11:02:41 -0700 Subject: [PATCH 1/3] Remove unused AMENT_CMAKE_ENVIRONMENT_GENERATION option Signed-off-by: Shane Loretz --- .../ament_cmake_environment-extras.cmake | 4 -- ...ament_cmake_environment_package_hook.cmake | 4 -- .../ament_generate_environment.cmake | 50 ------------------- .../package_templates/templates_2_cmake.py | 9 ---- 4 files changed, 67 deletions(-) delete mode 100644 ament_cmake_core/cmake/environment/ament_generate_environment.cmake diff --git a/ament_cmake_core/ament_cmake_environment-extras.cmake b/ament_cmake_core/ament_cmake_environment-extras.cmake index 5d2ea270..44981fc7 100644 --- a/ament_cmake_core/ament_cmake_environment-extras.cmake +++ b/ament_cmake_core/ament_cmake_environment-extras.cmake @@ -14,12 +14,8 @@ # copied from ament_cmake_core/ament_cmake_environment-extras.cmake -option(AMENT_CMAKE_ENVIRONMENT_GENERATION - "Generate environment files in the CMAKE_INSTALL_PREFIX" OFF) option(AMENT_CMAKE_ENVIRONMENT_PARENT_PREFIX_PATH_GENERATION "Generate marker file containing the parent prefix path" ON) -include("${ament_cmake_core_DIR}/environment/ament_generate_environment.cmake") - ament_register_extension("ament_package" "ament_cmake_core" "environment/ament_cmake_environment_package_hook.cmake") diff --git a/ament_cmake_core/cmake/environment/ament_cmake_environment_package_hook.cmake b/ament_cmake_core/cmake/environment/ament_cmake_environment_package_hook.cmake index 1567fcdf..379081b2 100644 --- a/ament_cmake_core/cmake/environment/ament_cmake_environment_package_hook.cmake +++ b/ament_cmake_core/cmake/environment/ament_cmake_environment_package_hook.cmake @@ -12,10 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -if(AMENT_CMAKE_ENVIRONMENT_GENERATION) - ament_generate_environment() -endif() - function(ament_cmake_environment_generate_package_run_dependencies_marker) # use all run dependencies from the package.xml set(run_depends "") diff --git a/ament_cmake_core/cmake/environment/ament_generate_environment.cmake b/ament_cmake_core/cmake/environment/ament_generate_environment.cmake deleted file mode 100644 index 4cc20c54..00000000 --- a/ament_cmake_core/cmake/environment/ament_generate_environment.cmake +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2014 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Generate setup files in the root of the install prefix. -# -# @public -# -function(ament_generate_environment) - if(ARGN) - message(FATAL_ERROR - "ament_generate_environment() called with unused arguments: ${ARGN}") - endif() - - # configure and install setup files - foreach(file ${ament_cmake_package_templates_PREFIX_LEVEL}) - # check if the file is a template - string_ends_with("${file}" ".in" is_template) - if(is_template) - # cut of .in extension - string(LENGTH "${file}" length) - math(EXPR offset "${length} - 3") - string(SUBSTRING "${file}" 0 ${offset} name) - # expand template - get_filename_component(name "${name}" NAME) - configure_file( - "${file}" - "${CMAKE_BINARY_DIR}/ament_cmake_environment/${name}" - @ONLY - ) - set(file "${CMAKE_BINARY_DIR}/ament_cmake_environment/${name}") - endif() - - install( - FILES "${file}" - DESTINATION "${CMAKE_INSTALL_PREFIX}" - ) - endforeach() -endfunction() diff --git a/ament_cmake_core/cmake/package_templates/templates_2_cmake.py b/ament_cmake_core/cmake/package_templates/templates_2_cmake.py index b7c0faf1..7f893ebe 100644 --- a/ament_cmake_core/cmake/package_templates/templates_2_cmake.py +++ b/ament_cmake_core/cmake/package_templates/templates_2_cmake.py @@ -21,8 +21,6 @@ from ament_package.templates import get_environment_hook_template_path from ament_package.templates import get_package_level_template_names from ament_package.templates import get_package_level_template_path -from ament_package.templates import get_prefix_level_template_names -from ament_package.templates import get_prefix_level_template_path IS_WINDOWS = os.name == 'nt' @@ -87,13 +85,6 @@ def generate_cmake_code(): 'PACKAGE_LEVEL', templates)) - templates = [] - for name in get_prefix_level_template_names(): - templates.append('"%s"' % get_prefix_level_template_path(name)) - variables.append(( - 'PREFIX_LEVEL', - templates)) - lines = [] for (k, v) in variables: if isinstance(v, list): From 2edfeedf52dba6bbefd7640cbb8fc2d7d9e5663e Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Fri, 6 Aug 2021 14:44:14 -0700 Subject: [PATCH 2/3] Add back ament_generate_environment for ros_workspace Signed-off-by: Shane Loretz --- .../ament_cmake_environment-extras.cmake | 3 ++ .../ament_generate_environment.cmake | 50 +++++++++++++++++++ .../package_templates/templates_2_cmake.py | 9 ++++ 3 files changed, 62 insertions(+) create mode 100644 ament_cmake_core/cmake/environment/ament_generate_environment.cmake diff --git a/ament_cmake_core/ament_cmake_environment-extras.cmake b/ament_cmake_core/ament_cmake_environment-extras.cmake index 44981fc7..fc69d768 100644 --- a/ament_cmake_core/ament_cmake_environment-extras.cmake +++ b/ament_cmake_core/ament_cmake_environment-extras.cmake @@ -17,5 +17,8 @@ option(AMENT_CMAKE_ENVIRONMENT_PARENT_PREFIX_PATH_GENERATION "Generate marker file containing the parent prefix path" ON) +# This is used by ros_workspace +include("${ament_cmake_core_DIR}/environment/ament_generate_environment.cmake") + ament_register_extension("ament_package" "ament_cmake_core" "environment/ament_cmake_environment_package_hook.cmake") diff --git a/ament_cmake_core/cmake/environment/ament_generate_environment.cmake b/ament_cmake_core/cmake/environment/ament_generate_environment.cmake new file mode 100644 index 00000000..4cc20c54 --- /dev/null +++ b/ament_cmake_core/cmake/environment/ament_generate_environment.cmake @@ -0,0 +1,50 @@ +# Copyright 2014 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Generate setup files in the root of the install prefix. +# +# @public +# +function(ament_generate_environment) + if(ARGN) + message(FATAL_ERROR + "ament_generate_environment() called with unused arguments: ${ARGN}") + endif() + + # configure and install setup files + foreach(file ${ament_cmake_package_templates_PREFIX_LEVEL}) + # check if the file is a template + string_ends_with("${file}" ".in" is_template) + if(is_template) + # cut of .in extension + string(LENGTH "${file}" length) + math(EXPR offset "${length} - 3") + string(SUBSTRING "${file}" 0 ${offset} name) + # expand template + get_filename_component(name "${name}" NAME) + configure_file( + "${file}" + "${CMAKE_BINARY_DIR}/ament_cmake_environment/${name}" + @ONLY + ) + set(file "${CMAKE_BINARY_DIR}/ament_cmake_environment/${name}") + endif() + + install( + FILES "${file}" + DESTINATION "${CMAKE_INSTALL_PREFIX}" + ) + endforeach() +endfunction() diff --git a/ament_cmake_core/cmake/package_templates/templates_2_cmake.py b/ament_cmake_core/cmake/package_templates/templates_2_cmake.py index 7f893ebe..b7c0faf1 100644 --- a/ament_cmake_core/cmake/package_templates/templates_2_cmake.py +++ b/ament_cmake_core/cmake/package_templates/templates_2_cmake.py @@ -21,6 +21,8 @@ from ament_package.templates import get_environment_hook_template_path from ament_package.templates import get_package_level_template_names from ament_package.templates import get_package_level_template_path +from ament_package.templates import get_prefix_level_template_names +from ament_package.templates import get_prefix_level_template_path IS_WINDOWS = os.name == 'nt' @@ -85,6 +87,13 @@ def generate_cmake_code(): 'PACKAGE_LEVEL', templates)) + templates = [] + for name in get_prefix_level_template_names(): + templates.append('"%s"' % get_prefix_level_template_path(name)) + variables.append(( + 'PREFIX_LEVEL', + templates)) + lines = [] for (k, v) in variables: if isinstance(v, list): From 5428cc038d924118edb6d6b603c112013447ddeb Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Mon, 9 Aug 2021 15:47:52 -0700 Subject: [PATCH 3/3] Remove comment Signed-off-by: Shane Loretz --- ament_cmake_core/ament_cmake_environment-extras.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/ament_cmake_core/ament_cmake_environment-extras.cmake b/ament_cmake_core/ament_cmake_environment-extras.cmake index fc69d768..3f55d76c 100644 --- a/ament_cmake_core/ament_cmake_environment-extras.cmake +++ b/ament_cmake_core/ament_cmake_environment-extras.cmake @@ -17,7 +17,6 @@ option(AMENT_CMAKE_ENVIRONMENT_PARENT_PREFIX_PATH_GENERATION "Generate marker file containing the parent prefix path" ON) -# This is used by ros_workspace include("${ament_cmake_core_DIR}/environment/ament_generate_environment.cmake") ament_register_extension("ament_package" "ament_cmake_core"