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 { 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/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 c762a989..fc24160c 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)); ///////////////////////////////////////////////// @@ -94,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. @@ -102,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();