diff --git a/bin/gen_build b/bin/gen_build index a16a0bfd..f69c60e4 100755 --- a/bin/gen_build +++ b/bin/gen_build @@ -449,8 +449,9 @@ SHELL derived_assets = [ ] queue = [ initial_asset ] + enable_filters = true while asset = queue.shift - if compiler = compiler_for(asset.file) + if compiler = compiler_for(asset.file, enable_filters: enable_filters) if compiler.filter? derived_assets += compiler.transform(asset, self) else @@ -459,6 +460,15 @@ SHELL else derived_assets << asset end + + # We disable filters after first iteration because filters do not change the + # file name and therefore can only be used when we go from source → build + # directory. + # + # Example of problem: file → expand variables → convert utf-8 to utf-16 + # src/InfoPlist.strings → build/InfoPlist.strings → build/InfoPlist.strings + # Here we need to mangle all but the last file path. + enable_filters = false end derived_assets @@ -502,7 +512,7 @@ SHELL private - def compiler_for(file) + def compiler_for(file, enable_filters: true) candidates = [] Plugin.plugins_of_type(Compiler).each do |klass| @@ -521,8 +531,10 @@ SHELL end unless klass.extensions.nil? end - if match = candidates.max { |lhs, rhs| lhs[:ext].length <=> rhs[:ext].length } - match[:class].new(self, @context, match[:ext], match[:canonical_ext] || match[:ext], match[:dest_ext]) + candidates.sort! { |lhs, rhs| lhs[:ext].length <=> rhs[:ext].length } + while match = candidates.pop + res = match[:class].new(self, @context, match[:ext], match[:canonical_ext] || match[:ext], match[:dest_ext]) + return res if enable_filters || !res.filter? end end end