Skip to content

Commit

Permalink
Fixes #706 Avoid duplicate files in bundle vs stdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
donv committed Mar 17, 2015
1 parent f8bf403 commit 4a48bb6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
57 changes: 35 additions & 22 deletions assets/rakelib/ruboto.rake
Expand Up @@ -742,28 +742,6 @@ file BUNDLE_JAR => [GEM_FILE, GEM_LOCK_FILE] do
end
end

# Remove duplicate files
Dir.chdir gem_path do
scanned_files = []
source_files = RUBY_SOURCE_FILES.map { |f| f.gsub("#{PROJECT_DIR}/src/", '') }
Dir['*/lib/**/*'].each do |f|
next if File.directory? f
raise 'Malformed file name' unless f =~ %r{^(.*?)/lib/(.*)$}
gem_name, lib_file = $1, $2
if (existing_file = scanned_files.find { |sf| sf =~ %r{(.*?)/lib/#{lib_file}} })
puts "Overwriting duplicate file #{lib_file} in gem #{$1} with file in #{gem_name}"
FileUtils.rm existing_file
scanned_files.delete existing_file
elsif source_files.include? lib_file
puts "Removing duplicate file #{lib_file} in gem #{gem_name}"
puts "Already present in project source src/#{lib_file}"
FileUtils.rm f
next
end
scanned_files << f
end
end

# Expand JARs
Dir.chdir gem_path do
Dir['*'].each do |gem_lib|
Expand Down Expand Up @@ -848,7 +826,42 @@ end
end
FileUtils.rm_f(jar)
end

# FIXME(uwe): Issue # 705 https://github.com/ruboto/ruboto/issues/705
# FIXME(uwe): Use the files from the bundle instead of stdlib.
stdlib_files = `jar tf #{PROJECT_DIR}/libs/jruby-stdlib-*.jar`.lines.map(&:chomp)
Dir['**/*'].each do |f|
if stdlib_files.include? f
puts "Removing duplicate file #{f} in gem #{gem_lib}."
puts "Already present in the Ruby Standard Library."
FileUtils.rm f
end
end
# EMXIF

end
end
end

# Remove duplicate files
Dir.chdir gem_path do
scanned_files = []
source_files = RUBY_SOURCE_FILES.map { |f| f.gsub("#{PROJECT_DIR}/src/", '') }
Dir['*/lib/**/*'].each do |f|
next if File.directory? f
raise 'Malformed file name' unless f =~ %r{^(.*?)/lib/(.*)$}
gem_name, lib_file = $1, $2
if (existing_file = scanned_files.find { |sf| sf =~ %r{(.*?)/lib/#{lib_file}} })
puts "Overwriting duplicate file #{lib_file} in gem #{$1} with file in #{gem_name}"
FileUtils.rm existing_file
scanned_files.delete existing_file
elsif source_files.include? lib_file
puts "Removing duplicate file #{lib_file} in gem #{gem_name}"
puts "Already present in project source src/#{lib_file}"
FileUtils.rm f
next
end
scanned_files << f
end
end

Expand Down
6 changes: 4 additions & 2 deletions lib/ruboto/util/setup.rb
Expand Up @@ -584,8 +584,10 @@ def install_haxm(accept_all)
if accept_all || a == 'Y' || a.empty?
case android_package_os_id
when MAC_OS_X
puts "Mounting the HAXM install image"
system "hdiutil attach #{@haxm_installer_loc}"
fileName = Dir['/Volumes/IntelHAXM*/IntelHAXM*.mpkg'][0]
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.'
Expand Down Expand Up @@ -621,9 +623,9 @@ def install_platform(accept_all, api_level)

def update_sdk(update_cmd, accept_all)
if accept_all
IO.popen(update_cmd, 'r+', external_encoding: "BINARY") do |cmd_io|
IO.popen(update_cmd, 'r+', external_encoding: Encoding::BINARY) do |cmd_io|
begin
output = ''.encode('BINARY')
output = ''.encode(Encoding::BINARY)
question_pattern = /.*Do you accept the license '[a-z-]+-[0-9a-f]{8}' \[y\/n\]: /m
STDOUT.sync = true
cmd_io.each_char do |text|
Expand Down

0 comments on commit 4a48bb6

Please sign in to comment.