PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/Library/Formula/smali.rb

https://bitbucket.org/JoshHagins/homebrew
Ruby | 70 lines | 56 code | 12 blank | 2 comment | 0 complexity | deb27ffdd45f7c464632e5e197cab286 MD5 | raw file
  1. require "formula"
  2. class Smali < Formula
  3. homepage "http://smali.googlecode.com/"
  4. url "https://bitbucket.org/JesusFreke/smali/downloads/smali-2.0.3.jar", :using => :nounzip
  5. sha1 "42774f5d949add1739299785feb83f3dec32f240"
  6. bottle do
  7. cellar :any
  8. sha1 "042f4692b35ab5d483aa291e3a4924565fe1510f" => :yosemite
  9. sha1 "a9e5893ba2cc5bdd4b0b1e9ab489cf8863a48dfb" => :mavericks
  10. sha1 "f6829e47d12e951c4ea37784496bed1b79cebf0d" => :mountain_lion
  11. end
  12. resource "baksmali-jar" do
  13. url "https://bitbucket.org/JesusFreke/smali/downloads/baksmali-2.0.3.jar", :using => :nounzip
  14. sha1 "39d860bc2539753c8575f39879cf8d515e1c1cb9"
  15. end
  16. resource "baksmali" do
  17. url "https://bitbucket.org/JesusFreke/smali/downloads/baksmali", :using => :nounzip
  18. sha1 "9f7a87ee158b89f9d376ba7de09e0bea39e0cad0"
  19. end
  20. resource "smali" do
  21. url "https://bitbucket.org/JesusFreke/smali/downloads/smali", :using => :nounzip
  22. sha1 "26423d6a1d882d3feac0fd0b93ddae0ab134551f"
  23. end
  24. def install
  25. resource("baksmali-jar").stage {
  26. libexec.install "baksmali-2.0.3.jar" => "baksmali.jar"
  27. }
  28. libexec.install resource("smali"), resource("baksmali"), "smali-2.0.3.jar" => "smali.jar"
  29. inreplace "#{libexec}/smali" do |s|
  30. s.gsub! /^libdir=.*$/, "libdir=\"#{libexec}\""
  31. end
  32. inreplace "#{libexec}/baksmali" do |s|
  33. s.gsub! /^libdir=.*$/, "libdir=\"#{libexec}\""
  34. end
  35. chmod 0755, "#{libexec}/smali"
  36. chmod 0755, "#{libexec}/baksmali"
  37. bin.install_symlink libexec/"smali"
  38. bin.install_symlink libexec/"baksmali"
  39. end
  40. test do
  41. # From examples/HelloWorld/HelloWorld.smali in Smali project repo.
  42. # See https://bitbucket.org/JesusFreke/smali/src/2d8cbfe6bc2d8ff2fcd7a0bf432cc808d842da4a/examples/HelloWorld/HelloWorld.smali?at=master
  43. (testpath/"input.smali").write <<-EOS.undent
  44. .class public LHelloWorld;
  45. .super Ljava/lang/Object;
  46. .method public static main([Ljava/lang/String;)V
  47. .registers 2
  48. sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
  49. const-string v1, "Hello World!"
  50. invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
  51. return-void
  52. .end method
  53. EOS
  54. system "#{bin}/smali", "-o", "classes.dex", "input.smali"
  55. system "#{bin}/baksmali", "-o", pwd, "classes.dex"
  56. assert File.read("HelloWorld.smali").include?("Hello World!")
  57. end
  58. end