Skip to content

Commit

Permalink
Modifying crazyfun Closure compilation to read command-line flags fro…
Browse files Browse the repository at this point in the history
…m file

Because of the large number of JavaScript files we pass through the
Closure compiler for some targets, we are running over the 8192 character
limit of the command line in Windows. The workaround is to have the
Closure compiler read its command-line flags from a file instead.
  • Loading branch information
jimevans committed Nov 21, 2016
1 parent 5c82646 commit 8b04d23
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions rake-tasks/crazy_fun/mappings/javascript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -557,20 +557,25 @@ def handle(fun, dir, args)

flags.push("--js_output_file=#{output}")

cmd = "java -cp third_party/closure/bin/compiler.jar com.google.javascript.jscomp.CommandLineRunner " <<
flags.join(" ") <<
expanded_flags = flags.join(" ") <<
" --js='" <<
all_deps.join("' --js='") << "'"

if (args[:externs])
args[:externs].each do |extern|
cmd << " --externs=#{File.join(dir, extern)} "
expanded_flags << " --externs=#{File.join(dir, extern)} "
end
end

mkdir_p File.dirname(output)

flag_file = File.join(File.dirname(output), "closure_flags.txt")
File.open(flag_file, 'w') {|f| f.write(expanded_flags)}

cmd = "java -cp third_party/closure/bin/compiler.jar com.google.javascript.jscomp.CommandLineRunner --flagfile " << flag_file
sh cmd

rm_rf flag_file
end
end
end
Expand Down

0 comments on commit 8b04d23

Please sign in to comment.