Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge ign-msgs8 ➡️ main #270

Merged
merged 13 commits into from
Jul 18, 2022
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

gz_configure_project(VERSION_SUFFIX pre1)

if (UNIX AND NOT APPLE)
set (EXTRA_TEST_LIB_DEPS stdc++fs)
else()
set (EXTRA_TEST_LIB_DEPS)
endif()

#============================================================================
# Set project-specific options
#============================================================================
Expand Down Expand Up @@ -89,8 +95,11 @@ gz_find_package(gz-math7 REQUIRED)
set(GZ_MATH_VER ${gz-math7_VERSION_MAJOR})

#--------------------------------------
# Find if gz command is available
# Find if command is available. This is used to enable tests.
# Note that CLI files are installed regardless of whether the dependency is
# available during build time
find_program(HAVE_GZ_TOOLS gz)
set(GZ_TOOLS_VER 1)

#--------------------------------------
# Find Tinyxml2
Expand Down
17 changes: 17 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

### Gazebo Msgs 9.0.0 (202x-xx-xx)

### Gazebo Msgs 8.5.0 (2022-06-23)

1. Add entity plugin v proto file
* [Pull request #261](https:/gazebosim/gz-msgs/pull/261)

1. Bash completion for flags
* [Pull request #254](https:/gazebosim/gz-msgs/pull/254)

1. Remove dead files
* [Pull request #255](https:/gazebosim/gz-msgs/pull/255)

1. Fix typo REGRESION/REGRESSION
* [Pull request #247](https:/gazebosim/gz-msgs/pull/247)

1. Generator: Add missing std namespace to string arguments
* [Pull request #242](https:/gazebosim/gz-msgs/pull/242)

## Gazebo Msgs 8.x

### Gazebo Msgs 8.4.0 (2022-04-06)
Expand Down
42 changes: 0 additions & 42 deletions appveyor.yml

This file was deleted.

41 changes: 41 additions & 0 deletions proto/gz/msgs/entity_plugin_v.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* 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.
*
*/

syntax = "proto3";
package gz.msgs;
option java_package = "com.gz.msgs";
option java_outer_classname = "EntityPluginVProtos";

/// \ingroup gz.msgs
/// \interface EntityPlugin_V
/// \brief An array of plugins for a entity.

import "gz/msgs/entity.proto";
import "gz/msgs/header.proto";
import "gz/msgs/plugin.proto";

message EntityPlugin_V
{
/// \brief Optional header data
Header header = 1;

/// \brief Entity the plugins belong to
Entity entity = 2;

/// \brief Plugin messages.
repeated Plugin plugins = 3;
}
14 changes: 14 additions & 0 deletions src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,17 @@ file(GENERATE

# Install the ruby command line library in an unversioned location.
install(FILES ${cmd_script_generated} DESTINATION lib/ruby/gz)


#===============================================================================
# Bash completion

# Tack version onto and install the bash completion script
configure_file(
"msgs.bash_completion.sh"
"${CMAKE_CURRENT_BINARY_DIR}/msgs${PROJECT_VERSION_MAJOR}.bash_completion.sh" @ONLY)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/msgs${PROJECT_VERSION_MAJOR}.bash_completion.sh
DESTINATION
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gz/gz${GZ_TOOLS_VER}.completion.d)
52 changes: 52 additions & 0 deletions src/cmd/msgs.bash_completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
#
# Copyright (C) 2022 Open Source Robotics Foundation
#
# 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.
#

# bash tab-completion

# This is a per-library function definition, used in conjunction with the
# top-level entry point in ign-tools.

GZ_MSGS_COMPLETION_LIST="
-i --info
-l --list
-h --help
--force-version
--versions
"

function _gz_msg
{
if [[ ${COMP_WORDS[COMP_CWORD]} == -* ]]; then
# Specify options (-*) word list for this subcommand
COMPREPLY=($(compgen -W "$GZ_MSGS_COMPLETION_LIST" \
-- "${COMP_WORDS[COMP_CWORD]}" ))
return
else
# Just use bash default auto-complete, because we never have two
# subcommands in the same line. If that is ever needed, change here to
# detect subsequent subcommands
COMPREPLY=($(compgen -o default -- "${COMP_WORDS[COMP_CWORD]}"))
return
fi
}

function _gz_msgs_flags
{
for word in $GZ_MSGS_COMPLETION_LIST; do
echo "$word"
done
}
2 changes: 1 addition & 1 deletion test/regression/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
gz_get_sources(tests)

gz_build_tests(TYPE REGRESION SOURCES ${tests})
gz_build_tests(TYPE REGRESSION SOURCES ${tests})
7 changes: 5 additions & 2 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ if (MSVC)
list(REMOVE_ITEM test_sources gz_TEST.cc)
endif()


if (HAVE_GZ_TOOLS)
gz_build_tests(TYPE UNIT SOURCES ${test_sources})
gz_build_tests(
TYPE UNIT
SOURCES ${test_sources}
LIB_DEPS
${EXTRA_TEST_LIB_DEPS})
endif ()
32 changes: 32 additions & 0 deletions tools/gz_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*
*/

#include <filesystem>
#include <fstream>
#include <string>
#include <gtest/gtest.h>
#include <gz/msgs/config.hh>
Expand Down Expand Up @@ -89,6 +91,36 @@ TEST(CmdLine, MsgInfo)
<< output;
}

/////////////////////////////////////////////////
TEST(CmdLine, MsgHelpVsCompletionFlags)
{
// Flags in help message
auto helpOutput = custom_exec_str("ign msg --help --force-version "
+ g_version);

// Call the output function in the bash completion script
std::filesystem::path scriptPath = PROJECT_SOURCE_PATH;
scriptPath = scriptPath / "src" / "cmd" / "msgs.bash_completion.sh";

// Equivalent to:
// sh -c "bash -c \". /path/to/msgs.bash_completion.sh; _gz_msgs_flags\""
std::string cmd = "bash -c \". " + scriptPath.string() + "; _gz_msgs_flags\"";
std::string scriptOutput = custom_exec_str(cmd);

// Tokenize script output
std::istringstream iss(scriptOutput);
std::vector<std::string> flags((std::istream_iterator<std::string>(iss)),
std::istream_iterator<std::string>());

EXPECT_GT(flags.size(), 0u);

// Match each flag in script output with help message
for (std::string flag : flags)
{
EXPECT_NE(std::string::npos, helpOutput.find(flag)) << helpOutput;
}
}

/////////////////////////////////////////////////
/// Main
int main(int argc, char **argv)
Expand Down