Skip to content

Commit

Permalink
Enable use of ign gazebo -s on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Silvio <[email protected]>
  • Loading branch information
traversaro committed Jul 5, 2022
1 parent 199237d commit b170a72
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
5 changes: 1 addition & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,4 @@ foreach(CMD_TEST

endforeach()

if(NOT WIN32)
add_subdirectory(cmd)
endif()

add_subdirectory(cmd)
8 changes: 7 additions & 1 deletion src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ set(cmd_script_configured "${cmd_script_generated}.configured")

# Set the library_location variable to the relative path to the library file
# within the install directory structure.
set(library_location "../../../${CMAKE_INSTALL_LIBDIR}/$<TARGET_FILE_NAME:${ign_lib_target}>")
if(WIN32)
set(plugin_location ${CMAKE_INSTALL_BINDIR})
else()
set(plugin_location ${CMAKE_INSTALL_LIBDIR})
endif()

set(library_location "../../../${plugin_location}/$<TARGET_FILE_NAME:${ign_lib_target}>")

configure_file(
"cmd${IGN_DESIGNATION}.rb.in"
Expand Down
6 changes: 4 additions & 2 deletions src/cmd/ModelCommandAPI.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
*
*/

#include "ignition/gazebo/Export.hh"

/// \brief External hook to get a list of available models.
extern "C" void cmdModelList();
extern "C" IGNITION_GAZEBO_VISIBLE void cmdModelList();

/// \brief External hook to dump model information.
/// \param[in] _modelName Model name.
/// \param[in] _pose --pose option.
/// \param[in] _linkName Link name.
/// \param[in] _jointName Joint name.
/// \param[in] _sensorName Sensor name.
extern "C" void cmdModelInfo(
extern "C" IGNITION_GAZEBO_VISIBLE void cmdModelInfo(
const char *_modelName, int _pose, const char *_linkName,
const char *_jointName,
const char *_sensorName);
Expand Down
12 changes: 12 additions & 0 deletions src/cmd/cmdgazebo.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,12 @@ See https://github.com/ignitionrobotics/ign-gazebo/issues/44 for more info."
exit(-1)
end

if plugin.end_with? ".dll"
puts "`ign gazebo` currently only works with the -s argument on Windows.
See https://github.com/gazebosim/gz-sim/issues/168 for more info."
exit(-1)
end

serverPid = Process.fork do
ENV['RMT_PORT'] = '1500'
Process.setpgid(0, 0)
Expand Down Expand Up @@ -512,6 +518,12 @@ See https://github.com/ignitionrobotics/ign-gazebo/issues/44 for more info."
exit(-1)
end

if plugin.end_with? ".dll"
puts "`ign gazebo` currently only works with the -s argument on Windows.
See https://github.com/gazebosim/gz-sim/issues/168 for more info."
exit(-1)
end

ENV['RMT_PORT'] = '1501'
Importer.runGui(options['gui_config'], options['render_engine_gui'])
end
Expand Down
15 changes: 8 additions & 7 deletions src/ign.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@

/// \brief External hook to read the library version.
/// \return C-string representing the version. Ex.: 0.1.2
extern "C" char *ignitionGazeboVersion();
extern "C" IGNITION_GAZEBO_VISIBLE char *ignitionGazeboVersion();

/// \brief Get the Gazebo version header.
/// \return C-string containing the Gazebo version information.
extern "C" char *gazeboVersionHeader();
extern "C" IGNITION_GAZEBO_VISIBLE char *gazeboVersionHeader();

/// \brief Set verbosity level
/// \param[in] _verbosity 0 to 4
extern "C" void cmdVerbosity(
extern "C" IGNITION_GAZEBO_VISIBLE void cmdVerbosity(
const char *_verbosity);

extern "C" const char *worldInstallDir();
extern "C" IGNITION_GAZEBO_VISIBLE const char *worldInstallDir();

/// \brief External hook to run simulation server.
/// \param[in] _sdfString SDF file to run, as a string.
Expand All @@ -56,7 +56,7 @@ extern "C" const char *worldInstallDir();
/// null to record the default topics.
/// \param[in] _headless True if server rendering should run headless
/// \return 0 if successful, 1 if not.
extern "C" int runServer(const char *_sdfString,
extern "C" IGNITION_GAZEBO_VISIBLE int runServer(const char *_sdfString,
int _iterations, int _run, float _hz, int _levels,
const char *_networkRole, int _networkSecondaries, int _record,
const char *_recordPath, int _recordResources, int _logOverwrite,
Expand All @@ -69,13 +69,14 @@ extern "C" int runServer(const char *_sdfString,
/// \param[in] _guiConfig Path to Ignition GUI configuration file.
/// \param[in] _renderEngine --render-engine-gui option
/// \return 0 if successful, 1 if not.
extern "C" int runGui(const char *_guiConfig, const char *_renderEngine);
extern "C" IGNITION_GAZEBO_VISIBLE int runGui(const char *_guiConfig,
const char *_renderEngine);

/// \brief External hook to find or download a fuel world provided a URL.
/// \param[in] _pathToResource Path to the fuel world resource, ie,
/// https://staging-fuel.ignitionrobotics.org/1.0/gmas/worlds/ShapesClone
/// \return C-string containing the path to the local world sdf file
extern "C" const char *findFuelResource(
extern "C" IGNITION_GAZEBO_VISIBLE const char *findFuelResource(
char *_pathToResource);

#endif
7 changes: 3 additions & 4 deletions src/systems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ function(gz_add_system system_name)
set(unversioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_NO_VERSION_LOWER}-${system_name}${CMAKE_SHARED_LIBRARY_SUFFIX})
if(WIN32)
# symlinks on Windows require admin priviledges, fallback to copy
ADD_CUSTOM_COMMAND(TARGET ${system_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:${system_target}>"
"$<TARGET_FILE_DIR:${system_target}>/${unversioned}")
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy
${IGNITION_GAZEBO_PLUGIN_INSTALL_DIR}\/${versioned}
${IGNITION_GAZEBO_PLUGIN_INSTALL_DIR}\/${unversioned})")
else()
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink ${versioned} ${unversioned} WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
Expand Down

0 comments on commit b170a72

Please sign in to comment.