* the input file name (using root-relative paths) before each file.
*/
@VisibleForTesting
void printBundleTo(Iterable<CompilerInput> inputs, Appendable out)
throws IOException {
ClosureBundler bundler = new ClosureBundler();
for (CompilerInput input : inputs) {
// Every module has an empty file in it. This makes it easier to implement
// cross-module code motion.
//
// But it also leads to a weird edge case because
// a) If we don't have a module spec, we create a singleton module, and
// b) If we print a bundle file, we copy the original input files.
//
// This means that in the (rare) case where we have no inputs, and no
// module spec, and we're printing a bundle file, we'll have a fake
// input file that shouldn't be copied. So we special-case this, to
// make all the other cases simpler.
if (input.getName().equals(
Compiler.createFillFileName(Compiler.SINGLETON_MODULE_NAME))) {
Preconditions.checkState(1 == Iterables.size(inputs));
return;
}
String rootRelativePath = rootRelativePathsMap.get(input.getName());
String displayName = rootRelativePath != null
? rootRelativePath
: input.getName();
File file = new File(input.getName());
out.append("//");
out.append(displayName);
out.append("\n");
bundler.appendTo(out, input, file, inputCharset);
out.append("\n");
}
}