Skip to content

Commit

Permalink
Merge pull request #277 from openstudiocoalition/fix-mac
Browse files Browse the repository at this point in the history
Fix loading openstudio_modeleditor.rb
  • Loading branch information
macumber authored Nov 26, 2020
2 parents cc49555 + b7ad980 commit bbbd1d3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 39 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/app_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ jobs:
echo SDKROOT=${{ matrix.SDKROOT }} >> $GITHUB_ENV
echo CMAKE_MACOSX_DEPLOYMENT_TARGET='-DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET' >> $GITHUB_ENV
brew install md5sha1sum
curl -L -O https://download.qt.io/official_releases/qt-installer-framework/3.2.2/QtInstallerFramework-mac-x64.dmg
hdiutil attach -mountpoint ./qtfiw_installer QtInstallerFramework-mac-x64.dmg
echo "ls ./qtfiw_installer"
Expand All @@ -259,6 +261,9 @@ jobs:
echo "~/Qt/QtIFW-3.2.2/bin/" >> $GITHUB_PATH
fi;
CONAN_INSTALL_MD5=$(md5sum ConanInstall.cmake | awk '{print $1}')
echo CONAN_INSTALL_MD5=$CONAN_INSTALL_MD5 >> $GITHUB_ENV
# TODO: cache the QtIFW folder too

- name: Cache entire build directory
Expand Down Expand Up @@ -352,8 +357,10 @@ jobs:
id: cacheconan
uses: actions/cache@v2
with:
path: ~/.conan
key: ${{ matrix.os }}-conan-cache
path: |
~/.conan
/.conan
key: ${{ matrix.os }}-conan-cache-${{ env.CONAN_INSTALL_MD5 }}

- name: Did restoring the conan-cache work? No
# If the SDK wasn't found in the cache
Expand All @@ -369,6 +376,7 @@ jobs:
run: |
ls ~/.conan/
ls ~/.conan/data/
ls /.conan
- name: Create Build Environment and locate openstudio
# Some projects don't allow in-source building, so create a separate build directory
Expand Down
2 changes: 2 additions & 0 deletions FindOpenStudioSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ find_package(openstudio "${OPENSTUDIO_VERSION}" CONFIG
"${OPENSTUDIO_ARCHIVE_DIR}/${OPENSTUDIO_ARCHIVE_BASENAME}"
HINTS
"${OPENSTUDIO_ARCHIVE_DIR}"
NO_DEFAULT_PATH
NO_PACKAGE_ROOT_PATH
)
if(openstudio_FOUND)
message("Found specified openstudio at openstudio_DIR=${openstudio_DIR}")
Expand Down
44 changes: 24 additions & 20 deletions SketchUpInstallName.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
def fixup(file, rpath_replacement)
puts
puts file
`otool -L #{file}`.split("\n").each do |line|
line.strip!
if md = /(@rpath[^\s]*)/.match(line)
line = md[1]
new_line = line.gsub("@rpath", rpath_replacement)
if md = /Qt.*\/(Qt.*?)$/.match(new_line)
new_line = new_line.gsub(md[0], md[1])
end
puts "#{line} -> #{new_line}"
`install_name_tool -change #{line} #{new_line} #{file}`
end
end
`install_name_tool -add_rpath #{rpath_replacement} #{file}`
#`otool -L #{file}`.split("\n").each do |line|
# line.strip!
# if md = /(@rpath[^\s]*)/.match(line)
# line = md[1]
# new_line = line.gsub("@rpath", rpath_replacement)
# if md = /Qt.*\/(Qt.*?)$/.match(new_line)
# #new_line = new_line.gsub(md[0], md[1])
# end
# puts "#{line} -> #{new_line}"
# `install_name_tool -change #{line} #{new_line} #{file}`
# end
#end
end

# Fix up any load paths in openstudio_modeleditor.bundle
Expand All @@ -23,14 +24,17 @@ def fixup_model_editor(lib_path, lib_path_replacemant, openstudio_modeleditor_pa
end

dir = File.dirname(ARGV[0])
fixup(ARGV[0], "@loader_path")
fixup(File.join(dir, "QtConcurrent"), "@loader_path")
fixup(File.join(dir, "QtCore"), "@loader_path")
fixup(File.join(dir, "QtGui"), "@loader_path")
fixup(File.join(dir, "QtNetwork"), "@loader_path")
fixup(File.join(dir, "QtPrintSupport"), "@loader_path")
fixup(File.join(dir, "QtWidgets"), "@loader_path")
fixup(File.join(dir, "QtXml"), "@loader_path")

fixup(ARGV[0], "@loader_path/")

qt_libs = ['QtConcurrent', 'QtCore', 'QtGui', 'QtNetwork','QtPrintSupport', 'QtWidgets', 'QtXml']
qt_libs.each do |qt_lib|
Dir.glob(File.join(dir, '**', qt_lib)).each do |file|
next if /Headers/.match(file)
fixup(file, "@loader_path/")
end
end

fixup(File.join(dir, "platforms/libqcocoa.dylib"), "@loader_path/..")

fixup_model_editor("libopenstudiolib.dylib", "@loader_path/libopenstudiolib.dylib", File.join(dir, "openstudio_modeleditor.bundle"))
32 changes: 16 additions & 16 deletions ruby/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ if(APPLE)
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/platforms/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::QCocoaIntegrationPlugin> $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/platforms/.
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::Concurrent> $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/.
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::Core> $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/.
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::DBus> $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/.
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::Gui> $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/.
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::Network> $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/.
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::PrintSupport> $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/.
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::Widgets> $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/.
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::Xml> $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/.
COMMAND ${CMAKE_COMMAND} -E copy_directory ${QT_INSTALL_DIR}/lib/QtConcurrent.framework $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtConcurrent.framework
COMMAND ${CMAKE_COMMAND} -E copy_directory ${QT_INSTALL_DIR}/lib/QtCore.framework $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtCore.framework
COMMAND ${CMAKE_COMMAND} -E copy_directory ${QT_INSTALL_DIR}/lib/QtDBus.framework $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtDBus.framework
COMMAND ${CMAKE_COMMAND} -E copy_directory ${QT_INSTALL_DIR}/lib/QtGui.framework $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtGui.framework
COMMAND ${CMAKE_COMMAND} -E copy_directory ${QT_INSTALL_DIR}/lib/QtNetwork.framework $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtNetwork.framework
COMMAND ${CMAKE_COMMAND} -E copy_directory ${QT_INSTALL_DIR}/lib/QtPrintSupport.framework $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtPrintSupport.framework
COMMAND ${CMAKE_COMMAND} -E copy_directory ${QT_INSTALL_DIR}/lib/QtWidgets.framework $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtWidgets.framework
COMMAND ${CMAKE_COMMAND} -E copy_directory ${QT_INSTALL_DIR}/lib/QtXml.framework $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtXml.framework
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:openstudio::openstudiolib> $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/.
COMMAND ruby "${PROJECT_SOURCE_DIR}/SketchUpInstallName.rb" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ruby/openstudio_modeleditor.bundle"
)
Expand All @@ -91,15 +91,15 @@ install(TARGETS openstudio_modeleditor_rb DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES openstudio_modeleditor.rb DESTINATION Ruby COMPONENT "RubyAPI")
if(APPLE)
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/platforms/$<TARGET_FILE_NAME:Qt5::QCocoaIntegrationPlugin> DESTINATION Ruby/platforms COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/$<TARGET_FILE_NAME:Qt5::Concurrent> DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/$<TARGET_FILE_NAME:Qt5::Core> DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/$<TARGET_FILE_NAME:Qt5::DBus> DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/$<TARGET_FILE_NAME:Qt5::Gui> DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/$<TARGET_FILE_NAME:Qt5::Network> DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/$<TARGET_FILE_NAME:Qt5::PrintSupport> DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/$<TARGET_FILE_NAME:Qt5::Widgets> DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtConcurrent.framework DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtCore.framework DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtDBus.framework DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtGui.framework DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtNetwork.framework DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtPrintSupport.framework DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtWidgets.framework DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/QtXml.framework DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/$<TARGET_FILE_NAME:openstudio::openstudiolib> DESTINATION Ruby COMPONENT "RubyAPI")
install(FILES $<TARGET_FILE_DIR:openstudio_modeleditor_rb>/$<TARGET_FILE_NAME:Qt5::Xml> DESTINATION Ruby COMPONENT "RubyAPI")
endif()

if( BUILD_PAT )
Expand Down
1 change: 0 additions & 1 deletion src/model_editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ set(${target_name}_moc
TableView.hpp
TableWidget.hpp
TestButton.hpp
Utilities.hpp
IGPrecisionDialog.hpp
IGLineEdit.hpp
IGSpinBoxes.hpp
Expand Down

0 comments on commit bbbd1d3

Please sign in to comment.