Module: Pindah
- Extended by:
- Rake::DSL
- Defined in:
- lib/pindah.rb
Constant Summary collapse
- VERSION =
'0.1.2'
- DEFAULTS =
{ :output => File.("bin"), :src => File.("src"), :classpath => Dir["jars/*jar"], :sdk => Pindah.infer_sdk_location(ENV["PATH"]) }
- TARGETS =
{ "1.5" => 3, "1.6" => 4, "2.1" => 7, "2.2" => 8, "2.3" => 9 }
- ANT_TASKS =
["clean", "javac", "compile", "debug", "release", "install", "uninstall"]
Class Method Summary collapse
Class Method Details
.ant_setup ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/pindah.rb', line 70 def self.ant_setup @ant = Ant.new # TODO: this is lame, but ant interpolation doesn't work for project name build_template = ERB.new(File.read(File.join(File.dirname(__FILE__), '..', 'templates', 'build.xml'))) build = "/tmp/pindah-#{Process.pid}-build.xml" File.open(build, "w") { |f| f.puts build_template.result(binding) } at_exit { File.delete build } # TODO: add key signing config { "target" => "android-#{@spec[:target]}", "target-version" => "android-#{@spec[:target_version]}", "src" => @spec[:src], "sdk.dir" => @spec[:sdk], "classes" => @spec[:classes], "classpath" => @spec[:classpath].join(Java::JavaLang::System:: getProperty("path.separator")) }.each do |key, value| @ant.project.set_user_property(key, value) end Ant::ProjectHelper.configure_project(@ant.project, java.io.File.new(build)) # Turn ant tasks into rake tasks ANT_TASKS.each do |name, description| desc @ant.project.targets[name].description task(name) { @ant.project.execute_target(name) } end end |
.infer_sdk_location(path) ⇒ Object
21 22 23 24 25 |
# File 'lib/pindah.rb', line 21 def self.infer_sdk_location(path) tools = path.split(":").detect {|p| File.exists? "#{p}/android" } abort "\"android\" executable not found on $PATH" if tools.nil? File.("#{tools}/..") end |
.spec=(spec) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pindah.rb', line 53 def self.spec=(spec) abort "Must provide :target_version in Pindah.spec!" if !spec[:target_version] abort "Must provide :name in Pindah.spec!" if !spec[:name] @spec = DEFAULTS.merge(spec) @spec[:root] = File. "." @spec[:target] ||= TARGETS[@spec[:target_version].to_s.sub(/android-/, '')] @spec[:classes] ||= "#{@spec[:output]}/classes/" @spec[:classpath] << @spec[:classes] @spec[:classpath] << "#{@spec[:sdk]}/platforms/android-#{@spec[:target]}/android.jar" @spec[:log_spec] ||= "ActivityManager:I #{@spec[:name]}:D " + "AndroidRuntime:E *:S" ant_setup end |