Skip to content

Instantly share code, notes, and snippets.

@xlab
Created April 6, 2013 18:39
Show Gist options
  • Select an option

  • Save xlab/5327120 to your computer and use it in GitHub Desktop.

Select an option

Save xlab/5327120 to your computer and use it in GitHub Desktop.
Generate PRODUCT_COPY_FILES for the Android.mk files
#!/usr/bin/env ruby
# Generate PRODUCT_COPY_FILES for the Android.mk files
# Usage: ./pcf_gen.rb <local_folder> <device_folder>
# (c) 2013 ROSA Lab
# Author: [email protected]
def show_help
puts "Usage:"
puts "./pcf_gen.rb <local_folder> <device_folder>"
end
def show_error reason
puts "Error!"
puts reason
end
def generate(local, remote)
remote = remote[1..-1] if remote.start_with? '/'
full_local = File.expand_path local
contents = Dir["#{full_local}/**/*"]
puts "PRODUCT_COPY_FILES += \\"
contents.each_with_index do |path, index|
path.sub! "#{full_local}/", ""
puts "#{local}/#{path}:#{remote}/#{path}#{" \\" if index < contents.count - 1}"
end
end
# main routine
if ARGV.count < 2
show_help
elsif not File.directory? ARGV[0]
show_error "No such directory: #{ARGV[0]}"
else
generate(ARGV[0], ARGV[1])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment