mac: osx_bundle_libs bundles recursive dependencies so libogg/libvorbis conundrum solved

heavy-resources
Martin Plicht 2012-03-25 15:30:01 +02:00
parent ef289a0c60
commit 4d504956c5
3 changed files with 34 additions and 21 deletions

View File

@ -1109,7 +1109,7 @@ endif()
if (APPLE)
add_custom_command(TARGET clonk
POST_BUILD COMMAND "/bin/sh" "${CMAKE_CURRENT_SOURCE_DIR}/tools/osx_bundle_libs.sh"
POST_BUILD COMMAND "/usr/bin/ruby" "${CMAKE_CURRENT_SOURCE_DIR}/tools/osx_bundle_libs"
)
set(CMAKE_XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER YES)

View File

@ -0,0 +1,33 @@
#!/usr/bin/env ruby
# Bundle all the libraries, no matter their potential existence on pristine OSX installations
$libs_to_bundle=".*?/lib(jpeg|GLEW|llvm|SDL|SDL_mixer|freetype|ogg|vorbis|vorbisfile|z\.|png[0-9]*|iconv)\.[^ ]+\.dylib"
$executable_path = ENV['EXECUTABLE_PATH']
$frameworks_folder_path = ENV['FRAMEWORKS_FOLDER_PATH']
Dir.chdir ENV['TARGET_BUILD_DIR']
puts "Bundling libraries..."
def bundle_dependencies(executable_path)
`otool -L #{executable_path} | grep -Eo "#{$libs_to_bundle}" | grep -v "@executable_path.*"`.each_line do |lib|
lib.strip!
break if not File.exists? lib
puts "Bundling #{lib}"
base = `basename #{lib}`.strip
bundle_path = "#{$frameworks_folder_path}/#{base}"
already_bundled = File.exists? bundle_path
id = "@executable_path/../Frameworks/#{base}"
if not already_bundled then
puts "Bundling #{base}..."
`cp #{lib} #{bundle_path}`
`chmod u+w #{bundle_path}`
end
`install_name_tool -id #{id} #{bundle_path}`
`install_name_tool -change #{lib} #{id} #{$executable_path}`
`install_name_tool -change #{lib} #{id} #{executable_path}` if $executable_path != executable_path
bundle_dependencies bundle_path if not already_bundled
end
end
`mkdir -p #{$frameworks_folder_path}`
bundle_dependencies $executable_path

View File

@ -1,20 +0,0 @@
#!/bin/sh
# Removed, I think those should exist on every Mac Os system: z|png[0-9]*|iconv
LIBS_TO_BUNDLE=".*?/lib(jpeg|GLEW|llvm|SDL|SDL_mixer|freetype|ogg|vorbis|vorbisfile)\.[^ ]+\.dylib"
cd $TARGET_BUILD_DIR
echo "Bundling libraries..."
for lib in `otool -L $EXECUTABLE_PATH | grep -Eo "$LIBS_TO_BUNDLE" | grep -v "@executable_path.*"`; do
echo "Bundling $lib"
base=`basename $lib`
mkdir -p $FRAMEWORKS_FOLDER_PATH
bundle_path=$FRAMEWORKS_FOLDER_PATH/$base
id=@executable_path/../Frameworks/$base
echo Bundling $base... cp $lib $bundle_path
cp $lib $bundle_path
chmod u+w $bundle_path
install_name_tool -id $id $bundle_path
install_name_tool -change $lib $id $EXECUTABLE_PATH
done