2012-03-25 13:30:01 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
# Bundle all the libraries, no matter their potential existence on pristine OSX installations
|
2014-09-21 20:37:27 +00:00
|
|
|
$libs_to_bundle=".*?/lib(jpeg|GLEW|llvm|SDL|SDL_mixer|freetype|ogg|vorbis|vorbisfile|z\.|png[0-9]*|iconv|alut)\.[^ ]+\.dylib"
|
2012-03-25 13:30:01 +00:00
|
|
|
$executable_path = ENV['EXECUTABLE_PATH']
|
|
|
|
$frameworks_folder_path = ENV['FRAMEWORKS_FOLDER_PATH']
|
|
|
|
|
2014-01-27 07:08:27 +00:00
|
|
|
Dir.chdir ENV['TARGET_BUILD_DIR'] if ENV['TARGET_BUILD_DIR']
|
2012-03-25 13:30:01 +00:00
|
|
|
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
|