lib/ruboto/util/setup.rb in ruboto-1.3.0 vs lib/ruboto/util/setup.rb in ruboto-1.3.1
- old
+ new
@@ -185,21 +185,26 @@
end
def check_for_haxm
case android_package_os_id
when MAC_OS_X
- @haxm_kext_loc = '/System/Library/Extensions/intelhaxm.kext'
- found = File.exists?(@haxm_kext_loc)
+ @haxm_kext_loc = '/Library/Extensions/intelhaxm.kext'
+ found = File.exist?(@haxm_kext_loc)
if found
@haxm_kext_version = `kextstat | grep com.intel.kext.intelhaxm`.slice(/\(.*\)/)[1..-2]
else
@haxm_kext_loc = nil
end
- # FIXME(uwe): Use the system version to choose the right .dmg
- os_x_version = ENV['_system_version']
- @haxm_installer_loc = Dir[File.join(android_package_directory, 'extras', 'intel', 'Hardware_Accelerated_Execution_Manager', 'IntelHAXM*.dmg')].first
- @haxm_installer_version = @haxm_installer_loc.slice(/IntelHAXM_1.1.1_/)[10..-2]
+
+ os_x_version = `sw_vers -productVersion`
+ if Gem::Version.new(os_x_version) > Gem::Version.new('10.9')
+ @haxm_installer_loc = Dir[File.join(android_package_directory, 'extras', 'intel', 'Hardware_Accelerated_Execution_Manager', 'IntelHAXM*_above*.dmg')][0]
+ else
+ @haxm_installer_loc = Dir[File.join(android_package_directory, 'extras', 'intel', 'Hardware_Accelerated_Execution_Manager', 'IntelHAXM*_below*.dmg')][0]
+ end
+
+ @haxm_installer_version = @haxm_installer_loc.scan(/\d+/).join('.')[0..4] unless @haxm_installer_loc.nil? || @haxm_installer_loc.empty?
if @haxm_kext_version == @haxm_installer_version
puts "#{'%-25s' % 'Intel HAXM'}: #{(found ? "Found" : 'Not found')}"
else
puts "#{'%-25s' % 'Intel HAXM'}: Old #{@haxm_kext_version}/#{@haxm_installer_version}"
end
@@ -222,11 +227,11 @@
File.join(android_package_directory, 'platform-tools', windows? ? 'adb.exe' : 'adb'))
end
def check_for_build_tools
dx_locations = Dir[File.join android_package_directory, 'build-tools', '*', windows? ? 'dx.bat' : 'dx']
- sorted_dx_locations = dx_locations.sort_by { |f| Gem::Version.new f[%r{build-tools/[^/]+/}][12..-2] }
+ sorted_dx_locations = dx_locations.sort_by { |f| Gem::Version.new f[%r{build-tools/[^/]+/(\d{1,}[.]){2}\d{1,}(_rc\d)?}]}
@dx_loc = check_for('dx', 'Android SDK Command dx', sorted_dx_locations[-1])
end
def check_for_android_sdk
@android_loc = check_for('android', 'Android Package Installer',
@@ -237,11 +242,11 @@
rv = which(cmd)
rv = nil if rv && rv.empty?
if rv
@existing_paths << File.dirname(rv)
- elsif alt_dir && File.exists?(alt_dir)
+ elsif alt_dir && File.exist?(alt_dir)
rv = alt_dir
if windows?
ENV['PATH'] = "#{File.dirname(rv).gsub('/', '\\')};#{ENV['PATH']}"
else
ENV['PATH'] = "#{File.dirname(rv)}:#{ENV['PATH']}"
@@ -252,18 +257,16 @@
puts "#{'%-25s' % (pretty_name || cmd)}: #{(rv ? 'Found' : 'Not found')}"
rv
end
def check_for_android_platform(api_level)
- begin
- @platform_sdk_loc[api_level] = File.expand_path "#{@android_loc}/../../platforms/#{api_level}"
- found = File.exists? @platform_sdk_loc[api_level]
- @platform_sdk_loc[api_level] = nil unless found
- puts "#{'%-25s' % "Platform SDK #{api_level}"}: #{(found ? 'Found' : 'Not found')}"
- rescue
- @platform_sdk_loc[api_level] = nil
- end
+ @platform_sdk_loc[api_level] = File.expand_path "#{@android_loc}/../../platforms/#{api_level}"
+ found = File.exist? @platform_sdk_loc[api_level]
+ @platform_sdk_loc[api_level] = nil unless found
+ puts "#{'%-25s' % "Platform SDK #{api_level}"}: #{(found ? 'Found' : 'Not found')}"
+ rescue
+ @platform_sdk_loc[api_level] = nil
end
#########################################
#
# Install Methods
@@ -359,11 +362,11 @@
puts 'http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html'
puts
end
unless check_for('javac')
ENV['JAVA_HOME'] = 'c:\\Program Files\\Java\\jdk1.7.0'
- if Dir.exists?(ENV['JAVA_HOME'])
+ if Dir.exist?(ENV['JAVA_HOME'])
@javac_loc = "#{ENV['JAVA_HOME'].gsub('\\', '/')}/bin/javac"
puts "Setting the JAVA_HOME environment variable to #{ENV['JAVA_HOME']}"
system %Q{setx JAVA_HOME "#{ENV['JAVA_HOME']}"}
@missing_paths << "#{File.dirname(@javac_loc)}"
end
@@ -422,11 +425,11 @@
puts 'http://ant.apache.org/bindownload.cgi'
puts
end
unless check_for('ant')
ENV['ANT_HOME'] = File.expand_path(File.join('~', 'apache-ant-1.9.0')).gsub('/', '\\')
- if Dir.exists?(ENV['ANT_HOME'])
+ if Dir.exist?(ENV['ANT_HOME'])
@ant_loc = "#{ENV['ANT_HOME'].gsub('\\', '/')}/bin/ant"
puts "Setting the ANT_HOME environment variable to #{ENV['ANT_HOME']}"
system %Q{setx ANT_HOME "#{ENV['ANT_HOME']}"}
@missing_paths << "#{File.dirname(@ant_loc)}"
end
@@ -615,10 +618,10 @@
end
if accept_all || a == 'Y' || a.empty?
android_cmd = windows? ? 'android.bat' : 'android'
# FIXME(uwe): Does this pattern work for all api levels?
- update_cmd = "#{android_cmd} update sdk --no-ui --filter #{api_level},sys-img-x86-#{api_level.downcase},sys-img-armeabi-v7a-#{api_level.downcase} --all"
+ update_cmd = "#{android_cmd} update sdk --no-ui --filter #{api_level},sys-img-x86-#{api_level.downcase},sys-img-x86_64-#{api_level.downcase},sys-img-armeabi-v7a-#{api_level.downcase} --all"
# EMXIF
update_sdk(update_cmd, accept_all)
check_for_android_platform(api_level)
end