From a24596e8304c591b5a2e2f4b2afebbc126943f9b Mon Sep 17 00:00:00 2001 From: Watson Date: Wed, 27 Feb 2013 23:29:20 +0900 Subject: [PATCH] fix a bug in build system which updated resource files are not copied --- lib/motion/project/builder.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/motion/project/builder.rb b/lib/motion/project/builder.rb index fe62bd26..671c17ff 100644 --- a/lib/motion/project/builder.rb +++ b/lib/motion/project/builder.rb @@ -444,13 +444,13 @@ EOS config.resources_dirs.each do |dir| if File.exist?(dir) resources_paths << Dir.chdir(dir) do - Dir.glob('*').reject { |x| ['.xib', '.storyboard', '.xcdatamodeld', '.lproj'].include?(File.extname(x)) }.map { |file| File.join(dir, file) } + Dir.glob('**{,/*/**}/*').reject { |x| ['.xib', '.storyboard', '.xcdatamodeld', '.lproj'].include?(File.extname(x)) }.map { |file| File.join(dir, file) } end end end resources_paths.flatten! resources_paths.each do |res_path| - res = File.basename(res_path) + res = resource_path_without_dir(config.resources_dirs, res_path) if reserved_app_bundle_files.include?(res) App.fail "Cannot use `#{res_path}' as a resource file because it's a reserved application bundle file" end @@ -463,7 +463,7 @@ EOS end # Delete old resource files. - resources_files = resources_paths.map { |x| File.basename(x) } + resources_files = resources_paths.map { |x| resource_path_without_dir(config.resources_dirs, x) } Dir.chdir(bundle_path) do Dir.glob('*').each do |bundle_res| bundle_res = convert_filesystem_encoding(bundle_res) @@ -489,6 +489,14 @@ EOS end end + def resource_path_without_dir(dirs, path) + dir = dirs.each do |dir| + break dir if path =~ /^#{dir}/ + end + path = path.sub(/^#{dir}\/*/, '') if dir + path + end + def convert_filesystem_encoding(string) begin string.encode("UTF-8", "UTF8-MAC")