Created
April 6, 2013 18:39
-
-
Save xlab/5327120 to your computer and use it in GitHub Desktop.
Generate PRODUCT_COPY_FILES for the Android.mk files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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