Skip to content

Commit

Permalink
Fix windows tests
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
  • Loading branch information
azeey committed Apr 19, 2024
1 parent 54fa1b8 commit f1aba12
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion core/src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ set(cmd_script_configured "${CMAKE_CURRENT_BINARY_DIR}/cmd${GZ_DESIGNATION}${PRO

# 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:${PROJECT_LIBRARY_TARGET_NAME}>")
if (MSVC)
set(library_location_prefix "${CMAKE_INSTALL_BINDIR}")
else()
set(library_location_prefix "${CMAKE_INSTALL_LIBDIR}")
endif()

set(library_location "../../../${library_location_prefix}/$<TARGET_FILE_NAME:${PROJECT_NAME}>")

configure_file(
"cmd${GZ_DESIGNATION}.rb.in"
Expand Down
10 changes: 9 additions & 1 deletion core/src/cmd/cmdmsgs.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ else
end

require 'optparse'
require 'pathname'

# Constants.
LIBRARY_NAME = '@library_location@'
Expand Down Expand Up @@ -101,7 +102,7 @@ class Cmd
# puts options

# Read the plugin that handles the command.
if LIBRARY_NAME[0] == '/'
if Pathname.new(LIBRARY_NAME).absolute?
# If the first character is a slash, we'll assume that we've been given an
# absolute path to the library. This is only used during test mode.
plugin = LIBRARY_NAME
Expand All @@ -112,6 +113,13 @@ class Cmd
end
conf_version = LIBRARY_VERSION

if defined? RubyInstaller
# RubyInstaller does not search for dlls in PATH or the directory that tests are running from,
# so we'll add the parent directory of the plugin to the search path.
# https://github.com/oneclick/rubyinstaller2/wiki/For-gem-developers#-dll-loading
RubyInstaller::Runtime.add_dll_directory(File.dirname(plugin))
end

begin
Importer.dlload plugin
rescue DLError
Expand Down

0 comments on commit f1aba12

Please sign in to comment.