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

Update xtypes #113

Merged
merged 49 commits into from
Jun 15, 2023
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
09aa5b6
Refs 16497. CMake upgrade.
Dec 14, 2022
9759c2e
Refs 16497. Fixing cross-platform issues.
Dec 16, 2022
d8b7827
Refs 16497. Fixing cross-platform issues.
Dec 16, 2022
ae117a5
Refs 16497. Update peglib api.
Dec 20, 2022
2140440
Refs 16497. Preprocessor strategy refactored
Dec 21, 2022
5aa3020
Refs 16497. Fixing gtest on windows
Dec 21, 2022
737860a
Refs 16497. Fixing testing
Dec 23, 2022
f1de241
Refs 16497. Fixing testing
Dec 29, 2022
48c4260
Refs 16497. Fixing testing
Dec 30, 2022
0ced5c0
Refs 16497. Populating test environment to locate preprocessor on win…
Dec 30, 2022
377a0dd
Refs 16497. Introducing some c++17 improvements
Jan 1, 2023
abdc04b
Refs 16497. Fixing encoding issues.
Jan 10, 2023
caedbef
Refs 16497. Enabling ctest for individual gtest execution
Jan 10, 2023
1e95e8a
Refs 16497. Fixing Parser::is_token()
Jan 10, 2023
2d82086
Refs 16497. Refactor static Parser object lifeliness
Jan 11, 2023
7a78e99
Refs 16497. Fix pipes crossplatform issues
Jan 12, 2023
9bb112e
Refs 16497. Refactor temporary filename generation. Fixings on crossp…
Jan 13, 2023
8ac4da9
Refs 16497. Fixing testing if xtypes exceptions are disabled
Jan 13, 2023
7f1461d
Refs 16497. Forcing current workding dir as preprocessor include path.
Jan 13, 2023
2522234
Refs 16497. Fixing windows type size on tests literals
Jan 13, 2023
2576179
Refs 16497. Match preprocessor and build platform and add copyright.
Jan 13, 2023
f5989aa
Refs 16497. Module ownership refactor from Parser to Context.
Jan 14, 2023
e0cf42f
Refs 16497. Simplify temporary files management
Jan 14, 2023
14f32e4
Refs 16497. Add github source indexing to pdb files
Jan 16, 2023
6c51e53
Refs 16497. Enabling Windows Error Reporting for ci purposes
Jan 16, 2023
0132181
Refs 16497. Fix the examples
Jan 16, 2023
81c70f8
Refs 16497. Fixing old ci
Jan 16, 2023
1696ece
Refs 16497. avoid deprecated string conversions
Jan 18, 2023
6fcb0c4
Refs 16497. New CI
Jan 17, 2023
7465b7e
Refs 16497. fixing clang/OS X errors
Jan 19, 2023
e1db308
Refs 16497. Fixing move semantics on DynamicData
Jan 20, 2023
fed71ef
Refs 16497. Compile warnings as errors.
Jan 21, 2023
a10b7ce
Refs 16497. Fixing clang/OS X errors
Jan 22, 2023
e30d3b3
Refs 16497. Avoid using as primitive size_t whose definition is platf…
Jan 22, 2023
8eae165
Refs 16497. Fixing assertion regex usage
Jan 22, 2023
bfdd7ae
Refs 16497. Nightly CI
Jan 22, 2023
8d2443a
Fix c++20 compatibility issues
Jan 23, 2023
cb25040
Refs 16497. Fix C++20 compatibility issues
Jan 24, 2023
9b69a74
Refs 16497. Refactor to link DataType lifecycle to their associated o…
Jan 25, 2023
87522f7
Refs 16497. Allow custom cpp-peglib version selection
Jan 26, 2023
2a6168a
Refs 16497. Added test StructType.russkel_issue
Feb 16, 2023
05c955a
Fix some errors
Jun 14, 2021
8e58611
Print types with scope
Jun 22, 2021
9b57378
Modify generator to return also the IDL separated by structures
Jul 1, 2021
f7be0a3
update log traces
May 9, 2023
1d2dc38
Print types with scope
Jun 22, 2021
49c936b
Fixing parser tool pin point issue
May 12, 2023
dc74a6d
Making platform tool distro independent
May 30, 2023
f22f500
Joakim Haugen's review
May 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion tools/idl_validator.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <xtypes/xtypes.hpp>
#include <xtypes/idl/idl.hpp>

#include <cstdlib>

using namespace eprosima::xtypes;

int main(
Expand All @@ -19,7 +21,19 @@ int main(
idl::Context context;
context.log_level(idl::log::LogLevel::xDEBUG);
context.print_log(true);
context.include_paths.push_back("/opt/ros/foxy/share/");

// Introduce current ros2 paths
std::string distro(std::getenv("ROS_DISTRO"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the environment variable is undefined, std::getenv returns a null pointer. The std::string constructor throws a std::logic_error instead of the graceful exit message. Suggest const char* distro = std::getenv("ROS_DISTRO");, check for null pointer and construct distro string in else .. + std::string(distro) +...

Is the xtypes_idl_validator only intended for ROS? The current implementation demands ROS_DISTRO to be defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got me! I turns out that construct a std::string from nullptr is undefined behavior. On MSVC leads to an empty string and in gcc a std::logic_error is raised. Crossplatform pitfalls 🙄.
We only used xtypes_idl_validator in an Integration-Service ROS2-SH related project. It is interesting for us to fail without a ROS2 overlay. But is a good hint too. Let's turn it into a warning.

if (distro.empty())
{
std::cout << "There is no ROS2 overlay loaded or ros_environment package is missing" << std::endl;
return -1;
}
else
{
context.include_paths.push_back("/opt/ros/" + distro + "/share/");
}

context.ignore_redefinition = true;
context.allow_keyword_identifiers = true;
context = idl::parse(idl_spec, context);
Expand Down