-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fix use of Backward on macOS #67
Changes from 5 commits
b6272d8
967c891
99f23c0
77e0f98
cb9c102
311d588
4d59184
abb4da5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,4 +220,6 @@ else (build_errors) | |
${PROJECT_NAME_LOWER}") | ||
endif(build_errors) | ||
|
||
include(CTest) | ||
|
||
add_subdirectory(src) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,78 @@ if(WIN32) | |
endif() | ||
install (TARGETS backward DESTINATION ${LIB_INSTALL_DIR}) | ||
|
||
#=============================================================================== | ||
# Used for the installed version. | ||
if(APPLE) | ||
# On macOS, the full path to the library since DYLD_LIBRARY_PATH may not work. | ||
set(backward_library_name ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/$<TARGET_FILE_NAME:backward>) | ||
else() | ||
set(backward_library_name $<TARGET_FILE_NAME:backward>) | ||
endif() | ||
|
||
# Two steps to create `ign`, First using `configure_file`, to interpolate cmake variables. Then | ||
# use `file(GENERATE ...)` to use generator expressions | ||
configure_file(ign.in ${PROJECT_BINARY_DIR}/${executable_name}_before_gen) | ||
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/$<CONFIG>/${executable_name} INPUT ${PROJECT_BINARY_DIR}/${executable_name}_before_gen ) | ||
install (PROGRAMS ${PROJECT_BINARY_DIR}/$<CONFIG>/${executable_name} DESTINATION ${BIN_INSTALL_DIR}) | ||
set(ign_script_configured ${PROJECT_BINARY_DIR}/${executable_name}_before_gen) | ||
set(ign_script_generated ${PROJECT_BINARY_DIR}/$<CONFIG>/${executable_name}) | ||
|
||
configure_file(ign.in ${ign_script_configured}) | ||
file(GENERATE OUTPUT ${ign_script_generated} INPUT ${ign_script_configured}) | ||
install (PROGRAMS ${ign_script_generated} DESTINATION ${BIN_INSTALL_DIR}) | ||
|
||
#=============================================================================== | ||
# BEGIN TEST ign command | ||
# Generate the ruby script for internal testing. | ||
if(BUILD_TESTING) | ||
set(backward_library_name $<TARGET_FILE:backward>) | ||
set(ign_script_configured_test ${PROJECT_BINARY_DIR}/test/bin/${executable_name}_before_gen) | ||
set(ign_script_generated_test ${PROJECT_BINARY_DIR}/$<CONFIG>/test/bin/${executable_name}) | ||
|
||
# Two steps to create `ign`, First using `configure_file`, to interpolate cmake variables. Then | ||
# use `file(GENERATE ...)` to use generator expressions | ||
configure_file(ign.in ${ign_script_configured_test}) | ||
file(GENERATE OUTPUT ${ign_script_generated_test} INPUT ${ign_script_configured_test}) | ||
|
||
set(IGN_DESIGNIATION tools) | ||
set(cmd_script_configured_test "${CMAKE_CURRENT_BINARY_DIR}/cmd${IGN_DESIGNIATION}_TEST.rb.configured") | ||
set(cmd_script_generated_test "${PROJECT_BINARY_DIR}/test/lib/$<CONFIG>/ruby/ignition/cmd${IGN_DESIGNIATION}_TEST.rb") | ||
|
||
configure_file( | ||
"cmd${IGN_DESIGNIATION}_TEST.rb.in" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 311d588. |
||
"${cmd_script_configured_test}" | ||
@ONLY) | ||
|
||
file(GENERATE | ||
OUTPUT "${cmd_script_generated_test}" | ||
INPUT "${cmd_script_configured_test}") | ||
|
||
set(ign_library_path ${cmd_script_generated_test}) | ||
|
||
set(yaml_output_dir "${PROJECT_BINARY_DIR}/test/conf/" ) | ||
set(yaml_output_configured_test "${yaml_output_dir}/${IGN_DESIGNIATION}_TEST.yaml.configured" ) | ||
set(yaml_output_generated_test "${yaml_output_dir}/$<CONFIG>/${IGN_DESIGNIATION}_TEST.yaml" ) | ||
configure_file( | ||
"${IGN_DESIGNIATION}_TEST.yaml.in" | ||
${yaml_output_configured_test} @ONLY) | ||
|
||
file(GENERATE | ||
OUTPUT "${yaml_output_generated_test}" | ||
INPUT "${yaml_output_configured_test}") | ||
|
||
add_test(NAME UNIT_ign_TEST COMMAND ruby ${ign_script_generated_test} tools_TEST) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. |
||
|
||
set_tests_properties( | ||
UNIT_ign_TEST | ||
PROPERTIES | ||
ENVIRONMENT | ||
"IGN_CONFIG_PATH=${yaml_output_dir}/$<CONFIG>" | ||
) | ||
set_tests_properties(UNIT_ign_TEST PROPERTIES | ||
PASS_REGULAR_EXPRESSION "Test passed" | ||
) | ||
|
||
set_tests_properties(UNIT_ign_TEST PROPERTIES | ||
FAIL_REGULAR_EXPRESSION "Library error" | ||
) | ||
endif() | ||
# END TEST | ||
#============================== |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/ruby | ||
|
||
# Copyright (C) 2021 Open Source Robotics Foundation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
require 'optparse' | ||
|
||
# Constants. | ||
COMMANDS = {'tools' => "Test ign tools.\n\n"} | ||
|
||
class Cmd | ||
# | ||
# Execute the command | ||
# | ||
def execute(args) | ||
puts "Test passed" | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,17 +282,10 @@ if ARGV.include?('--versions') | |
end | ||
|
||
# Start Backward before loading plugins | ||
backward_library_name = if (/darwin/ =~ RUBY_PLATFORM).nil? | ||
'$<TARGET_FILE_NAME:backward>' | ||
else | ||
# On macOS, the full path to the library since | ||
# DYLD_LIBRARY_PATH may not work. | ||
'$<TARGET_FILE:backward>' | ||
end | ||
begin | ||
SharedLibInterface::Importer.dlload backward_library_name | ||
SharedLibInterface::Importer.dlload '@backward_library_name@' | ||
rescue SharedLibInterface::DLError | ||
puts "Library error: #{backward_library_name} not found. Improved backtrace"\ | ||
puts 'Library error: @backward_library_name@ not found. Improved backtrace'\ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 311d588. I used |
||
' generation will be disabled' | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- # test commands | ||
format: 1.0.0 | ||
library_name: @PROJECT_NAME@ | ||
library_version: '' | ||
library_path: @ign_library_path@ | ||
commands: | ||
- tools_TEST : Test command | ||
--- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
someone recently submitted gazebosim/gazebo-classic#3076 to change
${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}
to${CMAKE_INSTALL_FULL_LIBDIR}
, so I think we could do the same here