Skip to content

Instantly share code, notes, and snippets.

@jfro
Created March 15, 2010 15:40
Show Gist options
  • Save jfro/332961 to your computer and use it in GitHub Desktop.
Save jfro/332961 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
begin
require 'rubygems'
rescue LoadError
error_string = "\n\nYou must install rubygems in order to use this script"
raise error_string
end
begin
require 'osx/plist'
rescue LoadError
error_string = "\n\nYou must install the plist ruby gem in order to use this script. \n gem sources -a http://gems.github.com \n sudo gem install kballard-osx-plist\n"
raise error_string
end
if ARGV.length < 1
puts "Usage: ruby archive_build.rb product_bundle"
exit
end
FRAMEWORKS_PATH = File.join(File.dirname(__FILE__), '..', '3rdparty', 'Frameworks')
RELEASES_PATH = File.join(File.dirname(__FILE__), '..', ' Releases')
def getFrameworkList(product_path)
frameworksPath = File.join(product_path, 'Contents', 'Frameworks')
frameworks = []
Dir.foreach(frameworksPath) do |path|
if path != '.' or path != '..'
frameworks << path
end
end
return frameworks
end
def getDSYMPaths(frameworks)
dsyms = []
for framework in frameworks
dsym = File.join(FRAMEWORKS_PATH, framework + ".dSYM")
if File.exists? dsym
dsyms << dsym
end
end
return dsyms
end
def makeReleaseDirectory(productPath)
productName = File.basename(productPath, File.extname(productPath))
plist = OSX::PropertyList.load(File.open(File.join(productPath, "Contents", "Info.plist")))
version = plist['CFBundleVersion']
versionStr = plist['CFBundleShortVersionString']
releasePath = File.join(RELEASES_PATH, "#{productName}-#{versionStr}-#{version}")
FileUtils.mkdir_p(releasePath)
return releasePath
end
productPath = ARGV[0]
productName = File.basename(productPath, File.extname(productPath))
productDSYM = productPath + ".dSYM"
puts "Product: #{productName}"
frameworks = getFrameworkList(productPath)
dsyms = getDSYMPaths(frameworks)
releasePath = makeReleaseDirectory(productPath)
FileUtils.cp_r(productPath, releasePath)
if File.exists? productDSYM
FileUtils.cp_r(productDSYM, releasePath)
end
for dsym in dsyms
FileUtils.cp_r(dsym, releasePath)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment