lib/calabash-android/env.rb in calabash-android-0.5.1 vs lib/calabash-android/env.rb in calabash-android-0.5.2.pre1
- old
+ new
@@ -1,5 +1,6 @@
+require_relative 'helpers'
class Env
require 'win32/registry' if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
def self.exit_if_env_not_set_up
@@ -77,13 +78,34 @@
def self.path_if_jdk(path)
path if path && File.exists?(File.join(path, 'bin', jarsigner_executable))
end
def self.zipalign_path
- %Q("#{android_home_path}/tools/zipalign")
+ zipalign_path = File.join(android_home_path, 'tools', zipalign_executable)
+
+ unless File.exists?(zipalign_path)
+ log "Did not find zipalign at '#{zipalign_path}'. Trying to find zipalign in tools directories."
+
+ tools_directories.each do |dir|
+ zipalign_path = File.join(dir, zipalign_executable)
+ break if File.exists?(zipalign_path)
+ end
+ end
+
+ if File.exists?(zipalign_path)
+ log "Found zipalign at '#{zipalign_path}'"
+ zipalign_path
+ else
+ log("Did not find zipalign in any of '#{tools_directories.join("','")}'.", true)
+ raise 'Could not find zipalign'
+ end
end
+ def self.zipalign_executable
+ is_windows? ? 'zipalign.exe' : 'zipalign'
+ end
+
def self.jarsigner_executable
is_windows? ? 'jarsigner.exe' : 'jarsigner'
end
def self.java_executable
@@ -105,13 +127,19 @@
def self.is_windows?
(RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
end
def self.tools_dir
+ tools_dir = tools_directories.first
+ log "Found tools directory at '#{tools_dir}'"
+ tools_dir
+ end
+
+ def self.tools_directories
Dir.chdir(android_home_path) do
dirs = Dir["build-tools/*"] + Dir["platform-tools"]
raise "Could not find tools directory in #{android_home_path}" if dirs.empty?
- File.expand_path(dirs.first)
+ dirs.map {|dir| File.expand_path(dir)}
end
end
def self.adb_path
%Q("#{android_home_path}/platform-tools/#{adb_executable}")
\ No newline at end of file