From 88386e4e7a38d0ccb0a96f9774ba5339bc7e5440 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 11 Apr 2022 19:03:59 +0200 Subject: [PATCH 1/3] Generator: Add missing std namespace to string arguments (#242) Signed-off-by: Silvio --- include/ignition/msgs/Generator.hh | 4 ++-- src/Generator.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/ignition/msgs/Generator.hh b/include/ignition/msgs/Generator.hh index 62d77c64..5785e512 100644 --- a/include/ignition/msgs/Generator.hh +++ b/include/ignition/msgs/Generator.hh @@ -43,9 +43,9 @@ class Generator : public CodeGenerator /// \param[in] _generatorContext Output directory. /// \param[in] _error Unused string value public: virtual bool Generate(const FileDescriptor *_file, - const string &_parameter, + const std::string &_parameter, OutputDirectory *_generatorContext, - string *_error) const; + std::string *_error) const; // private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator); }; diff --git a/src/Generator.cc b/src/Generator.cc index 7fa213a0..11599be0 100644 --- a/src/Generator.cc +++ b/src/Generator.cc @@ -67,7 +67,7 @@ Generator::~Generator() ///////////////////////////////////////////////// bool Generator::Generate(const FileDescriptor *_file, - const string &/*_parameter*/, + const std::string &/*_parameter*/, OutputDirectory *_generatorContext, std::string * /*_error*/) const { From 0aec5523c8953f50e770683d4ca1c58db23caf83 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Wed, 3 Apr 2019 14:07:09 +0200 Subject: [PATCH 2/3] Windows fixes for setenv and popen/pclose --- test/test_config.h.in | 31 +++++++++++++++++++++++++++++++ tools/ign_TEST.cc | 5 +++++ 2 files changed, 36 insertions(+) diff --git a/test/test_config.h.in b/test/test_config.h.in index 20e826c4..ec5ce452 100644 --- a/test/test_config.h.in +++ b/test/test_config.h.in @@ -22,4 +22,35 @@ #define IGN_CONFIG_PATH "@CMAKE_BINARY_DIR@/test/conf" #define IGN_TEST_LIBRARY_PATH "${PROJECT_BINARY_DIR}/src" +#if (_MSC_VER >= 1400) // Visual Studio 2005 + #include + + /// \brief setenv/unstenv are not present in Windows. Define them to make + /// the code portable. + /// \param[in] _name Variable name. + /// \param[in] _value Value. + /// \param[in] _rewrite If 'name' does exist in the environment, then its + /// value is changed to 'value' if 'rewrite' is nonzero. If overwrite is + /// zero, then the value of 'name' is not changed. + /// /return 0 on success or -1 on error. + int setenv(const char *_name, const char *_value, int /*_rewrite*/) + { + std::stringstream sstr; + std::string name = _name; + std::string value = _value; + sstr << name << '=' << value; + return _putenv(sstr.str().c_str()); + } + + /// \brief Deletes an environment variable. + /// \param[in] _name Variable name. + void unsetenv(const char *_name) + { + std::stringstream sstr; + std::string name = _name; + sstr << name << '='; + _putenv(sstr.str().c_str()); + } +#endif + #endif diff --git a/tools/ign_TEST.cc b/tools/ign_TEST.cc index c762a989..5c247e64 100644 --- a/tools/ign_TEST.cc +++ b/tools/ign_TEST.cc @@ -20,6 +20,11 @@ #include #include "ignition/msgs/test_config.h" +#ifdef _MSC_VER +# define popen _popen +# define pclose _pclose +#endif + static const std::string g_version(std::string(IGNITION_MSGS_VERSION_FULL)); ///////////////////////////////////////////////// From aff886cba00b94fd844f11689df6edd70a83d5a8 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Fri, 19 Apr 2019 07:25:37 -0700 Subject: [PATCH 3/3] disable test on windows --- tools/CMakeLists.txt | 7 ++++++- tools/ign_TEST.cc | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index a46f961e..7435362a 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -2,11 +2,16 @@ include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/test ) - set (test_sources ign_TEST.cc ) +# Skip command line tests for Windows, see +# https://bitbucket.org/ignitionrobotics/ign-msgs/issues/28 +if (MSVC) + list(REMOVE_ITEM test_sources ign_TEST.cc) +endif() + if (IGNITION-TOOLS_BINARY_DIRS) ign_build_tests(TYPE UNIT SOURCES ${test_sources}) endif () diff --git a/tools/ign_TEST.cc b/tools/ign_TEST.cc index 5c247e64..fc24160c 100644 --- a/tools/ign_TEST.cc +++ b/tools/ign_TEST.cc @@ -99,7 +99,6 @@ int main(int argc, char **argv) // Make sure that we load the library recently built and not the one installed // in your system. -#ifndef _WIN32 // Add the directory where ignition msgs has been built. std::string value = std::string(IGN_TEST_LIBRARY_PATH); // Save the current value of LD_LIBRARY_PATH. @@ -107,7 +106,6 @@ int main(int argc, char **argv) if (cvalue) value += ":" + std::string(cvalue); setenv("LD_LIBRARY_PATH", value.c_str(), 1); -#endif ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS();