lib/ruboto/util/setup.rb in ruboto-1.4.0 vs lib/ruboto/util/setup.rb in ruboto-1.4.1
- old
+ new
@@ -19,11 +19,11 @@
#
def setup_ruboto(accept_all, api_levels = [SdkVersions::DEFAULT_TARGET_SDK], upgrade_haxm = false)
@platform_sdk_loc = {}
api_levels = [project_api_level, *api_levels].compact.uniq
- install_all(accept_all, api_levels, upgrade_haxm) unless check_all(api_levels)
+ install_all(accept_all, api_levels, upgrade_haxm) unless check_all(api_levels, upgrade_haxm)
config_path(accept_all)
end
#
# OS independent "which"
@@ -159,11 +159,11 @@
#########################################
#
# Check Methods
#
- def check_all(api_levels)
+ def check_all(api_levels, update = false)
@existing_paths ||= []
@missing_paths ||= []
@java_loc = check_for('java', 'Java runtime', ENV['JAVA_HOME'] && "#{ENV['JAVA_HOME']}/bin/java")
@javac_loc = check_for('javac', 'Java Compiler', ENV['JAVA_HOME'] && "#{ENV['JAVA_HOME']}/bin/javac")
@@ -177,43 +177,66 @@
@existing_paths.uniq!
@missing_paths.uniq!
puts
- ok = @java_loc && @javac_loc && @ant_loc && @android_loc && @emulator_loc && @haxm_kext_loc && @adb_loc && @dx_loc && @platform_sdk_loc.all? { |_, path| !path.nil? }
+ ok = @java_loc && @javac_loc && @ant_loc && @android_loc && @emulator_loc && haxm_ok?(update) &&
+ @adb_loc && @dx_loc && @platform_sdk_loc.all? { |_, path| !path.nil? }
puts " #{ok ? '*** Ruboto setup is OK! ***' : '!!! Ruboto setup is NOT OK !!!'}\n\n"
ok
end
+ def haxm_ok?(update)
+ @haxm_kext_loc && !(update && haxm_old?)
+ end
+
+ def haxm_old?
+ @haxm_kext_version != @haxm_installer_version
+ end
+
def check_for_emulator
@emulator_loc = check_for('emulator', 'Android Emulator',
File.join(android_package_directory, 'tools', 'emulator'))
end
def check_for_haxm
case android_package_os_id
when MAC_OS_X
@haxm_kext_loc = '/Library/Extensions/intelhaxm.kext'
found = File.exist?(@haxm_kext_loc)
+
+ # FIXME(uwe): Remove when we stop supporting old HAXM installer versions, like mid 2016.
+ unless found
+ @haxm_kext_loc = '/System/Library/Extensions/intelhaxm.kext'
+ found = File.exist?(@haxm_kext_loc)
+ end
+ # EMXIF
+
if found
@haxm_kext_version = `kextstat | grep com.intel.kext.intelhaxm`.slice(/\(.*\)/)[1..-2]
else
@haxm_kext_loc = nil
end
- 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]
+ @haxm_installer_loc = Dir[File.join(android_package_directory, 'extras', 'intel', 'Hardware_Accelerated_Execution_Manager', 'IntelHAXM_*.dmg')][0]
+
+ # FIXME(uwe): Remove when we stop supporting old HAXM installer versions, like mid 2016.
+ if @haxm_installer_loc.nil?
+ 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
end
+ # EMXIF
- @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
+ @haxm_installer_version = File.basename(@haxm_installer_loc).scan(/\d+/).join('.') unless @haxm_installer_loc.nil? || @haxm_installer_loc.empty?
+ if haxm_old?
puts "#{'%-25s' % 'Intel HAXM'}: Old #{@haxm_kext_version}/#{@haxm_installer_version}"
+ else
+ puts "#{'%-25s' % 'Intel HAXM'}: #{(found ? 'Found' : 'Not found')}"
end
when LINUX
@haxm_installer_loc = 'Not supported, yet.'
@haxm_kext_loc = 'Not supported, yet.'
return
@@ -262,11 +285,11 @@
puts "#{'%-25s' % (pretty_name || cmd)}: #{(rv ? 'Found' : 'Not found')}"
rv
end
def check_for_android_platform(api_level)
- @platform_sdk_loc[api_level] = File.expand_path "#{@android_loc}/../../platforms/#{api_level}"
+ @platform_sdk_loc[api_level] = File.expand_path "#{android_package_directory}/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
@@ -282,12 +305,12 @@
install_ant(accept_all) unless @ant_loc
install_android_sdk(accept_all) unless @android_loc
# build-tools, platform-tools, tools, and haxm
install_android_tools(accept_all) unless @dx_loc && @adb_loc && @emulator_loc && @haxm_installer_loc
- install_haxm(accept_all) unless @haxm_kext_loc
- download_and_upgrade_haxm(true) unless upgrade_haxm.empty?
+ install_haxm(accept_all) unless haxm_ok?(upgrade_haxm)
+ # download_and_upgrade_haxm(true) if upgrade_haxm
if @android_loc
api_levels.each do |api_level|
install_platform(accept_all, api_level) unless @platform_sdk_loc[api_level]
end
@@ -588,11 +611,11 @@
print 'Would you like to download and install them? (Y/n): '
a = STDIN.gets.chomp.upcase
end
if accept_all || a == 'Y' || a.empty?
android_cmd = windows? ? 'android.bat' : 'android'
- update_cmd = "#{android_cmd} --silent update sdk --no-ui --filter build-tools-#{get_tools_version('build-tool')},extra-intel-Hardware_Accelerated_Execution_Manager,platform-tool,tool -a"
+ update_cmd = "#{android_cmd} --silent update sdk --no-ui --filter build-tools-#{get_tools_version('build-tool')},extra-intel-Hardware_Accelerated_Execution_Manager,platform-tool,tool"
update_sdk(update_cmd, accept_all)
check_for_build_tools
check_for_platform_tools
check_for_emulator
check_for_haxm
@@ -632,29 +655,37 @@
download_haxm(accept_all, filename)
install_haxm(accept_all, version)
end
def install_haxm(accept_all, custom_version=nil)
- filename = nil
haxm_file_override = "IntelHAXM_#{custom_version}.dmg" unless custom_version.nil?
- if @haxm_installer_loc && @haxm_kext_loc.nil?
- puts 'HAXM not installed.'
+ if @haxm_installer_loc && (@haxm_kext_loc.nil? || haxm_old?)
+ if @haxm_kext_loc.nil?
+ puts 'HAXM not installed.'
+ else
+ puts "HAXM is old: #{@haxm_kext_version} / #{@haxm_installer_version}"
+ end
+
unless accept_all
- print 'Would you like to install HAXM? (Y/n): '
+ if @haxm_kext_loc.nil?
+ print 'Would you like to install HAXM? (Y/n): '
+ else
+ print 'Would you like to update HAXM? (Y/n): '
+ end
a = STDIN.gets.chomp.upcase
end
if accept_all || a == 'Y' || a.empty?
case android_package_os_id
when MAC_OS_X
- puts "Mounting the HAXM install image"
+ puts 'Mounting the HAXM install image'
if custom_version.nil?
system "hdiutil attach #{@haxm_installer_loc}"
fileName = Dir['/Volumes/IntelHAXM*/IntelHAXM*.mpkg'][0]
else
system "hdiutil attach #{android_haxm_directory}/#{haxm_file_override}"
fileName = Dir["/Volumes/IntelHAXM_#{custom_version}/IntelHAXM_#{custom_version}.mpkg"][0]
end
- puts "Starting the HAXM installer. Sudo password required."
+ puts 'Starting the HAXM installer. Sudo password required.'
system "sudo -S installer -pkg #{fileName} -target /"
when LINUX
puts ' HAXM installation on Linux is not supported, yet.'
return
when WINDOWS