2015-06-06 19:31:08 +00:00
|
|
|
require "base64"
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class AndroidSdk < Formula
|
2015-05-19 00:00:59 +00:00
|
|
|
desc "Android API libraries and developer tools"
|
2015-03-10 14:42:06 +00:00
|
|
|
homepage "https://developer.android.com/index.html"
|
2015-10-21 01:31:36 +00:00
|
|
|
url "https://dl.google.com/android/android-sdk_r24.4.1-macosx.zip"
|
|
|
|
version "24.4.1"
|
|
|
|
sha256 "ce1638cb48526a0e55857fc46b57eda4349e6512006244ad13dd6c1361c74104"
|
2015-12-02 15:22:16 +00:00
|
|
|
revision 1
|
2010-01-06 00:01:19 +00:00
|
|
|
|
2015-12-03 11:27:54 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any
|
2016-09-28 10:26:47 +00:00
|
|
|
rebuild 1
|
|
|
|
sha256 "57701fa0dbd0c394208c04f2cab20f2638ec0c6a05853730e4e86c6b5874cd19" => :sierra
|
2016-03-23 19:14:07 +00:00
|
|
|
sha256 "17a99fa50d2e532d95e189f83fe84a5626c47386b30bbdd9203a9fcdb8087089" => :el_capitan
|
|
|
|
sha256 "c4453630cf237b3a54e09cf08867739f5d69841c466270b0c98a368f9d9d7b1a" => :yosemite
|
|
|
|
sha256 "88aac41e9525e897d207ba3e50cd36351ac5270c99cb3d85bed2306ccb623b21" => :mavericks
|
2015-12-03 11:27:54 +00:00
|
|
|
end
|
|
|
|
|
2016-03-23 05:08:09 +00:00
|
|
|
depends_on :java
|
2016-09-24 15:45:48 +00:00
|
|
|
depends_on :macos => :mountain_lion
|
2016-01-17 14:42:16 +00:00
|
|
|
|
2015-03-10 14:42:06 +00:00
|
|
|
conflicts_with "android-platform-tools",
|
2016-09-24 15:45:48 +00:00
|
|
|
:because => "The Android Platform-Tools need to be installed as part of the SDK."
|
2014-02-24 02:11:49 +00:00
|
|
|
|
2015-03-10 14:42:06 +00:00
|
|
|
resource "completion" do
|
2015-06-06 19:31:08 +00:00
|
|
|
url "https://android.googlesource.com/platform/sdk/+/7859e2e738542baf96c15e6c8b50bbdb410131b0/bash_completion/adb.bash?format=TEXT"
|
2016-05-27 19:54:59 +00:00
|
|
|
mirror "https://raw.githubusercontent.com/Homebrew/formula-patches/c3b801f/android-sdk/adb.bash"
|
2015-06-06 19:31:08 +00:00
|
|
|
sha256 "44b3e20ed9cb8fff01dc6907a57bd8648cd0d1bcc7b129ec952a190983ab5e1a"
|
2013-08-07 05:03:49 +00:00
|
|
|
end
|
|
|
|
|
2014-03-15 22:09:26 +00:00
|
|
|
# Version of the android-build-tools the wrapper scripts reference.
|
|
|
|
def build_tools_version
|
2015-09-09 11:17:38 +00:00
|
|
|
"23.0.1"
|
2014-03-15 22:09:26 +00:00
|
|
|
end
|
|
|
|
|
2010-01-06 00:01:19 +00:00
|
|
|
def install
|
2015-03-10 14:42:06 +00:00
|
|
|
prefix.install "tools", "SDK Readme.txt" => "README"
|
2010-01-06 00:01:19 +00:00
|
|
|
|
2014-06-29 19:57:27 +00:00
|
|
|
%w[android ddms draw9patch emulator
|
2015-03-10 14:42:06 +00:00
|
|
|
emulator-arm emulator-x86 hierarchyviewer lint mksdcard
|
|
|
|
monitor monkeyrunner traceview].each do |tool|
|
2012-03-22 09:33:21 +00:00
|
|
|
(bin/tool).write <<-EOS.undent
|
2014-03-15 22:09:26 +00:00
|
|
|
#!/bin/bash
|
2012-03-22 09:33:21 +00:00
|
|
|
TOOL="#{prefix}/tools/#{tool}"
|
|
|
|
exec "$TOOL" "$@"
|
|
|
|
EOS
|
2010-01-06 00:01:19 +00:00
|
|
|
end
|
2010-02-27 17:26:27 +00:00
|
|
|
|
2014-06-29 19:57:27 +00:00
|
|
|
%w[zipalign].each do |tool|
|
|
|
|
(bin/tool).write <<-EOS.undent
|
|
|
|
#!/bin/bash
|
|
|
|
TOOL="#{prefix}/build-tools/#{build_tools_version}/#{tool}"
|
|
|
|
exec "$TOOL" "$@"
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
%w[dmtracedump etc1tool hprof-conv].each do |tool|
|
|
|
|
(bin/tool).write <<-EOS.undent
|
|
|
|
#!/bin/bash
|
|
|
|
TOOL="#{prefix}/platform-tools/#{tool}"
|
|
|
|
exec "$TOOL" "$@"
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
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.
|
2014-02-24 02:11:49 +00:00
|
|
|
%w[platforms samples temp add-ons sources system-images extras].each do |d|
|
2014-03-26 22:27:10 +00:00
|
|
|
src = var/"lib/android-sdk"/d
|
|
|
|
src.mkpath
|
|
|
|
prefix.install_symlink src
|
2010-09-12 20:55:04 +00:00
|
|
|
end
|
2011-01-25 13:39:47 +00:00
|
|
|
|
2013-06-07 09:12:53 +00:00
|
|
|
%w[adb fastboot].each do |platform_tool|
|
2012-05-24 13:35:49 +00:00
|
|
|
(bin/platform_tool).write <<-EOS.undent
|
2014-03-15 22:09:26 +00:00
|
|
|
#!/bin/bash
|
2012-05-24 13:35:49 +00:00
|
|
|
PLATFORM_TOOL="#{prefix}/platform-tools/#{platform_tool}"
|
2014-03-15 22:09:26 +00:00
|
|
|
test -x "$PLATFORM_TOOL" && exec "$PLATFORM_TOOL" "$@"
|
|
|
|
echo "It appears you do not have 'Android SDK Platform-tools' installed."
|
|
|
|
echo "Use the 'android' tool to install them: "
|
|
|
|
echo " android update sdk --no-ui --filter 'platform-tools'"
|
2012-05-24 13:35:49 +00:00
|
|
|
EOS
|
|
|
|
end
|
2012-10-18 15:04:21 +00:00
|
|
|
|
2013-06-07 09:12:53 +00:00
|
|
|
%w[aapt aidl dexdump dx llvm-rs-cc].each do |build_tool|
|
|
|
|
(bin/build_tool).write <<-EOS.undent
|
2014-03-15 22:09:26 +00:00
|
|
|
#!/bin/bash
|
|
|
|
BUILD_TOOLS_VERSION='#{build_tools_version}'
|
|
|
|
BUILD_TOOL="#{prefix}/build-tools/$BUILD_TOOLS_VERSION/#{build_tool}"
|
|
|
|
test -x "$BUILD_TOOL" && exec "$BUILD_TOOL" "$@"
|
|
|
|
echo "It appears you do not have 'build-tools-$BUILD_TOOLS_VERSION' installed."
|
|
|
|
echo "Use the 'android' tool to install them: "
|
|
|
|
echo " android update sdk --no-ui --filter 'build-tools-$BUILD_TOOLS_VERSION'"
|
2013-06-07 09:12:53 +00:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2015-06-06 19:31:08 +00:00
|
|
|
resource("completion").stage do
|
|
|
|
# googlesource.com only serves up the file in base64-encoded format; we
|
|
|
|
# need to decode it before installing
|
|
|
|
decoded_file = buildpath/"adb-completion.bash"
|
|
|
|
decoded_file.write Base64.decode64(File.read("adb.bash"))
|
|
|
|
bash_completion.install decoded_file
|
|
|
|
end
|
2015-12-02 14:11:35 +00:00
|
|
|
|
|
|
|
# automatically install platform and build tools
|
|
|
|
system "echo y | bash #{bin}/android --verbose update sdk --no-ui --all --filter platform-tools,build-tools-#{build_tools_version}"
|
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
|
2014-03-15 22:09:26 +00:00
|
|
|
Now run the 'android' tool to install the actual SDK stuff.
|
2012-01-18 17:52:38 +00:00
|
|
|
|
2015-05-10 18:31:26 +00:00
|
|
|
The Android-SDK is available at #{opt_prefix}
|
2012-01-18 17:52:38 +00:00
|
|
|
|
2012-03-01 16:54:53 +00:00
|
|
|
You may need to add the following to your .bashrc:
|
2013-06-07 08:42:17 +00:00
|
|
|
export ANDROID_HOME=#{opt_prefix}
|
2010-02-27 17:26:27 +00:00
|
|
|
EOS
|
2010-01-06 00:01:19 +00:00
|
|
|
end
|
2016-03-23 05:08:09 +00:00
|
|
|
|
|
|
|
test do
|
|
|
|
assert_match version.to_s, shell_output("#{prefix}/tools/emulator -version")
|
|
|
|
end
|
2010-01-06 00:01:19 +00:00
|
|
|
end
|