2010-01-06 00:01:19 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class AndroidSdk < Formula
|
2012-03-21 22:50:47 +00:00
|
|
|
url 'http://dl.google.com/android/android-sdk_r17-macosx.zip'
|
2010-01-06 00:01:19 +00:00
|
|
|
homepage 'http://developer.android.com/index.html'
|
2012-03-21 22:50:47 +00:00
|
|
|
md5 '52639aae036b7c2e47cf291696b23236'
|
|
|
|
version 'r17'
|
2010-01-06 00:01:19 +00:00
|
|
|
|
2010-12-10 12:37:25 +00:00
|
|
|
def self.var_dirs
|
2012-03-23 00:15:56 +00:00
|
|
|
%w[platforms samples temp add-ons sources system-images extras]
|
2012-03-22 09:33:21 +00:00
|
|
|
# TODO docs and platform-tools
|
2011-01-25 13:39:47 +00:00
|
|
|
# See the long comment below for the associated problems
|
2010-12-10 12:37:25 +00:00
|
|
|
end
|
2010-09-12 20:55:04 +00:00
|
|
|
|
2010-12-10 12:37:25 +00:00
|
|
|
skip_clean var_dirs
|
2010-01-06 00:01:19 +00:00
|
|
|
|
|
|
|
def install
|
2010-09-12 20:55:04 +00:00
|
|
|
mkdir bin
|
2010-01-06 00:01:19 +00:00
|
|
|
|
2010-09-12 20:55:04 +00:00
|
|
|
mv 'SDK Readme.txt', prefix/'README'
|
|
|
|
mv 'tools', prefix
|
2010-01-06 00:01:19 +00:00
|
|
|
|
2012-03-22 09:33:21 +00:00
|
|
|
%w[android apkbuilder ddms dmtracedump draw9patch etc1tool emulator
|
|
|
|
hierarchyviewer hprof-conv lint mksdcard monkeyrunner traceview
|
|
|
|
zipalign].each do |tool|
|
|
|
|
(bin/tool).write <<-EOS.undent
|
|
|
|
#!/bin/sh
|
|
|
|
TOOL="#{prefix}/tools/#{tool}"
|
|
|
|
exec "$TOOL" "$@"
|
|
|
|
EOS
|
2010-01-06 00:01:19 +00:00
|
|
|
end
|
2010-02-27 17:26:27 +00:00
|
|
|
|
2010-09-12 20:55:04 +00:00
|
|
|
# this is data that should be preserved across upgrades, but the Android
|
|
|
|
# SDK isn't too smart, so we still have to symlink it back into its tree.
|
2010-12-10 12:37:25 +00:00
|
|
|
AndroidSdk.var_dirs.each do |d|
|
2010-09-12 20:55:04 +00:00
|
|
|
dst = prefix/d
|
|
|
|
src = var/'lib/android-sdk'/d
|
|
|
|
src.mkpath unless src.directory?
|
|
|
|
dst.make_relative_symlink src
|
|
|
|
end
|
2011-01-25 13:39:47 +00:00
|
|
|
|
2011-07-26 03:45:02 +00:00
|
|
|
(bin+'adb').write <<-EOS.undent
|
2011-01-25 13:39:47 +00:00
|
|
|
#!/bin/sh
|
|
|
|
ADB="#{prefix}/platform-tools/adb"
|
2011-02-25 22:15:49 +00:00
|
|
|
test -f "$ADB" && exec "$ADB" "$@"
|
2012-03-22 09:33:21 +00:00
|
|
|
echo Use the \\`android\\' tool to install the \\"Android SDK Platform-tools\\".
|
2011-01-25 13:39:47 +00:00
|
|
|
EOS
|
2010-09-12 20:55:04 +00:00
|
|
|
end
|
2010-02-27 17:26:27 +00:00
|
|
|
|
2010-12-10 12:37:25 +00:00
|
|
|
def caveats; <<-EOS.undent
|
2011-01-25 13:39:47 +00:00
|
|
|
Now run the `android' tool to install the actual SDK stuff.
|
2012-01-18 17:52:38 +00:00
|
|
|
|
2012-01-18 18:25:10 +00:00
|
|
|
NOTE you should tell Eclipse, IntelliJ etc. to use the Android-SDK found
|
|
|
|
here: #{prefix}
|
2012-01-18 17:52:38 +00:00
|
|
|
|
2012-03-22 09:33:21 +00:00
|
|
|
You will have to install the platform-tools and docs EVERY time this formula
|
|
|
|
updates. If you want to try and fix this then see the comment in this formula.
|
2012-03-01 16:54:53 +00:00
|
|
|
|
|
|
|
You may need to add the following to your .bashrc:
|
|
|
|
|
|
|
|
export ANDROID_SDK_ROOT=#{prefix}
|
2010-02-27 17:26:27 +00:00
|
|
|
EOS
|
2010-01-06 00:01:19 +00:00
|
|
|
end
|
2011-01-25 13:39:47 +00:00
|
|
|
|
2012-03-06 16:00:47 +00:00
|
|
|
# The `android' tool insists on deleting #{prefix}/platform-tools
|
2011-01-25 13:39:47 +00:00
|
|
|
# and then installing the new one. So it is impossible for us to redirect
|
|
|
|
# the SDK location to var so that the platform-tools don't have to be
|
2012-03-06 16:00:47 +00:00
|
|
|
# freshly installed EVERY DANG time the base SDK updates.
|
2011-01-25 13:39:47 +00:00
|
|
|
|
|
|
|
# Ideas: make android a script that calls the actual android tool, but after
|
|
|
|
# that tool exits it repairs the directory locations?
|
2010-01-06 00:01:19 +00:00
|
|
|
end
|