2014-11-24 12:20:21 +00:00
|
|
|
class Smali < Formula
|
2015-05-19 00:00:59 +00:00
|
|
|
desc "Assembler/disassembler for Android's Java VM implementation"
|
2015-09-16 06:08:26 +00:00
|
|
|
homepage "https://github.com/JesusFreke/smali"
|
2015-05-18 17:45:15 +00:00
|
|
|
url "https://bitbucket.org/JesusFreke/smali/downloads/smali-2.0.6.jar"
|
|
|
|
sha256 "fcadc564a35b121361930223a4e6431e000b24b3cc992ca63dd2e35f7b28746d"
|
2015-09-16 06:08:26 +00:00
|
|
|
revision 1
|
2014-11-24 12:20:21 +00:00
|
|
|
|
2014-11-24 13:44:34 +00:00
|
|
|
bottle do
|
2015-09-28 15:54:17 +00:00
|
|
|
cellar :any_skip_relocation
|
|
|
|
sha256 "48eefb1d2ad76ccdaed3201af6bf2db59d160df687b9f4aafcfddac90037ca71" => :el_capitan
|
|
|
|
sha256 "8f0e302e316b2854cab3a410eb48b59039a7b19818c0f30dfa1c441a03142737" => :yosemite
|
|
|
|
sha256 "a0cedabdb27dc89526183ecab69efd986b569ef320d77fcd5530bb3e43250779" => :mavericks
|
2014-11-24 13:44:34 +00:00
|
|
|
end
|
|
|
|
|
2014-11-24 12:20:21 +00:00
|
|
|
resource "baksmali-jar" do
|
2015-05-18 17:45:15 +00:00
|
|
|
url "https://bitbucket.org/JesusFreke/smali/downloads/baksmali-2.0.6.jar"
|
|
|
|
sha256 "73c62f32ff53f43a0e551959d5ef1ce4adcc900e44035063b7a360c199912652"
|
2014-11-24 12:20:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
resource "baksmali" do
|
2015-05-18 17:45:15 +00:00
|
|
|
url "https://bitbucket.org/JesusFreke/smali/downloads/baksmali"
|
2015-09-16 06:08:26 +00:00
|
|
|
sha256 "5d4b79776d401f2cbdb66c7c88e23cca773b9a939520fef4bf42e2856bbbfed4"
|
2014-11-24 12:20:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
resource "smali" do
|
2015-05-18 17:45:15 +00:00
|
|
|
url "https://bitbucket.org/JesusFreke/smali/downloads/smali"
|
2015-09-16 06:08:26 +00:00
|
|
|
sha256 "910297fbeefb4590e6bffd185726c878382a0960fb6a7f0733f045b6faf60a30"
|
2014-11-24 12:20:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def install
|
2015-05-18 17:45:15 +00:00
|
|
|
resource("baksmali-jar").stage do
|
|
|
|
libexec.install "baksmali-#{version}.jar" => "baksmali.jar"
|
|
|
|
end
|
|
|
|
libexec.install resource("smali"), resource("baksmali"), "smali-#{version}.jar" => "smali.jar"
|
2014-11-24 12:20:21 +00:00
|
|
|
|
|
|
|
inreplace "#{libexec}/smali" do |s|
|
|
|
|
s.gsub! /^libdir=.*$/, "libdir=\"#{libexec}\""
|
|
|
|
end
|
|
|
|
inreplace "#{libexec}/baksmali" do |s|
|
|
|
|
s.gsub! /^libdir=.*$/, "libdir=\"#{libexec}\""
|
|
|
|
end
|
|
|
|
|
|
|
|
chmod 0755, "#{libexec}/smali"
|
|
|
|
chmod 0755, "#{libexec}/baksmali"
|
|
|
|
|
|
|
|
bin.install_symlink libexec/"smali"
|
|
|
|
bin.install_symlink libexec/"baksmali"
|
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
|
|
|
# From examples/HelloWorld/HelloWorld.smali in Smali project repo.
|
|
|
|
# See https://bitbucket.org/JesusFreke/smali/src/2d8cbfe6bc2d8ff2fcd7a0bf432cc808d842da4a/examples/HelloWorld/HelloWorld.smali?at=master
|
|
|
|
(testpath/"input.smali").write <<-EOS.undent
|
|
|
|
.class public LHelloWorld;
|
|
|
|
.super Ljava/lang/Object;
|
|
|
|
|
|
|
|
.method public static main([Ljava/lang/String;)V
|
|
|
|
.registers 2
|
|
|
|
sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
|
|
|
|
const-string v1, "Hello World!"
|
|
|
|
invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
|
|
|
|
return-void
|
|
|
|
.end method
|
|
|
|
EOS
|
|
|
|
|
|
|
|
system "#{bin}/smali", "-o", "classes.dex", "input.smali"
|
|
|
|
system "#{bin}/baksmali", "-o", pwd, "classes.dex"
|
2015-09-16 06:08:26 +00:00
|
|
|
assert_match "Hello World!", File.read("HelloWorld.smali")
|
2014-11-24 12:20:21 +00:00
|
|
|
end
|
|
|
|
end
|